Skip to content

Commit

Permalink
Use helm/kind-action to set up KinD cluster (ko-build#381)
Browse files Browse the repository at this point in the history
Also:
- collect and upload logs as build artifacts
- don't bother testing many k8s versions
- don't checkout and install into GOPATH
- install ko from ./ to avoid warning
- remove unnecessary knative cruft
  • Loading branch information
imjasonh authored Jul 15, 2021
1 parent ef45f11 commit 674932f
Showing 1 changed file with 17 additions and 108 deletions.
125 changes: 17 additions & 108 deletions .github/workflows/kind-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,78 +5,29 @@ on:
pull_request:
branches: ['main']

defaults:
run:
shell: bash
working-directory: ./src/github.com/google/ko

jobs:

e2e-tests:
name: e2e tests
runs-on: ubuntu-latest
strategy:
fail-fast: false # Keep running if one leg fails.
matrix:
k8s-version:
- v1.17.11
- v1.18.8
- v1.19.1

include:
# Map between K8s and KinD versions.
# This is attempting to make it a bit clearer what's being tested.
# See: https://github.com/kubernetes-sigs/kind/releases/tag/v0.9.0
- k8s-version: v1.17.11
kind-version: v0.9.0
kind-image-sha: sha256:5240a7a2c34bf241afb54ac05669f8a46661912eab05705d660971eeb12f6555
- k8s-version: v1.18.8
kind-version: v0.9.0
kind-image-sha: sha256:f4bcc97a0ad6e7abaf3f643d890add7efe6ee4ab90baeb374b4f41a4c95567eb
- k8s-version: v1.19.1
kind-version: v0.9.0
kind-image-sha: sha256:98cf5288864662e37115e362b23e4369c8c4a408f99cbc06e58ac30ddc721600

env:
GOPATH: ${{ github.workspace }}
GO111MODULE: off
# https://github.com/google/go-containerregistry/pull/125 allows insecure registry for
# '*.local' hostnames. This works both for `ko` and our own tag-to-digest resolution logic,
# thus allowing us to test without bypassing tag-to-digest resolution.
REGISTRY_NAME: registry.local
REGISTRY_PORT: 5000
KO_DOCKER_REPO: registry.local:5000/knative
KO_DOCKER_REPO: registry.local:5000/ko

steps:
- uses: actions/setup-go@v2
with:
go-version: 1.16.x

- name: Check out code onto GOPATH
uses: actions/checkout@v2
with:
path: ./src/github.com/google/ko
- uses: actions/checkout@v2

- name: Install ko
run: go install ./cmd/ko

- name: Install KinD
run: |
set -x
# Disable swap otherwise memory enforcement doesn't work
# See: https://kubernetes.slack.com/archives/CEKK1KTN2/p1600009955324200
sudo swapoff -a
sudo rm -f /swapfile
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${{ matrix.kind-version }}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
run: go install ./

- name: Configure KinD Cluster
run: |
set -x
# KinD configuration.
cat > kind.yaml <<EOF
apiVersion: kind.x-k8s.io/v1alpha4
Expand All @@ -87,29 +38,11 @@ jobs:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."$REGISTRY_NAME:$REGISTRY_PORT"]
endpoint = ["http://$REGISTRY_NAME:$REGISTRY_PORT"]
# This is needed in order to support projected volumes with service account tokens.
# See: https://kubernetes.slack.com/archives/CEKK1KTN2/p1600268272383600
kubeadmConfigPatches:
- |
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
metadata:
name: config
apiServer:
extraArgs:
"service-account-issuer": "kubernetes.default.svc"
"service-account-signing-key-file": "/etc/kubernetes/pki/sa.key"
nodes:
- role: control-plane
image: kindest/node:${{ matrix.k8s-version }}@${{ matrix.kind-image-sha }}
- role: worker
image: kindest/node:${{ matrix.k8s-version }}@${{ matrix.kind-image-sha }}
EOF
- name: Create KinD Cluster
run: kind create cluster --config kind.yaml
- uses: helm/kind-action@v1.2.0
with:
cluster_name: kind
config: kind.yaml

- name: Setup local registry
run: |
Expand Down Expand Up @@ -140,38 +73,14 @@ jobs:
kubectl wait --timeout=60s --for=condition=Ready pod/kodata
kubectl delete pod kodata
- name: Collect pod diagnostics
if: ${{ failure() }}
env:
SYSTEM_NAMESPACE: default
- name: Collect logs
if: ${{ always() }}
run: |
kubectl -n${SYSTEM_NAMESPACE} get pods
echo '::group:: describe'
kubectl -n${SYSTEM_NAMESPACE} describe pods
echo '::endgroup::'
for x in $(kubectl get pods -n${SYSTEM_NAMESPACE} -oname); do
echo "::group:: describe $x"
kubectl -n${SYSTEM_NAMESPACE} describe $x
echo '::endgroup::'
echo "::group:: $x logs"
kubectl -n${SYSTEM_NAMESPACE} logs $x --all-containers
echo '::endgroup::'
done
- name: Collect node diagnostics
if: ${{ failure() }}
run: |
kubectl get nodes
echo '::group:: describe'
kubectl describe nodes
echo '::endgroup::'
for x in $(kubectl get nodes -oname); do
echo "::group:: describe $x"
kubectl describe $x
echo '::endgroup::'
done
mkdir -p /tmp/logs
kind export logs /tmp/logs
- name: Upload artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: logs
path: /tmp/logs

0 comments on commit 674932f

Please sign in to comment.