1)使用Deployment控制器部署镜像:
kubectl create deployment web-demo --image=lizhenliang/web-demo:v1
kubectl get deployment,pods
[root@k8s-matser ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
test-54f8df84dd-2xmtr 1/1 Running 1 (44h ago) 3d12h
test-54f8df84dd-66z2p 1/1 Running 1 (44h ago) 3d12h
test-54f8df84dd-sgl8w 1/1 Running 1 (44h ago) 3d11h
web-demo-67d6f868b7-bnnmb 0/1 ContainerCreating 0 10m
- 镜像拉取加速
# 查看pod镜像
kubectl describe pod web-demo-67d6f868b7-bnnmb
# 本地拉取镜像 【3个节点均拉下】docker pull lizhenliang/web-demo:v1
2)使用Service将Pod暴露出去:
kubectl expose deployment web-demo --port=80 --type=NodePort --target-port=80
3)访问应用
kubectl get service 获取应用端口
# 访问应用:
http://NodeIP:Port # 端口随机生成,通过kubectl get service获取
# http://10.12.16.11:30570/
4) 其他命令
# 删除 deployment
kubectl delete deployment web-demo
# 删除 service
kubectl delete svc web-demo