实操: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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值