Skip to content

Commit

Permalink
Add yaml configuration file snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
kkanska committed Feb 5, 2020
1 parent 466f7d5 commit 7cc9719
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ It defines an index.php page which performs some CPU intensive computations:
?>
```

First, we will start a deployment running the image and expose it as a service:
First, we will start a deployment running the image and expose it as a service
using the following configuration:

{{< codenew file="application/php-apache.yaml" >}}


Run the following command:
```shell
kubectl apply -f https://k8s.io/examples/application/php-apache.yaml
```
Expand All @@ -74,17 +79,18 @@ service/php-apache created

## Create Horizontal Pod Autoscaler

Now that the server is running, we will create the autoscaler using
[kubectl autoscale](/docs/reference/generated/kubectl/kubectl-commands#autoscale).
The following command will create a Horizontal Pod Autoscaler that maintains between 1 and 10 replicas of the Pods
Now that the server is running, we will create a Horizontal Pod Autoscaler that maintains between 1 and 10 replicas of the Pods
controlled by the php-apache deployment we created in the first step of these instructions.
Roughly speaking, HPA will increase and decrease the number of replicas
(via the deployment) to maintain an average CPU utilization across all Pods of 50%
(since each pod requests 200 milli-cores by `kubectl run`), this means average CPU usage of 100 milli-cores).
See [here](/docs/tasks/run-application/horizontal-pod-autoscale/#algorithm-details) for more details on the algorithm.

{{< codenew file="application/hpa/php-apache.yaml" >}}

Run the following command:
```shell
kubectl autoscale deployment php-apache --cpu-percent=50 --min=1 --max=10
kubectl apply -f https://k8s.io/examples/application/hpa/php-apache.yaml
```
```
horizontalpodautoscaler.autoscaling/php-apache autoscaled
Expand Down

0 comments on commit 7cc9719

Please sign in to comment.