|
| 1 | +[[dev-guide-kubernetes-deployments-support]] |
| 2 | += Kubernetes Deployments Support |
| 3 | +{product-author} |
| 4 | +{product-version} |
| 5 | +:data-uri: |
| 6 | +:icons: |
| 7 | +:experimental: |
| 8 | +:toc: macro |
| 9 | +:toc-title: |
| 10 | + |
| 11 | +toc::[] |
| 12 | + |
| 13 | +== New Object Type: Deployments |
| 14 | + |
| 15 | +In the upstream Kubernetes project, a new first-class object type called |
| 16 | +_deployments_ was added in version 1.2. This object type (referred to here as |
| 17 | +_Kubernetes deployments_ for distinction) serves as a descendant of the |
| 18 | +deployment configuration object type that has been in {product-title} since |
| 19 | +ifdef::openshift-origin[] |
| 20 | +1.0. |
| 21 | +endif::[] |
| 22 | +ifdef::openshift-enterprise[] |
| 23 | +3.0. |
| 24 | +endif::[] |
| 25 | +Starting in {product-title} |
| 26 | +ifdef::openshift-origin[] |
| 27 | +1.4, |
| 28 | +endif::[] |
| 29 | +ifdef::openshift-enterprise[] |
| 30 | +3.4, |
| 31 | +endif::[] |
| 32 | +support for Kubernetes deployments is available as a |
| 33 | +ifdef::openshift-origin[] |
| 34 | +link:https://github.com/openshift/origin#alpha-and-unsupported-kubernetes-features[Tech Preview] |
| 35 | +endif::[] |
| 36 | +ifdef::openshift-enterprise[] |
| 37 | +link:https://access.redhat.com/support/offerings/techpreview[Technology Preview] |
| 38 | +endif::[] |
| 39 | +feature. |
| 40 | + |
| 41 | +Like deployment configurations, Kubernetes deployments describe the desired |
| 42 | +state of a particular component of an application as a pod template. Kubernetes |
| 43 | +deployments create _replica sets_ (an iteration of |
| 44 | +xref:../../architecture/core_concepts/deployments.adoc#replication-controllers[replication controllers]), which orchestrate pod lifecycles. |
| 45 | + |
| 46 | +For example, this definition of a Kubernetes deployment creates a replica set to |
| 47 | +bring up three nginx pods: |
| 48 | + |
| 49 | +.Example Kubernetes Deployment Definition *_nginx-deployment.yaml_* |
| 50 | +---- |
| 51 | +apiVersion: extensions/v1beta1 |
| 52 | +kind: Deployment |
| 53 | +metadata: |
| 54 | + name: nginx |
| 55 | +spec: |
| 56 | + replicas: 3 |
| 57 | + template: |
| 58 | + metadata: |
| 59 | + labels: |
| 60 | + app: nginx |
| 61 | + spec: |
| 62 | + containers: |
| 63 | + - name: nginx |
| 64 | + image: nginx:1.7.9 |
| 65 | + ports: |
| 66 | + - containerPort: 80 |
| 67 | +---- |
| 68 | + |
| 69 | +After saving the definition to a local file, you could then use it to create a |
| 70 | +Kubernetes deployment: |
| 71 | + |
| 72 | +---- |
| 73 | +$ oc create -f nginx-deployment.yaml |
| 74 | +---- |
| 75 | + |
| 76 | +You can use the CLI to inspect and operate on Kubernetes deployments and replica |
| 77 | +sets like other object types, as described in |
| 78 | +xref:../../cli_reference/basic_cli_operations.adoc#oc-common-operations[Common |
| 79 | +Operations], like `get` and `describe`. For the object type, use `deployments` |
| 80 | +or `deploy` for Kubernetes deployments and `replicasets` or `rs` for replica |
| 81 | +sets. |
| 82 | + |
| 83 | +See the Kubernetes documentation for more details about |
| 84 | +link:http://kubernetes.io/docs/user-guide/deployments/[Deployments] and |
| 85 | +link:http://kubernetes.io/docs/user-guide/replicasets/[Replica Sets], |
| 86 | +substituting `oc` for `kubectl` in CLI usage examples. |
| 87 | + |
| 88 | +[[kubernetes-deployments-vs-deployment-configurations]] |
| 89 | +== Kubernetes Deployments vs Deployment Configurations |
| 90 | + |
| 91 | +Because deployment configurations existed in {product-title} prior to |
| 92 | +deployments being added in Kubernetes 1.2, the latter object type naturally |
| 93 | +diverges slightly from the former. The long-term goal in {product-title} is to reach |
| 94 | +full feature parity in Kubernetes deployments and switch to using them as a |
| 95 | +single object type that provides fine-grained management over applications. |
| 96 | + |
| 97 | +Kubernetes deployments are supported to ensure upstream projects and examples |
| 98 | +that use the new object type can run smoothly on {product-title}. Given the |
| 99 | +current feature set of Kubernetes deployments, you may want to use them instead |
| 100 | +of deployment configurations in {product-title} if you do not plan to use any of |
| 101 | +the following in particular: |
| 102 | + |
| 103 | +- xref:../../dev_guide/managing_images.adoc#dev-guide-managing-images[image streams] |
| 104 | +- xref:../../dev_guide/deployments/deployment_strategies.html#lifecycle-hooks[lifecycle hooks] |
| 105 | +- xref:../../dev_guide/deployments/deployment_strategies.html#custom-strategy[Custom deployment strategies] |
| 106 | + |
| 107 | +The following sections go into more details on the differences between the two |
| 108 | +object types to further help you decide when you might want to use Kubernetes |
| 109 | +deployments over deployment configurations. |
| 110 | + |
| 111 | +[[deployment-configuration-specific-features]] |
| 112 | +=== Deployment Configuration-Specific Features |
| 113 | + |
| 114 | +[[dc-vs-d-automatic-rollbacks]] |
| 115 | +==== Automatic Rollbacks |
| 116 | + |
| 117 | +Kubernetes deployments do not support automatically rolling back to the last |
| 118 | +successfully deployed replica set in case of a failure. This feature should be |
| 119 | +added soon. |
| 120 | + |
| 121 | +[[dc-vs-d-triggers]] |
| 122 | +==== Triggers |
| 123 | + |
| 124 | +Kubernetes deployments have an implicit `ConfigChange` trigger in that every |
| 125 | +change in the pod template of a deployment automatically triggers a new rollout. |
| 126 | +If you do not want new rollouts on pod template changes, pause the deployment: |
| 127 | + |
| 128 | +---- |
| 129 | +$ oc rollout pause deployments/<name> |
| 130 | +---- |
| 131 | + |
| 132 | +At the moment, Kubernetes deployments do not support `ImageChange` triggers. A |
| 133 | +generic triggering mechanism has been proposed upstream, but it is unknown if |
| 134 | +and when it may be accepted. Eventually, a {product-title}-specific mechanism |
| 135 | +could be implemented to layer on top of Kubernetes deployments, but it would be |
| 136 | +more desirable for it to exist as part of the Kubernetes core. |
| 137 | + |
| 138 | +[[dc-vs-d-lifecycle-hooks]] |
| 139 | +==== Lifecycle Hooks |
| 140 | + |
| 141 | +Kubernetes deployments do not support any lifecycle hooks. |
| 142 | + |
| 143 | +[[dc-vs-d-custom-strategies]] |
| 144 | +==== Custom Strategies |
| 145 | + |
| 146 | +Kubernetes deployments do not yet support user-specified Custom deployment |
| 147 | +strategies yet. |
| 148 | + |
| 149 | +[[dc-vs-d-canary-deployments]] |
| 150 | +==== Canary Deployments |
| 151 | + |
| 152 | +Kubernetes deployments do not yet run canaries as part of a new rollout. |
| 153 | + |
| 154 | +[[dc-vs-d-test-deployments]] |
| 155 | +==== Test Deployments |
| 156 | + |
| 157 | +Kubernetes deployments do not support running test tracks. |
| 158 | + |
| 159 | +[[kubernetes-deployments-specific-features]] |
| 160 | +=== Kubernetes Deployment-Specific Features |
| 161 | + |
| 162 | +[[dc-vs-d-rollover]] |
| 163 | +==== Rollover |
| 164 | + |
| 165 | +The deployment process for Kubernetes deployments is driven by a controller |
| 166 | +loop, in contrast to deployment configurations which use deployer pods for every |
| 167 | +new rollout. This means that a Kubernetes deployment can have as many active |
| 168 | +replica sets as possible, and eventually the deployment controller will scale |
| 169 | +down all old replica sets and scale up the newest one. |
| 170 | + |
| 171 | +Deployment configurations can have at most one deployer pod running, otherwise |
| 172 | +multiple deployers end up fighting with each other trying to scale up what they |
| 173 | +think should be the newest replication controller. Because of this, only two |
| 174 | +replication controllers can be active at any point in time. Ultimately, this |
| 175 | +translates to faster rapid rollouts for Kubernetes deployments. |
| 176 | + |
| 177 | +[[dc-vs-d-proportional-scaling]] |
| 178 | +==== Proportional Scaling |
| 179 | + |
| 180 | +Because the Kubernetes deployment controller is the sole source of truth for the sizes of |
| 181 | +new and old replica sets owned by a deployment, it is able to scale ongoing |
| 182 | +rollouts. Additional replicas are distributed proportionally based on the size |
| 183 | +of each replica set. |
| 184 | + |
| 185 | +Deployment configurations cannot be scaled when a rollout is ongoing because the |
| 186 | +deployment configuration controller will end up fighting with the deployer |
| 187 | +process about the size of the new replication controller. |
| 188 | + |
| 189 | +[[dc-vs-d-pausing-mid-rollout]] |
| 190 | +==== Pausing Mid-rollout |
| 191 | + |
| 192 | +Kubernetes deployments can be paused at any point in time, meaning you can also |
| 193 | +pause ongoing rollouts. On the other hand, you cannot pause deployer pods |
| 194 | +currently, so if you try to pause a deployment configuration in the middle of a |
| 195 | +rollout, the deployer process will not be affected and will continue until it |
| 196 | +finishes. |
0 commit comments