實操:kubernetes使用yaml、json創建資源概述

前言:

kubernetes支持yaml和json格式創建資源對象

一:yaml和json

  • json格式用於接口之間消息的傳遞

    json是偏向於二次開發的

  • yaml格式用於管理者的配置和管理

    yaml是一種簡潔的非標記性語言

    yaml多用於運維工作

  • yaml文件被執行時,會先被轉化成json,再執行

1.1 創建資源的方式

使用run創建pod資源時,無法詳細指定其中的參數

而使用yaml和json可以進行DIY的設置,可以根絕自己需求配置參數

1.2 yaml文件格式

xxx.yaml
pod資源創建參數
---
service資源參數

pod資源提供業務,後面的service將服務對外提供出去

1.3 yaml語法格式

縮進表示層級關係

不支持tab製表符縮進,使用空格縮進

通常開頭縮進兩個字符

字符後面索引一個空格,比如:或者,或者-

"—"表示yaml文件中一個文件的開始,開頭可以默認不寫

"#"表示註釋

1.4 查看當前可用的api版本

api-server可以調用的資源版本信息

在yaml文件中apiVersion標籤中指定,apiserver纔可以啓用識別

beta代表測試版本

apps代表創建pod資源

1.4.1 各種apiVersion的含義

alpha

  • 該軟件可能包含錯誤。啓用一個功能可能會導致bug
  • 隨時可能會丟棄對該功能的支持,恕不另行通知

beta

  • 軟件經過很好的測試。啓用功能被認爲是安全的。
  • 默認情況下功能是開啓的
  • 細節可能會改變,但功能在後續版本不會被刪除

stable

  • 該版本名稱命名方式:vX這裏X是一個整數
  • 穩定版本、放心使用
  • 將出現在後續發佈的軟件版本中

v1

  • Kubernetes API的穩定版本,包含很多核心對象:pod、service等
[root@master1 ~]# kubectl api-versions
admissionregistration.k8s.io/v1beta1
apiextensions.k8s.io/v1beta1
apiregistration.k8s.io/v1
apiregistration.k8s.io/v1beta1
apps/v1	
#在kubernetes1.9版本中,引入apps/v1,deployment等資源從extensions/v1beta1, apps/v1beta1 和 apps/v1beta2遷入apps/v1,原來的v1beta1等被廢棄。
#apps/v1代表:包含一些通用的應用層的api組合,如:Deployments, RollingUpdates, and ReplicaSets

apps/v1beta1
#在kubernetes1.8版本中,新增加了apps/v1beta2的概念,apps/v1beta1同理
#DaemonSet,Deployment,ReplicaSet 和 StatefulSet的當時版本遷入apps/v1beta2,兼容原有的extensions/v1beta1
apps/v1beta2
authentication.k8s.io/v1
#資源鑑權相關的api組合
authentication.k8s.io/v1beta1
authorization.k8s.io/v1
authorization.k8s.io/v1beta1
autoscaling/v1
#代表自動擴縮容的api組合,kubernetes1.8版本中引入。
#這個組合中後續的alpha 和 beta版本將支持基於memory使用量、其他監控指標進行擴縮容
autoscaling/v2beta1
autoscaling/v2beta2
batch/v1
#代表job相關的api組合
#在kubernetes1.8版本中,新增了batch/v1beta1,後CronJob 已經遷移到了 batch/v1beta1,然後再遷入batch/v1
batch/v1beta1
certificates.k8s.io/v1beta1
#安全認證相關的api組合
coordination.k8s.io/v1beta1
events.k8s.io/v1beta1
extensions/v1beta1
#deployment等資源在1.6版本時放在這個版本中,後遷入到apps/v1beta2,再到apps/v1中統一管理
networking.k8s.io/v1
policy/v1beta1
rbac.authorization.k8s.io/v1
rbac.authorization.k8s.io/v1beta1
scheduling.k8s.io/v1beta1
storage.k8s.io/v1
storage.k8s.io/v1beta1
v1

首先先寫這個標籤

二:演示yaml

2.1 創建一個專門的目錄

