k8s编辑yaml文件可选指令,在例子内指出

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  namespace: my-namespace  #选择加入的命名空间
spec:
  nodeName: node1 #指定某个node节点
  replicas: 3
  selector:
    matchLabels:
      app: nginx #管理的键值对,保证该标签的容器保持3个
  template:
    metadata:
      labels:
        app: nginx #设置的键值对名称
    spec:
      nodeSelector: #使用nodeSelector字段指定了Pod将被调度到指定的标签键值对
        kubernetes.io/hostname: my-node 
      containers:
        - name: nginx
          image: nginx
          ports:
            - containerPort: 80
          env:
            - name: FOO
              value: BAR
---
apiVersion: v1 
kind: Service #第二个对象Service
metadata:
  name: nginx-service
  namespace: my-namespace
spec:
  selector:
    app: nginx #该标签都加入到Service下
  type: LoadBalancer
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30001