Created
November 4, 2019 23:49
-
-
Save grampelberg/c48911b1bb996a732139abee44ac8836 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTALLS ?= nginx-linkerd nginx-bare | |
define getsvc | |
kubectl get svc --all-namespaces -l app=nginx-ingress \ | |
--no-headers | |
endef | |
define lbip | |
$(call getsvc) \ | |
"-ocustom-columns=:.status.loadBalancer.ingress[0].ip" | \ | |
grep -v none | wc -l | |
endef | |
define clusterip | |
$(call getsvc) \ | |
"-ocustom-columns=:.spec.type,:.spec.clusterIP" | \ | |
grep -v ClusterIP | awk '{ print $$2 }' | |
endef | |
define run | |
kubectl -n test exec -it \ | |
$$(kubectl -n test get po -o name -lapp=curl | cut -d/ -f2) -- | |
endef | |
kubectl get svc --all-namespaces -l app=nginx-ingress | |
.PHONY: linkerd | |
linkerd: | |
linkerd install | kubectl apply -f - | |
kubectl -n linkerd wait --for=condition=available deploy --all | |
.PHONY: nginx | |
nginx: | |
kubectl apply -f ns.yaml | |
helm fetch stable/nginx-ingress | |
for i in $(INSTALLS); do \ | |
helm template nginx-ingress-*.tgz -n $$i --namespace $$i -f $$i.yml | \ | |
kubectl -n $$i apply -f - \ | |
; done | |
kubectl -n nginx-linkerd get deploy -o yaml | \ | |
linkerd inject - | kubectl apply -f - | |
kubectl wait -lapp=nginx-ingress deploy --for=condition=available \ | |
--all-namespaces | |
timeout 60 bash -c 'while [ $$($(call lbip)) -ne 2 ]; do \ | |
echo "waiting..."; \ | |
sleep 1 \ | |
; done' | |
.PHONY: emojivoto | |
emojivoto: | |
curl -sL run.linkerd.io/emojivoto.yml | \ | |
linkerd inject - | kubectl apply -f - | |
kubectl -n emojivoto wait --for=condition=available deploy --all | |
.PHONY: test | |
test: | |
for i in $$($(call clusterip)); do \ | |
$(call run) curl -vv -s -o /dev/null -I -w "%{http_code}" \ | |
--resolve nginx.example.com:80:$$i http://nginx.example.com; \ | |
done | |
.PHONY: install | |
install: linkerd emojivoto nginx | |
.PHONY: clean | |
clean: | |
linkerd install --ignore-cluster | kubectl delete -f - || true | |
kubectl delete -f ns.yaml || true | |
curl -sL run.linkerd.io/emojivoto.yml | kubectl delete -f - || true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment