HPA Prescaler Controller docker image https://github.com/hepapi/hpa-prescaler-controller
401
Kubernetes Controller for prescaling HPA replicas of ArgoCD Apps
Login to ArgoCD Server with CLI
# define without https:// or http://
export ARGOCD_ENDPOINT="a4c345906685b46...........eu-west-1.elb.amazonaws.com"
argocd login $ARGOCD_ENDPOINT
Create hpaprescaler local account
kubectl patch configmap argocd-cm -n argocd --type merge -p '{"data":{"accounts.hpaprescaler":"apiKey","accounts.hpaprescaler.enabled":"true"}}'
Create hpaprescalerrole role and permissions
kubectl edit -n argocd cm argocd-rbac-cm
Add the following lines to policy.csv:
policy.csv: |
p, role:hpaprescalerrole, applications, *, */*, allow
p, role:hpaprescalerrole, projects, *, *, allow
g, hpaprescaler, role:hpaprescalerrole
Restart argocd-server deployment
kubectl -n argocd rollout restart deployment/argocd-server
Generate hpaprescaler Api Token
argocd account list
argocd account generate-token --account hpaprescaler
kubectl apply -f https://raw.githubusercontent.com/hepapi/hpa-prescaler-controller/main/deploy/crds/HpaPrescaler.yaml
kubectl apply -f https://raw.githubusercontent.com/hepapi/hpa-prescaler-controller/main/deploy/crds/HpaPrescalerProfile.yaml
values.yaml to generate Alarms .kube-state-metrics to export the CRDs object info as Prometheus Metrics.kube-state-metrics metrics installation with new helm values.Assuming you have kube-prometheus-stack deployed on the monitoring namespace:
helm -n monitoring get values kube-prometheus-stack -o yaml > current-stack-values.yaml
helm -n monitoring list -o yaml
current-stack-values.yaml file:
kube-state-metrics:
prometheus:
# deploy a ServiceMonitor so the metrics are collected by Prometheus
monitor:
enabled: true
rbac:
create: true
extraRules:
- apiGroups: ["hepapi.com"]
resources: ["hpaprescalers", "hpaprescalerprofiles", "hpaprescalers/status", "hpaprescalerprofiles/status"]
verbs: ["list", "watch"]
customResourceState:
enabled: true
config:
kind: CustomResourceStateMetrics
spec:
resources:
- groupVersionKind:
group: hepapi.com
version: v1
kind: HpaPrescaler
labelsFromPath:
name: ["metadata", "name"]
namespace: ["metadata", "namespace"]
metrics:
- name: hpaprescaler_info
help: "Exposes details about HpaPrescaler objects"
each:
type: Info
info:
labelsFromPath:
argoAppName: ["spec", "argocdAppName"]
targetProfileName: ["spec", "targetProfileName"]
targetTime: ["spec", "timeStart"]
state: ["status", "state"]
message: ["status", "message"]
processedAt: ["status", "processedAt"]
helm upgrade --install \
kube-prometheus-stack prometheus-community/kube-prometheus-stack \
--version "51.2.0" \
-f current-stack-values.yaml \
--namespace monitoring --atomic
update Values.yaml
vim deploy/helm-chart/values.yaml
Helm Chart Installation
helm upgrade --install hpaprescaler deploy/helm-chart
[optional] Remove objects
kubectl get hpaprescaler -o json | jq '.items[] | del(.metadata.finalizers)' | kubectl replace -f -
kubectl delete hpaprescaler --all
kubectl get hpaprescalerprofiles -o json | jq '.items[] | del(.metadata.finalizers)' | kubectl replace -f -
kubectl delete hpaprescalerprofiles --all
Helm Uninstall
helm uninstall hpaprescaler deploy/helm-chart
kubectl delete crd hpaprescalers.hepapi.com
kubectl delete crd hpaprescalerprofiles.hepapi.com
Content type
Image
Digest
sha256:c6290228a…
Size
419.7 MB
Last updated
2 months ago
docker pull hepapi/hpa-prescaler-controller:main