第154天学习打卡(Kubernetes 使用Helm快速部署应用, 如何自己创建Chart) (3)

service.yaml

 [root@master templates]# kubectl create deployment web1 --image=nginx --dry-run -o yaml > deployment.yaml
 W0611 16:53:59.635980   32639 helpers.go:553] --dry-run is deprecated and can be replaced with --dry-run=client.
 [root@master templates]# ls
 deployment.yaml
 [root@master templates]# cat deployment.yaml
 apiVersion: apps/v1
 kind: Deployment
 metadata:
  creationTimestamp: null
  labels:
    app: web1
  name: web1
 spec:
  replicas: 1
  selector:
    matchLabels:
      app: web1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: web1
    spec:
      containers:
       - image: nginx
        name: nginx
        resources: {}
 status: {}
 [root@master templates]# kubectl create deployment web1 --image=nginx #先创建web1 ,然后再执行下面的service.yaml
 deployment.apps/web1 created
 [root@master templates]# kubectl get pods
 [root@master templates]# kubectl expose deployment web1 --port=80 --target-port=80 --type=NodePort --dry-run -o yaml > service.yaml
 W0611 16:59:07.608904    2461 helpers.go:553] --dry-run is deprecated and can be replaced with --dry-run=client.
 [root@master templates]# ls
 deployment.yaml  service.yaml
 [root@master templates]# vi service.yaml
 #然后再删除web1
 [root@master templates]# kubectl delete deployment web1
 deployment.apps "web1" deleted
 [root@master templates]# kubectl get pods
 [root@master templates]# ls
 deployment.yaml  service.yaml
 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzzjdp.html