Skip to content
travis edited this page Apr 14, 2020 · 9 revisions

MyThaiStar on Native Kubernetes as a Service (nKaaS)

The MyThaiStar sample application can be deployed on a nKaaS environment. The required Kubernetes configuration files can be found in the MyThaiStar repository. There are no additional changes required in order to deploy the application.

Setting up the environment

Following the nKaaS guide

After requesting access to the nKaaS platform you’ll be greeted with a welcome mail which contains your personal credentials. Make sure to change the given password to a personal one within the 24 hour time period, otherwise the credentials will expire.

After successfully following the guide mentioned in the welcome mail you should be able to establish a connection to the nKaaS VPN and have access to all their services (Jenkins, BitBucket, etc.). You should also be able to communicate with Kubernetes using kubectl.

Known issues: The nKaaS guide provides a download link for OpenVPN Connect. However, some users experienced connection issues with this client. If you’re having issues connecting to the VPN with OpenVPN Connect, you may try out the client by OVPN.

Requesting a namespace

Initially, you won’t be able to edit anything on Kubernetes, as you don’t have any privileges on any namespace. To request your own namespace you should raise a ticket at the Customer Support Portal containing your desired name for the namespace.

As soon as the namespace was created you can change your kubectl context:

kubectl config set-context --current -namespace=YOUR-NAMESPACE

On your own namespace you should have permissions to create/delete deployments/services etc. and perform other actions.

Setting up Harbor

Jenkins will build the MyThaiStar Docker images and push them to the nKaaS Harbor registry. The Jenkinsfile defaults to a Harbor project called "my-thai-star". If there’s no such project on Harbor, simply create a new one.

Setting up Jenkins

As MyThaiStar includes all required Jenkinsfiles for nKaaS, almost no configurations have to be performed by the user. Create a new Pipeline on Jenkins and configure its definition to be a "Pipeline script from SCM". The SCM used is "Git" and the repository URL is the MyThaiStar repository https://github.com/devonfw/my-thai-star.git or your fork of it.

The Branch Specifier should point to \*/develop, the Script Path is jenkins/nKaaS/Jenkinsfile as that’s where the Jenkinsfile is located at the MyThaiStar repository. Checking the "Lightweight checkout" could speed up the Pipeline.

Note: If you’re using the nKaaS Bitbucket as repository for your MyThaiStar clone you have to perform some additional configurations. First you’ll have to create a new SSH keypair, for example with ssh-keygen. Add the public key to the Bitbucket authentication methods and the private key in Jenkins to a new pair of credentials. This step is required for Jenkins to be able to authenticate against Bitbucket. Afterwards, instead of the official MyThaiStar repository, specify your Bitbucket repository:

ssh://git@bitbucket.demo.xpaas.io:7999/YOUR-PROJECT/YOUR-MTS-REPO.git

Under "Credentials" choose the credentials that contain your Bitbucket private key you’ve created earlier.

Building the MyThaiStar images

After configuring the Jenkins Pipeline it can be started with the "Build now" button. The pipeline will checkout the MyThaiStar repository, build an image for the Angular frontend, an image for the Java backend and push both onto the Harbor registry. If every step was executed successfully, you should be able to see the images on Harbor.

Deploying MyThaiStar on Kubernetes

Currently, the deployment is done manually and not yet included in the Jenkins pipeline. kubectl will be used for this step. First, change directory to your local clone of your MyThaiStar project.

cd YOUR-MTS-REPO/nKaaS

There are three Kubernetes resource files that have to be deployed onto your Kubernetes namespace: - angular-app.yaml: This file includes a Deployment and a Service for the Angular frontend - java-app.yaml: This file includes a Deployment and a Service for the Java backend - ingress.yaml: This file includes two Ingress services, one for Angular, one for Java

The Ingress ressource specifies the host on which your MyThaiStar application will be accessible. Open ingress.yaml in your preferred editor and change both host values to your preferred hostname in the pattern YOUR-HOSTNAME.demo.xpaas.io.

These files can be applied onto Kubernetes with the following commands:

kubectl apply -f angular-app.yaml
kubectl apply -f java-app.yaml
kubectl apply -f ingress.yaml

Finally, after waiting a few moments, you should be able to access your MyThaiStar application within your browser by navigating to your previously specified host.