We will be using Appsody from Kabanero Project for this hands on.
https://www.katacoda.com/courses/ubuntu/playground1804
Sign in using your gmail id.
$ cat /etc/os-release
output should be
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
Get installable
$ wget https://github.com/appsody/appsody/releases/download/0.2.8/appsody_0.2.8_amd64.deb
$ sudo apt install ./appsody_0.2.8_amd64.deb
For Mac or Linux:
-> To install latest version of the IBM Cloud CLI, run the command:
$ curl -sL https://ibm.biz/idt-installer | bash
-> To verify that the CLI and Developer tools were installed successfully, run the help command:
$ ibmcloud dev help
Output lists the usage instructions, the current version, and the supported commands.
-> Now configure your environment, log in to IBM Cloud with your IBMid.
$ ibmcloud login
-> To access Cloud Foundry services, you must specify a Cloud Foundry org and space. You can run the following command to interactively identify the org and space:
$ ibmcloud target --cf
Or, if you know which org and space that the service belongs to, you can use the following command:
$ ibmcloud target -o <value> -s <value>
The above commands are also available in the web page: https://cloud.ibm.com/docs/cli?topic=cloud-cli-getting-started
Go to browser and login to IBM Cloud UI.
From the Dashboard, click on the Kubernetes cluster.
A pop-up window will appear.
Execute the commands from your pop-up window on the command prompt.
First, choose a development stack. To see all the available stacks, run:
$ appsody list
Create a new directory for your project and run appsody init to download the template project.
The following example uses the nodejs-express stack to create a fully functional Appsody project:
$ mkdir illustration
$ cd illustration
$ appsody init nodejs-express
$ appsody run
Now the project is running in a docker container, and the container is linked to the project source code on your local system. Great!
Open New terminal
$ curl http://localhost:3000
OR open in browser: http://localhost:3000
You should see out put as
"Hello from Appsody!"
Now let's try changing the code. Edit the file app.js to output something other than "Hello from Appsody!".
When you save the file, Appsody picks up the change and automatically updates the container.
Run
$ curl http://localhost:3000
OR If using Mac/Linux local machine command prompt, open in browser: http://localhost:3000 to see the new message!
11. Now, let's tag and push the container onto docker hub and deploy the image to your IBM Kubernetes cluster.
In the command prompt, login to docker with your username/password. Sign up if you are a new user.
$ docker login
-> Build the container
$ appsody build
-> Tag and push the image to docker hub
$ docker tag <app-name> <docker_user>/<app-name>
For this appsody project:
$ docker tag illustration myDockerUsername/illustration
Now push:
$ docker push <docker_user>/<app-name>
For this appsody project:
$ docker push myDockerUsername/illustration
-> Deploy.
$ appsody deploy
One step command to build, tag, push and deploy the development container on to the Kubernetes cluster:
$ appsody deploy --tag <dockerhub-space>/<app-name>:<version> --push
In this case:
$ appsody deploy --tag <mydocker-username>/illustration:1 --push
Output: : : Attempting to get resource from Kubernetes ... Running command: kubectl[get svc sampleapp -o jsonpath=http://{.status.loadBalancer.ingress[0].hostname}:{.spec.ports[0].nodePort} --namespace default] Deployed project running at http://:31649
Note the port number that the project is deployed on.
Fetch the external IP of your cluster with the command:
$ kubectl get node -o wide
If using Mac/Linux local machine command prompt, open your web browser with http://[external-ip-cluster]:[port-no]
OR
Open New terminal
$ curl http://[external-ip-cluster]:[port-no]
You should see the message output.
When you're all done, you can stop the environment.