DEV Community

Abhishek Gupta
Abhishek Gupta

Posted on

Hacking on the KEDA project 👩‍💻

If you're planning to work on the KEDA project (Kubernetes Event-driven Autoscaling), you can the following steps for local development.

From the docs: "KEDA is a Kubernetes-based Event Driven Autoscaler. With KEDA, you can drive the scaling of any container in Kubernetes based on the number of events needing to be processed. KEDA is a single-purpose and lightweight component that can be added into any Kubernetes cluster. KEDA works alongside standard Kubernetes components like the horizontal pod autoscaler and can extend functionality without overwriting or duplication"

Switch to $GOPATH and clone required KEDA projects

cd $GOPATH

git clone https://github.com/kedacore/keda
git clone https://github.com/kedacore/chart
Enter fullscreen mode Exit fullscreen mode

Make required code changes for your feature/bug etc.

If you have an existing installation (this will just delete the KEDA operator Deployment)

helm uninstall -n keda keda
Enter fullscreen mode Exit fullscreen mode

see Troubleshooting section for a possible issue

Confirm that there are no KEDA Pods

kubectl get pods -n keda
Enter fullscreen mode Exit fullscreen mode

Switch to keda source directory

cd $GOPATH/src/github.com/kedacore/keda
Enter fullscreen mode Exit fullscreen mode

Set environment variables

//change accordingly using another registry such as quay.io
export IMAGE_REGISTRY=docker.io

//use tag of your choice
export IMAGE_TAG=latest

//use a docker repo of your choice
export IMAGE_REPO=abhirockzz
Enter fullscreen mode Exit fullscreen mode

If you're using minikube for local Kubernetes dev, doing this will allow you to iterate faster since it will build the Docker images on the minikube host and you won't need to push it to an external Docker repo

eval $(minikube docker-env)
export IMAGE_PULL_POLICY=Never
make build
Enter fullscreen mode Exit fullscreen mode

If you want to use an external docker repo

make publish
export $IMAGE_PULL_POLICY=Always
Enter fullscreen mode Exit fullscreen mode

publish will build and docker push

Once build is complete, install KEDA using Helm

I used Helm 3, but Helm 2 is also supported

This will use the Docker image which you just built (with the code changes)

cd ../charts/keda

helm install keda kedacore/keda --set image.keda=$IMAGE_REGISTRY/$IMAGE_REPO/keda:$IMAGE_TAG,image.pullPolicy=$IMAGE_PULL_POLICY --namespace keda
Enter fullscreen mode Exit fullscreen mode

Confirm all is good (wait till status is Running)

kubectl get pods -n keda -w
Enter fullscreen mode Exit fullscreen mode

To check KEDA operator container logs

kubectl logs -f <keda_pod_name> -c keda-operator -n keda
Enter fullscreen mode Exit fullscreen mode

Troubleshooting

helm uninstall -n keda keda might return this

Error: uninstallation completed with 1 error(s): could not get apiVersions from Kubernetes: could not get apiVersions from Kubernetes: unable to retrieve the complete list of server APIs: external.metrics.k8s.io/v1beta1: the server is currently unable to handle the request
Enter fullscreen mode Exit fullscreen mode

To resolve

kubectl delete apiservice v1beta1.external.metrics.k8s.io
Enter fullscreen mode Exit fullscreen mode

see https://github.com/helm/helm/issues/6361#issuecomment-538220109

Further, if helm install gives you this error

manifest_sorter.go:175: info: skipping unknown hook: "crd-install"
manifest_sorter.go:175: info: skipping unknown hook: "crd-install"
Error: rendered manifests contain a resource that already exists. Unable to continue with install: existing resource conflict: kind: Service, namespace: keda, name: keda-operator
Enter fullscreen mode Exit fullscreen mode

Delete stuff manually

kubectl delete deployment keda-operator -n keda
kubectl delete serviceaccount keda-operator -n keda
kubectl delete clusterrole keda-operator-external-metrics-reader
kubectl delete clusterrole keda-operator
kubectl delete clusterrolebinding keda-operator-hpa-controller-external-metrics
kubectl delete clusterrolebinding keda-operator
kubectl delete clusterrolebinding keda-operator:system:auth-delegator
kubectl delete rolebinding keda-operator-auth-reader -n kube-system
kubectl delete service keda-operator -n keda
Enter fullscreen mode Exit fullscreen mode

Happy hacking! 👩‍💻👨‍💻

Top comments (0)