Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Key to the components in the steps above

componentdescription
nginx-deploymentIt should be the value of metadata:/name: in the deployment file
--type=LoadBalancerThe type of service being created
--port=80

What port the service will be exposed on.  I have had to set this to 80 in order the view the service in a browser (I cannot se another way of accessing the service when the following URL is used in the browser - http://localhost:8001/api/v1/namespaces/default/services/nginx-deployment/proxy/

In the URL shown above, http://localhost:8001 is the URL given for the minikube proxy that is invoked with the command kubectl proxy

Notice in the URL the use of the deployment value nginx-deployment for the key metadata:/name:

Notice the path to your service is always <minikube proxy IP>:<port>/api/v1/namespaces/default/services


Info
titleNote on Service Port

When you execute the command kubectl expose deployment <deployment name> --type=LoadBalancer --port=<port>, you do not need to use a port value of 80 when another service is going to use this service.  The only reason we have used 80 here is because we want to view the service via a browser.

...

The service is not available to the outside world until it is exposed with the kubectl expose deployment <deployment name> command

Image Added

The --type=NodePort is an important switch.  It tells kubernetes to expose the service onto the Nodes Port.  We can see the exposed service using the following command

Image Added

Notice shw has been exposed on port 32638 on the node, so it is now visible to the outside world.

To see the service use the kubectl service <deployment name> command

Image Added

Go to your browser and enter the URL shown if the app is not visible