From 7f379ac92026604180b277368b4dc06d35e22835 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Tue, 25 Aug 2020 12:26:54 +0200 Subject: [PATCH] Add kustomize testing This extends our test coverages for kured-* manifest changes on PRs, and any eventual changes in kubernetes/kubectl on periodics. Signed-off-by: Jean-Philippe Evrard --- .github/kustomize/kured-dev.yaml | 15 ++++++++ .github/kustomize/kustomization.yaml | 7 ++++ .github/workflows/kustomize-test.yml | 53 ++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 .github/kustomize/kured-dev.yaml create mode 100644 .github/kustomize/kustomization.yaml create mode 100644 .github/workflows/kustomize-test.yml diff --git a/.github/kustomize/kured-dev.yaml b/.github/kustomize/kured-dev.yaml new file mode 100644 index 0000000..daa9427 --- /dev/null +++ b/.github/kustomize/kured-dev.yaml @@ -0,0 +1,15 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: kured + namespace: kube-system +spec: + template: + spec: + containers: + - name: kured + image: docker.io/weaveworks/kured + imagePullPolicy: Always + command: + - /usr/bin/kured + - --period=1m diff --git a/.github/kustomize/kustomization.yaml b/.github/kustomize/kustomization.yaml new file mode 100644 index 0000000..fdcdd8c --- /dev/null +++ b/.github/kustomize/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - kured-ds.yaml + - kured-rbac.yaml +patchesStrategicMerge: + - kured-dev.yaml diff --git a/.github/workflows/kustomize-test.yml b/.github/workflows/kustomize-test.yml new file mode 100644 index 0000000..72144e8 --- /dev/null +++ b/.github/workflows/kustomize-test.yml @@ -0,0 +1,53 @@ +#This tests if our kustomize manifests still work with an update +#of kustomize or with an update of our manifests (keeping the image +# the same). + +name: Kustomize deploy + +on: + pull_request: + paths: + - "**/kured-*.yaml" + schedule: + - cron: '0 0 1 * *' + +jobs: + deploy-with-kustomize: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: "0" + + # We need to unpin kind-action so we can test is new versions of kind + # and therefore kubernetes will break with our manifests + # This creates a 1 node cluster. + - name: Create a default kind cluster + uses: helm/kind-action@master + + # Kustomize won't work with symlinks to resources outside its folder + # kind-action already installed kind and kubectl. + - name: Deploy with kubectl using kustomization + run: | + cp kured-{ds,rbac}.yaml .github/kustomize/ + VERSION=$(curl -s https://api.github.com/repos/weaveworks/kured/releases | jq -r .[0].tag_name) + sed -i "s#docker.io/weaveworks/kured#docker.io/weaveworks/kured:$VERSION#g" .github/kustomize/kured-dev.yaml + kubectl apply -k .github/kustomize/ + + - name: Show kured is deploying + run: | + sleep 10; kubectl describe ds kured -n kube-system + + - name: Ensure kured is up + uses: nick-invision/retry@v1 + with: + timeout_minutes: 10 + max_attempts: 10 + retry_wait_seconds: 60 + # DESIRED CURRENT READY UP-TO-DATE AVAILABLE should all be =1 + command: "kubectl get ds -n kube-system | grep -E 'kured.*1.*1.*1.*1.*1' " + + - name: Show kured is successfully deployed + run: | + kubectl get ds -n kube-system