Deploy 的控制器定义参数介绍

  1. [root@master manifests]# kubectl explain deploy
  2. KIND: Deployment
  3. VERSION: extensions/v1beta1
  4.  
  5. DESCRIPTION:
  6. DEPRECATED - This group version of Deployment is deprecated by
  7. apps/v1beta2/Deployment. See the release notes for more information.
  8. Deployment enables declarative updates for Pods and ReplicaSets.
  9.  
  10. FIELDS:
  11. apiVersion <string>
  12. APIVersion defines the versioned schema of this representation of an
  13. object. Servers should convert recognized schemas to the latest internal
  14. value, and may reject unrecognized values. More info:
  15. https://git.k8s.io/community/contributors/devel/api-conventions.md#resources
  16.  
  17. kind <string>
  18. Kind is a string value representing the REST resource this object
  19. represents. Servers may infer this from the endpoint the client submits
  20. requests to. Cannot be updated. In CamelCase. More info:
  21. https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
  22.  
  23. metadata <Object> 元数据
  24. Standard object metadata.
  25.  
  26. spec <Object> 控制器的期望状态定义
  27. Specification of the desired behavior of the Deployment.
  28.  
  29. status <Object>
  30. Most recently observed status of the Deployment.

  deploy的控制器期望状态的定义参数介绍

  1. [root@master manifests]# kubectl explain deploy.spec
  2. KIND: Deployment
  3. VERSION: extensions/v1beta1
  4.  
  5. RESOURCE: spec <Object>
  6.  
  7. DESCRIPTION:
  8. Specification of the desired behavior of the Deployment.
  9.  
  10. DeploymentSpec is the specification of the desired behavior of the
  11. Deployment.
  12.  
  13. FIELDS:
  14. minReadySeconds <integer>
  15. Minimum number of seconds for which a newly created pod should be ready
  16. without any of its container crashing, for it to be considered available.
  17. Defaults to 0 (pod will be considered available as soon as it is ready)
  18.  
  19. paused <boolean> 暂停更新
  20. Indicates that the deployment is paused and will not be processed by the
  21. deployment controller.
  22.  
  23. progressDeadlineSeconds <integer>
  24. The maximum time in seconds for a deployment to make progress before it is
  25. considered to be failed. The deployment controller will continue to process
  26. failed deployments and a condition with a ProgressDeadlineExceeded reason
  27. will be surfaced in the deployment status. Note that progress will not be
  28. estimated during the time a deployment is paused. This is set to the max
  29. value of int32 (i.e. 2147483647) by default, which means "no deadline".
  30.  
  31. replicas <integer> pod的副本个数
  32. Number of desired pods. This is a pointer to distinguish between explicit
  33. zero and not specified. Defaults to 1.
  34.  
  35. revisionHistoryLimit <integer> 最多在历史中保留多少版本,默认10
  36. The number of old ReplicaSets to retain to allow rollback. This is a
  37. pointer to distinguish between explicit zero and not specified. This is set
  38. to the max value of int32 (i.e. 2147483647) by default, which means
  39. "retaining all old RelicaSets".
  40.  
  41. rollbackTo <Object>
  42. DEPRECATED. The config this deployment is rolling back to. Will be cleared
  43. after rollback is done.
  44.  
  45. selector <Object>
  46. Label selector for pods. Existing ReplicaSets whose pods are selected by
  47. this will be the ones affected by this deployment.
  48.  
  49. strategy <Object> 更新策略的定义
  50. The deployment strategy to use to replace existing pods with new ones.
  51.  
  52. template <Object> -required- pod的定义
  53. Template describes the pods that will be created.

  更新策略定义参数介绍

  1. [root@master manifests]# kubectl explain deploy.spec.strategy
  2. KIND: Deployment
  3. VERSION: extensions/v1beta1
  4.  
  5. RESOURCE: strategy <Object>
  6.  
  7. DESCRIPTION:
  8. The deployment strategy to use to replace existing pods with new ones.
  9.  
  10. DeploymentStrategy describes how to replace existing pods with new ones.
  11.  
  12. FIELDS:
  13. rollingUpdate <Object> 定义滚动策略
  14. Rolling update config params. Present only if DeploymentStrategyType =
  15. RollingUpdate.
  16.  
  17. type <string>Recreate 重建式更新表示删一个旧的,创建一个新的;RollingUpdate 表示滚动更新
  18. Type of deployment. Can be "Recreate" or "RollingUpdate". Default is
  19. RollingUpdate.
  20.  
  21. [root@master manifests]# kubectl explain deploy.spec.strategy.rollingUpdate
  22. KIND: Deployment
  23. VERSION: extensions/v1beta1
  24.  
  25. RESOURCE: rollingUpdate <Object>
  26.  
  27. DESCRIPTION:
  28. Rolling update config params. Present only if DeploymentStrategyType =
  29. RollingUpdate.
  30.  
  31. Spec to control the desired behavior of rolling update.
  32.  
  33. FIELDS:
  34. maxSurge <string> 更新过程中最多超出去pod期望副本几个;取值可以百分比也可以是具体个数
  35. The maximum number of pods that can be scheduled above the desired number
  36. of pods. Value can be an absolute number (ex: 5) or a percentage of desired
  37. pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number
  38. is calculated from percentage by rounding up. By default, a value of 1 is
  39. used. Example: when this is set to 30%, the new RC can be scaled up
  40. immediately when the rolling update starts, such that the total number of
  41. old and new pods do not exceed 130% of desired pods. Once old pods have
  42. been killed, new RC can be scaled up further, ensuring that total number of
  43. pods running at any time during the update is at most 130% of desired pods.
  44.  
  45. maxUnavailable <string> 最多不可用pod数量
  46. The maximum number of pods that can be unavailable during the update. Value
  47. can be an absolute number (ex: 5) or a percentage of desired pods (ex:
  48. 10%). Absolute number is calculated from percentage by rounding down. This
  49. can not be 0 if MaxSurge is 0. By default, a fixed value of 1 is used.
  50. Example: when this is set to 30%, the old RC can be scaled down to 70% of
  51. desired pods immediately when the rolling update starts. Once new pods are
  52. ready, old RC can be scaled down further, followed by scaling up the new
  53. RC, ensuring that the total number of pods available at all times during
  54. the update is at least 70% of desired pods.

  控制器pod的定义参数

  1. [root@master manifests]# kubectl explain deploy.spec.template
  2. KIND: Deployment
  3. VERSION: extensions/v1beta1
  4.  
  5. RESOURCE: template <Object>
  6.  
  7. DESCRIPTION:
  8. Template describes the pods that will be created.
  9.  
  10. PodTemplateSpec describes the data a pod should have when created from a
  11. template
  12.  
  13. FIELDS:
  14. metadata <Object> pod 元数据定义
  15. Standard object's metadata. More info:
  16. https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
  17.  
  18. spec <Object> pod 期望状态定义
  19. Specification of the desired behavior of the pod. More info:
  20. https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status

  控制器pod 元数据定义

  1. [root@master manifests]# kubectl explain deploy.spec.template.metadata
  2. KIND: Deployment
  3. VERSION: extensions/v1beta1
  4.  
  5. RESOURCE: metadata <Object>
  6.  
  7. DESCRIPTION:
  8. Standard object's metadata. More info:
  9. https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
  10.  
  11. ObjectMeta is metadata that all persisted resources must have, which
  12. includes all objects users must create.
  13.  
  14. FIELDS:
  15. annotations <map[string]string>
  16. Annotations is an unstructured key value map stored with a resource that
  17. may be set by external tools to store and retrieve arbitrary metadata. They
  18. are not queryable and should be preserved when modifying objects. More
  19. info: http://kubernetes.io/docs/user-guide/annotations
  20.  
  21. clusterName <string>
  22. The name of the cluster which the object belongs to. This is used to
  23. distinguish resources with same name and namespace in different clusters.
  24. This field is not set anywhere right now and apiserver is going to ignore
  25. it if set in create or update request.
  26.  
  27. creationTimestamp <string>
  28. CreationTimestamp is a timestamp representing the server time when this
  29. object was created. It is not guaranteed to be set in happens-before order
  30. across separate operations. Clients may not set this value. It is
  31. represented in RFC3339 form and is in UTC. Populated by the system.
  32. Read-only. Null for lists. More info:
  33. https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
  34.  
  35. deletionGracePeriodSeconds <integer>
  36. Number of seconds allowed for this object to gracefully terminate before it
  37. will be removed from the system. Only set when deletionTimestamp is also
  38. set. May only be shortened. Read-only.
  39.  
  40. deletionTimestamp <string>
  41. DeletionTimestamp is RFC 3339 date and time at which this resource will be
  42. deleted. This field is set by the server when a graceful deletion is
  43. requested by the user, and is not directly settable by a client. The
  44. resource is expected to be deleted (no longer visible from resource lists,
  45. and not reachable by name) after the time in this field, once the
  46. finalizers list is empty. As long as the finalizers list contains items,
  47. deletion is blocked. Once the deletionTimestamp is set, this value may not
  48. be unset or be set further into the future, although it may be shortened or
  49. the resource may be deleted prior to this time. For example, a user may
  50. request that a pod is deleted in 30 seconds. The Kubelet will react by
  51. sending a graceful termination signal to the containers in the pod. After
  52. that 30 seconds, the Kubelet will send a hard termination signal (SIGKILL)
  53. to the container and after cleanup, remove the pod from the API. In the
  54. presence of network partitions, this object may still exist after this
  55. timestamp, until an administrator or automated process can determine the
  56. resource is fully terminated. If not set, graceful deletion of the object
  57. has not been requested. Populated by the system when a graceful deletion is
  58. requested. Read-only. More info:
  59. https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
  60.  
  61. finalizers <[]string>
  62. Must be empty before the object is deleted from the registry. Each entry is
  63. an identifier for the responsible component that will remove the entry from
  64. the list. If the deletionTimestamp of the object is non-nil, entries in
  65. this list can only be removed.
  66.  
  67. generateName <string>
  68. GenerateName is an optional prefix, used by the server, to generate a
  69. unique name ONLY IF the Name field has not been provided. If this field is
  70. used, the name returned to the client will be different than the name
  71. passed. This value will also be combined with a unique suffix. The provided
  72. value has the same validation rules as the Name field, and may be truncated
  73. by the length of the suffix required to make the value unique on the
  74. server. If this field is specified and the generated name exists, the
  75. server will NOT return a 409 - instead, it will either return 201 Created
  76. or 500 with Reason ServerTimeout indicating a unique name could not be
  77. found in the time allotted, and the client should retry (optionally after
  78. the time indicated in the Retry-After header). Applied only if Name is not
  79. specified. More info:
  80. https://git.k8s.io/community/contributors/devel/api-conventions.md#idempotency
  81.  
  82. generation <integer>
  83. A sequence number representing a specific generation of the desired state.
  84. Populated by the system. Read-only.
  85.  
  86. initializers <Object>
  87. An initializer is a controller which enforces some system invariant at
  88. object creation time. This field is a list of initializers that have not
  89. yet acted on this object. If nil or empty, this object has been completely
  90. initialized. Otherwise, the object is considered uninitialized and is
  91. hidden (in list/watch and get calls) from clients that haven't explicitly
  92. asked to observe uninitialized objects. When an object is created, the
  93. system will populate this list with the current set of initializers. Only
  94. privileged users may set or modify this list. Once it is empty, it may not
  95. be modified further by any user. DEPRECATED - initializers are an alpha
  96. field and will be removed in v1.15.
  97.  
  98. labels <map[string]string> 标签定义
  99. Map of string keys and values that can be used to organize and categorize
  100. (scope and select) objects. May match selectors of replication controllers
  101. and services. More info: http://kubernetes.io/docs/user-guide/labels
  102.  
  103. managedFields <[]Object>
  104. ManagedFields maps workflow-id and version to the set of fields that are
  105. managed by that workflow. This is mostly for internal housekeeping, and
  106. users typically shouldn't need to set or understand this field. A workflow
  107. can be the user's name, a controller's name, or the name of a specific
  108. apply path like "ci-cd". The set of fields is always in the version that
  109. the workflow used when modifying the object. This field is alpha and can be
  110. changed or removed without notice.
  111.  
  112. name <string> 名字定义
  113. Name must be unique within a namespace. Is required when creating
  114. resources, although some resources may allow a client to request the
  115. generation of an appropriate name automatically. Name is primarily intended
  116. for creation idempotence and configuration definition. Cannot be updated.
  117. More info: http://kubernetes.io/docs/user-guide/identifiers#names
  118.  
  119. namespace <string> 名称空间的定义
  120. Namespace defines the space within each name must be unique. An empty
  121. namespace is equivalent to the "default" namespace, but "default" is the
  122. canonical representation. Not all objects are required to be scoped to a
  123. namespace - the value of this field for those objects will be empty. Must
  124. be a DNS_LABEL. Cannot be updated. More info:
  125. http://kubernetes.io/docs/user-guide/namespaces
  126.  
  127. ownerReferences <[]Object>
  128. List of objects depended by this object. If ALL objects in the list have
  129. been deleted, this object will be garbage collected. If this object is
  130. managed by a controller, then an entry in this list will point to this
  131. controller, with the controller field set to true. There cannot be more
  132. than one managing controller.
  133.  
  134. resourceVersion <string>
  135. An opaque value that represents the internal version of this object that
  136. can be used by clients to determine when objects have changed. May be used
  137. for optimistic concurrency, change detection, and the watch operation on a
  138. resource or set of resources. Clients must treat these values as opaque and
  139. passed unmodified back to the server. They may only be valid for a
  140. particular resource or set of resources. Populated by the system.
  141. Read-only. Value must be treated as opaque by clients and . More info:
  142. https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency
  143.  
  144. selfLink <string>
  145. SelfLink is a URL representing this object. Populated by the system.
  146. Read-only.
  147.  
  148. uid <string>
  149. UID is the unique in time and space value for this object. It is typically
  150. generated by the server on successful creation of a resource and is not
  151. allowed to change on PUT operations. Populated by the system. Read-only.
  152. More info: http://kubernetes.io/docs/user-guide/identifiers#uids

  控制器pod期望状态定义

  1. [root@master manifests]# kubectl explain deploy.spec.template.spec
  2. KIND: Deployment
  3. VERSION: extensions/v1beta1
  4.  
  5. RESOURCE: spec <Object>
  6.  
  7. DESCRIPTION:
  8. Specification of the desired behavior of the pod. More info:
  9. https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
  10.  
  11. PodSpec is a description of a pod.
  12.  
  13. FIELDS:
  14. activeDeadlineSeconds <integer>
  15. Optional duration in seconds the pod may be active on the node relative to
  16. StartTime before the system will actively try to mark it failed and kill
  17. associated containers. Value must be a positive integer.
  18.  
  19. affinity <Object>
  20. If specified, the pod's scheduling constraints
  21.  
  22. automountServiceAccountToken <boolean>
  23. AutomountServiceAccountToken indicates whether a service account token
  24. should be automatically mounted.
  25.  
  26. containers <[]Object> -required- pod 里容器相关定义
  27. List of containers belonging to the pod. Containers cannot currently be
  28. added or removed. There must be at least one container in a Pod. Cannot be
  29. updated.
  30.  
  31. dnsConfig <Object>
  32. Specifies the DNS parameters of a pod. Parameters specified here will be
  33. merged to the generated DNS configuration based on DNSPolicy.
  34.  
  35. dnsPolicy <string>
  36. Set DNS policy for the pod. Defaults to "ClusterFirst". Valid values are
  37. 'ClusterFirstWithHostNet', 'ClusterFirst', 'Default' or 'None'. DNS
  38. parameters given in DNSConfig will be merged with the policy selected with
  39. DNSPolicy. To have DNS options set along with hostNetwork, you have to
  40. specify DNS policy explicitly to 'ClusterFirstWithHostNet'.
  41.  
  42. enableServiceLinks <boolean>
  43. EnableServiceLinks indicates whether information about services should be
  44. injected into pod's environment variables, matching the syntax of Docker
  45. links. Optional: Defaults to true.
  46.  
  47. hostAliases <[]Object>
  48. HostAliases is an optional list of hosts and IPs that will be injected into
  49. the pod's hosts file if specified. This is only valid for non-hostNetwork
  50. pods.
  51.  
  52. hostIPC <boolean>
  53. Use the host's ipc namespace. Optional: Default to false.
  54.  
  55. hostNetwork <boolean>
  56. Host networking requested for this pod. Use the host's network namespace.
  57. If this option is set, the ports that will be used must be specified.
  58. Default to false.
  59.  
  60. hostPID <boolean>
  61. Use the host's pid namespace. Optional: Default to false.
  62.  
  63. hostname <string>
  64. Specifies the hostname of the Pod If not specified, the pod's hostname will
  65. be set to a system-defined value.
  66.  
  67. imagePullSecrets <[]Object>
  68. ImagePullSecrets is an optional list of references to secrets in the same
  69. namespace to use for pulling any of the images used by this PodSpec. If
  70. specified, these secrets will be passed to individual puller
  71. implementations for them to use. For example, in the case of docker, only
  72. DockerConfig type secrets are honored. More info:
  73. https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod
  74.  
  75. initContainers <[]Object>
  76. List of initialization containers belonging to the pod. Init containers are
  77. executed in order prior to containers being started. If any init container
  78. fails, the pod is considered to have failed and is handled according to its
  79. restartPolicy. The name for an init container or normal container must be
  80. unique among all containers. Init containers may not have Lifecycle
  81. actions, Readiness probes, or Liveness probes. The resourceRequirements of
  82. an init container are taken into account during scheduling by finding the
  83. highest request/limit for each resource type, and then using the max of of
  84. that value or the sum of the normal containers. Limits are applied to init
  85. containers in a similar fashion. Init containers cannot currently be added
  86. or removed. Cannot be updated. More info:
  87. https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
  88.  
  89. nodeName <string>
  90. NodeName is a request to schedule this pod onto a specific node. If it is
  91. non-empty, the scheduler simply schedules this pod onto that node, assuming
  92. that it fits resource requirements.
  93.  
  94. nodeSelector <map[string]string>
  95. NodeSelector is a selector which must be true for the pod to fit on a node.
  96. Selector which must match a node's labels for the pod to be scheduled on
  97. that node. More info:
  98. https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
  99.  
  100. preemptionPolicy <string>
  101. PreemptionPolicy is the Policy for preempting pods with lower priority. One
  102. of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset.
  103. This field is alpha-level and is only honored by servers that enable the
  104. NonPreemptingPriority feature.
  105.  
  106. priority <integer>
  107. The priority value. Various system components use this field to find the
  108. priority of the pod. When Priority Admission Controller is enabled, it
  109. prevents users from setting this field. The admission controller populates
  110. this field from PriorityClassName. The higher the value, the higher the
  111. priority.
  112.  
  113. priorityClassName <string>
  114. If specified, indicates the pod's priority. "system-node-critical" and
  115. "system-cluster-critical" are two special keywords which indicate the
  116. highest priorities with the former being the highest priority. Any other
  117. name must be defined by creating a PriorityClass object with that name. If
  118. not specified, the pod priority will be default or zero if there is no
  119. default.
  120.  
  121. readinessGates <[]Object>
  122. If specified, all readiness gates will be evaluated for pod readiness. A
  123. pod is ready when all its containers are ready AND all conditions specified
  124. in the readiness gates have status equal to "True" More info:
  125. https://git.k8s.io/enhancements/keps/sig-network/0007-pod-ready%2B%2B.md
  126.  
  127. restartPolicy <string>
  128. Restart policy for all containers within the pod. One of Always, OnFailure,
  129. Never. Default to Always. More info:
  130. https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy
  131.  
  132. runtimeClassName <string>
  133. RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group,
  134. which should be used to run this pod. If no RuntimeClass resource matches
  135. the named class, the pod will not be run. If unset or empty, the "legacy"
  136. RuntimeClass will be used, which is an implicit class with an empty
  137. definition that uses the default runtime handler. More info:
  138. https://git.k8s.io/enhancements/keps/sig-node/runtime-class.md This is a
  139. beta feature as of Kubernetes v1.14.
  140.  
  141. schedulerName <string>
  142. If specified, the pod will be dispatched by specified scheduler. If not
  143. specified, the pod will be dispatched by default scheduler.
  144.  
  145. securityContext <Object>
  146. SecurityContext holds pod-level security attributes and common container
  147. settings. Optional: Defaults to empty. See type description for default
  148. values of each field.
  149.  
  150. serviceAccount <string>
  151. DeprecatedServiceAccount is a depreciated alias for ServiceAccountName.
  152. Deprecated: Use serviceAccountName instead.
  153.  
  154. serviceAccountName <string>
  155. ServiceAccountName is the name of the ServiceAccount to use to run this
  156. pod. More info:
  157. https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
  158.  
  159. shareProcessNamespace <boolean>
  160. Share a single process namespace between all of the containers in a pod.
  161. When this is set containers will be able to view and signal processes from
  162. other containers in the same pod, and the first process in each container
  163. will not be assigned PID 1. HostPID and ShareProcessNamespace cannot both
  164. be set. Optional: Default to false. This field is beta-level and may be
  165. disabled with the PodShareProcessNamespace feature.
  166.  
  167. subdomain <string>
  168. If specified, the fully qualified Pod hostname will be
  169. "<hostname>.<subdomain>.<pod namespace>.svc.<cluster domain>". If not
  170. specified, the pod will not have a domainname at all.
  171.  
  172. terminationGracePeriodSeconds <integer>
  173. Optional duration in seconds the pod needs to terminate gracefully. May be
  174. decreased in delete request. Value must be non-negative integer. The value
  175. zero indicates delete immediately. If this value is nil, the default grace
  176. period will be used instead. The grace period is the duration in seconds
  177. after the processes running in the pod are sent a termination signal and
  178. the time when the processes are forcibly halted with a kill signal. Set
  179. this value longer than the expected cleanup time for your process. Defaults
  180. to 30 seconds.
  181.  
  182. tolerations <[]Object>
  183. If specified, the pod's tolerations.
  184.  
  185. volumes <[]Object>
  186. List of volumes that can be mounted by containers belonging to the pod.
  187. More info: https://kubernetes.io/docs/concepts/storage/volumes

  控制器pod 容器相关定义

  1. [root@master manifests]# kubectl explain deploy.spec.template.spec.containers
  2. KIND: Deployment
  3. VERSION: extensions/v1beta1
  4.  
  5. RESOURCE: containers <[]Object>
  6.  
  7. DESCRIPTION:
  8. List of containers belonging to the pod. Containers cannot currently be
  9. added or removed. There must be at least one container in a Pod. Cannot be
  10. updated.
  11.  
  12. A single application container that you want to run within a pod.
  13.  
  14. FIELDS:
  15. args <[]string>
  16. Arguments to the entrypoint. The docker image's CMD is used if this is not
  17. provided. Variable references $(VAR_NAME) are expanded using the
  18. container's environment. If a variable cannot be resolved, the reference in
  19. the input string will be unchanged. The $(VAR_NAME) syntax can be escaped
  20. with a double $$, ie: $$(VAR_NAME). Escaped references will never be
  21. expanded, regardless of whether the variable exists or not. Cannot be
  22. updated. More info:
  23. https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
  24.  
  25. command <[]string>
  26. Entrypoint array. Not executed within a shell. The docker image's
  27. ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME)
  28. are expanded using the container's environment. If a variable cannot be
  29. resolved, the reference in the input string will be unchanged. The
  30. $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME).
  31. Escaped references will never be expanded, regardless of whether the
  32. variable exists or not. Cannot be updated. More info:
  33. https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
  34.  
  35. env <[]Object>
  36. List of environment variables to set in the container. Cannot be updated.
  37.  
  38. envFrom <[]Object>
  39. List of sources to populate environment variables in the container. The
  40. keys defined within a source must be a C_IDENTIFIER. All invalid keys will
  41. be reported as an event when the container is starting. When a key exists
  42. in multiple sources, the value associated with the last source will take
  43. precedence. Values defined by an Env with a duplicate key will take
  44. precedence. Cannot be updated.
  45.  
  46. image <string> 镜像定义
  47. Docker image name. More info:
  48. https://kubernetes.io/docs/concepts/containers/images This field is
  49. optional to allow higher level config management to default or override
  50. container images in workload controllers like Deployments and StatefulSets.
  51.  
  52. imagePullPolicy <string> 镜像的获取方法定义
  53. Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always
  54. if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated.
  55. More info:
  56. https://kubernetes.io/docs/concepts/containers/images#updating-images
  57.  
  58. lifecycle <Object>
  59. Actions that the management system should take in response to container
  60. lifecycle events. Cannot be updated.
  61.  
  62. livenessProbe <Object>
  63. Periodic probe of container liveness. Container will be restarted if the
  64. probe fails. Cannot be updated. More info:
  65. https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
  66.  
  67. name <string> -required-
  68. Name of the container specified as a DNS_LABEL. Each container in a pod
  69. must have a unique name (DNS_LABEL). Cannot be updated.
  70.  
  71. ports <[]Object> 容器里暴露端口的定义
  72. List of ports to expose from the container. Exposing a port here gives the
  73. system additional information about the network connections a container
  74. uses, but is primarily informational. Not specifying a port here DOES NOT
  75. prevent that port from being exposed. Any port which is listening on the
  76. default "0.0.0.0" address inside a container will be accessible from the
  77. network. Cannot be updated.
  78.  
  79. readinessProbe <Object>
  80. Periodic probe of container service readiness. Container will be removed
  81. from service endpoints if the probe fails. Cannot be updated. More info:
  82. https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
  83.  
  84. resources <Object>
  85. Compute Resources required by this container. Cannot be updated. More info:
  86. https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
  87.  
  88. securityContext <Object>
  89. Security options the pod should run with. More info:
  90. https://kubernetes.io/docs/concepts/policy/security-context/ More info:
  91. https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
  92.  
  93. stdin <boolean>
  94. Whether this container should allocate a buffer for stdin in the container
  95. runtime. If this is not set, reads from stdin in the container will always
  96. result in EOF. Default is false.
  97.  
  98. stdinOnce <boolean>
  99. Whether the container runtime should close the stdin channel after it has
  100. been opened by a single attach. When stdin is true the stdin stream will
  101. remain open across multiple attach sessions. If stdinOnce is set to true,
  102. stdin is opened on container start, is empty until the first client
  103. attaches to stdin, and then remains open and accepts data until the client
  104. disconnects, at which time stdin is closed and remains closed until the
  105. container is restarted. If this flag is false, a container processes that
  106. reads from stdin will never receive an EOF. Default is false
  107.  
  108. terminationMessagePath <string>
  109. Optional: Path at which the file to which the container's termination
  110. message will be written is mounted into the container's filesystem. Message
  111. written is intended to be brief final status, such as an assertion failure
  112. message. Will be truncated by the node if greater than 4096 bytes. The
  113. total message length across all containers will be limited to 12kb.
  114. Defaults to /dev/termination-log. Cannot be updated.
  115.  
  116. terminationMessagePolicy <string>
  117. Indicate how the termination message should be populated. File will use the
  118. contents of terminationMessagePath to populate the container status message
  119. on both success and failure. FallbackToLogsOnError will use the last chunk
  120. of container log output if the termination message file is empty and the
  121. container exited with an error. The log output is limited to 2048 bytes or
  122. 80 lines, whichever is smaller. Defaults to File. Cannot be updated.
  123.  
  124. tty <boolean>
  125. Whether this container should allocate a TTY for itself, also requires
  126. 'stdin' to be true. Default is false.
  127.  
  128. volumeDevices <[]Object>
  129. volumeDevices is the list of block devices to be used by the container.
  130. This is a beta feature.
  131.  
  132. volumeMounts <[]Object>
  133. Pod volumes to mount into the container's filesystem. Cannot be updated.
  134.  
  135. workingDir <string>
  136. Container's working directory. If not specified, the container runtime's
  137. default will be used, which might be configured in the container image.
  138. Cannot be updated.

  编写deploy的yaml文件,并且启动pod

  1. [root@master manifests]# cat deploy.yaml
  2. apiVersion: apps/v1 api版本
  3. kind: Deployment
  4. metadata: 控制器元数据
  5. name: myapp-dp
  6. namespace: default
  7. spec: 控制器期望状态
  8. replicas: 10 pod副本个数
  9. revisionHistoryLimit: 5 保留5个历史版本
  10. selector: 选择标签选择器
  11. matchLabels: 使用的标签选择器
  12. app: myapp-cx 定义的标签
  13. cx: yl
  14. strategy: 更新策相关定义
  15. rollingUpdate: 更新策略方式定义
  16. maxSurge: 3 #表示每次更新时允许最多比期望状态pod个数多出3个
  17. type: RollingUpdate 采用上面定义的更新方式更新
  18. template: pod 的定义
  19. metadata: pod 元数据定义
  20. labels: 标签定义
  21. app: myapp-cx
  22. cx: yl
  23. name: myapp-dp
  24. namespace: default
  25. spec: pod 期望状态定义
  26. containers: pod 里容器定义
  27. - name: myapp-f 名字
  28. image: ikubernetes/myapp:v1 镜像
  29. ports: 暴露端口定义
  30. - name: httpd 端口名字
  31. containerPort: 80 容器里暴露端口
  32. livenessProbe: 容器状态探针定义
  33. tcpSocket: 使用tcpSocket方式
  34. port: 80 80端口

  启动;声明式创建

  1. [root@master manifests]# kubectl apply -f deploy.yaml

  查看

  1. [root@master manifests]# kubectl get deploy
  2. NAME READY UP-TO-DATE AVAILABLE AGE
  3. myapp 1/1 1 1 16d
  4. myapp-dp 10/10 10 10 14m
  5. nginx 1/1 1 1 16d

更新pod 副本个数为3个

  1. [root@master manifests]# vim deploy.yaml
  2.  
  3. apiVersion: apps/v1
  4. kind: Deployment
  5. metadata:
  6. name: myapp-dp
  7. namespace: default
  8. spec:
  9. replicas: 3 副本数调整为3
  10. revisionHistoryLimit: 5
  11. selector:
  12. matchLabels:
  13. app: myapp-cx
  14. cx: yl
  15. strategy:
  16. rollingUpdate:
  17. maxSurge: 3
  18. type: RollingUpdate
  19. template:
  20. metadata:
  21. labels:
  22. app: myapp-cx
  23. cx: yl
  24. name: myapp-dp
  25. namespace: default
  26. spec:
  27. containers:
  28. - name: myapp-f
  29. image: ikubernetes/myapp:v1
  30. ports:
  31. - name: httpd
  32. containerPort: 80
  33. livenessProbe:
  34. tcpSocket:
  35. port: 80
  36. [root@master manifests]# kubectl apply -f deploy.yaml 更新
  37. deployment.apps/myapp-dp configured
  38. [root@master manifests]# kubectl get deploy 查看
  39. NAME READY UP-TO-DATE AVAILABLE AGE
  40. myapp 1/1 1 1 16d
  41. myapp-dp 3/3 3 3 19m
  42. nginx 1/1 1 1 16d

  查看这个控制器的信息

  1. [root@master manifests]# kubectl describe deploy myapp-dp
  2. Name: myapp-dp
  3. Namespace: default
  4. CreationTimestamp: Sat, 10 Aug 2019 17:47:36 +0800
  5. Labels: <none>
  6. Annotations: deployment.kubernetes.io/revision: 1
  7. kubectl.kubernetes.io/last-applied-configuration:
  8. {"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"name":"myapp-dp","namespace":"
  9. default"},"spec":{"replicas":3,"re...Selector: app=myapp-cx,cx=yl
  10. Replicas: 3 desired | 3 updated | 3 total | 3 available | 0 unavailable
  11. StrategyType: RollingUpdate
  12. MinReadySeconds: 0
  13. RollingUpdateStrategy: 25% max unavailable, 3 max surge #更新策略
  14. Pod Template:
  15. Labels: app=myapp-cx
  16. cx=yl
  17. Containers:
  18. myapp-f:
  19. Image: ikubernetes/myapp:v1
  20. Port: 80/TCP
  21. Host Port: 0/TCP
  22. Liveness: tcp-socket :80 delay=0s timeout=1s period=10s #success=1 #failure=3
  23. Environment: <none>
  24. Mounts: <none>
  25. Volumes: <none>
  26. Conditions:
  27. Type Status Reason
  28. ---- ------ ------
  29. Available True MinimumReplicasAvailable
  30. Progressing True NewReplicaSetAvailable
  31. OldReplicaSets: <none>
  32. NewReplicaSet: myapp-dp-d86f5c644 (3/3 replicas created)
  33. Events:
  34. Type Reason Age From Message
  35. ---- ------ ---- ---- -------
  36. Normal ScalingReplicaSet 21m deployment-controller Scaled up replica set myapp-dp-d86f5c644 to 10
  37. Normal ScalingReplicaSet 2m46s deployment-controller Scaled down replica set myapp-dp-d86f5c644 to 3

  版本更新操作

  1. [root@master manifests]# vim deploy.yaml
  2.  
  3. apiVersion: apps/v1
  4. kind: Deployment
  5. metadata:
  6. name: myapp-dp
  7. namespace: default
  8. spec:
  9. replicas: 3
  10. revisionHistoryLimit: 5
  11. selector:
  12. matchLabels:
  13. app: myapp-cx
  14. cx: yl
  15. strategy:
  16. rollingUpdate:
  17. maxSurge: 3
  18. type: RollingUpdate
  19. template:
  20. metadata:
  21. labels:
  22. app: myapp-cx
  23. cx: yl
  24. name: myapp-dp
  25. namespace: default
  26. spec:
  27. containers:
  28. - name: myapp-f
  29. image: ikubernetes/myapp:v2 v1 v2
  30. ports:
  31. - name: httpd
  32. containerPort: 80
  33. livenessProbe:
  34. tcpSocket:
  35. port: 80
  36. [root@master manifests]# kubectl apply -f deploy.yaml
  37. deployment.apps/myapp-dp configured

  查看更新结果

  1. [root@master manifests]# kubectl get rs -o wide
  2. NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR
  3. myapp-dp-5ffd8b95f9 3 3 3 2m16s myapp-f ikubernetes/myapp:v2 app=myapp-cx,cx=yl,pod-template-hash=5ffd8b95f9 版本更新
  4. myapp-dp-d86f5c644 0 0 0 33m myapp-f ikubernetes/myapp:v1 app=myapp-cx,cx=yl,pod-template-hash=d86f5c644 保留历史版本

  跟历史版本相关的操作帮助

  1. [root@master manifests]# kubectl rollout --help
  2. Manage the rollout of a resource.
  3.  
  4. Valid resource types include:
  5.  
  6. * deployments
  7. * daemonsets
  8. * statefulsets
  9.  
  10. Examples:
  11. # Rollback to the previous deployment
  12. kubectl rollout undo deployment/abc
  13.  
  14. # Check the rollout status of a daemonset
  15. kubectl rollout status daemonset/foo
  16.  
  17. Available Commands:
  18. history 显示 rollout 历史
  19. pause 标记提供的 resource 为中止状态
  20. restart Restart a resource
  21. resume 继续一个停止的 resource
  22. status 显示 rollout 的状态
  23. undo 撤销上一次的 rollout
  24.  
  25. Usage:
  26. kubectl rollout SUBCOMMAND [options]
  27.  
  28. Use "kubectl <command> --help" for more information about a given command.
  29. Use "kubectl options" for a list of global command-line options (applies to all commands

  查看历史版本

  1. [root@master manifests]# kubectl rollout history deploy myapp-dp
  2. deployment.extensions/myapp-dp
  3. REVISION CHANGE-CAUSE
  4. 1 <none>
  5. 2 <none>

  通过打补丁方式更新pod副本个数

  1. [root@master manifests]# kubectl patch deploy myapp-dp -p '{"spec":{"replicas":5}}'
  2. deployment.extensions/myapp-dp patched
  3. [root@master manifests]# kubectl get rs -o wide
  4. NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR
  5. myapp-dp-5ffd8b95f9 5 5 5 13m myapp-f ikubernetes/myapp:v2 app=myapp-cx,cx=yl,pod-template-hash=5ffd8b95f9 修改为5
  6. myapp-dp-d86f5c644 0 0 0 44m myapp-f ikubernetes/myapp:v1 app=myapp-cx,cx=yl,pod-template-hash=d86f5c644

  通过打补丁方式修改更新策略

  1. [root@master manifests]# kubectl patch deploy myapp-dp -p '{"spec":{"strategy":{"rollingUpdate":{"maxSurge":1,"maxUnavailable":0}}}}'
  2. deployment.extensions/myapp-dp patched
  3. [root@master manifests]# kubectl describe deploy myapp-dp
  4. Name: myapp-dp
  5. Namespace: default
  6. CreationTimestamp: Sat, 10 Aug 2019 17:47:36 +0800
  7. Labels: app=myapp-cx
  8. cx=yl
  9. Annotations: deployment.kubernetes.io/revision: 2
  10. kubectl.kubernetes.io/last-applied-configuration:
  11. {"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"name":"myapp-dp","namespace":"default"},"spec":{"replicas":3,"re...
  12. Selector: app=myapp-cx,cx=yl
  13. Replicas: 5 desired | 5 updated | 5 total | 5 available | 0 unavailable
  14. StrategyType: RollingUpdate
  15. MinReadySeconds: 0
  16. RollingUpdateStrategy: 0 max unavailable, 1 max surge 更新策略
  17. Pod Template:
  18. Labels: app=myapp-cx
  19. cx=yl
  20. Containers:
  21. myapp-f:
  22. Image: ikubernetes/myapp:v2
  23. Port: 80/TCP
  24. Host Port: 0/TCP
  25. Liveness: tcp-socket :80 delay=0s timeout=1s period=10s #success=1 #failure=3
  26. Environment: <none>
  27. Mounts: <none>
  28. Volumes: <none>
  29. Conditions:
  30. Type Status Reason
  31. ---- ------ ------
  32. Progressing True NewReplicaSetAvailable
  33. Available True MinimumReplicasAvailable
  34. OldReplicaSets: <none>
  35. NewReplicaSet: myapp-dp-5ffd8b95f9 (5/5 replicas created)
  36. Events:
  37. Type Reason Age From Message
  38. ---- ------ ---- ---- -------
  39. Normal ScalingReplicaSet 56m deployment-controller Scaled up replica set myapp-dp-d86f5c644 to 10
  40. Normal ScalingReplicaSet 37m deployment-controller Scaled down replica set myapp-dp-d86f5c644 to 3
  41. Normal ScalingReplicaSet 25m deployment-controller Scaled up replica set myapp-dp-5ffd8b95f9 to 3
  42. Normal ScalingReplicaSet 25m deployment-controller Scaled down replica set myapp-dp-d86f5c644 to 2
  43. Normal ScalingReplicaSet 25m deployment-controller Scaled down replica set myapp-dp-d86f5c644 to 1
  44. Normal ScalingReplicaSet 24m deployment-controller Scaled down replica set myapp-dp-d86f5c644 to 0
  45. Normal ScalingReplicaSet 11m deployment-controller Scaled up replica set myapp-dp-5ffd8b95f9 to 5

  使用 kubectl set image 更新镜像版本了,并且只更新一个版本,金丝雀发布方式

  1. [root@master manifests]# kubectl set image deploy myapp-dp myapp-f=ikubernetes/myapp:v3 && kubectl rollout pause deploy myapp-dp
  2. deployment.extensions/myapp-dp image updated
  3. deployment.extensions/myapp-dp paused
  4.  
  5. [root@master ~]# kubectl get pods -l app=myapp-cx -w
  6. NAME READY STATUS RESTARTS AGE
  7. myapp-dp-5ffd8b95f9-5fctb 1/1 Running 0 19m
  8. myapp-dp-5ffd8b95f9-mxcwk 1/1 Running 0 32m
  9. myapp-dp-5ffd8b95f9-pzzv7 1/1 Running 0 32m
  10. myapp-dp-5ffd8b95f9-rfhmf 1/1 Running 0 19m
  11. myapp-dp-5ffd8b95f9-wblsj 1/1 Running 0 32m
  12. myapp-dp-758bf787f4-lrbzj 0/1 Pending 0 0s
  13. myapp-dp-758bf787f4-lrbzj 0/1 Pending 0 0s
  14. myapp-dp-758bf787f4-lrbzj 0/1 ContainerCreating 0 0s
  15. myapp-dp-758bf787f4-lrbzj 1/1 Running 0 12s
  16. [root@master ~]# curl 10.244.1.52
  17. Hello MyApp | Version: v2 | <a href="hostname.html">Pod Name</a>
  18. [root@master ~]# curl 10.244.1.51
  19. Hello MyApp | Version: v2 | <a href="hostname.html">Pod Name</a>
  20. [root@master ~]# curl 10.244.2.32
  21. Hello MyApp | Version: v2 | <a href="hostname.html">Pod Name</a>
  22. [root@master ~]# curl 10.244.2.33
  23. Hello MyApp | Version: v2 | <a href="hostname.html">Pod Name</a>
  24. [root@master ~]# curl 10.244.2.34
  25. Hello MyApp | Version: v3 | <a href="hostname.html">Pod Name</a> 只更新一个

  继续下面的更新操作

  1. [root@master manifests]# kubectl rollout resume deploy myapp-dp 继续这个控制器的更新操作
  2. deployment.extensions/myapp-dp resumed
    监控更新状态
  3. [root@master ~]# kubectl get pods -l app=myapp-cx -w
  4. NAME READY STATUS RESTARTS AGE
  5. myapp-dp-5ffd8b95f9-5fctb 1/1 Running 0 19m
  6. myapp-dp-5ffd8b95f9-mxcwk 1/1 Running 0 32m
  7. myapp-dp-5ffd8b95f9-pzzv7 1/1 Running 0 32m
  8. myapp-dp-5ffd8b95f9-rfhmf 1/1 Running 0 19m
  9. myapp-dp-5ffd8b95f9-wblsj 1/1 Running 0 32m
  10. myapp-dp-758bf787f4-lrbzj 0/1 Pending 0 0s
  11. myapp-dp-758bf787f4-lrbzj 0/1 Pending 0 0s
  12. myapp-dp-758bf787f4-lrbzj 0/1 ContainerCreating 0 0s
  13. myapp-dp-758bf787f4-lrbzj 1/1 Running 0 12s
  14. myapp-dp-5ffd8b95f9-rfhmf 1/1 Terminating 0 29m
  15. myapp-dp-758bf787f4-zwp6c 0/1 Pending 0 0s
  16. myapp-dp-758bf787f4-zwp6c 0/1 Pending 0 0s
  17. myapp-dp-758bf787f4-zwp6c 0/1 ContainerCreating 0 0s
  18. myapp-dp-5ffd8b95f9-rfhmf 0/1 Terminating 0 29m
  19. myapp-dp-5ffd8b95f9-rfhmf 0/1 Terminating 0 29m
  20. myapp-dp-5ffd8b95f9-rfhmf 0/1 Terminating 0 29m
  21. myapp-dp-758bf787f4-zwp6c 1/1 Running 0 11s
  22. myapp-dp-5ffd8b95f9-5fctb 1/1 Terminating 0 30m
  23. myapp-dp-758bf787f4-t8bpk 0/1 Pending 0 0s
  24. myapp-dp-758bf787f4-t8bpk 0/1 Pending 0 0s
  25. myapp-dp-758bf787f4-t8bpk 0/1 ContainerCreating 0 0s
  26. myapp-dp-5ffd8b95f9-5fctb 0/1 Terminating 0 30m
  27. myapp-dp-758bf787f4-t8bpk 1/1 Running 0 1s
  28. myapp-dp-5ffd8b95f9-mxcwk 1/1 Terminating 0 43m
  29. myapp-dp-758bf787f4-n24d9 0/1 Pending 0 0s
  30. myapp-dp-758bf787f4-n24d9 0/1 Pending 0 0s
  31. myapp-dp-758bf787f4-n24d9 0/1 ContainerCreating 0 0s
  32. myapp-dp-5ffd8b95f9-5fctb 0/1 Terminating 0 30m
  33. myapp-dp-5ffd8b95f9-5fctb 0/1 Terminating 0 30m
  34. myapp-dp-5ffd8b95f9-mxcwk 0/1 Terminating 0 43m
  35. myapp-dp-758bf787f4-n24d9 1/1 Running 0 1s
  36. myapp-dp-5ffd8b95f9-wblsj 1/1 Terminating 0 43m
  37. myapp-dp-758bf787f4-n5hzm 0/1 Pending 0 0s
  38. myapp-dp-758bf787f4-n5hzm 0/1 Pending 0 0s
  39. myapp-dp-758bf787f4-n5hzm 0/1 ContainerCreating 0 0s
  40. myapp-dp-758bf787f4-n5hzm 1/1 Running 0 1s
  41. myapp-dp-5ffd8b95f9-wblsj 0/1 Terminating 0 43m
  42. myapp-dp-5ffd8b95f9-pzzv7 1/1 Terminating 0 43m
  43. myapp-dp-5ffd8b95f9-pzzv7 0/1 Terminating 0 43m
  44. myapp-dp-5ffd8b95f9-mxcwk 0/1 Terminating 0 43m
  45. myapp-dp-5ffd8b95f9-mxcwk 0/1 Terminating 0 43m
  46. myapp-dp-5ffd8b95f9-wblsj 0/1 Terminating 0 43m
  47. myapp-dp-5ffd8b95f9-wblsj 0/1 Terminating 0 43m
  48. myapp-dp-5ffd8b95f9-pzzv7 0/1 Terminating 0 43m
  49. myapp-dp-5ffd8b95f9-pzzv7 0/1 Terminating 0 43m
    监控更新状态
  50. [root@master ~]# kubectl rollout status deploy myapp-dp
  51. Waiting for deployment "myapp-dp" rollout to finish: 1 out of 5 new replicas have been updated...
  52. Waiting for deployment spec update to be observed...
  53. Waiting for deployment spec update to be observed...
  54. Waiting for deployment "myapp-dp" rollout to finish: 1 out of 5 new replicas have been updated...
  55. Waiting for deployment "myapp-dp" rollout to finish: 2 out of 5 new replicas have been updated...
  56. Waiting for deployment "myapp-dp" rollout to finish: 2 out of 5 new replicas have been updated...
  57. Waiting for deployment "myapp-dp" rollout to finish: 2 out of 5 new replicas have been updated...
  58. Waiting for deployment "myapp-dp" rollout to finish: 3 out of 5 new replicas have been updated...
  59. Waiting for deployment "myapp-dp" rollout to finish: 3 out of 5 new replicas have been updated...
  60. Waiting for deployment "myapp-dp" rollout to finish: 3 out of 5 new replicas have been updated...
  61. Waiting for deployment "myapp-dp" rollout to finish: 4 out of 5 new replicas have been updated...
  62. Waiting for deployment "myapp-dp" rollout to finish: 4 out of 5 new replicas have been updated...
  63. Waiting for deployment "myapp-dp" rollout to finish: 4 out of 5 new replicas have been updated...
  64. Waiting for deployment "myapp-dp" rollout to finish: 1 old replicas are pending termination...
  65. Waiting for deployment "myapp-dp" rollout to finish: 1 old replicas are pending termination...
  66. deployment "myapp-dp" successfully rolled out

  查看更新pod

  1. [root@master manifests]# kubectl get rs -o wide
  2. NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR
  3. myapp-dp-5ffd8b95f9 0 0 0 46m myapp-f ikubernetes/myapp:v2 app=myapp-cx,cx=yl,pod-template-hash=5ffd8b95f9
  4. myapp-dp-758bf787f4 5 5 5 13m myapp-f ikubernetes/myapp:v3 app=myapp-cx,cx=yl,pod-template-hash=758bf787f4 更新到v3
  5. myapp-dp-d86f5c644 0 0 0 77m myapp-f ikubernetes/myapp:v1 app=myapp-cx,cx=yl,pod-template-hash=d86f5c644

  回滚操作帮助介绍

  1. [root@master manifests]# kubectl rollout undo --help
  2. Rollback to a previous rollout.
  3.  
  4. Examples:
  5. # Rollback to the previous deployment
  6. kubectl rollout undo deployment/abc 默认回滚上一个版本
  7.  
  8. # Rollback to daemonset revision 3
  9. kubectl rollout undo daemonset/abc --to-revision=3 这是指定回滚到那个版本,结合历史版本操作
  10.  
  11. # Rollback to the previous deployment with dry-run
  12. kubectl rollout undo --dry-run=true deployment/abc
  13.  
  14. Options:
  15. --allow-missing-template-keys=true: If true, ignore any errors in templates when a field or map key is missing in
  16. the template. Only applies to golang and jsonpath output formats.
  17. --dry-run=false: If true, only print the object that would be sent, without sending it.
  18. -f, --filename=[]: Filename, directory, or URL to files identifying the resource to get from a server.
  19. -k, --kustomize='': Process the kustomization directory. This flag can't be used together with -f or -R.
  20. -o, --output='': Output format. One of:
  21. json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file.
  22. -R, --recursive=false: Process the directory used in -f, --filename recursively. Useful when you want to manage
  23. related manifests organized within the same directory.
  24. --template='': Template string or path to template file to use when -o=go-template, -o=go-template-file. The
  25. template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
  26. --to-revision=0: The revision to rollback to. Default to 0 (last revision).
  27.  
  28. Usage:
  29. kubectl rollout undo (TYPE NAME | TYPE/NAME) [flags] [options]
  30.  
  31. Use "kubectl options" for a list of global command-line options (applies to all commands).
  32. 查看历史版本
  33. [root@master manifests]# kubectl rollout history deploy myapp-dp
  34. deployment.extensions/myapp-dp
  35. REVISION CHANGE-CAUSE
  36. 1 <none>
  37. 2 <none>
  38. 3 <none>

  回滚具体操作方法

  1. [root@master manifests]# kubectl rollout undo deploy myapp-dp --to-revision=1
  2. deployment.extensions/myapp-dp rolled back
  3. [root@master manifests]# kubectl get rs -o wide
  4. NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR
  5. myapp-dp-5ffd8b95f9 0 0 0 55m myapp-f ikubernetes/myapp:v2 app=myapp-cx,cx=yl,pod-template-hash=5ffd8b95f9
  6. myapp-dp-758bf787f4 0 0 0 22m myapp-f ikubernetes/myapp:v3 app=myapp-cx,cx=yl,pod-template-hash=758bf787f4
  7. myapp-dp-d86f5c644 5 5 5 86m myapp-f ikubernetes/myapp:v1 app=myapp-cx,cx=yl,pod-template-hash=d86f5c644 回滚这个版本了

  

  

Kubernetes的控制器之Deployment的定义的更多相关文章

  1. Kubernetes 控制器之 Deployment 介绍(六)

    一.Deployment.ReplicaSet.Pod之间的关系 我们接着前面的文章说,如果不清楚的请查看之前的博文:http://blog.51cto.com/wzlinux/2322616 前面我 ...

  2. kubernetes学习控制器之StatefulSet控制器

    StatefulSet介绍 一.StatefulSet概述 StatefulSet是用来管理stateful(有状态)应用的StatefulSet管理Pod时,确保Pod有一个按序增长的ID与Depl ...

  3. 十五、资源控制之Deployment

    资源控制器之Deployment Deployment 为 Pod 和 ReplicaSet 提供了一个声明式定义(declarative)方法,用来替代以前的ReplicationControlle ...

  4. k8s运行容器之deployment(三)

    deployment 我们已经知道k8s是通过各种controller来管理pod的生命周期.为了满足不同业务场景,k8s开发了Deployment.ReplicaSet.DaemonSet.Stat ...

  5. Kubernetes中如何让Deployment更新镜像

    问题描述 我的deployment有单个pod,我的自定义docker镜像如下: 123 containers: - name: mycontainer image: myimage:latest 在 ...

  6. kubernetes资源清单之Deployment

    Deployment为Pod和ReplicaSets提供声明性更新 示例 --- apiVersion: apps/v1 kind: Deployment metadata:     name: de ...

  7. 十六、资源控制器之DaemonSet

    资源控制器之DaemonSet DaemonSet 确保全部(或者一些) Node上运行一个 Pod 的副本,当有 Node 加入集群时,也会为他们新增一个 Pod,当有 Node 从集群移除时,这些 ...

  8. Kubernetes的pod控制器之DaemonSet

    DaemonSet 顶级参数介绍 [root@master manifests]# kubectl explain ds KIND: DaemonSet VERSION: extensions/v1b ...

  9. Kubernetes---资源控制器之ReplicationController、ReplicaSet和Deployment

    1.ReplicationController和ReplicaSet介绍 RC(ReplicationController)主要的作用就是用来确保容器应用的副本数始终保持在用户定义的副本数.即如果有容 ...

随机推荐

  1. vue项目接入百度地图

    方法一 :使用第三方工具 vue-baidu-map 安装命令: yarn add vue-baidu-map --save 文档地址:https://dafrok.github.io/vue-bai ...

  2. 使用yum时出现Error: rpmdb open failed解决方案

    一.问题描述 使用yum安装软件时出现Error: rpmdb open failed,报错信息显示rpm数据库被损坏. 二.解决方案 重建rpm数据库. [root@localhost yum.re ...

  3. 大白话Web三大组件之一Servlet

    很多学习到Servlet这里的童鞋,听到那么多专业名词解释这个Servlet,相信都是很蒙圈的,在这里我先不跟大家扯Servlet的大概念,先跟大家探讨一下关于Servlet的作用 相信MVC这个概念 ...

  4. ubuntu 切换用户

    app切换root ubuntu: sudo su - app sudo su - root centos : sudo su ############ root 切换app sudo su - ap ...

  5. 剑指Offer:面试题20:表示数值的字符串

    记录一下书上的写法.很整洁,每个函数的功能都显而易见.自己开始写的一堆if else语句像是一坨屎.另外注释的地方短路效应也要注意一下.总之这题还挺考察代码素质的(我这种就不存在什么素质..乱糟糟一团 ...

  6. arcgis计算X坐标值、Y坐标值

    arcgis计算X坐标值.Y坐标值 要计算的字段上点击右键,选择计算几何,弹出计算几何对话框.可以设置属性.坐标系.单位等.

  7. C#堆和栈的入门理解

    声明:以下内容从网络整理,非原创,适当待入个人理解. 解释1.栈是编译期间就分配好的内存空间,因此你的代码中必须就栈的大小有明确的定义:堆是程序运行期间动态分配的内存空间,你可以根据程序的运行情况确定 ...

  8. DataGridView 更改Header样式

    '必须先设置 EnableHeadersVisualStyles 属性 才能设置Header颜色dgv.EnableHeadersVisualStyles = Falsedgv.ColumnHeade ...

  9. 计算几何-UVa10652

    This article is made by Jason-Cow.Welcome to reprint.But please post the article's address. 题意见白书,P2 ...

  10. 【 Struts2 配置】Struts2基本搭建

    struts.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBL ...