1. Deploy Applications to IBM Cloud
Source:
1.1. Create a Quarkus Project
mvn io.quarkus:quarkus-maven-plugin:1.7.2.Final:create \
-DprojectGroupId=at.htl \
-DprojectArtifactId=config-quickstart \
-DclassName="at.htl.config.GreetingResource" \
-Dpath="/greeting"
cd config-quickstart
idea .
open a terminal
./mvnw clean compile quarkus:dev
cURL
curl -w "\n" http://localhost:8080/greeting
hello
httpie
http :8080/greeting
HTTP/1.1 200 OK Content-Length: 5 Content-Type: text/plain;charset=UTF-8 hello
./mvnw quarkus:add-extension -Dextensions="kubernetes, container-image-docker"
[INFO] Scanning for projects... [INFO] [INFO] ----------------------< at.htl:config-quickstart >---------------------- [INFO] Building config-quickstart 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- quarkus-maven-plugin:1.7.2.Final:add-extension (default-cli) @ config-quickstart --- ? Extension io.quarkus:quarkus-kubernetes has been installed ? Extension io.quarkus:quarkus-container-image-docker has been installed [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.227 s [INFO] Finished at: 2020-09-07T11:21:40+02:00 [INFO] ------------------------------------------------------------------------
1.2. Package the Application
application.properties
quarkus.kubernetes.part-of=todo-app
quarkus.container-image.name=getting-started
quarkus.container-image.tag=1.0
quarkus.container-image.registry=
quarkus.container-image.group=
quarkus.kubernetes.service-type=NodePort (1)
1 | The default value ClusterIP is not working with minikube. |
./mvnw clean package
-
There should be a BUILD SUCCESS.
-
Examine the
target/kubernetes/kubernetes.yml
- file. -
Notice the
Service
- andDeployment
-Sections in the yml-file.
1.3. Deploy to minikube
quarkus.kubernetes.part-of=todo-app
quarkus.container-image.name=getting-started
quarkus.container-image.tag=1.0
quarkus.container-image.registry=
quarkus.container-image.group=
quarkus.kubernetes.image-pull-policy=never
quarkus.kubernetes.service-type=NodePort
./mvnw clean package -Dquarkus.kubernetes.deploy=true
[INFO] [io.quarkus.kubernetes.deployment.KubernetesDeployer] Deploying to kubernetes server: https://127.0.0.1:32772/ in namespace: default.
kubectl get pod
kubectl get deploy
kubectl get svc
-
Hier sieht man den Port des Nodeport
minikube ip
-
Mit
minikube ip
kann man die Ip von minikube abrufen
curl <ip-von-minikube>/<port-von-nodeport>/greeting
-
This didn’t work under MacOS.
-
In this case you have to open a tunnel with
minikube
.
minikube service getting-started
terminal output
|-----------|-----------------|-------------|-------------------------| | NAMESPACE | NAME | TARGET PORT | URL | |-----------|-----------------|-------------|-------------------------| | default | getting-started | http/8080 | http://172.17.0.4:31908 | |-----------|-----------------|-------------|-------------------------| 🏃 Starting tunnel for service getting-started. |-----------|-----------------|-------------|------------------------| | NAMESPACE | NAME | TARGET PORT | URL | |-----------|-----------------|-------------|------------------------| | default | getting-started | | http://127.0.0.1:57075 | |-----------|-----------------|-------------|------------------------| 🎉 Opening service default/getting-started in default browser... ❗ Because you are using a Docker driver on darwin, the terminal needs to be open to run it.
-
The browser opens and show the webpage
-
add /greeting to the url and it works
-
with ` minikube service getting-started --url` you only print out the url.
-
don’t forget NOT to close the terminal, because it would close the tunnel too.
1.4. IBM Cloud Internet Services
-
First sign up for a cloud account. Choose the type "lite".
-
Install the ibm-cloud-cli
Login and install plugins
ibmcloud login
ibmcloud plugin install container-service
ibmcloud plugin install container-registry
ibmcloud plugin install observe-service
ibmcloud plugin list