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.

kubectl apply -f .
deployment.apps/student1-deployment created
service/nginx-service created
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