learning kubernetes by minikube, 2

Goals

  1. Starting up minikube
  2. Run helloworld application
  3. Expose application via a load balancer and see it running
  4. 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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容