Before starting, you need send to a metric to Newrelic. Simply change the account id and the api key in the following command and execute it
docker run -d --restart unless-stopped --name newrelic-statsd -h $(hostname) -e NR_ACCOUNT_ID=1234 -e NR_API_KEY=api_key -p 8125:8125/udp newrelic/nri-statsd:latest
echo "test.k8s.num:1|g" | nc -w 1 -u localhost 8125
In sample/externalmetric.yaml you can decide on your query
Deploy The smaple application
kubectl apply -f sample/
- Check the number of pods
kubectl get po
NAME READY STATUS RESTARTS AGE
sample-application-757df6d98-g6rkq 1/1 Running 0 5s
- Increate your metric to 5
echo "test.k8s.num:5|g" | nc -w 1 -u localhost 8125
- Wait a few seconds and see that The deployment scaled
kubectl get po
NAME READY STATUS RESTARTS AGE
sample-application-757df6d98-4722t 1/1 Running 0 20s
sample-application-757df6d98-5j779 1/1 Running 0 20s
sample-application-757df6d98-6jcrr 1/1 Running 0 3s
sample-application-757df6d98-g6rkq 1/1 Running 0 2m17s
sample-application-757df6d98-v8rqk 1/1 Running 0 20s