Skip to content

isItObservable/Keda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Is it Observable

Is It observable Logo

Episode dedicated to Keda

keda

This repository contains the files utilized during the tutorial presented in the dedicated IsItObservable episode related to Keda.

What you will learn :

  • How to deploy Keda
  • How to configure a ScaledObject using the metric API scaler
  • How to observe Keda

This repository showcase the usage of the Keda by using GKE with :

  • the HipsterShop
  • Dynatrace
  • Nginx ingress controller

Prerequisite

The following tools need to be install on your machine :

  • jq
  • kubectl
  • git
  • gcloud ( if you are using GKE)
  • Helm
  • Dynatrace tenant.

If you don't have any dynatrace tenant , then let's start a trial on Dynatrace

Deployment Steps in GCP

You will first need a Kubernetes cluster with 2 Nodes. You can either deploy on Minikube or K3s or follow the instructions to create GKE cluster:

1.Create a Google Cloud Platform Project

PROJECT_ID="<your-project-id>"
gcloud services enable container.googleapis.com --project ${PROJECT_ID}
gcloud services enable monitoring.googleapis.com \
    cloudtrace.googleapis.com \
    clouddebugger.googleapis.com \
    cloudprofiler.googleapis.com \
    --project ${PROJECT_ID}

2.Create a GKE cluster

ZONE=us-central1-b
gcloud container clusters create onlineboutique \
--project=${PROJECT_ID} --zone=${ZONE} \
--machine-type=e2-standard-2 --num-nodes=4

3.Clone the Github Repository

git clone https://github.com/isItObservable/Keda
cd Keda

4.Deploy Nginx Ingress Controller with the Prometheus exporter

helm upgrade --install ingress-nginx ingress-nginx \
  --repo https://kubernetes.github.io/ingress-nginx \
  --namespace ingress-nginx --create-namespace
  --set controller.enableLatencyMetrics=true --set prometheus.create=true

1. get the ip adress of the ingress gateway

Since we are using Ingress controller to route the traffic , we will need to get the public ip adress of our ingress. With the public ip , we would be able to update the deployment of the ingress for :

  • hipstershop
IP=$(kubectl get svc ingress-nginx-controller -n ingress-nginx -ojson | jq -j '.status.loadBalancer.ingress[].ip')

2. Update the manifest files

update the following files to update the ingress definitions :

sed -i "s,IP_TO_REPLACE,$IP," kubernetes-manifests/k8s-manifest.yaml
sed -i "s,IP_TO_REPLACE,$IP," K6/load.yaml

5. Deploy Dynatrace in your K8s cluster

1. The Dynatrace Operator

In order to configure the ScaledObject based on Dynatrace metrics, we will need to deploy the Dynatrace Operator to be able to observe our cluster in Dynatrace. To deploy it from the Dynatrace UI , you will need to click on the left menu "Deploy Dynatrace". Then click on the "Start installation" and select the type of deployment : Kubernetes and follow the instructions.

Dynatrace

Or you can also Follow the steps describe in the documnetation to deploy the dynatrace operator

2. The API Token to ingest k6 metrics

To be able to observe Keda and the autoscalling process, we will need to run a small K6 load test. To be able to use the k6 integration, we will need to create an API Token with the following scope:

  • ingest metrics API v2
  • Read metrics API V2 To create token, click on the left menu on Access Tokens , and create token.

Dynatrace

Copy the value of your token and fill :

TOKEN= YOU TOKEN
DYNATRACE_HOST=YOU DYNATRACE HOST ( with https)
sed -i "s,URL_TO_REPLACE,$DYNATRACE_HOST," kubernetes-manifests/k6dynatrace.yaml
sed -i "s,URL_TO_REPLACE,$DYNATRACE_HOST," keda/keda.yaml
sed -i "s,TOKEN_TO_REPLACE,$TOKEN," kubernetes-manifests/k6dynatrace.yaml

6. Add the dynatrace annotation on the nginx deployment

To let dynatrace collect the prometheus metrics generated by the ingress controller, we need to add the following annation on the nginx deployment :

metrics.dynatrace.com/path: /metrics
metrics.dynatrace.com/port: "10254"
metrics.dynatrace.com/scrape: "true"

to edit the deployment :

kubectl edit deployment ingress-nginx-controller -n ingress-nginx

Add the annotation in the template section of the deployment.

7. Deploy the hipstershop

kubectl create ns hipster-shop
kubectl apply -n hipster-shop -f kubernetes-manifests/k6dynatrace.yaml
kubectl apply -n hipster-shop -f kubernetes-manifests/k8s-manifest.yaml

8. Keda

helm repo add kedacore https://kedacore.github.io/charts
helm repo update
kubectl create namespace keda
helm install keda kedacore/keda --namespace keda

9. Deploy the ScaledObject

kubectl apply -f keda/keda.yaml -n hipster-shop

let's generate some extra load to reach our threshold

kubectl apply -f K6/load.yaml -n hipster-shop

Let's Open Dynatrace and see the data coming in from Keda.

9 [Optional] Clean up: TODO

gcloud container clusters delete onlineboutique \
    --project=${PROJECT_ID} --zone=${ZONE}

About

repository for the Keda Tutorial

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published