通过一段学习,我们的Kubernetes已经部署起来,现在就开始功能的演示。
如果又不会部署的小伙伴,可以看我以前的博客,都有详细的教程。
目录
修改nginx-deployment的ip类型【可以暴露端口,实现内部网访问】
查看node的节点情况
kubectl get node
查看pod的运行情况
kubectl get pod
查看deployment情况
kubectl get deployment
查看pod的运行详细信息
kubectl get pod -o wide
删除deployment
kubectl delete deployment nginx
删除一个pod应用
kubectl delete pod nginx-deployment-5d9dfb999c-t6xdq
查看kubectl创建提示
kubectl run --help
kubectl创建nginx应用
kubectl run nginx-deployment --image=wangyanglinux/myapp:v1 --port=80 --replicas=1
[root@master ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-deployment-5d9dfb999c-t6xdq 1/1 Running 0 5m43s
[root@master ~]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-deployment-5d9dfb999c-t6xdq 1/1 Running 0 5m51s 10.244.2.7 node1 <none> <none>
[root@master ~]# curl 10.244.2.7
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>
[root@master ~]# curl 10.244.2.7/hostname.html
nginx-deployment-5d9dfb999c-t6xdq
副本集扩容
kubectl scale --replicas=3 deployment/nginx-deployment
应用pod的端口修改【把80端口改成了 30003】
kubectl expose deployment nginx-deployment --port=30003 --target-port=80
修改nginx-deployment的ip类型【可以暴露端口,实现内部网访问】
kubectl edit svc nginx-deployment