How to deploy an application on IBM Kubernetes Services (a.k.a. IKS)

ibmcloud login -a https://cloud.ibm.com -u passcode -p xxxxxx 
(xxxx generated randomly by IBM Cloud)
ibmcloud ks cluster config --cluster xxxxx
or in our example
ibmcloud ks cluster config --cluster c2jr04vd0gva8pgpoam0
kubectl config current-context

1. Deployement of a sample application

kubectl create deployment guestbook --image=ibmcom/guestbook:v1
deployment.apps/guestbook created
kubectl get pods
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
guestbook-59bd679fdc-bxdg7 1/1 Running 0 1m

2. Make the application visible and accessible to users

  • Port: the port on which the service is exposed. Other pods can communicate with it via this port.
  • TargetPort: the actual port on which your container is deployed. The service sends requests to this port and the pod container must listen to the same port.
  • NodePort: exposes a service externally to the cluster. So the application can be accessed via this port externally. By default, it’s automatically assigned during deployment.
kubectl expose deployment guestbook --type="NodePort" --port=3000
service/guestbook exposed
kubectl get service guestbook
NAME        TYPE       CLUSTER-IP    EXTERNAL-IP   PORT(S)          AGE
guestbook NodePort 172.21.40.1 <none> 3000:31747/TCP 2m2s
ibmcloud ks workers --cluster $CLUSTER_NAME 
(if you have already set this) or
ibmcloud ks workers --cluster c2jr04vd0gva8pgpoam0
(in case of this example)
ID                                                       Public IP       Private IP      Flavor   State    Status   Zone    Version
kube-c0igf50d0t5cp9eut8o0-aammycluste-default-0000004d 169.57.85.182 10.131.83.214 free normal Ready mex01 1.18.15_1540

3. Additional information and resources

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alain Airom (Ayrom)

Alain Airom (Ayrom)

196 Followers

IT guy for a long time, looking for technical challenges everyday!