Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and use cronhpa of Kubernetes

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge of this article "how to install and use cronhpa of Kubernetes", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to install and use cronhpa of Kubernetes" article.

Mode of use

Cronhpa is a controller developed based on CRD. The way to use cronhpa is very simple, and the overall usage is consistent with HPA as much as possible. Code warehouse address

1. Install CRDkubectl apply-f config/crds/autoscaling_v1beta1_cronhorizontalpodautoscaler.yaml2. Install RBAC license # create ClusterRole kubectl apply-f config/rbac/rbac_role.yaml# create ClusterRolebinding and ServiceAccount kubectl apply-f config/rbac/rbac_role_binding.yaml3. Deploy kubernetes-cronhpa-controllerkubectl apply-f config/deploy/deploy.yaml4. Verify kubernetes-cronhpa-controller installation status kubectl get deploy kubernetes-cronhpa-controller-n kube-system-o wide kubernetes-cronhpa-controller git: (master) kubectl get deploy kubernetes-cronhpa-controller-n kube-systemNAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGEkubernetes-cronhpa-controller 1 1 1 49 s run a cronhpa demo

After installing kubernetes-cronhpa-controller, we can verify the functionality through a simple demo. Before deploying, let's take a look at the next standard definition of cronhpa.

ApiVersion: autoscaling.alibabacloud.com/v1beta1kind: CronHorizontalPodAutoscalermetadata: labels: controller-tools.k8s.io: "1.0" name: cronhpa-sample namespace: default spec: scaleTargetRef: apiVersion: apps/v1beta2 kind: Deployment name: nginx-deployment-basic jobs:-name: "scale-down" schedule: "30 * / 1 *" targetSize: 1-name: "scale-up" schedule: " 0 * / 1 * "targetSize: 3

The scaleTargetRef field is responsible for describing the scalable object, and the extended crontab timing task is defined in jobs. In this example, the capacity is expanded to 3 Pod in the 0th second of each minute and reduced to 1 Pod in the 30s of every minute. If the execution is normal, we can see two changes in the number of loads within 30 seconds.

1. Deploy the configuration of demo application and cronhpa kubectl apply-f examples/deployment_cronhpa.yaml2. Check the number of copies of demo application kubectl get deploy nginx-deployment-basic kubernetes-cronhpa-controller git: (master) kubectl get deploy nginx-deployment-basicNAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGEnginx-deployment-basic 22 22 9s3. View the status of cronhpa Confirm that the job of cronhpa has been submitted to kubectl describe cronhpa cronhpa-sampleName: cronhpa-sampleNamespace: defaultLabels: controller-tools.k8s.io=1.0Annotations: kubectl.kubernetes.io/last-applied-configuration: {"apiVersion": "autoscaling.alibabacloud.com/v1beta1", "kind": "CronHorizontalPodAutoscaler", "metadata": {"annotations": {} "labels": {"controll...API Version: autoscaling.alibabacloud.com/v1beta1Kind: CronHorizontalPodAutoscalerMetadata: Creation Timestamp: 2019-04-14T10:42:38Z Generation: 1 Resource Version: 4017247 Self Link: / apis/autoscaling.alibabacloud.com/v1beta1/namespaces/default/cronhorizontalpodautoscalers/cronhpa-sample UID: 05e41c95-5ea2-11e9-8ce6-00163e12e274Spec: Jobs: Name: scale-down Schedule: 30 * / 1 * Target Size: 1 Name: scale-up Schedule: 0 * / 1 * Target Size: 3 Scale Target Ref: API Version: apps/v1beta2 Kind: Deployment Name: nginx-deployment-basicStatus: Conditions: Job Id: 38e79271-9a42-4131-9acd-1f5bfab38802 Last Probe Time: 2019-04 -14T10:43:02Z Message: Name: scale-down Schedule: 30 * / 1 * State: Submitted Job Id: a7db95b6-396a-4753-91d5-23c2e73819ac Last Probe Time: 2019-04-14T10:43:02Z Message: Name: scale-up Schedule: 0 * / 1 * State: SubmittedEvents: 4. Wait for a while. View the running status of cronhpa kubernetes-cronhpa-controller git: (master) kubectl describe cronhpa cronhpa-sampleName: cronhpa-sampleNamespace: defaultLabels: controller-tools.k8s.io=1.0Annotations: kubectl.kubernetes.io/last-applied-configuration: {"apiVersion": "autoscaling.alibabacloud.com/v1beta1", "kind": "CronHorizontalPodAutoscaler", "metadata": {"annotations": {} "labels": {"controll...API Version: autoscaling.alibabacloud.com/v1beta1Kind: CronHorizontalPodAutoscalerMetadata: Creation Timestamp: 2019-04-15T06:41:44Z Generation: 1 Resource Version: 15673230 Self Link: / apis/autoscaling.alibabacloud.com/v1beta1/namespaces/default/cronhorizontalpodautoscalers/cronhpa-sample UID: 88ea51e0-5f49-11e9-bd0b-00163e30eb10Spec: Jobs: Name: scale-down Schedule: 30 * / 1 * Target Size: 1 Name: scale-up Schedule: 0 * / 1 * Target Size: 3 Scale Target Ref: API Version: apps/v1beta2 Kind: Deployment Name: nginx-deployment-basicStatus: Job Id: 84818af0-3293-43e8-8ba6-6fd3ad2c35a4 Last Probe Time: 2019-04 -15T06:42:30Z Message: cron hpa job scale-down executed successfully Name: scale-down Schedule: 30 * / 1 * State: Succeed Job Id: f8579f11-b129-4e72-b35f-c0bdd32583b3 Last Probe Time: 2019-04-15T06:42:20Z Message: Name: scale-up Schedule: 0 * / 1 * State: SubmittedEvents: Type Reason Age From Message-Normal Succeed 5s cron-horizontal-pod-autoscaler cron hpa job scale-down executed successfully

At this point, you can find that the scheduled scaling of the load has taken effect in the event.

The above is about the content of this article on "how to install and use cronhpa of Kubernetes". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report