diff --git a/docs/native.adoc b/docs/native.adoc index 675e8d8..0978448 100644 --- a/docs/native.adoc +++ b/docs/native.adoc @@ -47,7 +47,7 @@ We use a profile because, you will see very soon, packaging the native image tak Create a native executable by once again opening the command palette and choose **Build Native Quarkus App**. This will execute `mvn clean package -Pnative` behind the scenes. The `-Pnative` argument selects the `native` maven profile which invokes the Graal compiler. -This will take a minute or so to finish. Wait for it! +**This will take about 3-4 minutes to finish. Wait for it!** [NOTE] ==== @@ -74,11 +74,11 @@ Notice the amazingly fast startup time: [source,none,role="copypaste"] ---- -2019-03-07 18:34:16,642 INFO [io.quarkus] (main) Quarkus 0.17.0 started in 0.004s. Listening on: http://127.0.0.1:8080 -2019-03-07 18:34:16,643 INFO [io.quarkus] (main) Installed features: [cdi, resteasy] +2019-07-10 04:04:11,817 INFO [io.quarkus] (main) Quarkus 0.18.0 started in 0.015s. Listening on: http://[::]:8080 +2019-07-10 04:04:11,818 INFO [io.quarkus] (main) Installed features: [agroal, cdi, jdbc-h2, narayana-jta, resteasy] ---- -That's 4 milliseconds. A _mere 4000 nanoseconds_. +That's 15 milliseconds to start up. And extremely low memory usage as reported by the Linux `ps` utility. While the app is running, open another Terminal (click the `+` button on the terminal tabs line) and run: diff --git a/files/stack.imagestream.yaml b/files/stack.imagestream.yaml new file mode 100644 index 0000000..25944b7 --- /dev/null +++ b/files/stack.imagestream.yaml @@ -0,0 +1,17 @@ +apiVersion: image.openshift.io/v1 +kind: ImageStream +metadata: + name: quarkus-stack + namespace: openshift +spec: + tags: + - annotations: + description: Quarkus stack for Java and CodeReady Workspaces + iconClass: icon-java + supports: java + tags: builder,java + version: "1.0" + from: + kind: DockerImage + name: docker.io/schtool/che-quarkus-odo:latest + name: "1.0" diff --git a/files/stack.json b/files/stack.json index b167c12..313b26b 100644 --- a/files/stack.json +++ b/files/stack.json @@ -1,5 +1,5 @@ { - "name": "Quarkus - Java, CodeReady, odo", + "name": "Quarkus Java, CodeReady, odo", "description": "Java JDK Stack for Quarkus Apps", "scope": "general", "workspaceConfig": { @@ -7,7 +7,7 @@ "default": { "recipe": { "type": "dockerimage", - "content": "schtool/che-quarkus-odo:latest" + "content": "image-registry.openshift-image-registry.svc:5000/openshift/quarkus-stack:1.0" }, "machines": { "dev-machine": { @@ -38,7 +38,7 @@ ], "attributes": { - "memoryLimitBytes": "3221225472" + "memoryLimitBytes": "5368709120" } } } diff --git a/files/workspace.json b/files/workspace.json new file mode 100644 index 0000000..68876fc --- /dev/null +++ b/files/workspace.json @@ -0,0 +1,94 @@ +{ + "commands": [ + { + "commandLine": "mvn verify -f ${current.project.path}", + "name": "Run Quarkus Tests", + "type": "mvn", + "attributes": { + "goal": "Test", + "previewUrl": "" + } + }, + { + "commandLine": "mvn clean compile quarkus:dev -f ${current.project.path}", + "name": "Build and Run Locally", + "type": "custom", + "attributes": { + "goal": "Run", + "previewUrl": "${server.8080/tcp}" + } + }, + { + "commandLine": "MAVEN_OPTS=\"-Xmx1024M -Xss128M -XX:MetaspaceSize=512M -XX:MaxMetaspaceSize=1024M -XX:+CMSClassUnloadingEnabled\" mvn -f ${current.project.path} clean package -Pnative -DskipTests", + "name": "Build Native Quarkus App", + "type": "custom", + "attributes": { + "goal": "Package", + "previewUrl": "" + } + }, + { + "commandLine": "MAVEN_OPTS=\"-Xmx1024M -Xss128M -XX:MetaspaceSize=512M -XX:MaxMetaspaceSize=1024M -XX:+CMSClassUnloadingEnabled\" mvn -f ${current.project.path} clean package -DskipTests", + "name": "Create Executable JAR", + "type": "custom", + "attributes": { + "goal": "Package", + "previewUrl": "" + } + }, + { + "commandLine": "mvn clean compile quarkus:dev -Ddebug -f ${current.project.path}", + "name": "Debug Quarkus App", + "type": "custom", + "attributes": { + "goal": "Debug", + "previewUrl": "${server.8080/tcp}" + } + } + ], + "defaultEnv": "default", + "environments": { + "default": { + "recipe": { + "type": "dockerimage", + "content": "image-registry.openshift-image-registry.svc:5000/openshift/quarkus-stack:1.0" + }, + "machines": { + "dev-machine": { + "servers": { + "5005/tcp": { + "protocol": "http", + "port": "5005", + "attributes": {} + }, + "8080/tcp": { + "protocol": "http", + "port": "8080", + "attributes": {} + }, + "8000/tcp": { + "protocol": "http", + "port": "8000", + "attributes": {} + } + }, + "volumes": {}, + "installers": [ + "org.eclipse.che.exec", + "org.eclipse.che.terminal", + "org.eclipse.che.ws-agent", + "org.eclipse.che.ls.java" + ], + "env": {}, + "attributes": { + "memoryLimitBytes": "5368709120" + } + } + } + } + }, + "name": "WORKSPACENAME", + "attributes": {}, + "temporary": false, + "links": [] + } \ No newline at end of file diff --git a/setup/load.sh b/setup/load.sh new file mode 100644 index 0000000..9eaddcd --- /dev/null +++ b/setup/load.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +TMP_PROJ="dummy-$RANDOM" +oc new-project $TMP_PROJ +oc create route edge dummy --service=dummy --port=8080 -n $TMP_PROJ +ROUTE=$(oc get route dummy -o=go-template --template='{{ .spec.host }}' -n $TMP_PROJ) +HOSTNAME_SUFFIX=$(echo $ROUTE | sed 's/^dummy-'${TMP_PROJ}'\.//g') +oc delete project $TMP_PROJ +MASTER_URL=$(oc whoami --show-server) +CONSOLE_URL=$(oc whoami --show-console) +MYDIR=`pwd` + +SSO_CHE_TOKEN=$(curl -s -d "username=admin&password=admin&grant_type=password&client_id=admin-cli" \ + -X POST http://keycloak-che.${HOSTNAME_SUFFIX}/auth/realms/codeready/protocol/openid-connect/token | jq -r '.access_token') + +for i in {1..50} ; do + + TMPWORK=$(mktemp) + sed 's/WORKSPACENAME/WORKSPACE'${i}'/g' $MYDIR/../files/workspace.json > $TMPWORK + + curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' \ + --header "Authorization: Bearer ${SSO_CHE_TOKEN}" -d @${TMPWORK} \ + "http://codeready-che.${HOSTNAME_SUFFIX}/api/workspace?start-after-create=true" + rm -f $TMPWORK +done \ No newline at end of file diff --git a/setup/preparelab.sh b/setup/preparelab.sh index 77a02a0..ea4b5ed 100755 --- a/setup/preparelab.sh +++ b/setup/preparelab.sh @@ -182,6 +182,10 @@ spec: cheFlavor: codeready tlsSupport: false selfSignedCert: false + serverMemoryRequest: '2Gi' + serverMemoryLimit: '6Gi' + + database: externalDb: false chePostgresHostName: '' @@ -217,6 +221,18 @@ oc get --export cm/custom -n che -o yaml | yq w - 'data.CHE_INFRA_KUBERNETES_PVC oc scale -n che deployment/codeready --replicas=0 oc scale -n che deployment/codeready --replicas=1 +# Wait for che to be back up +echo "Waiting for Che to come back up..." +while [ 1 ]; do + STAT=$(curl -s -w '%{http_code}' -o /dev/null http://codeready-che.${HOSTNAME_SUFFIX}/dashboard/) + if [ "$STAT" = 200 ] ; then + break + fi + echo -n . + sleep 10 +done + + # workaround for Che Terminal timeouts # must be run from AWS bastion host @@ -265,6 +281,7 @@ curl -X POST --header 'Content-Type: application/json' --header 'Accept: applica # MANUALLY set permissions according to # https://access.redhat.com/documentation/en-us/red_hat_codeready_workspaces/1.2/html/administration_guide/administering_workspaces#stacks +# THEN # Scale the cluster WORKERCOUNT=$(oc get nodes|grep worker | wc -l) @@ -275,6 +292,28 @@ if [ "$WORKERCOUNT" -lt 10 ] ; then done fi +# Adjust cpu limits to 500/1500 +# oc patch -n che limitrange/che-core-resource-limits -p '' --type=merge + +# import stack image +oc create -n openshift -f $MYDIR/../files/stack.imagestream.yaml +oc import-image --all quarkus-stack -n openshift + +# Pre-create workspaces for users +for i in {1..$USERCOUNT} ; do + SSO_CHE_TOKEN=$(curl -s -d "username=user${i}&password=pass${i}&grant_type=password&client_id=admin-cli" \ + -X POST http://keycloak-che.${HOSTNAME_SUFFIX}/auth/realms/codeready/protocol/openid-connect/token | jq -r '.access_token') + + TMPWORK=$(mktemp) + sed 's/WORKSPACENAME/WORKSPACE'${i}'/g' $MYDIR/../files/workspace.json > $TMPWORK + + curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' \ + --header "Authorization: Bearer ${SSO_CHE_TOKEN}" -d @${TMPWORK} \ + "http://codeready-che.${HOSTNAME_SUFFIX}/api/workspace?start-after-create=true&namespace=user${i}" + rm -f $TMPWORK +done + + # Install the strimzi operator for all namespaces cat <