Add e2e testing with Kubernetes Kind and Helm

This commit is contained in:
stefanprodan
2019-08-06 21:36:25 +03:00
parent c907163073
commit fed04ad692
5 changed files with 74 additions and 1 deletions
+9
View File
@@ -1,5 +1,13 @@
version: 2.1
jobs:
e2e-kubernetes:
machine: true
steps:
- checkout
- run: e2e/bootstrap.sh
- run: e2e/install.sh
- run: e2e/test.sh
build-container:
docker:
- image: circleci/golang:1.12
@@ -71,6 +79,7 @@ workflows:
build-test:
jobs:
- build-container
- e2e-kubernetes
release:
jobs:
- build-container:
+2 -1
View File
@@ -16,7 +16,8 @@ Specifications:
* Structured logging with zap
* 12-factor app with viper
* Fault injection (random errors and latency)
* Helm chart
* Helm and Kustomize installers
* End-to-End testing with Kubernetes Kind and Helm
Web API:
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -o errexit
REPO_ROOT=$(git rev-parse --show-toplevel)
KIND_VERSION=v0.4.0
if [[ "$1" ]]; then
KIND_VERSION=$1
fi
echo ">>> Installing kubectl"
curl -sLO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \
chmod +x kubectl && \
sudo mv kubectl /usr/local/bin/
echo ">>> Installing kind"
curl -sSLo kind "https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-linux-amd64"
chmod +x kind
sudo mv kind /usr/local/bin/kind
echo ">>> Creating kind cluster"
kind create cluster --wait 5m
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
kubectl get pods --all-namespaces
echo ">>> Installing Helm"
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash
echo '>>> Installing Tiller'
kubectl --namespace kube-system create sa tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller --upgrade --wait
Executable
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -o errexit
REPO_ROOT=$(git rev-parse --show-toplevel)
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
echo ">>> Building container"
docker build -t test/podinfo:latest .
echo '>>> Loading image in Kind'
kind load docker-image test/podinfo:latest
echo '>>> Installing'
helm upgrade -i podinfo ${REPO_ROOT}/charts/podinfo --namespace=default
kubectl set image deployment/podinfo podinfo=test/podinfo:latest
kubectl rollout status deployment/podinfo
Executable
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -o errexit
REPO_ROOT=$(git rev-parse --show-toplevel)
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
echo '>>> Testing'
helm test podinfo
echo '>>> Test logs'
kubectl logs -l app=podinfo