Kubernetes 常用yaml

Projected

1、secret、configmap、downwardAPI的结合挂载使用

Kubernetes 常用yaml
apiVersion: v1
kind: Pod
metadata:
  name: volume-test
spec:
  imagePullSecrets:
  - name: centos
  containers:
  - name: container-test
    image: 'registry.cn-hangzhou.aliyuncs.com/xy-k8s-study/centos:7'
    imagePullPolicy: Always
    command: ["/bin/bash","-c","while true; do echo ok; sleep 1000 ; done"]
    resources:
      requests:
        memory: 900Mi
    volumeMounts:
    - name: all-in-one
      mountPath: "/project"
      readOnly: true
  volumes:
  - name: all-in-one
    projected:
      # 注意:这里的sources 资源必须存在才可以被挂载使用
      sources:
      - secret:
          name: mysecret
          items:
            - key: username
              path: my-group/my-username
      - downwardAPI:
          items:
            - path: "labels"
              fieldRef:
                fieldPath: metadata.labels
            - path: "cpu_limit"
              resourceFieldRef:
                containerName: container-test
                resource: limits.cpu
      - configMap:
          name: myconfigmap
          items:
            - key: config
              path: my-group/my-config
View Code

 

downwardAPI

1、api 与 自定义配置项结合

Kubernetes 常用yaml
apiVersion: v1
kind: Pod
metadata:
  name: kubernetes-downwardapi-volume-example
  labels:
    zone: us-est-coast
    cluster: test-cluster1
    rack: rack-22
  annotations:
    build: two
    builder: john-doe
spec:
  imagePullSecrets:
  - name: centos
  containers:
    - name: client-container
      image: 'registry.cn-hangzhou.aliyuncs.com/xy-k8s-study/centos:7'
      imagePullPolicy: Always
      command: ["/bin/bash","-c","while true; do echo ok; sleep 1000 ; done"]
      resources:
        requests:
          memory: 900Mi
      volumeMounts:
        - name: podinfo
          mountPath: /etc/podinfo
  volumes:
    - name: podinfo
      downwardAPI:
        items:
          - path: "labels"
            fieldRef:
              fieldPath: metadata.labels
          - path: "annotations"
            fieldRef:
              fieldPath: metadata.annotations
View Code

 

上一篇:【YOLO v5】训练VisDrone数据集


下一篇:python简单记录