From fbe7cba2c4a613bdab7c7da531620963b780f168 Mon Sep 17 00:00:00 2001 From: Jun Xiang Tee Date: Tue, 12 Sep 2017 16:30:50 -0700 Subject: [PATCH] Update kubectl patch doc to use apps/v1beta2 APIs --- .../deployment-patch-demo.yaml | 5 ++- .../deployment-patch-demo.yaml | 5 ++- .../update-api-object-kubectl-patch.md | 34 ++++++++----------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/cn/docs/tasks/run-application/deployment-patch-demo.yaml b/cn/docs/tasks/run-application/deployment-patch-demo.yaml index 3c45b6c8a931e..f3f1bc34d85ac 100644 --- a/cn/docs/tasks/run-application/deployment-patch-demo.yaml +++ b/cn/docs/tasks/run-application/deployment-patch-demo.yaml @@ -1,9 +1,12 @@ -apiVersion: apps/v1beta1 +apiVersion: apps/v1beta2 kind: Deployment metadata: name: patch-demo spec: replicas: 2 + selector: + matchLabels: + app: nginx template: metadata: labels: diff --git a/docs/tasks/run-application/deployment-patch-demo.yaml b/docs/tasks/run-application/deployment-patch-demo.yaml index 3c45b6c8a931e..f3f1bc34d85ac 100644 --- a/docs/tasks/run-application/deployment-patch-demo.yaml +++ b/docs/tasks/run-application/deployment-patch-demo.yaml @@ -1,9 +1,12 @@ -apiVersion: apps/v1beta1 +apiVersion: apps/v1beta2 kind: Deployment metadata: name: patch-demo spec: replicas: 2 + selector: + matchLabels: + app: nginx template: metadata: labels: diff --git a/docs/tasks/run-application/update-api-object-kubectl-patch.md b/docs/tasks/run-application/update-api-object-kubectl-patch.md index ec4b63642d5a6..2785adb72298f 100644 --- a/docs/tasks/run-application/update-api-object-kubectl-patch.md +++ b/docs/tasks/run-application/update-api-object-kubectl-patch.md @@ -54,15 +54,12 @@ get terminated and replaced by new ones. At this point, each Pod has one Container that runs the nginx image. Now suppose you want each Pod to have two containers: one that runs nginx and one that runs redis. -Create a file named `patch-file.yaml` that has this content: +Create a file named `patch-file.yaml` that has `.spec.template.spec.containers` field as follow: ```shell -spec: - template: - spec: - containers: - - name: patch-demo-ctr-2 - image: redis +containers: +- name: patch-demo-ctr-2 + image: redis ``` Patch your Deployment: @@ -81,14 +78,14 @@ The output shows that the PodSpec in the Deployment has two Containers: ```shell containers: -- image: nginx - imagePullPolicy: Always - name: patch-demo-ctr - ... - image: redis imagePullPolicy: Always name: patch-demo-ctr-2 ... +- image: nginx + imagePullPolicy: Always + name: patch-demo-ctr + ... ``` View the Pods associated with your patched Deployment: @@ -118,10 +115,10 @@ The output shows that the Pod has two Containers: one running nginx and one runn ``` containers: -- image: nginx - ... - image: redis ... +- image: nginx + ... ``` ### Notes on the strategic merge patch @@ -160,15 +157,12 @@ The default value for the `type` parameter is `strategic`. So in the preceding e did a strategic merge patch. Next, do a JSON merge patch on your same Deployment. Create a file named `patch-file-2.yaml` -that has this content: +that has `.spec.template.spec.containers` field as follow: ```shell -spec: - template: - spec: - containers: - - name: patch-demo-ctr-3 - image: gcr.io/google-samples/node-hello:1.0 +containers: +- name: patch-demo-ctr-3 + image: gcr.io/google-samples/node-hello:1.0 ``` In your patch command, set `type` to `merge`: