|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2025 Cisco and/or its affiliates. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +--- |
| 5 | + |
| 6 | +name: Setup Kubernetes tooling |
| 7 | +description: Setup Kubernetes tooling |
| 8 | +inputs: |
| 9 | + helm-version: |
| 10 | + description: 'Helm version' |
| 11 | + required: false |
| 12 | + default: "3.12.1" |
| 13 | + helm-ct-version: |
| 14 | + description: 'Helm chart-testing version' |
| 15 | + required: false |
| 16 | + default: "3.11.0" |
| 17 | + kind-version: |
| 18 | + description: 'Kind version' |
| 19 | + required: false |
| 20 | + default: "0.24.0" |
| 21 | + kind-create-cluster: |
| 22 | + description: 'Create kind K8s cluster' |
| 23 | + required: false |
| 24 | + default: "false" |
| 25 | + kind-cluster-name: |
| 26 | + description: 'Kind K8s cluster name to create' |
| 27 | + required: false |
| 28 | + default: "kind" |
| 29 | + kind-cluster-gateway: |
| 30 | + description: 'Gateway IP to use for kind server nodes. Useful when running actions inside containers.' |
| 31 | + required: false |
| 32 | + default: "127.0.0.1" |
| 33 | +runs: |
| 34 | + using: "composite" |
| 35 | + steps: |
| 36 | + # |
| 37 | + # Install kubernetes tools |
| 38 | + # |
| 39 | + - name: Setup Helm |
| 40 | + uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0 |
| 41 | + with: |
| 42 | + version: ${{ inputs.helm-version }} |
| 43 | + |
| 44 | + - name: Set up Helm chart-testing |
| 45 | + uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1 |
| 46 | + with: |
| 47 | + version: ${{ inputs.helm-ct-version }} |
| 48 | + |
| 49 | + - name: Setup kind |
| 50 | + uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0 |
| 51 | + with: |
| 52 | + version: v${{ inputs.kind-version }} |
| 53 | + install_only: true |
| 54 | + |
| 55 | + - name: Setup kubectl |
| 56 | + uses: azure/setup-kubectl@3e0aec4d80787158d308d7b364cb1b702e7feb7f # v4.0.0 |
| 57 | + |
| 58 | + # |
| 59 | + # Setup cluster |
| 60 | + # |
| 61 | + - name: Setup Kind cluster |
| 62 | + if: ${{ inputs.kind-create-cluster == 'true' }} |
| 63 | + shell: bash |
| 64 | + run: | |
| 65 | + # Create cluster config |
| 66 | + KIND_CONFIG_FILE=$(mktemp -p /tmp) |
| 67 | + cat <<EOF > $KIND_CONFIG_FILE |
| 68 | + kind: Cluster |
| 69 | + apiVersion: kind.x-k8s.io/v1alpha4 |
| 70 | + networking: |
| 71 | + apiServerAddress: "${{ inputs.kind-cluster-gateway }}" |
| 72 | + apiServerPort: 6443 |
| 73 | + EOF |
| 74 | +
|
| 75 | + # Create cluster |
| 76 | + kind create cluster --config $KIND_CONFIG_FILE --name ${{ inputs.kind-cluster-name }} |
| 77 | + kubectl cluster-info |
0 commit comments