In last post I completed the workload cluster deployment. The deployed cluster is now ready to be consumed. In this post I will show how we can deploy a sample application/workload in the newly provisioned kubernetes cluster.
If you have missed earlier post of this series, you can read them from below links:
2: TKG Management Cluster Deployment
3: TKG Workload Cluster Deployment
To deploy any application in the kubernetes cluster, we first have to connect to the workload cluster context.
Below command shows that I am currently connected to cluster “mj-tkgc01”, which is my workload cluster.
1 2 3 4 5 |
root@tkg-client:~# kubectl config get-contexts CURRENT NAME CLUSTER AUTHINFO NAMESPACE mj-tkgc01-admin@mj-tkgc01 mj-tkgc01 mj-tkgc01-admin * mj-tkgm01-admin@mj-tkgm01 mj-tkgm01 mj-tkgm01-admin |
Note: We can use command kubectl config use-context <cluster-context-name> to switch between the clusters.
Deploy Sample Nginx Web Server
In my environment I have deployed nginx web server using below command
1 2 |
root@tkg-client:~# kubectl create deployment nginx --image=nginx deployment.apps/nginx created |
kubectl get all command can be used to verify status of deployed application.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
root@tkg-client:~# kubectl get all NAME READY STATUS RESTARTS AGE pod/nginx-f89759699-6qqgz 1/1 Running 0 4h9m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 100.64.0.1 <none> 443/TCP 18h service/nginx NodePort 100.66.190.8 <none> 80:31693/TCP 4h6m NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/nginx 1/1 1 1 4h9m NAME DESIRED CURRENT READY AGE replicaset.apps/nginx-f89759699 1 1 1 4h9m |
Create Service for Nginx
1 2 |
root@tkg-client:~# kubectl create service nodeport nginx --tcp=80:80 service/nginx created |
Verify Service Details
When we create a service for an application, kubernetes assigns a system generated port for the service.
1 2 3 4 5 6 7 |
root@tkg-client:~# kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 100.64.0.1 <none> 443/TCP 23h nginx NodePort 100.66.190.8 <none> 80:31693/TCP 9h |
Since no external ip address is configured for nginx, it can be accessed by connecting to any of the worker node IP on port 31693
And that’s it for this post. In next post I will cover how to scale up/scale down application running inside kubernetes cluster.
I hope you enjoyed reading the post. Feel free to share this on social media if it is worth sharing 🙂