https://cloud.ibm.com/kubernetes/clusters
Click on shopping-cluster
to view:
https://cloud.ibm.com/docs/containers?topic=containers-cs_cli_install
If this is your first time connecting to an IBM Cloud cluster, see the full setup directions.
https://cloud.ibm.com/docs/containers?topic=containers-helm
kubectl create serviceaccount tiller -n kube-system
kubectl create clusterrolebinding tiller --clusterrole=cluster-admin --serviceaccount=kube-system:tiller -n kube-system
kubectl get serviceaccount -n kube-system tiller
helm init --service-account tiller
https://cloud.ibm.com/kubernetes/registry/main/start
- Login into IBM Cloud container registry
ibmcloud cr login
- Use an existing namespace for the container registry or create a new one:
In sections below, we assume the namespace is loopback
. Please substitute
loopback
to the container registry namespace you choose for IBM Cloud.
Existing namespaces can be listed:
ibmcloud cr namespaces
You can add a namespace as follows:
ibmcloud cr namespace-add loopback
- Upload docker images
- Build docker images locally
Before we rebuild docker images, consider to bump the project to the next version:
npm run docker:version
To specify the exact version:
npm run docker:version -- <version>
Run the the following command to build docker images:
npm run docker:build
- Tag and push images to IBM Cloud container registry
docker tag loopback4-example-shopping:1.1.1 us.icr.io/loopback/loopback4-example-shopping:1.1.1
docker push us.icr.io/loopback/loopback4-example-shopping:1.1.1
docker tag loopback4-example-recommender:1.1.1 us.icr.io/loopback/loopback4-example-recommender:1.1.1
docker push us.icr.io/loopback/loopback4-example-recommender:1.1.1
Please note that the fully qualified docker image name is in the form of
<registry>/<namespace>/<repository>:<tag>
. For example,
us.icr.io/loopback/loopback4-example-shopping:1.1.1
represents the following:
- registry - us.icr.io
- namespace - loopback
- repository - loopback-example-shopping
- tag - 1.1.0
- Update
kubernetes/shopping-app/ibmcloud-values.yaml
:
images:
recommender: us.icr.io/loopback/loopback4-example-recommender:1.1.1
shopping: us.icr.io/loopback/loopback4-example-shopping:1.1.1
- Build the helm chart with dependencies
helm dependency build kubernetes/shopping-app
- Install the helm chart to IBM Cloud
helm install --name shopping-app -f kubernetes/shopping-app/ibmcloud-values.yaml kubernetes/shopping-app/
If you have an existing release named as shopping-app
, use the following
command to uninstall it:
helm del --purge shopping-app
A few steps are involved to find the public URL of the application:
-
Get the public IP of the k8s cluster
ibmcloud ks worker ls shopping-cluster
Sample output:
ID Public IP Private IP Flavor State Status Zone Version kube-bm5qug9d04ikneuepcj0-shoppingclu-default-0000003e 173.193.79.83 10.76.217.70 free normal Ready hou02 1.14.6_1533*
In the example above, the public ip is
173.193.79.83
. -
Get the NodePort for
shopping
servicekubectl describe services shopping
Sample output:
Name: shopping Namespace: default Labels: service=shopping Annotations: <none> Selector: service=shopping Type: NodePort IP: 172.21.202.240 Port: rest 3000/TCP TargetPort: rest/TCP NodePort: rest 31094/TCP <= Public Port is 31094 Endpoints: 172.30.232.30:3000 Session Affinity: None External Traffic Policy: Cluster Events: <none>
In this example, the public port is
31094
asNodePort: rest 31094/TCP
maps31094
to3000
. -
Open the home page
http://<public-ip>:<public-port>
In the example output, the public url is http://173.193.79.83:31094.