Skip to content

Commit

Permalink
Merge pull request #6545 from surajssd/fix-hpa-declarative-instructions
Browse files Browse the repository at this point in the history
Fix instructions to define HPA declaratively
  • Loading branch information
tengqm authored Dec 5, 2017
2 parents 34ca17e + 8ad19e8 commit dc788d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
23 changes: 5 additions & 18 deletions docs/tasks/run-application/horizontal-pod-autoscale-walkthrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
13 changes: 13 additions & 0 deletions docs/tasks/run-application/hpa-php-apache.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dc788d1

Please sign in to comment.