当前位置:   article > 正文

k8s 资源管理_matchexpressions 样例

matchexpressions 样例

模板

apiVersion: apps/v1
kind: Deployment
metadata:
  name: $APPNAME
  namespace: $NAMESPACE
spec:
  replicas: 2
  selector:
    matchLabels:
      appname: $APPNAME
  template:
    metadata:
      annotations:
        prometheus.io/path: "/actuator/prometheus"
        prometheus.io/port: "80"
        prometheus.io/scrape: "true"
      labels:
        appname: $APPNAME
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: appname
                  operator: In
                  values:
                  - $APPNAME
              topologyKey: kubernetes.io/hostname
            weight: 50
      containers:
      - name: $APPNAME
        image: $IMAGENAME
        ports:
        - containerPort: 80
        readinessProbe:
          failureThreshold: 3  #探测失败的重试次数,重试一定次数后将认为失败
          httpGet:
            path: /
            port: 80
            scheme: HTTP
          initialDelaySeconds: 60  #容器启动后要等待多少秒后探测
          periodSeconds: 10  #执行探测的时间间隔
          successThreshold: 1 #探测成功次数
          timeoutSeconds: 1  #探针执行检测请求后,等待响应的超时时间
        resources:
          requests:
            cpu: 200m
            memory: 512Mi
          limits:
            cpu: 200m
            memory: 512Mi
---
apiVersion: v1   
kind: Service
metadata:
  annotations:
    blackbox_path: "/"
    blackbox_port: "80"
    blackbox_scheme: "http"
  name: $APPNAME
  namespace: $NAMESPACE
spec:
  selector:
    appname: $APPNAME
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
---
apiVersion: networking.k8s.io/v1 
kind: Ingress
metadata:
  name: $APPNAME
  namespace: $NAMESPACE
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/proxy-body-size: "1000m"
spec:
  rules:
    - host: $URL
      http:
        paths:
          - path: /
            pathType: ImplementationSpecific
            backend:
              service:
                name: $APPNAME
                port:
                  number: 80
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91

样例

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-xia
  namespace: xia
spec:
  replicas: 2
  selector:
    matchLabels:
      appname: nginx-xia
  template:
    metadata:
      annotations:
        prometheus.io/path: "/actuator/prometheus"
        prometheus.io/port: "80"
        prometheus.io/scrape: "true"
      labels:
        appname: nginx-xia
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: appname
                  operator: In
                  values:
                  - nginx-xia
              topologyKey: kubernetes.io/hostname
            weight: 50
      containers:
      - name: nginx-xia
        image: harbor.wuxing.com/library/nginx:alpine-base
        ports:
        - containerPort: 80
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /
            port: 80
            scheme: HTTP
          initialDelaySeconds: 10
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        resources:
          requests:
            cpu: 200m
            memory: 512Mi
          limits:
            cpu: 200m
            memory: 512Mi
---
apiVersion: v1   
kind: Service
metadata:
  annotations:
    blackbox_path: "/"
    blackbox_port: "80"
    blackbox_scheme: "http"
  name: nginx-xia
  namespace: xia
spec:
  selector:
    appname: nginx-xia
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
---
apiVersion: networking.k8s.io/v1 
kind: Ingress
metadata:
  name: nginx-xia
  namespace: xia
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/proxy-body-size: "1000m"
spec:
  rules:
    - host: xia.wuxingge.com
      http:
        paths:
          - path: /
            pathType: ImplementationSpecific
            backend:
              service:
                name: nginx-xia
                port:
                  number: 80
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/614028
推荐阅读
相关标签
  

闽ICP备14008679号