[root@master1 ~]# mkdir gsy
[root@master1 ~]# cd gsy/
[root@master1 gsy]# 

2.2 編寫yaml

apiversion代表apiserver版本

kind代表要創建的資源

spec 選擇器模板

三個labels標籤要吻合、建立關係

matchlabels匹配標籤

[root@master1 gsy]# vim nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx1
        image: nginx:1.15.4
        ports:
        - containerPort: 80

2.3 創建資源,kind種類爲deployment

此時寫的是創建pod的資源,接下來還需要編寫service的yaml

[root@master1 gsy]# kubectl create --help
Create a resource from a file or from stdin. 

JSON and YAML formats are accepted.

Examples:
  # Create a pod using the data in pod.json.
  kubectl create -f ./pod.json
  
  # Create a pod based on the JSON passed into stdin.
  cat pod.json | kubectl create -f -
  
  # Edit the data in docker-registry.yaml in JSON then create the resource using
the edited data.
  kubectl create -f docker-registry.yaml --edit -o json

Available Commands:
  clusterrole         Create a ClusterRole.
  clusterrolebinding  Create a ClusterRoleBinding for a particular ClusterRole
  configmap           Create a configmap from a local file, directory or literal
value
  deployment          Create a deployment with the specified name.
  job                 Create a job with the specified name.
  namespace           Create a namespace with the specified name
  poddisruptionbudget Create a pod disruption budget with the specified name.
  priorityclass       Create a priorityclass with the specified name.
  quota               Create a quota with the specified name.
  role                Create a role with single rule.
  rolebinding         Create a RoleBinding for a particular Role or ClusterRole
  secret              Create a secret using specified subcommand
  service             Create a service using specified subcommand.
  serviceaccount      Create a service account with the specified name

Options:
      --allow-missing-template-keys=true: If true, ignore any errors in
templates when a field or map key is missing in the template. Only applies to
golang and jsonpath output formats.
      --dry-run=false: If true, only print the object that would be sent,
without sending it.
      --edit=false: Edit the API resource before creating
  -f, --filename=[]: Filename, directory, or URL to files to use to create the
resource
  -o, --output='': Output format. One of:
json|yaml|name|template|go-template|go-template-file|templatefile|jsonpath-file|jsonpath.
      --raw='': Raw URI to POST to the server.  Uses the transport specified by
the kubeconfig file.
      --record=false: Record current kubectl command in the resource annotation.
If set to false, do not record the command. If set to true, record the command.
If not set, default to updating the existing annotation value only if one
already exists.
  -R, --recursive=false: Process the directory used in -f, --filename
recursively. Useful when you want to manage related manifests organized within
the same directory.
      --save-config=false: If true, the configuration of current object will be
saved in its annotation. Otherwise, the annotation will be unchanged. This flag
is useful when you want to perform kubectl apply on this object in the future.
  -l, --selector='': Selector (label query) to filter on, supports '=', '==',
and '!='.(e.g. -l key1=value1,key2=value2)
      --template='': Template string or path to template file to use when
-o=go-template, -o=go-template-file. The template format is golang templates
[http://golang.org/pkg/text/template/#pkg-overview].
      --validate=true: If true, use a schema to validate the input before
sending it
      --windows-line-endings=false: Only relevant if --edit=true. Defaults to
the line ending native to your platform.

Usage:
  kubectl create -f FILENAME [options]

Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all
commands).
[root@master1 gsy]# kubectl create -f nginx-deployment.yaml 
deployment.apps/nginx-deployment created
[root@master1 gsy]# kubectl get all
NAME                                    READY   STATUS    RESTARTS   AGE
pod/nginx-6c94d899fd-xsxct              1/1     Running   0          2d
pod/nginx-deployment-78cdb5b557-2nwdf   1/1     Running   0          68s
pod/nginx-deployment-78cdb5b557-4qd2j   1/1     Running   0          68s
pod/nginx-deployment-78cdb5b557-s8wgj   1/1     Running   0          68s
pod/nginx-gsy1-7df78bc5fd-29mgf         1/1     Running   0          38h
pod/nginx-gsy1-7df78bc5fd-bn824         1/1     Running   0          38h
pod/nginx-gsy1-7df78bc5fd-fsllt         1/1     Running   0          38h

NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   10.0.0.1     <none>        443/TCP   10d

NAME                               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/nginx              1         1         1            1           7d19h
deployment.apps/nginx-deployment   3         3         3            3           68s
deployment.apps/nginx-gsy1         3         3         3            3           38h

NAME                                          DESIRED   CURRENT   READY   AGE
replicaset.apps/nginx-6c94d899fd              1         1         1       2d
replicaset.apps/nginx-dbddb74b8               0         0         0       7d19h
replicaset.apps/nginx-deployment-78cdb5b557   3         3         3       68s
replicaset.apps/nginx-gsy1-7df78bc5fd         3         3         3       38h

2.4 編寫service的yaml

想要把業務發佈出去,還要寫一個service資源

[root@master1 gsy]# vim nginx-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  labels:
    app: nginx
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 80
  selector:
    app: nginx

開始創建

[root@master1 gsy]# kubectl create -f nginx-service.yaml 
service/nginx-service created
[root@master1 gsy]# kubectl get all
NAME                                    READY   STATUS    RESTARTS   AGE
pod/nginx-6c94d899fd-xsxct              1/1     Running   0          2d1h
pod/nginx-deployment-78cdb5b557-6z2sf   1/1     Running   0          22m
pod/nginx-deployment-78cdb5b557-9pdf8   1/1     Running   0          22m
pod/nginx-deployment-78cdb5b557-f2hx2   1/1     Running   0          22m

NAME                    TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
service/kubernetes      ClusterIP   10.0.0.1     <none>        443/TCP        10d
service/nginx-service   NodePort    10.0.0.131   <none>        80:37651/TCP   27s

NAME                               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/nginx              1         1         1            1           7d19h
deployment.apps/nginx-deployment   3         3         3            3           22m

NAME                                          DESIRED   CURRENT   READY   AGE
replicaset.apps/nginx-6c94d899fd              1         1         1       2d1h
replicaset.apps/nginx-dbddb74b8               0         0         0       7d19h
replicaset.apps/nginx-deployment-78cdb5b557   3         3         3       22m

三:自動測試命令的正確性,不執行創建操作——dry-run

[root@master1 gsy]# kubectl run nginx-01 --image=nginx --port=80 --replicas=3 --dry-run
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
deployment.apps/nginx-01 created (dry run)
kubectl運行,發電機=部署/應用程序。v1beta1已被棄用,將在未來的版本中刪除。使用kubectl創建。
部署。apps/nginx-01創建(預演)

四:使用測試–dry-run創建資源-o輸出yaml格式

[root@master1 gsy]# kubectl run nginx-01 --image=nginx --port=80 --replicas=3 --dry-run -o yaml
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    run: nginx-01
  name: nginx-01
spec:
  replicas: 3
  selector:
    matchLabels:
      run: nginx-01
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        run: nginx-01
    spec:
      containers:
      - image: nginx
        name: nginx-01
        ports:
        - containerPort: 80
        resources: {}
status: {}

備註:也可以> 導出到一個新文件

[root@master1 gsy]# kubectl run nginx-01 --image=nginx --port=80 --replicas=3 --dry-run -o yaml > nginx-01.yaml
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
[root@master1 gsy]# ls
nginx-01.yaml  nginx-deployment.yaml  nginx-service.yaml

五:使用–dry run也可以生成json格式

json是以鍵值對的方式存在

[root@master1 gsy]# kubectl run nginx-01 --image=nginx --port=80 --replicas=3 --dry-run -o json
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
{
    "kind": "Deployment",
    "apiVersion": "apps/v1beta1",
    "metadata": {
        "name": "nginx-01",
        "creationTimestamp": null,
        "labels": {
            "run": "nginx-01"
        }
    },
    "spec": {
        "replicas": 3,
        "selector": {
            "matchLabels": {
                "run": "nginx-01"
            }
        },
        "template": {
            "metadata": {
                "creationTimestamp": null,
                "labels": {
                    "run": "nginx-01"
                }
            },
            "spec": {
                "containers": [
                    {
                        "name": "nginx-01",
                        "image": "nginx",
                        "ports": [
                            {
                                "containerPort": 80
                            }
                        ],
                        "resources": {}
                    }
                ]
            }
        },
        "strategy": {}
    },
    "status": {}
}

六:將現有的資源生成模板導出

[root@master1 gsy]# kubectl get all
NAME                                    READY   STATUS    RESTARTS   AGE
pod/nginx-6c94d899fd-xsxct              1/1     Running   0          2d1h
pod/nginx-deployment-78cdb5b557-6z2sf   1/1     Running   0          47m
pod/nginx-deployment-78cdb5b557-9pdf8   1/1     Running   0          47m
pod/nginx-deployment-78cdb5b557-f2hx2   1/1     Running   0          47m

NAME                    TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
service/kubernetes      ClusterIP   10.0.0.1     <none>        443/TCP        10d
service/nginx-service   NodePort    10.0.0.131   <none>        80:37651/TCP   25m

NAME                               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/nginx              1         1         1            1           7d19h
deployment.apps/nginx-deployment   3         3         3            3           47m

NAME                                          DESIRED   CURRENT   READY   AGE
replicaset.apps/nginx-6c94d899fd              1         1         1       2d1h
replicaset.apps/nginx-dbddb74b8               0         0         0       7d19h
replicaset.apps/nginx-deployment-78cdb5b557   3         3         3       47m
[root@master1 gsy]# kubectl get deploy/nginx-deployment --export -o yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  creationTimestamp: null
  generation: 1
  labels:
    app: nginx
  name: nginx-deployment
  selfLink: /apis/extensions/v1beta1/namespaces/default/deployments/nginx-deployment
spec:
  progressDeadlineSeconds: 600
  replicas: 3
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: nginx
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx:1.15.4
        imagePullPolicy: IfNotPresent
        name: nginx1
        ports:
        - containerPort: 80
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status: {}

6.1 也可以生成模板導出到文件中

[root@master1 gsy]# kubectl get deploy/nginx-deployment --export -o yaml > nginx-02.yaml
[root@master1 gsy]# ls
nginx-01.yaml  nginx-02.yaml  nginx-deployment.yaml  nginx-service.yaml

七:查看字段幫助信息

explain 解釋

