From 8ad19e8ec64ae92e275588bafecc9a89b3ea4378 Mon Sep 17 00:00:00 2001 From: Suraj Deshmukh Date: Mon, 4 Dec 2017 10:53:42 +0530 Subject: [PATCH] Fix instructions to define HPA declaratively --- .../horizontal-pod-autoscale-walkthrough.md | 23 ++++--------------- .../tasks/run-application/hpa-php-apache.yaml | 13 +++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 docs/tasks/run-application/hpa-php-apache.yaml diff --git a/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough.md b/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough.md index ee2b0ba65b..d6bc7302e6 100644 --- a/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough.md +++ b/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough.md @@ -311,29 +311,16 @@ HorizontalPodAutoscaler. ## Appendix: Other possible scenarios -### Creating the autoscaler from a .yaml file +### Creating the autoscaler declaratively -Instead of using `kubectl autoscale` command we can use the [hpa-php-apache.yaml](/docs/user-guide/horizontal-pod-autoscaling/hpa-php-apache.yaml) file, which looks like this: +Instead of using `kubectl autoscale` command to create a HorizontalPodAutoscaler imperatively we +can use the following file to create it declaratively: -```yaml -apiVersion: autoscaling/v1 -kind: HorizontalPodAutoscaler -metadata: - name: php-apache - namespace: default -spec: - scaleTargetRef: - apiVersion: apps/v1beta1 - kind: Deployment - name: php-apache - minReplicas: 1 - maxReplicas: 10 - targetCPUUtilizationPercentage: 50 -``` +{% include code.html language="yaml" file="hpa-php-apache.yaml" ghlink="/docs/tasks/run-application/hpa-php-apache.yaml" %} We will create the autoscaler by executing the following command: ```shell -$ kubectl create -f docs/user-guide/horizontal-pod-autoscaling/hpa-php-apache.yaml +$ kubectl create -f https://k8s.io/docs/tasks/run-application/hpa-php-apache.yaml horizontalpodautoscaler "php-apache" created ``` diff --git a/docs/tasks/run-application/hpa-php-apache.yaml b/docs/tasks/run-application/hpa-php-apache.yaml new file mode 100644 index 0000000000..efe4bc149b --- /dev/null +++ b/docs/tasks/run-application/hpa-php-apache.yaml @@ -0,0 +1,13 @@ +apiVersion: autoscaling/v1 +kind: HorizontalPodAutoscaler +metadata: + name: php-apache + namespace: default +spec: + scaleTargetRef: + apiVersion: apps/v1beta1 + kind: Deployment + name: php-apache + minReplicas: 1 + maxReplicas: 10 + targetCPUUtilizationPercentage: 50