From 2385e496ae180f473b221660f7f33c1a03b0d91f Mon Sep 17 00:00:00 2001 From: Jesse Adelman Date: Wed, 29 Dec 2021 19:24:48 -0500 Subject: [PATCH] Add ECK. Reorganize ./extras dependencies, seperate concerns. Add READMEs. Start supporting Ingress (Ambassador for now). --- extras/README.md | 2 +- extras/create-plain-cluster.sh | 4 + extras/eck.sh | 11 +++ extras/fun_with_prometheus_grafana_and_k8s.sh | 15 +--- extras/google-demo-microservice.sh | 2 +- extras/kind-example-app-ambassador.sh | 80 +++++++++++++++++++ extras/lib/README.md | 1 + extras/lib/create-cluster.sh | 47 +++++++++++ extras/lib/dashboard.sh | 60 +++++++------- extras/lib/ingress.sh | 17 ++++ extras/nginx-ingress-controller.sh | 4 + 11 files changed, 198 insertions(+), 45 deletions(-) create mode 100644 extras/create-plain-cluster.sh create mode 100644 extras/eck.sh create mode 100644 extras/kind-example-app-ambassador.sh create mode 100644 extras/lib/README.md create mode 100644 extras/lib/create-cluster.sh create mode 100644 extras/lib/ingress.sh create mode 100644 extras/nginx-ingress-controller.sh diff --git a/extras/README.md b/extras/README.md index 0505289..746a653 100644 --- a/extras/README.md +++ b/extras/README.md @@ -1,6 +1,6 @@ # Extras -Files in this directory could be used to create example deployments, demos, local proof-of-concepts,etc. All are meant to be run within the Vagrant VM/Guest. +Files in this directory could be used to create example deployments, demos, local proof-of-concepts,etc. All are meant to be run within the Vagrant VM/Guest, and you must change directory in the guest to `/vagrant/extras`. Quality may vary, though there should be simple instructions output at the end of the script runs. Please report any issues, and include the shell output in the Issue you report. New 'extras' are also welcome! Thanks! diff --git a/extras/create-plain-cluster.sh b/extras/create-plain-cluster.sh new file mode 100644 index 0000000..d1eb242 --- /dev/null +++ b/extras/create-plain-cluster.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +. ./lib/create-cluster.sh + diff --git a/extras/eck.sh b/extras/eck.sh new file mode 100644 index 0000000..1bd9025 --- /dev/null +++ b/extras/eck.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +. ./lib/dashboard.sh + +# Install Elasticsearch ECK, and add necessary glue to Prometheus +helm repo add elastic https://helm.elastic.co +helm repo update + +helm install --atomic elastic-operator elastic/eck-operator -n elastic-system --create-namespace \ + --set podMonitor.enabled=true \ + --set config.metricsPort="8080" diff --git a/extras/fun_with_prometheus_grafana_and_k8s.sh b/extras/fun_with_prometheus_grafana_and_k8s.sh index 7532f03..e239609 100644 --- a/extras/fun_with_prometheus_grafana_and_k8s.sh +++ b/extras/fun_with_prometheus_grafana_and_k8s.sh @@ -1,14 +1,5 @@ . ./lib/dashboard.sh -helm repo add bitnami https://charts.bitnami.com/bitnami -helm repo update -#helm install --atomic my-metrics-server bitnami/metrics-server --version 5.9.2 -#helm upgrade --atomic my-metrics-server bitnami/metrics-server --set apiService.create=true -helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/ -helm repo update -kubectl create namespace monitor -helm install --atomic my-metrics-server metrics-server/metrics-server --version 3.6.0 --set apiService.create=true --set args={--kubelet-insecure-tls} -n monitor -helm install --atomic my-kube-state-metrics bitnami/kube-state-metrics --version 2.1.1 helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update helm install --atomic my-prometheus-stack prometheus-community/kube-prometheus-stack --create-namespace -n monitor \ @@ -16,9 +7,7 @@ helm install --atomic my-prometheus-stack prometheus-community/kube-prometheus-s --set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false sleep 30 kubectl port-forward -n monitor prometheus-my-prometheus-stack-kube-p-prometheus-0 9090 --address 0.0.0.0 >> /dev/null & -my_ip=$(ip -j -p addr show eth1 | jq -r .[].addr_info[0].local) +#my_ip=$(ip -j -p addr show eth1 | jq -r .[].addr_info[0].local) echo "Prometheus UI: http://kind.test:9090/ or http://$my_ip:9090/" kubectl --namespace monitor port-forward svc/my-prometheus-stack-grafana 3000:80 --address 0.0.0.0 >> /dev/null & -echo "Grafana: http://kind.test:3000/ or http://$my_ip:9090/ user: admin password: prom-operator" - - +echo "Grafana: http://kind.test:3000/ or http://$my_ip:3000/ user: admin password: prom-operator" diff --git a/extras/google-demo-microservice.sh b/extras/google-demo-microservice.sh index e083dd4..83e54e2 100644 --- a/extras/google-demo-microservice.sh +++ b/extras/google-demo-microservice.sh @@ -9,5 +9,5 @@ kubectl -n demo apply -f ./release/kubernetes-manifests.yaml kubectl wait --for=condition=available deployment/frontend -n demo #kubectl port-forward deployment/frontend 9292:8080 kubectl -n demo port-forward svc/frontend 8081:80 --address 0.0.0.0 >> /dev/null & -my_ip=$(ip -j -p addr show eth1 | jq -r .[].addr_info[0].local) +#my_ip=$(ip -j -p addr show eth1 | jq -r .[].addr_info[0].local) echo "Browse to http://kind.test:8081 or http://$my_ip:8081/" diff --git a/extras/kind-example-app-ambassador.sh b/extras/kind-example-app-ambassador.sh new file mode 100644 index 0000000..7231e24 --- /dev/null +++ b/extras/kind-example-app-ambassador.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +# Deploy example app from KinD Ingress documentation, but add relevant Ambassador ingress annotations + + +kubectl apply -f - <> /dev/null & -echo "Display the Token (copy and paste this into the Dashboard Web UI)" -kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}") -o go-template="{{.data.token | base64decode}}" +echo "Copy and paste the token below into the Dashboard Web UI" +echo "---snip---" +kubectl get secret -n kubernetes-dashboard \ + $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}") \ + -o go-template="{{.data.token | base64decode}}" echo +echo "---snip--" diff --git a/extras/lib/ingress.sh b/extras/lib/ingress.sh new file mode 100644 index 0000000..88c3370 --- /dev/null +++ b/extras/lib/ingress.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +. ./lib/dashboard.sh + +# Tried: +# NGINX Ingress: Failed +# Ambassador: Success + +kubectl apply -f https://github.com/datawire/ambassador-operator/releases/latest/download/ambassador-operator-crds.yaml + +kubectl apply -n ambassador -f https://github.com/datawire/ambassador-operator/releases/latest/download/ambassador-operator-kind.yaml +kubectl wait --timeout=180s -n ambassador --for=condition=deployed ambassadorinstallations/ambassador + +echo "NOTE: You will need to annotate any ingress resources you wish to expose via Ambassador" +echo "with the following *after* the resources are created:" +echo +echo "kubectl annotate ingress example-ingress kubernetes.io/ingress.class=ambassador" diff --git a/extras/nginx-ingress-controller.sh b/extras/nginx-ingress-controller.sh new file mode 100644 index 0000000..1a5c3d1 --- /dev/null +++ b/extras/nginx-ingress-controller.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +. ./lib/ingress.sh +