nginx-Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: ns-test
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:alpine
        ports:
        - containerPort: 80
      nodeName: cn-shenzhen.10.0.21.20
---
apiVersion: v1        
kind: Service              #kind类型Service
metadata:                  #类型元数据
 name: nginx-service       #元数据名称
spec: 
 selector:                 #定义标签选择器
  app: nginx               #这里填写的nginx要跟Deployment的标签名称一致才能进行匹配
 ports:                     #开启一个端口参数
 - protocol: TCP            #定义TCP协议
   port: 80                 #定义Service端口
   targetPort: 80           #目标Pod的端口
   nodePort: 31000          #node节点暴露的SSL端口
 type: NodePort   

你可能感兴趣的:(nginx,网络,运维)