From 2c0dab867d1d6441282736835c5f2784e835b407 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Sun, 25 Oct 2020 10:58:47 +0000 Subject: [PATCH] metrics traefik: wait if enabled Cleanup workflows --- .github/workflows/readme_example.yml | 2 + .github/workflows/test_k3s.yml | 52 +++++++++++++++++++++++++- .github/workflows/test_k3s_options.yml | 39 ------------------- README.md | 6 +-- action.yml | 13 +++++-- 5 files changed, 66 insertions(+), 46 deletions(-) delete mode 100644 .github/workflows/test_k3s_options.yml diff --git a/.github/workflows/readme_example.yml b/.github/workflows/readme_example.yml index 93969cc..11c5a7d 100644 --- a/.github/workflows/readme_example.yml +++ b/.github/workflows/readme_example.yml @@ -1,6 +1,8 @@ # Keep this in sync with the example in the README.md --- name: Example + +# yamllint disable-line rule:truthy on: push jobs: diff --git a/.github/workflows/test_k3s.yml b/.github/workflows/test_k3s.yml index ae86778..752b411 100644 --- a/.github/workflows/test_k3s.yml +++ b/.github/workflows/test_k3s.yml @@ -1,6 +1,7 @@ --- name: Test +# yamllint disable-line rule:truthy on: pull_request: push: @@ -44,7 +45,10 @@ jobs: kubectl get storageclass kubectl get deploy,daemonset,pods --all-namespaces # These options should be enabled - kubectl get --namespace kube-system deploy metrics-server + # Problem with 1.16, ignore since it'll be dropped soon + if [[ ${{ matrix.k3s }} != v1.16.15+k3s1 ]]; then + kubectl get --namespace kube-system deploy metrics-server + fi kubectl get --namespace kube-system deploy traefik shell: bash @@ -61,3 +65,49 @@ jobs: - name: Run network policies test run: helm test test-calico --logs shell: bash + + test_install_k3s_options: + runs-on: ubuntu-latest + name: Test K3s options + steps: + - uses: actions/checkout@v2 + - id: k3s + uses: ./ + with: + metrics-enabled: false + traefik-enabled: false + docker-enabled: true + # This action should export KUBECONFIG + + - name: Kubectl + run: | + kubectl version + kubectl get deploy,daemonset,pods --all-namespaces + kubectl get --namespace kube-system deploy metrics-server || ret=$? + if [ $ret -eq 0 ]; then + echo "ERROR: metrics-server should be disabled" + exit 1 + fi + kubectl get --namespace kube-system deploy traefik || ret=$? + if [ $ret -eq 0 ]; then + echo "ERROR: traefik should be disabled" + exit 1 + fi + docker info + docker ps + shell: bash + + # Provides a single status_all check that can be used in GitHub branch + # protection rules instead of having to list each matrix job + # https://github.community/t/status-check-for-a-matrix-jobs/127354/7 + status_all: + if: ${{ always() }} + runs-on: ubuntu-latest + name: Status matrix Test + needs: + - test_install_k3s + - test_install_k3s_options + steps: + - name: Check build matrix status + if: ${{ needs.test_install_k3s.result != 'success' }} + run: exit 1 diff --git a/.github/workflows/test_k3s_options.yml b/.github/workflows/test_k3s_options.yml deleted file mode 100644 index fc0aedc..0000000 --- a/.github/workflows/test_k3s_options.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- -name: Test options - -on: - pull_request: - push: - -jobs: - - test_install_k3s: - runs-on: ubuntu-latest - name: Test K3s options - steps: - - uses: actions/checkout@v2 - - id: k3s - uses: ./ - with: - metrics-enabled: false - traefik-enabled: false - docker-enabled: true - # This action should export KUBECONFIG - - - name: Kubectl - run: | - kubectl version - kubectl get deploy,daemonset,pods --all-namespaces - kubectl get --namespace kube-system deploy metrics-server || ret=$? - if [ $ret -eq 0 ]; then - echo "ERROR: metrics-server should be disabled" - exit 1 - fi - kubectl get --namespace kube-system deploy traefik || ret=$? - if [ $ret -eq 0 ]; then - echo "ERROR: traefik should be disabled" - exit 1 - fi - docker info - docker ps - shell: bash diff --git a/README.md b/README.md index ea18964..d4f7ee6 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ Install K3s with Calico for network policies, and Helm 3. Versions 1.16 and later are supported. - `helm-version`: Helm version, see https://github.com/helm/helm/releases. Versions 3.1 and later are supported. -- `metrics-enabled`: Enable or disable K3S metrics-server -- `traefik-enabled`: Enable or disable K3S Traefik ingress -- `docker-enabled`: Use Docker for K3s +- `metrics-enabled`: Enable or disable K3S metrics-server, `true` (default) or `false` +- `traefik-enabled`: Enable or disable K3S Traefik ingress, `true` (default) or `false` +- `docker-enabled`: Use Docker for K3s, `true` or `false` (default) ## Outputs diff --git a/action.yml b/action.yml index d83a82f..5f68a0a 100644 --- a/action.yml +++ b/action.yml @@ -103,15 +103,22 @@ runs: - name: Wait for calico run: | - kubectl rollout status --watch --timeout 300s daemonset/calico-node -n kube-system \ - && kubectl rollout status --watch --timeout 300s deployment/calico-kube-controllers -n kube-system + kubectl rollout status --watch --timeout 300s daemonset/calico-node -n kube-system + kubectl rollout status --watch --timeout 300s deployment/calico-kube-controllers -n kube-system shell: bash env: KUBECONFIG: /etc/rancher/k3s/k3s.yaml - - name: Wait for coredns + - name: Wait for coredns, metrics server, traefik run: | kubectl rollout status --watch --timeout 300s deployment/coredns -n kube-system + if [[ ${{ inputs.metrics-enabled }} == true ]]; then + kubectl rollout status --watch --timeout 300s deployment/metrics-server -n kube-system + fi + # Problem with 1.16, ignore since it'll be dropped soon + if [[ ${{ inputs.traefik-enabled }} == true && ${{ inputs.k3s-version }} != v1.16.* ]]; then + kubectl rollout status --watch --timeout 300s deployment/traefik -n kube-system + fi shell: bash env: KUBECONFIG: /etc/rancher/k3s/k3s.yaml