zoukankan      html  css  js  c++  java
  • k8s定义yaml文件常用的一些字段

    spec:
      replicas: 6  # 定义副本数量
      strategy:
        rollingUpdate: # 滚动更新通过参数 maxSurge 和 maxUnavailable 来控制副本替换的数量
          maxSurge: 35%
          maxUnavailable: 35% 
      template:
        spec:
          containers:
            livenessProbe:
              exec:
                command:
                - cat
                - /tmp/healthy # 定义存活健康检查(exec方式)
            readinessProbe: # 定义就绪健康检查(httpGet方式)
              httpGet:
                scheme: HTTP
                path: /healthy
                port: 8080
              initialDelaySeconds: 10
              periodSeconds: 5
            volumeMounts: # 使用empty_dir作为存储(pod不在,volume也在)
            - mountPath: /consumer_dir
              name: shared-volume
            - mountPath: /etc/ssl/certs  # 使用host-path作为存储
              name: ca-certs
              readOnly: true
            - mountPath: /test-ebs # 使用外部的storage provider作为存储
              name: ebs-volume
            - name: foo # 通过volume的方式来使用secret
              mountPath: "/etc/foo"
              readOnly: true
            - name: foo # 通过volume的方式来使用configmap
              mountPath: /etc/foo
              readOnly: true
            env: # 通过env的方式来使用secret
              - name: SECRET_USERNAME
                valueFrom:
                  secretKeyRef:
                    name: my-secret
                    key: username
              - name: SECRET_PASSWORD
                valueFrom:
                  secretKeyRef:
                    name: my-secret
                    key: password
              - name: CONFIG_1 # 通过env的方式来使用configmap
                valueFrom:
                  configMapKeyRef:
                    name: my-configmap1
                    key: config1
              - name: CONFIG_2
                valueFrom:
                  configMapKeyRef:
                    name: my-configmap1
                    key: config2
          volumes:
          - name: shared-volume
            emptyDir: {}
          - hostPath:  # 使用host-path作为存储
              path: /etc/ssl/certs
              type: DirectoryOrCreate
            name: ca-certs
          - name: ebs-volume # 使用外部的storage provider作为存储
            awsElasticBlockStore:
              volumeID: <volume-id>
              fsType: ext4
          - name: wwwroot # 定义使用pvc来做存储
            persistentVolumeClaim:
              claimName: my-pvc
          - name: foo # 通过volume的方式来使用secret
            secret:
              secretName: mysecret
            items: # 自定义存放数据的文件名
            - key: username
              path: my-group/my-username
            - key: password
              path: my-group/my-password
          - name: foo # 通过volume的方式来使用configmap
            configMap:
              name: my-configmap
              items:
                - key: logging.conf
                  path: myapp/logging.conf
          nodeSelector:
            disktype: ssd  # 定义节点标签选择器
    
  • 相关阅读:
    前言
    实用逆袭课【时间管理、记忆训练、工作效率、人际社交】
    读书确实是一辈子的事
    求职宝典(笔记不详细,但你自己看完消化了真的受用)
    重新认识【时间、金钱、自我、人际关系】
    即兴演讲不是即兴
    大数据和AI的未来畅想
    女性30的思考1
    第四课 人际关系
    第三课 干好工作
  • 原文地址:https://www.cnblogs.com/Richardo-M-Q/p/14139928.html
Copyright © 2011-2022 走看看