|
| 1 | +name: "Set up KinD" |
| 2 | +description: "Step to start and configure KinD cluster" |
| 3 | + |
| 4 | +inputs: |
| 5 | + kind-node-hostname: |
| 6 | + description: "Hostname of the main kind node" |
| 7 | + required: false |
| 8 | + default: kind |
| 9 | + |
| 10 | +runs: |
| 11 | + using: "composite" |
| 12 | + steps: |
| 13 | + - name: Init directories |
| 14 | + shell: bash |
| 15 | + run: | |
| 16 | + TEMP_DIR="$(pwd)/tmp" |
| 17 | + mkdir -p "${TEMP_DIR}" |
| 18 | + echo "TEMP_DIR=${TEMP_DIR}" >> $GITHUB_ENV |
| 19 | +
|
| 20 | + mkdir -p "$(pwd)/bin" |
| 21 | + echo "$(pwd)/bin" >> $GITHUB_PATH |
| 22 | +
|
| 23 | + - name: Container image registry |
| 24 | + shell: bash |
| 25 | + run: | |
| 26 | + podman run -d -p 5000:5000 --name registry registry:2.8.1 |
| 27 | +
|
| 28 | + export REGISTRY_ADDRESS=$(hostname -i):5000 |
| 29 | + echo "REGISTRY_ADDRESS=${REGISTRY_ADDRESS}" >> $GITHUB_ENV |
| 30 | + echo "Container image registry started at ${REGISTRY_ADDRESS}" |
| 31 | +
|
| 32 | + KIND_CONFIG_FILE=${{ env.TEMP_DIR }}/kind.yaml |
| 33 | + echo "KIND_CONFIG_FILE=${KIND_CONFIG_FILE}" >> $GITHUB_ENV |
| 34 | + envsubst < ${GITHUB_ACTION_PATH}/resouces/kind.yaml > ${KIND_CONFIG_FILE} |
| 35 | +
|
| 36 | + sudo --preserve-env=REGISTRY_ADDRESS sh -c 'cat > /etc/containers/registries.conf.d/local.conf <<EOF |
| 37 | + [[registry]] |
| 38 | + prefix = "$REGISTRY_ADDRESS" |
| 39 | + insecure = true |
| 40 | + location = "$REGISTRY_ADDRESS" |
| 41 | + EOF' |
| 42 | +
|
| 43 | + - name: Setup KinD cluster |
| 44 | + |
| 45 | + with: |
| 46 | + cluster_name: cluster |
| 47 | + version: v0.17.0 |
| 48 | + config: ${{ env.KIND_CONFIG_FILE }} |
| 49 | + |
| 50 | + - name: Print cluster info |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + echo "KinD cluster:" |
| 54 | + kubectl cluster-info |
| 55 | + kubectl describe nodes |
| 56 | +
|
| 57 | + - name: Install Ingress controller |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + VERSION=controller-v1.6.4 |
| 61 | + echo "Deploying Ingress controller into KinD cluster" |
| 62 | + curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/"${VERSION}"/deploy/static/provider/kind/deploy.yaml | sed "s/--publish-status-address=localhost/--report-node-internal-ip-address\\n - --status-update-interval=10/g" | kubectl apply -f - |
| 63 | + kubectl annotate ingressclass nginx "ingressclass.kubernetes.io/is-default-class=true" |
| 64 | + kubectl -n ingress-nginx wait --timeout=300s --for=condition=Available deployments --all |
| 65 | +
|
| 66 | + - name: Add ${{ inputs.kind-node-hostname }} host to machine hosts |
| 67 | + shell: bash |
| 68 | + run: echo "127.0.0.1 ${{ inputs.kind-node-hostname }}" | sudo tee -a /etc/hosts |
| 69 | + |
| 70 | + - name: Set env variables for tests to properly leverage KinD cluster |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + echo "CLUSTER_TYPE=KIND" >> $GITHUB_ENV |
| 74 | + echo "CLUSTER_HOSTNAME=${{ inputs.kind-node-hostname }}" >> $GITHUB_ENV |
0 commit comments