Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HorizontalPodAutoscaler Example #27

Closed
wants to merge 14 commits into from

Conversation

waltherman
Copy link

Greetings!
This PR covers #19, please check it.
Thanks!
Regards

Trying to solve next error during build procedure:
"14:3      error    wrong indentation: expected 4 but found 2  (indentation)"
Second attempt to fix wrong indentation error.
Fixing wrong indentation errors
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: nginx-cpu-ram-autoscale
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please follow naming conventions of other resources in this repo

kind: Deployment
metadata:
name: nginx-cpu-autoscale
namespace: default
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namespace is not needed

For deleting cluster, use next:
> `kubectl delete deployment %deployment-name%`

To create the Deployment with multiple autoscale metrics, run:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be a good idea to move this to the top of the doc, under the first apply. When I first followed this document, I didn't really know why I wasn't seeing any hpas, or what I was supposed to do about it.

> `kubectl get hpa`

To view an HPA's configuration and statistics, use the following command:
> `kubectl describe hpa %hpa-name%`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be better to put the name used in this specific example; users will want an unambiguous example to follow/copy

@@ -0,0 +1,26 @@
See:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move refs to the end. this doc should be self-standing, with further reading at the end.

@waltherman
Copy link
Author

@ianmiell, thanks for your remarks! Fixed them and doublechecked. Should be better, please take a look.


To create an HPA object that only targets average CPU utilization, use the following command:

> `kubectl autoscale deployment horizontal-pod-autoscaler-cpu-based --cpu-percent=50 --min=1 --max=10`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not 'kubectl apply -f hpa-multi.yaml'?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To demonstrate another way to create a HPA object - manually by kubectl autoscale command.
Creating HPA object by manifest ('kubectl apply -f hpa-multi.yaml') used a bit later, after removing previously created HPA object:
kubectl delete hpa horizontal-pod-autoscaler-cpu-based
If kubectl autoscale unnecessary - I'll remove all related commands.


To view an HPA's configuration and statistics, use the following command:

> `kubectl describe hpa horizontal-pod-autoscaler-cpu-based`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be 'horizontal-pod-autoscaler-multiple-metrics'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or delete this, as the right command is lower down

@@ -0,0 +1,51 @@
To create the Deployment, apply the nginx.yaml manifest:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this out, but the hpa doesn't fully work because this requires the metrics server to be there too. On docker-desktop I followed this: https://github.com/kubernetes-sigs/metrics-server#deployment but ran into other problems where the pod metrics are not available. Is this something you've solved, and can you supply those steps too?

Copy link
Author

@waltherman waltherman Oct 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for delay - needed some time for checks and troubleshooting. I created 3 nodes of Kubernetes on DigitalOcean, copied components.yaml from https://github.com/kubernetes-sigs/metrics-server and added next strings to in args section:

  • --kubelet-insecure-tls
  • --kubelet-preferred-address-types=InternalIP

I agree - this is not secure and not good for production deployments. During troubleshooting of this issue I found that now using "kubelet-insecure-tls" in Kubernetes on DigitalOcean is not needed anymore - digitalocean/DOKS#2
But I still cannot make HPA work correctly without "--kubelet-insecure-tls", it works only with both options.
I'll test on a new cluster on DO and on a local server and add needed changes to my examples.

@ianmiell
Copy link
Collaborator

ianmiell commented Sep 6, 2023

Just added one independently of this PR (forgot about it!) Happy to revive if there's something wrong with the one on master.

@ianmiell ianmiell closed this Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants