Kubernetes explain the YAML file format

pod definition file complete contents # yaml format:

apiVersion: v1 # Required, version number, e.g. v1 // red portion defined Pod metadata information, POD,

kind: Pod # Required, Pod // namespace, pod labels, relevant comments

metadata: # Required metadata

  name: string # Required, Pod name

  namespace: string # Required, belongs to a namespace Pod

  labels: # Custom label

    - name: string # Custom label name

  annotations: # Custom comment lists

    - name: string

// definition of container in volume, port,

// start-up mode, the working directory, environment variables

// volume mount position, the size of the resource request

spec: # Required, detailed definitions of the container Pod // definition of container related POD,

  containers: # Required, Pod in the container list //

  - name: string # Required, container name

    image: string # Required, mirroring name of the container

    imagePullPolicy: [Always | Never | IfNotPresent] # image acquisition strategy Alawys the download mirrors IfnotPresent represent priority use of local mirroring, or download the image, Nerver uses only local mirror

    command: [string] # start command list container, if not specified, the start command used when using the Package

    args: [string] # container startup command parameter list

    workingDir: string # container working directory

    volumeMounts: # mount disposed inside of the container storage volume

    - name: string # reference name of the shared storage volume pod definition, required volumes [] section defines the volume name

      mountPath: string # storage volume in the container mount absolute path, should be less than 512 characters

      readOnly: boolean # is read-only mode

    ports: # list of ports needs to be exposed bank number

    - name: string # Name Port Number

      containerPort: int # container needs to listen on port number

      hostPort: int # container where the host needs to listen to the port number, default and Container same

      protocol: string # port protocol that supports TCP and UDP, TCP default

    env: # container environment variables to be set before running list

    - name: string # environment variable name

      value: the value of an environment variable string #

    resources: # Set resource limits and requests

      limits: # set resource limits

        cpu: string #Cpu limited number of units of Core, for docker run --cpu-shares parameters

        memory: string # memory limit, the unit may be Mib / Gib, parameters for docker run --memory

      requests: Set # resource request

        cpu: string #Cpu request, the initial number of available start container

        memory: string # clear memory, the number of containers can be used to start the initial

// this pod for the maintenance of the way, strategies

    livenessProbe: # container set within the Pod health examination, as a method wherein the detecting no response after several automatically restart the container inspection methods exec, httpGet TCPsocket and, to a container by simply setting

      exec: # Pod for the container inspection mode is set to mode exec

        command: [string] #exec need to develop ways of command or script

      httpGet: # of the vessel within the Pod health check method is set to HttpGet, the need to develop Path, port

        path: string

        port: number

        host: string

        scheme: string

        HttpHeaders:

        - name: string

          value: string

      tcpSocket: # health check method for the vessel to TCPsocket mode Pod

         port: number

       initialDelaySeconds: 0 # container startup time after the completion of the first probe, in seconds

       timeoutSeconds: 0 # container probe health check response wait timeout time, in seconds, default 1 second

       periodSeconds: 0 # periodic monitoring inspection probe time the container is provided, in seconds, 10 seconds by default

       successThreshold: 0

       failureThreshold: 0

       securityContext:

         privileged:false

    restartPolicy: [Always | Never | OnFailure] #Pod restart strategy, Always that once regardless of the manner in which terminates, kubelet will restart, OnFailure means that only non-zero exit code Pod to withdraw before the restart, Nerver said not to restart the Pod

    nodeSelector: obeject # Set the Pod scheduled NodeSelector represents the node containing this label to key: the specified value format.

    imagePullSecrets: secret name used #Pull mirror to key: secretkey specified format

    - name: string

    hostNetwork: false # whether to use the host network mode, the default is false, if set to true, indicates the use of the host network

// position of the container storage volume

    volumes: # define a shared storage volume in the list on the pod

    - name: string # shared storage volume name (there are many types of volumes)

      emptyDir: {} # emtyDir type of storage volumes, with a temporary directory Pod same life cycle. It is null

      hostPath: string # hostPath type of storage volumes, where the host Pod represents mount directory

        path: string #Pod directory where the host will be used to mount the directory in the same period

      secret: # secret type of storage volumes, the object mount secre defined clusters and into the container

        scretname: string  

        items:     

        - key: string

          path: string

      configMap: # configMap type of storage volume, loading the predefined objects into the container configMap

        name: string

        items:

        - key: string

          path: string

Released nine original articles · won praise 2 · Views 961

Guess you like

Origin blog.csdn.net/qq_34072169/article/details/103979501