Goals
- Starting up minikube
- Run helloworld application
- Expose application via a load balancer and see it running
- Clear all data
1 Start up minikube
minikube start --docker-env http_proxy=http://192.168.99.1:8118 --docker-env https_proxy=http://192.168.99.1:8118 --docker-env no_proxy=127.0.0.1, localhost, 192.168.0.0/16, 10.0.0.0/8
verify this by running the command kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready master 19h v1.10.0
2 Run helloworld application
We will run one of the most common Docker helloworld applications out there- [https://hub.docker.com/r/karthequian/helloworld/]
To run this, type:
kubectl run hw --image=karthequian/helloworld --port=80
shows
deployment.apps "hw" created
MacbookHome:~ karthik$ kubectl run hw --image=karthequian/helloworld --port=80
deployment "hw" created
run the command kubectl get all
to see all our resources running, as shown in the output below.
localhost:~ xunyang$ kubectl get all
NAME READY STATUS RESTARTS AGE
hw-596b578c58-zclqm 1/1 Running 0 1m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 19h
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
hw 1 1 1 1 1m
NAME DESIRED CURRENT READY AGE
hw-596b578c58 1 1 1 1m
3 Expose application via a load balancer and see it running
localhost:~ xunyang$ kubectl expose deployment hw --type=NodePort
service "hw" exposed
localhost:~ xunyang$ kubectl get all
NAME READY STATUS RESTARTS AGE
hw-596b578c58-zclqm 1/1 Running 0 2m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hw NodePort 10.111.243.223 <none> 80:30952/TCP 1s
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 19h
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
hw 1 1 1 1 2m
NAME DESIRED CURRENT READY AGE
hw-596b578c58 1 1 1 2m
To do this in the minikube environment, the nodeport or loadbalancer type makes the service accessible through the minikube service command.
localhost:~ xunyang$ minikube service hw
Opening kubernetes service default/hw in default browser...
This will open your web browser to your application that is running in Kubernetes!
screenshot_288.png
5. Clear all data
localhost:~ xunyang$ kubectl delete deployment --all
deployment.extensions "hw" deleted
localhost:~ xunyang$ kubectl get all
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hw NodePort 10.111.243.223 <none> 80:30952/TCP 7m
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 19h
localhost:~ xunyang$ kubectl delete service hw
service "hw" deleted
localhost:~ xunyang$ kubectl get all
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 19h