[root@master1 gsy]# kubectl explain
error: You must specify the type of resource to explain. Use "kubectl api-resources" for a complete list of supported resources.
[root@master1 gsy]# kubectl api-resources
NAME                              SHORTNAMES   APIGROUP                       NAMESPACED   KIND
bindings                                                                      true         Binding
componentstatuses                 cs                                          false        ComponentStatus
configmaps                        cm                                          true         ConfigMap
endpoints                         ep                                          true         Endpoints
events                            ev                                          true         Event
limitranges                       limits                                      true         LimitRange
namespaces                        ns                                          false        Namespace
nodes                             no                                          false        Node
persistentvolumeclaims            pvc                                         true         PersistentVolumeClaim
persistentvolumes                 pv                                          false        PersistentVolume
pods                              po                                          true         Pod
podtemplates                                                                  true         PodTemplate
replicationcontrollers            rc                                          true         ReplicationController
resourcequotas                    quota                                       true         ResourceQuota
secrets                                                                       true         Secret
serviceaccounts                   sa                                          true         ServiceAccount
services                          svc                                         true         Service
mutatingwebhookconfigurations                  admissionregistration.k8s.io   false        MutatingWebhookConfiguration
validatingwebhookconfigurations                admissionregistration.k8s.io   false        ValidatingWebhookConfiguration
customresourcedefinitions         crd,crds     apiextensions.k8s.io           false        CustomResourceDefinition
apiservices                                    apiregistration.k8s.io         false        APIService
controllerrevisions                            apps                           true         ControllerRevision
daemonsets                        ds           apps                           true         DaemonSet
deployments                       deploy       apps                           true         Deployment
replicasets                       rs           apps                           true         ReplicaSet
statefulsets                      sts          apps                           true         StatefulSet
tokenreviews                                   authentication.k8s.io          false        TokenReview
localsubjectaccessreviews                      authorization.k8s.io           true         LocalSubjectAccessReview
selfsubjectaccessreviews                       authorization.k8s.io           false        SelfSubjectAccessReview
selfsubjectrulesreviews                        authorization.k8s.io           false        SelfSubjectRulesReview
subjectaccessreviews                           authorization.k8s.io           false        SubjectAccessReview
horizontalpodautoscalers          hpa          autoscaling                    true         HorizontalPodAutoscaler
cronjobs                          cj           batch                          true         CronJob
jobs                                           batch                          true         Job
certificatesigningrequests        csr          certificates.k8s.io            false        CertificateSigningRequest
leases                                         coordination.k8s.io            true         Lease
events                            ev           events.k8s.io                  true         Event
daemonsets                        ds           extensions                     true         DaemonSet
deployments                       deploy       extensions                     true         Deployment
ingresses                         ing          extensions                     true         Ingress
networkpolicies                   netpol       extensions                     true         NetworkPolicy
podsecuritypolicies               psp          extensions                     false        PodSecurityPolicy
replicasets                       rs           extensions                     true         ReplicaSet
networkpolicies                   netpol       networking.k8s.io              true         NetworkPolicy
poddisruptionbudgets              pdb          policy                         true         PodDisruptionBudget
podsecuritypolicies               psp          policy                         false        PodSecurityPolicy
clusterrolebindings                            rbac.authorization.k8s.io      false        ClusterRoleBinding
clusterroles                                   rbac.authorization.k8s.io      false        ClusterRole
rolebindings                                   rbac.authorization.k8s.io      true         RoleBinding
roles                                          rbac.authorization.k8s.io      true         Role
priorityclasses                   pc           scheduling.k8s.io              false        PriorityClass
storageclasses                    sc           storage.k8s.io                 false        StorageClass
volumeattachments                              storage.k8s.io                 false        VolumeAttachment

[root@master1 gsy]# kubectl explain pods
KIND:     Pod
VERSION:  v1

DESCRIPTION:
     Pod is a collection of containers that can run on a host. This resource is
     created by clients and scheduled onto hosts.

FIELDS:
   apiVersion   <string>
     APIVersion defines the versioned schema of this representation of an
     object. Servers should convert recognized schemas to the latest internal
     value, and may reject unrecognized values. More info:
     https://git.k8s.io/community/contributors/devel/api-conventions.md#resources

   kind <string>
     Kind is a string value representing the REST resource this object
     represents. Servers may infer this from the endpoint the client submits
     requests to. Cannot be updated. In CamelCase. More info:
     https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

   metadata     <Object>
     Standard object's metadata. More info:
     https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata

   spec <Object>
     Specification of the desired behavior of the pod. More info:
     https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status

   status       <Object>
     Most recently observed status of the pod. This data may not be up to date.
     Populated by the system. Read-only. More info:
     https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
[root@master1 gsy]# kubectl explain pods.spec.containers
KIND:     Pod
VERSION:  v1

RESOURCE: containers <[]Object>

DESCRIPTION:
     List of containers belonging to the pod. Containers cannot currently be
     added or removed. There must be at least one container in a Pod. Cannot be
     updated.

     A single application container that you want to run within a pod.

