initial commit
39
README.adoc
Normal file
@@ -0,0 +1,39 @@
|
||||
= Quarkus Workshop Guide
|
||||
|
||||
This workshop focuses on https://quarkus.io[Quarkus], supersonic, subatomic container-native Java. The workshop uses https://eclipse.org/che[Eclipse Che] to develop Quarkus apps and deploy them to a Kubernetes cluster (based on OpenShift), and covers several other developer topics such as:
|
||||
|
||||
* Dependency Injection
|
||||
* Testing Quarkus Apps
|
||||
* Debugging Quarkus Apps
|
||||
* Building Native Quarkus Apps
|
||||
* Developing Cloud Native with Quarkus
|
||||
* Using Quarkus extensions
|
||||
* Hibernate ORM with Panache
|
||||
* Event-driven Messaging
|
||||
* Streaming Data with Quarkus and Kafka
|
||||
* Monitoring with Prometheus and Grafana
|
||||
* Tracing Quarkus Apps with Jaeger and MicroProfile Tracing
|
||||
|
||||
|
||||
== Prerequisites
|
||||
|
||||
Assumes you have a running OpenShift 4 cluster and have:
|
||||
|
||||
- CLI Utils: `htpasswd` (part of Apache HTTPD) - used to generate users for OpenShift
|
||||
- https://github.com/mikefarah/yq[`yq`] (YAML processor)
|
||||
- OpenShift 4 CLI `oc` for your environment from https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/.
|
||||
|
||||
[IMPORTANT]
|
||||
====
|
||||
If you not have OCP4 cluster then please proceed to https://try.openshift.com[try.openshift.com] to get one installed and configured before proceeding to next section.
|
||||
====
|
||||
|
||||
== Setup Workshop
|
||||
|
||||
Login to OpenShift with `cluster-admin` privileges and run:
|
||||
|
||||
[source, none]
|
||||
```
|
||||
setup/preparelab.sh -a [ADMIN_PASSWORD] -c [COUNT]
|
||||
```
|
||||
|
||||
27
docs/_modules.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
modules:
|
||||
intro:
|
||||
name: Lab Instructions
|
||||
basics:
|
||||
name: Getting Started with Quarkus
|
||||
cdi:
|
||||
name: Dependency Injection
|
||||
testing:
|
||||
name: Testing Quarkus Apps
|
||||
debugging:
|
||||
name: Debugging Quarkus Apps
|
||||
native:
|
||||
name: Building Native Quarkus Apps
|
||||
cloudnative:
|
||||
name: Developing Cloud Native with Quarkus
|
||||
extensions:
|
||||
name: Using Quarkus extensions
|
||||
panache:
|
||||
name: Hibernate ORM with Panache
|
||||
messaging:
|
||||
name: Event-driven Messaging
|
||||
kafka:
|
||||
name: Streaming Data with Quarkus and Kafka
|
||||
monitoring:
|
||||
name: Monitoring with Prometheus and Grafana
|
||||
tracing:
|
||||
name: Tracing Quarkus Apps
|
||||
24
docs/_workshop.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
id: quarkus-lab
|
||||
name: Quarkus Hands-on Lab
|
||||
|
||||
vars:
|
||||
ROUTE_SUBDOMAIN:
|
||||
MASTER_URL:
|
||||
CHE_URL:
|
||||
|
||||
modules:
|
||||
activate:
|
||||
- intro
|
||||
- basics
|
||||
- cdi
|
||||
- testing
|
||||
- debugging
|
||||
- native
|
||||
- cloudnative
|
||||
- extensions
|
||||
- panache
|
||||
- messaging
|
||||
- kafka
|
||||
- monitoring
|
||||
- tracing
|
||||
124
docs/basics.adoc
Normal file
@@ -0,0 +1,124 @@
|
||||
## The Basics
|
||||
|
||||
In this step, you will create a straightforward application serving a `hello` endpoint. To demonstrate dependency injection this endpoint uses a `greeting` bean.
|
||||
|
||||
image::imgs/arch.png[]
|
||||
|
||||
## Import new project
|
||||
|
||||
In Che, click on **Import Project...**. In the dialog box, select **GITHUB** as the type of import, and then enter the following URL into the URL field and click **Import**.
|
||||
|
||||
[source,none,role="copypaste"]
|
||||
----
|
||||
https://github.com/jamesfalkner/summit-2019-devzone
|
||||
----
|
||||
|
||||
image::imgs/import.png[]
|
||||
|
||||
After a few seconds, you'll get a _Project Configuration_ Dialog. Select **Maven** as the project type, and click **Save**.
|
||||
|
||||
image::imgs/importmaven.png[]
|
||||
|
||||
This will tell Che that the project is a Maven-based project, and be able to resolve dependencies and do error checking on the `pom.xml` file.
|
||||
|
||||
The structure of the project can be seen in the project browser to the left of the code editor:
|
||||
|
||||
image::imgs/structure.png[]
|
||||
|
||||
The project has
|
||||
|
||||
* The Maven structure
|
||||
* An `org.acme.quickstart.GreetingResource` resource exposed on `/hello`
|
||||
* A landing page that is accessible on `http://localhost:8080` after starting the application
|
||||
* The application configuration file
|
||||
|
||||
Double-click on `pom.xml` in the project browser to open it in the editor. You will find the import of the Quarkus BOM, allowing to omit the version on the different Quarkus dependencies. In addition, you can see the `quarkus-maven-plugin` responsible of the packaging of the application and also providing the development mode.
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-bom</artifactId>
|
||||
<version>${quarkus.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
----
|
||||
|
||||
And a few more `<dependency>` imports and other ancillary sections. We will be adding things to our `pom.xml` in future sections.
|
||||
|
||||
Navigate to `src -> main -> java -> org.acme.quarkus.sample` in the project tree and double click on `GreetingResource.java`. This class has a very simple RESTful endpoint definition:
|
||||
|
||||
[source, java]
|
||||
----
|
||||
@Path("/hello")
|
||||
public class GreetingResource {
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String hello() {
|
||||
return "hello";
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
It’s a very simple REST endpoint, returning "hello" to requests on `/hello`.
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
Compared to vanilla JAX-RS, with Quarkus there is no need to create an `Application` class. It’s supported but not required. In addition, only one instance of the resource is created and not one per request. You can configure this using the different `*Scoped` annotations (`ApplicationScoped`, `RequestScoped`, etc).
|
||||
====
|
||||
|
||||
## Running the Application
|
||||
|
||||
Now we are ready to run our application. In Che, select the _Command Palette_ by clicking on its icon in the upper right, and double-click on **Run Locally**:
|
||||
|
||||
image::images/runlocally.png[]
|
||||
|
||||
This will compile and run the app using `mvn compile quarkus:dev` in a Terminal window.
|
||||
|
||||
You should see:
|
||||
|
||||
[source,none]
|
||||
----
|
||||
2019-02-28 17:05:22,347 INFO [io.qua.dep.QuarkusAugmentor] (main) Beginning quarkus augmentation
|
||||
2019-02-28 17:05:22,635 INFO [io.qua.dep.QuarkusAugmentor] (main) Quarkus augmentation completed in 288ms
|
||||
2019-02-28 17:05:22,770 INFO [io.quarkus] (main) Quarkus started in 0.668s. Listening on: http://localhost:8080
|
||||
2019-02-28 17:05:22,771 INFO [io.quarkus] (main) Installed features: [cdi, resteasy]
|
||||
----
|
||||
|
||||
Note the amazingly fast startup time! The app is now running "locally" (within the Che container in which the workspace is also running). Che also makes the app accessible from outside the container by creating a Route (ingress) that is displayed at the top of the Terminal window. Look for _Preview URL_:
|
||||
|
||||
image::imgs/previewurl.png[]
|
||||
|
||||
Click on this link to open the link in a new tab, which will access the default Quarkus HTML page included in this app:
|
||||
|
||||
image::images/defaultpage.png[]
|
||||
|
||||
Since our RESTful endpoint listens on the `/hello` endpoint, add `/hello` to the end of the URL in your browser tab to access it.
|
||||
|
||||
You should see `hello` in your browser tab, which means its working!
|
||||
|
||||
Now, let's exercise the **live reload** capabilities of Quarkus. In Che, edit the `GreetingResource.java` file and change `return "hello";` to `return "hola";` in the editor. Press `CTRL-S` (or `CMD-S` on Mac OS) to save the file. Don't recompile or restart anything. Just try to reload the same brower tab that was showing `hello`. It should now show `hola`.
|
||||
|
||||
Wow, how cool is that? Supersonic Subatomic live reload! Go ahead and change it a few more times and access the endpoint again. And we're just getting started.
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
`quarkus:dev` runs Quarkus in development mode. This enables live reload with background compilation, which means that when you modify your Java files your resource files and refresh your browser these changes will automatically take effect.
|
||||
====
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
This will also listen for a debugger on port `5005`. If your want to wait for the debugger to attach before running you can pass `-Ddebug` on the command line. If you don’t want the debugger at all you can use `-Ddebug=false`. We'll use this later.
|
||||
====
|
||||
|
||||
## Congratulations!
|
||||
|
||||
You've seen how to build a basic app, package it as an executable JAR and start it up very quickly. We'll leave the app running and rely on hot reload for the next steps.
|
||||
|
||||
In the next step we'll inject a custom bean to showcase Quarkus' CDI capabilities.
|
||||
1
docs/cdi.adoc
Normal file
@@ -0,0 +1 @@
|
||||
## The Basics
|
||||
1
docs/cloudnative.adoc
Normal file
@@ -0,0 +1 @@
|
||||
## The Basics
|
||||
1
docs/debugging.adoc
Normal file
@@ -0,0 +1 @@
|
||||
## The Basics
|
||||
1
docs/extensions.adoc
Normal file
@@ -0,0 +1 @@
|
||||
## The Basics
|
||||
BIN
docs/imgs/50pods.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
docs/imgs/arch.png
Normal file
|
After Width: | Height: | Size: 112 KiB |
BIN
docs/imgs/login.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
docs/imgs/logo.png
Normal file
|
After Width: | Height: | Size: 71 KiB |
BIN
docs/imgs/native-image-process.png
Normal file
|
After Width: | Height: | Size: 184 KiB |
BIN
docs/imgs/openshift-console-tab.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
docs/imgs/overview.png
Normal file
|
After Width: | Height: | Size: 166 KiB |
BIN
docs/imgs/panache-datatable.png
Normal file
|
After Width: | Height: | Size: 253 KiB |
BIN
docs/imgs/panache-overview-empty.png
Normal file
|
After Width: | Height: | Size: 160 KiB |
BIN
docs/imgs/panache-overview.png
Normal file
|
After Width: | Height: | Size: 193 KiB |
BIN
docs/imgs/panache-projects.png
Normal file
|
After Width: | Height: | Size: 480 KiB |
BIN
docs/imgs/projects.png
Normal file
|
After Width: | Height: | Size: 446 KiB |
BIN
docs/imgs/scaling.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
docs/imgs/ui.png
Normal file
|
After Width: | Height: | Size: 137 KiB |
49
docs/intro.adoc
Normal file
@@ -0,0 +1,49 @@
|
||||
## What is Quarkus?
|
||||
|
||||
image::imgs/logo.png[]
|
||||
|
||||
Quarkus is a Kubernetes Native Java stack tailored for GraalVM & OpenJDK HotSpot, crafted from the best of breed Java libraries and standards. Amazingly fast boot time, incredibly low RSS memory (not just heap size!) offering near instant scale up and high density memory utilization in container orchestration platforms like Kubernetes. Quarkus uses a technique called https://quarkus.io/vision/container-first[compile time boot] and offers a unified imperative and reactive programming model and a number of other developer features like Live Reload to bring _real joy to your development_.
|
||||
|
||||
## Conventions
|
||||
You will see various code and command blocks throughout these exercises. Some of
|
||||
the command blocks can be copy/pasted directly. Others will require modification
|
||||
of the command before execution. If you see a command block with a red border
|
||||
(see below), the command will require slight modification.
|
||||
|
||||
[source,none,role="copypaste copypaste-warning"]
|
||||
----
|
||||
some command to modify
|
||||
----
|
||||
|
||||
Others, including source code snippets can by copy/pasted directly, and do not require modification.
|
||||
|
||||
[source,java,role="copypaste"]
|
||||
----
|
||||
/* A sample Java snippet that you can copy/paste by clicking */
|
||||
public class CopyMeDirectly {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("You can copy this whole class with a click!");
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
Most command blocks support auto highlighting with a click. If you hover over
|
||||
the command block above and left-click, it should automatically highlight all the
|
||||
text to make for easier copying.
|
||||
|
||||
## Your Development Environment
|
||||
|
||||
You will be using Red Hat CodeReady Workspaces, an online IDE based on https://www.eclipse.org/che/[Eclipe Che]. To get started, {{ CHE_URL }}[access the Che instance] and register as a new user using the username you've been assigned (e.g. `user32`, `user8`, etc):
|
||||
|
||||
image::imgs/che-register.png[]
|
||||
|
||||
Once you register, you'll be placed on your personal dashboard allowing you to spawn new workspaces to work on code in a traditional IDE environment. Click on the **Add Workspace** tab on the left, and select the "J4K Stack - Java, Quarkus, odo", and click **Create & Open** to start the workspace:
|
||||
|
||||
image::imgs/che-createworkspace.png[]
|
||||
|
||||
After a minute or two, you'll be placed in the workspace:
|
||||
|
||||
image::imgs/che-workspace.png[]
|
||||
|
||||
Users of Eclipse, IntelliJ IDEA or Visual Studio Code will see a familiar layout: a project/file browser on the left, a code editor on the right, and a terminal at the bottom. You'll use all of these during the course of this workshop, so keep this browser tab open throughout. If things get weird, you can simply reload the browser tab to refresh the view.
|
||||
|
||||
1
docs/kafka.adoc
Normal file
@@ -0,0 +1 @@
|
||||
## The Basics
|
||||
1
docs/messaging.adoc
Normal file
@@ -0,0 +1 @@
|
||||
## The Basics
|
||||
1
docs/monitoring.adoc
Normal file
@@ -0,0 +1 @@
|
||||
## The Basics
|
||||
1
docs/native.adoc
Normal file
@@ -0,0 +1 @@
|
||||
## The Basics
|
||||
1
docs/panache.adoc
Normal file
@@ -0,0 +1 @@
|
||||
## The Basics
|
||||
11
docs/runlocal.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
docker run -it --rm -p 8080:8080 -v $(pwd):/app-data \
|
||||
-e CONTENT_URL_PREFIX="file:///app-data" \
|
||||
-e WORKSHOPS_URLS="file:///app-data/_workshop.yml" \
|
||||
-e LOG_TO_STDOUT=true \
|
||||
-e ROUTE_SUBDOMAIN=".route.subdomain.com" \
|
||||
-e MASTER_URL="https://master.url.com:8443" \
|
||||
-e CHE_URL="http://che-che.master.com" \
|
||||
quay.io/osevg/workshopper
|
||||
|
||||
1
docs/testing.adoc
Normal file
@@ -0,0 +1 @@
|
||||
## The Basics
|
||||
1
docs/tracing.adoc
Normal file
@@ -0,0 +1 @@
|
||||
## The Basics
|
||||
8
setup/htpass.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
spec.identityProviders[+]:
|
||||
name: htpassidp
|
||||
type: HTPasswd
|
||||
mappingMethod: claim
|
||||
htpasswd:
|
||||
fileData:
|
||||
name: workshop-user-secret
|
||||
|
||||
210
setup/preparelab.sh
Executable file
@@ -0,0 +1,210 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Prereqs: a running ocp 4 cluster, logged in as kubeadmin
|
||||
#
|
||||
MYDIR="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
function usage() {
|
||||
echo "usage: $(basename $0) [-c/--count usercount] -a/--admin-password admin_password"
|
||||
}
|
||||
|
||||
# Defaults
|
||||
USERCOUNT=10
|
||||
ADMIN_PASSWORD=
|
||||
|
||||
POSITIONAL=()
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
key="$1"
|
||||
|
||||
case $key in
|
||||
-c|--count)
|
||||
USERCOUNT="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
-a|--admin-pasword)
|
||||
ADMIN_PASSWORD="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
*) # unknown option
|
||||
echo "Unknown option: $key"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
set -- "${POSITIONAL[@]}" # restore positional parameters
|
||||
echo "USERCOUNT: $USERCOUNT"
|
||||
echo "ADMIN_PASSWORD: $ADMIN_PASSWORD"
|
||||
|
||||
if [ -z "$ADMIN_PASSWORD" ] ; then
|
||||
echo "Admin password (-a) required"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! "$(oc get clusterrolebindings)" ] ; then
|
||||
echo "not cluster-admin"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# get routing suffix
|
||||
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)
|
||||
|
||||
# create users
|
||||
TMPHTPASS=$(mktemp)
|
||||
for i in {1..$USERCOUNT} ; do
|
||||
htpasswd -b ${TMPHTPASS} "user$i" "pass$i"
|
||||
done
|
||||
|
||||
# Add openshift cluster admin user
|
||||
htpasswd -b ${TMPHTPASS} admin "${ADMIN_PASSWORD}"
|
||||
|
||||
# Create user secret in OpenShift
|
||||
! oc -n openshift-config delete secret workshop-user-secret
|
||||
oc -n openshift-config create secret generic workshop-user-secret --from-file=htpasswd=${TMPHTPASS}
|
||||
rm -f ${TMPHTPASS}
|
||||
|
||||
# Set the users to OpenShift OAuth
|
||||
oc -n openshift-config get oauth cluster -o yaml | \
|
||||
yq d - spec.identityProviders | \
|
||||
yq w - -s ${MYDIR}/htpass.yaml | \
|
||||
oc apply -f -
|
||||
|
||||
# sleep for 30 seconds for the pods to be restarted
|
||||
echo "Wait for 30s for new OAuth to take effect"
|
||||
sleep 30
|
||||
|
||||
# Make the admin as cluster admin
|
||||
oc adm policy add-cluster-role-to-user cluster-admin admin
|
||||
|
||||
# create projects for users
|
||||
for i in {1..$USERCOUNT} ; do
|
||||
PROJ="user${i}-project"
|
||||
oc new-project $PROJ --display-name="Working Project for user${i}" >&- && \
|
||||
oc label namespace $PROJ quarkus-workshop=true && \
|
||||
oc adm policy add-role-to-user admin user${i} -n $PROJ
|
||||
done
|
||||
|
||||
# deploy guides
|
||||
oc new-project guides
|
||||
oc new-app quay.io/osevg/workshopper --name=web \
|
||||
-e ROUTE_SUBDOMAIN=${HOSTNAME_SUFFIX} \
|
||||
-e MASTER_URL=${MASTER_URL} \
|
||||
-e CHE_URL=http://codeready-che.${ROUTE_SUBDOMAIN} \
|
||||
-e WORKSHOPS_URLS="https://raw.githubusercontent.com/openshift-evangelists/workshopper-template/master/_workshop.yml" \
|
||||
-e LOG_TO_STDOUT=true
|
||||
oc expose svc/web
|
||||
|
||||
# Install Che
|
||||
oc new-project che
|
||||
cat <<EOF | oc apply -n openshift-marketplace -f -
|
||||
apiVersion: operators.coreos.com/v1
|
||||
kind: CatalogSourceConfig
|
||||
metadata:
|
||||
name: installed-redhat-che
|
||||
namespace: openshift-marketplace
|
||||
spec:
|
||||
targetNamespace: che
|
||||
packages: codeready-workspaces
|
||||
EOF
|
||||
|
||||
cat <<EOF | oc apply -n che -f -
|
||||
apiVersion: operators.coreos.com/v1alpha2
|
||||
kind: OperatorGroup
|
||||
metadata:
|
||||
name: che-operator-group
|
||||
namespace: che
|
||||
spec:
|
||||
targetNamespaces:
|
||||
- che
|
||||
EOF
|
||||
|
||||
cat <<EOF | oc apply -n che -f -
|
||||
apiVersion: operators.coreos.com/v1alpha1
|
||||
kind: Subscription
|
||||
metadata:
|
||||
name: codeready-workspaces
|
||||
namespace: che
|
||||
labels:
|
||||
csc-owner-name: installed-redhat-che
|
||||
csc-owner-namespace: openshift-marketplace
|
||||
spec:
|
||||
channel: final
|
||||
installPlanApproval: Automatic
|
||||
name: eclipse-che
|
||||
source: installed-community-che
|
||||
sourceNamespace: che
|
||||
startingCSV: crwoperator.v1.2.0
|
||||
EOF
|
||||
|
||||
cat <<EOF | oc apply -n che -f -
|
||||
apiVersion: org.eclipse.che/v1
|
||||
kind: CheCluster
|
||||
metadata:
|
||||
name: codereadyt
|
||||
namespace: che
|
||||
spec:
|
||||
server:
|
||||
tlsSupport: false
|
||||
selfSignedCert: false
|
||||
database:
|
||||
externalDb: false
|
||||
chePostgresHostName: ''
|
||||
chePostgresPort: ''
|
||||
chePostgresUser: ''
|
||||
chePostgresPassword: ''
|
||||
chePostgresDb: ''
|
||||
auth:
|
||||
openShiftoAuth: false
|
||||
externalKeycloak: false
|
||||
keycloakURL: ''
|
||||
keycloakRealm: ''
|
||||
keycloakClientId: ''
|
||||
storage:
|
||||
pvcStrategy: per-workspace
|
||||
pvcClaimSize: 1Gi
|
||||
preCreateSubPaths: true
|
||||
EOF
|
||||
|
||||
# Wait for che to be up
|
||||
echo "Waiting for Che to come up..."
|
||||
while [ 1 ]; do
|
||||
STAT=$(curl -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 PVC problem
|
||||
oc get --export cm/custom -n che -o yaml | yq w - 'data.CHE_INFRA_KUBERNETES_PVC_WAIT__BOUND' \"false\" | oc apply -f - -n che
|
||||
oc scale -n che deployment/che --replicas=0
|
||||
oc scale -n che deployment/che --replicas=1
|
||||
|
||||
# Add custom stack manually
|
||||
|
||||
# Add che users
|
||||
# ./kcadm.sh config credentials --server http://$KEYCLOAK_SERVICE_HOST:$KEYCLOAK_SERVICE_PORT_HTTP/auth --realm codeready
|
||||
|
||||
# Scale the cluster
|
||||
WORKERCOUNT=$(oc get nodes|grep worker | wc -l)
|
||||
if [ "$WORKERCOUNT" -lt 10 ] ; then
|
||||
for i in $(oc get machinesets -n openshift-machine-api -o name | grep worker| cut -d'/' -f 2) ; do
|
||||
echo "Scaling $i to 3 replicas"
|
||||
oc patch -n openshift-machine-api machineset/$i -p '{"spec":{"replicas": 3}}' --type=merge
|
||||
done
|
||||
fi
|
||||
|
||||
# Pre-pull some images
|
||||
|
||||
# Build stack
|
||||
# docker build --build-arg RH_USERNAME='YOURUSERNAME' --build-arg RH_PASSWORD='YOURPASSWORD' -t docker.io/schtool/che-quarkus-odo:j4k -f stack.Dockerfile .
|
||||
28
setup/resetlab.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Prereqs: a running ocp 4 cluster, logged in as kubeadmin
|
||||
#
|
||||
MYDIR="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
function usage() {
|
||||
echo "usage: $(basename $0)"
|
||||
}
|
||||
|
||||
if [ ! "$(oc get clusterrolebindings)" ] ; then
|
||||
echo "not cluster-admin"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
oc delete project che
|
||||
oc delete project guides
|
||||
oc delete project app-monitoring
|
||||
|
||||
# delete user projects
|
||||
for proj in $(oc get projects -l quarkus-workshop=true -o name|cut -d/ -f2) ; do
|
||||
oc delete project $proj
|
||||
done
|
||||
|
||||
# scale back down
|
||||
for i in $(oc get machinesets -n openshift-machine-api -o name | grep worker| cut -d'/' -f 2) ; do
|
||||
echo "Scaling $i to 1 replica"
|
||||
oc patch -n openshift-machine-api machineset/$i -p '{"spec":{"replicas": 1}}' --type=merge
|
||||
done
|
||||
33
setup/stack.Dockerfile
Normal file
@@ -0,0 +1,33 @@
|
||||
FROM registry.access.redhat.com/codeready-workspaces/stacks-java-rhel8:1.2
|
||||
|
||||
ARG RH_USERNAME
|
||||
ARG RH_PASSWORD
|
||||
|
||||
USER root
|
||||
|
||||
RUN wget -O /usr/local/bin/odo https://github.com/openshift/odo/releases/download/v1.0.0-beta2/odo-linux-amd64 && chmod a+x /usr/local/bin/odo
|
||||
|
||||
RUN wget -O /tmp/oc.tar.gz https://mirror.openshift.com/pub/openshift-v4/clients/oc/4.1/linux/oc.tar.gz && cd /usr/bin && tar -xvzf /tmp/oc.tar.gz && chmod a+x /usr/bin/oc && rm -f /tmp/oc.tar.gz
|
||||
|
||||
RUN wget -O /tmp/graalvm.tar.gz https://github.com/oracle/graal/releases/download/vm-1.0.0-rc16/graalvm-ce-1.0.0-rc16-linux-amd64.tar.gz && cd /usr/local && tar -xvzf /tmp/graalvm.tar.gz && rm -rf /tmp/graalvm.tar.gz
|
||||
|
||||
ENV GRAALVM_HOME="/usr/local/graalvm-ce-1.0.0-rc16"
|
||||
|
||||
RUN wget -O /tmp/mvn.tar.gz http://www.eu.apache.org/dist/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz
|
||||
|
||||
RUN tar xzf /tmp/mvn.tar.gz && rm -rf /tmp/mvn.tar.gz && mkdir /usr/local/maven && mv apache-maven-3.6.0/ /usr/local/maven/ && alternatives --install /usr/bin/mvn mvn /usr/local/maven/apache-maven-3.6.0/bin/mvn 1
|
||||
|
||||
ENV PATH="/usr/local/maven/apache-maven-3.6.0/bin:${PATH}"
|
||||
|
||||
ENV MAVEN_OPTS="-Xmx1024M -Xss128M -XX:MetaspaceSize=512M -XX:MaxMetaspaceSize=1024M -XX:+CMSClassUnloadingEnabled"
|
||||
|
||||
RUN subscription-manager register --username $RH_USERNAME --password $RH_PASSWORD --auto-attach && yum install -y gcc zlib-devel && yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && yum install -y siege && subscription-manager remove --all && subscription-manager unregister
|
||||
|
||||
RUN chown -R jboss /home/jboss/.m2
|
||||
USER jboss
|
||||
|
||||
RUN cd /tmp && mkdir project && cd project && mvn io.quarkus:quarkus-maven-plugin:0.16.1:create -DprojectGroupId=org.acme -DprojectArtifactId=footest -Dextensions="reactive-kafka,vert.x" && mvn clean compile package && mvn clean compile package -Pnative && mvn clean && cd / && rm -rf /tmp/project
|
||||
|
||||
RUN siege && sed -i 's/^connection = close/connection = keep-alive/' $HOME/.siege/siege.conf && sed -i 's/^benchmark = false/benchmark = true/' $HOME/.siege/siege.conf
|
||||
|
||||
RUN echo '-w "\n"' > $HOME/.curlrc
|
||||