标签:service containe creation pps template 常用 端口 code rgba
# 生成命令对应的yaml文件(资源清单)
kubectl create deployment xxxxxxxxxxx --image=nginx --dry-run -o yaml
kubectl create deployment xxxxxxxxxxx --image=nginx --dry-run -o yaml > xxxxxxxxxxx.yaml
kubectl create deployment sss-nginx-sss --image=nginx --dry-run -o yaml > sss-nginx-sss.yaml
# yaml文件内容
apiVersion: apps/v1 kind: Deployment metadata: creationTimestamp: null labels: app: xxxxxxxxxxx name: xxxxxxxxxxx spec: replicas: 1 selector: matchLabels: # controller匹配pod标签 app: xxxxxxxxxxx strategy: {} template: metadata: creationTimestamp: null labels: # 标签 app: xxxxxxxxxxx spec: containers: - image: nginx name: nginx resources: {} status: {}
# 应用yaml文件
kubectl apply -f xxxxxxxxxxx.yaml
kubectl apply -f sss-nginx-sss.yaml
# 对外暴露端口
kubectl expose deployment xxxxxxxxxxx --port=80 --type=NodePort --target-port=80 --name=yyyyyyyyyyyyyyy
kubectl expose deployment xxxxxxxxxxx --port=80 --type=NodePort --target-port=80 \
--name=yyyyyyyyyyyyyyy -o yaml > yyyyyyyyyyyyyyy.yaml
kubectl expose deployment sss-nginx-sss --port=80 --type=NodePort --target-port=80 \
--name=eee-xxx-ppp -o yaml > eee-xxx-ppp.yaml
# 应用yaml文件,执行对外暴露端口动作
kubectl apply -f yyyyyyyyyyyyyyy.yaml
kubectl apply -f eee-xxx-ppp.yaml
# 查看pod与service(svc - 简写的service)
kubectl get pods,svc
标签:service containe creation pps template 常用 端口 code rgba
原文地址:https://www.cnblogs.com/Tifahfyf/p/14457305.html