11 Deploy with Service
It’s normal to split up Kubernetes configuration files, into more files. To deploy them all, in one command, simply add a .
in the end, instead of specifiying a single file. We will use this, to deploy both the deployment, and the service, at the same time.
Note, if you have already deployed something, running the command again, just updated the deployment, in case there are changes.
- To deploy all .yml files in the directory run
kubectl apply -f .
- You should see each file being created
deployment.apps/student1-deployment created
service/nginx-service created
- To see your deployment and services has been deployed run
kubectl get all -n studentx
NAME READY STATUS RESTARTS AGE
pod/student1-deployment-9888cf49d-w855n 1/1 Running 0 77s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/nginx-service NodePort 10.152.183.251 <none> 80:30010/TCP 77s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/student1-deployment 1/1 1 1 77s
NAME DESIRED CURRENT READY AGE
replicaset.apps/student1-deployment-9888cf49d 1 1 1 77s
- Open a browser to the public ip of the K8S server, with the port number you specified earlier
http://K8SPublicIp:30010
and see your deployment is working, and is exposed to the outside world.