yaml文件介绍:

https://blog.csdn.net/weixin_45403773/article/details/121552675
官方介绍:
https://kubernetes.io/docs/concepts/workloads/controllers/deployment/

#部署
kubectl apply -f deploy.yaml
重启部署
kubectl rollout restart deployment ngx-dpy
kubectl rollout restart deployment   -n nginx-nm ngx-dpy
删除部署 
kubectl delete deployment ngx-dpy     -n nginx  

#查看
kubectl get deployment
kubectl get deployment -o wide    命名空间 --namespace=nginx
kubectl get deployment      命名空间 --namespace=nginx
#详情
kubectl describe  deployment dpy-ngx-php

测试


kubectl get pods 
kubectl get pod -o wide
curl http://10.72.1.25

yaml文件

apiVersion: apps/v1
kind: Deployment
metadata:
  name: dpy-ngx-php
  labels:
    app: nginx2
  #namespace: nginx   #default 
spec:
  replicas: 1
  selector:         #标签选择器
    matchLabels:    #查找匹配的标签
      app: nginx2  #选择使用此标签
  template:         #Pod的模板信息,根据模板信息来创建Pod
    metadata:       #Pod的元数据
      labels:       #Pod的标签
        app: nginx2
    spec:           #容器的信息
      containers:
      - name: nginx21
        image: nginx:1.21.5-alpine
        ports:
        - containerPort: 80
        - containerPort: 8080
        volumeMounts:
        - name: confd
          mountPath: /etc/nginx/conf.d
        - name: conf
          mountPath: /etc/nginx/nginx.conf
        - name: fastcgi-php
          mountPath: /etc/nginx/fastcgi_php.conf
        - name: log
          mountPath: /var/log/nginx
        - name: html
          mountPath: /etc/nginx/html
      - name: php
        image: registry.51nca.com:8950/php-fpm:7.4.30.702
        ports:
        - containerPort: 9000
        volumeMounts:
        - name: phpini
          mountPath: /usr/local/etc/php/php.ini
        - name: php-fpmd
          mountPath: /usr/local/etc/php-fpm.d
        - name: log
          mountPath: /var/log
        - name: html
          mountPath: /etc/nginx/html
      nodeName: node3
      volumes:
        - name: confd
          hostPath:
            path: /data/ngx/conf.d
        - name: conf
          hostPath:
            path: /data/ngx/nginx.conf
        - name: log
          hostPath:
            path: /data/ngx/logs
        - name: html
          hostPath:
            path: /data/ngx/html
        - name: fastcgi-php
          hostPath:
            path: /data/ngx/fastcgi_php.conf
        - name: phpini
          hostPath:
            path: /data/ngx/php.ini
        - name: php-fpmd
          hostPath:
            path: /data/ngx/php-fpm.d