...

/

Services and External Access

Services and External Access

Learn why Services are not the best fit for enabling external access to the applications.

Only Services won’t suffice

We cannot explore solutions before we know what the problems are. Therefore, we’ll recreate a few objects using the knowledge we’ve already gained. This will let us see whether Kubernetes Services satisfy all the needs that the users of our applications might have. To be more clear, we’ll explore which features we’re missing when making our applications accessible to users.

We’ve already discussed that it is not recommended to publish fixed ports through Services. This method is likely to result in conflicts or, at the very least, create the additional burden of carefully keeping track of which port belongs to which Service. We already discarded that option before and we won’t change it now.

Press + to interact
kubectl create -f go-demo-2-deploy.yml
kubectl get -f go-demo-2-deploy.yml

The output of the get command is as follows:

Press + to interact
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/go-demo-2-db 0/1 1 0 2m15s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/go-demo-2-db ClusterIP 10.111.211.179 <none> 27017/TCP 2m15s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/go-demo-2-api 0/3 3 0 2m15s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/go-demo-2-api NodePort 10.103.180.226 <none> 8080:30753/TCP 2m15s

As we can see, these are the same Services and Deployments we previously created.

Before we move on, we should wait until all the Pods are up and running.

Press + to interact
kubectl get pods

The output is as follows:

Press + to interact
NAME READY STATUS RESTARTS AGE
go-demo-2-api-68df567fb5-8qcmv 1/1 Running 0 3m
go-demo-2-api-68df567fb5-k55d4 1/1 Running 0 3m
go-demo-2-api-68df567fb5-ws9cj 1/1 Running 0 3m
go-demo-2-db-dd48b7dfc-hdxbz 1/1 Running 0 3m

If, in your case, some of the Pods are not yet running, please wait a few moments and re-execute the kubectl get ...

Access this course and 1400+ top-rated courses and projects.