1、deployment的简单写法: nginx-deploy.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-depoly namespace: default labels: app: nginxapp spec: replicas: 3 selector: matchLabels: app: nginxpod template: metadata: labels: app: nginxpod spec: containers: - name: nginxpod image: nginx:latest imagePullPolicy: IfNotPresent ports: - containerPort: 80
2、写个对应的service文件 nginx-svc.yaml
apiVersion: v1 kind: Service metadata: name: nginx-svc namespace: default labels: app: nginxsvcapp spec: type: ClusterIP selector: app: nginxpod ports: - port: 81 protocol: TCP targetPort: 80