This work is based on the New Relic Custom Metrics adapter found here.
minikube -p hpa-demo start --extra-config=controller-manager.horizontal-pod-autoscaler-upscale-delay=1m --extra-config=controller-manager.horizontal-pod-autoscaler-downscale-delay=1m --extra-config=controller-manager.horizontal-pod-autoscaler-sync-period=15s --extra-config=controller-manager.horizontal-pod-autoscaler-downscale-stabilization=1m
kubectl create namespace newrelic-custom-metrics
kubectl create namespace hpa-demo
kubectl create secret generic nrlicensekey -n hpa-demo --from-literal=nrlicensekey=<NR LICENSE KEY>
kubectl create secret generic newrelic-adapter -n newrelic-custom-metrics --from-literal=account_id=<NR ACCOUNT ID> --from-literal=personal_api_key=<NR USER API KEY>
kubectl apply -f 01-hello-world-deployment.yaml && \
kubectl apply -f 02-custom-metrics-adapter.yaml && \
kubectl apply -f 03-external-metric.yaml && \
kubectl apply -f 04-hpa.yaml
kubectl get --raw "/apis/external.metrics.k8s.io/v1beta1" | jq .
You should see output similar to this:
{
"kind": "APIResourceList",
"apiVersion": "v1",
"groupVersion": "external.metrics.k8s.io/v1beta1",
"resources": [
{
"name": "hello-world-throughput",
"singularName": "",
"namespaced": true,
"kind": "ExternalMetricValueList",
"verbs": [
"get"
]
}
]
}
kubectl port-forward svc/hello-world-service -n hpa-demo 8000 > /dev/null &
while true; do curl -s http://localhost:8000/ > /dev/null; sleep 0.5; done