创建一个nginx资源清单

注意selector一定要书写正确,否则通过集群IP:端口 或者是节点ip:外部访问端口 都无法访问

apiVersion: v1
kind: Pod
metadata:
  name: test-pod
  namespace: test
  labels:
    environment: stg
spec:  
  containers:
  - name: my-nginx-container
    image: nginx:latest
    imagePullPolicy: IfNotPresent
    ports:
    - name: nginx-port
      containerPort: 80
      protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  name: svc-nginx
  namespace: test
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    environment: stg
  type: NodePort
posted @ 2022-10-27 11:57  弩哥++  阅读(24)  评论(0)    收藏  举报