FIELDS:
   args <[]string>
     Arguments to the entrypoint. The docker image's CMD is used if this is not
     provided. Variable references $(VAR_NAME) are expanded using the
     container's environment. If a variable cannot be resolved, the reference in
     the input string will be unchanged. The $(VAR_NAME) syntax can be escaped
     with a double $$, ie: $$(VAR_NAME). Escaped references will never be
     expanded, regardless of whether the variable exists or not. Cannot be
     updated. More info:
     https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell

   command      <[]string>
     Entrypoint array. Not executed within a shell. The docker image's
     ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME)
     are expanded using the container's environment. If a variable cannot be
     resolved, the reference in the input string will be unchanged. The
     $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME).
     Escaped references will never be expanded, regardless of whether the
     variable exists or not. Cannot be updated. More info:
     https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell

   env  <[]Object>
     List of environment variables to set in the container. Cannot be updated.

   envFrom      <[]Object>
     List of sources to populate environment variables in the container. The
     keys defined within a source must be a C_IDENTIFIER. All invalid keys will
     be reported as an event when the container is starting. When a key exists
     in multiple sources, the value associated with the last source will take
     precedence. Values defined by an Env with a duplicate key will take
     precedence. Cannot be updated.

   image        <string>
     Docker image name. More info:
     https://kubernetes.io/docs/concepts/containers/images This field is
     optional to allow higher level config management to default or override
     container images in workload controllers like Deployments and StatefulSets.

   imagePullPolicy      <string>
     Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always
     if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated.
     More info:
     https://kubernetes.io/docs/concepts/containers/images#updating-images

   lifecycle    <Object>
     Actions that the management system should take in response to container
     lifecycle events. Cannot be updated.

   livenessProbe        <Object>
     Periodic probe of container liveness. Container will be restarted if the
     probe fails. Cannot be updated. More info:
     https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes

   name <string> -required-
     Name of the container specified as a DNS_LABEL. Each container in a pod
     must have a unique name (DNS_LABEL). Cannot be updated.

   ports        <[]Object>
     List of ports to expose from the container. Exposing a port here gives the
     system additional information about the network connections a container
     uses, but is primarily informational. Not specifying a port here DOES NOT
     prevent that port from being exposed. Any port which is listening on the
     default "0.0.0.0" address inside a container will be accessible from the
     network. Cannot be updated.

   readinessProbe       <Object>
     Periodic probe of container service readiness. Container will be removed
     from service endpoints if the probe fails. Cannot be updated. More info:
     https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes

   resources    <Object>
     Compute Resources required by this container. Cannot be updated. More info:
     https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/

   securityContext      <Object>
     Security options the pod should run with. More info:
     https://kubernetes.io/docs/concepts/policy/security-context/ More info:
     https://kubernetes.io/docs/tasks/configure-pod-container/security-context/

   stdin        <boolean>
     Whether this container should allocate a buffer for stdin in the container
     runtime. If this is not set, reads from stdin in the container will always
     result in EOF. Default is false.

   stdinOnce    <boolean>
     Whether the container runtime should close the stdin channel after it has
     been opened by a single attach. When stdin is true the stdin stream will
     remain open across multiple attach sessions. If stdinOnce is set to true,
     stdin is opened on container start, is empty until the first client
     attaches to stdin, and then remains open and accepts data until the client
     disconnects, at which time stdin is closed and remains closed until the
     container is restarted. If this flag is false, a container processes that
     reads from stdin will never receive an EOF. Default is false

   terminationMessagePath       <string>
     Optional: Path at which the file to which the container's termination
     message will be written is mounted into the container's filesystem. Message
     written is intended to be brief final status, such as an assertion failure
     message. Will be truncated by the node if greater than 4096 bytes. The
     total message length across all containers will be limited to 12kb.
     Defaults to /dev/termination-log. Cannot be updated.

   terminationMessagePolicy     <string>
     Indicate how the termination message should be populated. File will use the
     contents of terminationMessagePath to populate the container status message
     on both success and failure. FallbackToLogsOnError will use the last chunk
     of container log output if the termination message file is empty and the
     container exited with an error. The log output is limited to 2048 bytes or
     80 lines, whichever is smaller. Defaults to File. Cannot be updated.

   tty  <boolean>
     Whether this container should allocate a TTY for itself, also requires
     'stdin' to be true. Default is false.

   volumeDevices        <[]Object>
     volumeDevices is the list of block devices to be used by the container.
     This is an alpha feature and may change in the future.

   volumeMounts <[]Object>
     Pod volumes to mount into the container's filesystem. Cannot be updated.

   workingDir   <string>
     Container's working directory. If not specified, the container runtime's
     default will be used, which might be configured in the container image.
     Cannot be updated.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章