From bc809cd76312bde2adb6de2d7bbb468ab527f650 Mon Sep 17 00:00:00 2001 From: "Deavon M. McCaffery" Date: Tue, 17 Nov 2020 23:04:55 +0000 Subject: [PATCH] docs(deploy): add script to test podinfo using kind --- deploy/README.md | 15 ++++++++++++++- deploy/kind.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ deploy/kind.yaml | 11 +++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100755 deploy/kind.sh create mode 100644 deploy/kind.yaml diff --git a/deploy/README.md b/deploy/README.md index 824eff1..4aef4bf 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -1,6 +1,7 @@ -# Deploy demo webapp +# Deploy demo webapp Demo webapp manifests: + - [common](webapp/common) - [frontend](webapp/frontend) - [backend](webapp/backend) @@ -30,3 +31,15 @@ Deploy the demo in the `production` namespace: ```bash kustomize build ./overlays/production | kubectl apply -f- ``` + +## Testing Locally Using Kind + +> NOTE: You can install [kind from here](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) + +The following will create a new cluster called "podinfo" and configure host ports on 80 and 443. You can access the +endpoints on localhost. The example also deploys cert-manager within the cluster along with a self-signed cluster issuer +used to generate the certificate to validate the secure port. + +```sh +./kind.sh +``` diff --git a/deploy/kind.sh b/deploy/kind.sh new file mode 100755 index 0000000..300a24d --- /dev/null +++ b/deploy/kind.sh @@ -0,0 +1,49 @@ +#! /usr/bin/env sh + +# create the kind cluster +kind create cluster --config=kind.yaml + +# add certificate manager +kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.0.4/cert-manager.yaml + +# wait for cert manager webhook +kubectl wait --namespace cert-manager \ + --for=condition=available deployment \ + --selector=app=webhook \ + --timeout=120s + +# wait for the injector +kubectl wait --namespace cert-manager \ + --for=condition=available deployment \ + --selector=app=cainjector \ + --timeout=120s + +# wait for the cert manager +kubectl wait --namespace cert-manager \ + --for=condition=available deployment \ + --selector=app=cert-manager \ + --timeout=120s + +# apply the secure webapp +kubectl apply -f ./secure/common +kubectl apply -f ./secure/backend +kubectl apply -f ./secure/frontend + +# wait for the podinfo frontend to come up +kubectl wait --namespace secure \ + --for=condition=ready pod \ + --selector=app=frontend \ + --timeout=120s + +# curl the endpoints (responds with info due to header regexp on route handler) +echo +echo "http enpdoint:" +echo "curl http://localhost" +echo +curl http://localhost + +echo +echo "https (secure) enpdoint:" +echo "curl --insecure https://localhost" +echo +curl --insecure https://localhost diff --git a/deploy/kind.yaml b/deploy/kind.yaml new file mode 100644 index 0000000..fd7063b --- /dev/null +++ b/deploy/kind.yaml @@ -0,0 +1,11 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: +- role: control-plane + extraPortMappings: + - containerPort: 80 + hostPort: 80 + protocol: TCP + - containerPort: 443 + hostPort: 443 + protocol: TCP