k8s yaml

 

ingress

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx-test-v2-ingress    #ingress名
spec:
  rules:
    - host: www.zzx2.com     #域名
      http:
        paths:
        - path: /zzx/     #匹配的上下文
          backend:
            serviceName: nginx-test-v2-svc     # svc的metadata下的 name,就是svc的name
            servicePort: 8123

  

svc                         selector: app:  要写deploy的metadata下的name,  targetPort是deploy的pod

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: nginx
  name: nginx-test-v2-svc
spec:
  ports:
  - port: 8123
    protocol: TCP
    targetPort: 80
  selector:
    app: nginx-test     ##deploy的spec下matchLabels和labels下的app 
status:
  loadBalancer: {}

   

deploy

hostPath      mountPath: /etc/localtime 被计算节点映射的pod文件 计算节点/etc/localtime替换容器/etc/localtime, 计算节点/root挂载到容器/zzx 

apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: nginx-xxx
  name: nginx-test-v2
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx-test # -o wide显示的 SELECTOR , 和svc的selector一致
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: nginx-test   # 和selector的matchLabels的app一致
    spec:
      containers:
      - image: zzxng:v2
        name: zzxng-containers-v2
        resources: {}
        volumeMounts:
        - mountPath: /etc/localtime
          name: mylocaltime
        - mountPath: /zzx
          name: mountdata
      volumes:
      - hostPath:
          path: /etc/localtime
          type: ""
        name: mylocaltime
      - hostPath:
          path: /root
          type: Directory
        name: mountdata    
status: {}

  

selector
posted on 2022-04-10 17:31  寒星12345678999  阅读(35)  评论(0编辑  收藏  举报