Skip to content

Instantly share code, notes, and snippets.

@subnetmarco
Created August 22, 2019 17:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save subnetmarco/1ea6b56defac13bac324a7f154c3f9c1 to your computer and use it in GitHub Desktop.
Save subnetmarco/1ea6b56defac13bac324a7f154c3f9c1 to your computer and use it in GitHub Desktop.

Start Kong

helm install stable/kong --name kong --namespace kong --values https://bit.ly/2RgSRio --version 0.9.0

To check status: watch -n 1 kubectl get pod -n kong

Expose Kong

kubectl --namespace kong port-forward $(kubectl get pods --namespace kong -l "app=kong" -o jsonpath="{.items[1].metadata.name}") 8000 &

Install some Services

kubectl apply -f https://gist.githubusercontent.com/hbagdi/2d8ef66fe22cb99e1514f410f992268d/raw/a03d789b70c46ccd0b99d9f1ed838dc21419fc33/multiple-services.yaml

Install ingress for Services

echo "apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
  name: strip-path
route:
  strip_path: true
" | kubectl apply -f -

and

echo "apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    configuration.konghq.com: strip-path
  name: sample-ingresses
spec:
  rules:
  - http:
     paths:
     - path: /billing
       backend:
         serviceName: billing
         servicePort: 80
     - path: /comments
       backend:
         serviceName: comments
         servicePort: 80
     - path: /invoice
       backend:
         serviceName: invoice
         servicePort: 80" | kubectl apply -f -

Let's make some calls to those Services

curl -i http://localhost:8000/billing/status/200

and some fake traffic

while true;
do
  curl http://localhost:8000/billing/status/200
  curl http://localhost:8000/billing/status/501
  curl http://localhost:8000/billing/status/501
  curl http://localhost:8000/invoice/status/201
  curl http://localhost:8000/invoice/status/404
  curl http://localhost:8000/comments/status/200
  sleep 0.01
done

Let's monitor that traffic! Install Prometheus..

helm install --name prometheus stable/prometheus --namespace monitoring --values https://bit.ly/2RgzDtg --version 8.4.1

Install Grafana

helm install stable/grafana --name grafana --namespace monitoring --values http://bit.ly/2FuFVfV --version 1.22.1

Let's expose both Prometheus and Grafana

kubectl --namespace monitoring port-forward $(kubectl get pods --namespace monitoring -l "app=prometheus,component=server" -o jsonpath="{.items[0].metadata.name}") 9090 &

and expose Grafana:

kubectl --namespace monitoring port-forward $(kubectl get pods --namespace monitoring -l "app=grafana" -o jsonpath="{.items[0].metadata.name}") 3000 &

Get credentials to access Grafana

kubectl get secret --namespace monitoring grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo

Let's add the Plugins! Enabling Prometheus..

echo "apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  labels:
    global: \"true\"
  name: prometheus
plugin: prometheus
" | kubectl apply -f -

And let's check the charts! We have to manually re-import the Kong grafana dashboard

Let's install Jaeger

kubectl create -f https://raw.githubusercontent.com/jaegertracing/jaeger-kubernetes/master/all-in-one/jaeger-all-in-one-template.yml --namespace monitoring

Expose Jaeger UI

minikube service jaeger-query -n monitoring

Enable Zipkin plugin

echo "apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  labels:
    global: \"true\"
  name: zipkin
plugin: zipkin
config:
  sample_ratio: 1.0
  http_endpoint: http://zipkin.monitoring.svc.cluster.local:9411/api/v2/spans 
" | kubectl apply -f -

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment