Java Magazine, May/June 2019
ORACLE COM JAVAMAGAZINE MAY JUNE 2019 16 containers kubectl create deployment hello node image gcr io hello minikube zero install hello deployment apps hello node created kubectl get deployments NAME READY UP TO DATE AVAILABLE AGE hello node 0 1 1 0 27s kubectl get pods NAME READY STATUS RESTARTS AGE hello node 64c578bdf8 5b7jm 1 1 Running 0 10m By default Kubernetes assigns a pod an internal IP address that is accessible only from within the cluster To enable external access to the containers running within a pod you will expose the pod as a service In Kubernetes a service is an abstraction that defines a way to access a pod or a set of pods Create a simple LoadBalancer service with kubectl expose This will enable external access to your service through a load balancer kubectl expose deployment hello node type LoadBalancer port 8080 service hello node exposed kubectl get services NAME TYPE CLUSTER IP EXTERNAL IP PORT S hello node LoadBalancer 1010410847 pending 8080 30631 TCP kubernetes ClusterIP 109601 none 443 TCP The output includes other fields that are omitted to fit on this page This is also true of some subsequent output listings Ed On a cloud provider or other managed Kubernetes platform this action would result in the allocation of a load balancer resource and its IP address would be shown in the EXTERNAL IP column In Minikube use the service command which will open a browser and show you that the service is working
You must have JavaScript enabled to view digital editions.