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.
kubectl create -f go-demo-2-deploy.ymlkubectl get -f go-demo-2-deploy.yml
The output of the get
command is as follows:
NAME READY UP-TO-DATE AVAILABLE AGEdeployment.apps/go-demo-2-db 0/1 1 0 2m15sNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEservice/go-demo-2-db ClusterIP 10.111.211.179 <none> 27017/TCP 2m15sNAME READY UP-TO-DATE AVAILABLE AGEdeployment.apps/go-demo-2-api 0/3 3 0 2m15sNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEservice/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.
kubectl get pods
The output is as follows:
NAME READY STATUS RESTARTS AGEgo-demo-2-api-68df567fb5-8qcmv 1/1 Running 0 3mgo-demo-2-api-68df567fb5-k55d4 1/1 Running 0 3mgo-demo-2-api-68df567fb5-ws9cj 1/1 Running 0 3mgo-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
...