8000 feat: Add cloud provider by waltermity · Pull Request #135 · helm/kind-action · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Add cloud provider #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the commun 8000 ity.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,23 @@ jobs:

curl -X DELETE $LOCAL_REGISTRY/v2/localbusybox/manifests/$DIGEST
[[ "$(curl -Ls $LOCAL_REGISTRY/v2/localbusybox/tags/list | jq .tags)" == null ]]


test-with-cloud-provider-enabled:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Create kind cluster with cloud provider
uses: ./
with:
cloud_provider: true

- name: Test
run: |
if ps aux | grep -v grep | grep cloud-provider-kind; then
echo "Cloud provider is present."
else
echo "Cloud provider is not present."
8000 exit 1
fi
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ For more information on inputs, see the [API Documentation](https://developer.gi
- `registry_enable_delete`: Enable delete operations on the registry (default: false)
- `install_only`: Skips cluster creation, only install kind (default: false)
- `ignore_failed_clean`: Whether to ignore the post delete cluster action failing (default: false)
- `cloud_provider`: Whether to use cloud provider loadbalancer (default: false)

### Example Workflow

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ inputs:
description: "Whether to ignore the post-delete the cluster (default: false)"
default: "false"
required: false
cloud_provider:
description: "Whether to use cloud provider loadbalancer (default: false)"
required: false
default: "false"
runs:
using: "node20"
main: "main.js"
Expand Down
7 changes: 7 additions & 0 deletions cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ main() {
args=(--name "${INPUT_CLUSTER_NAME:-$DEFAULT_CLUSTER_NAME}")
registry_args=("${INPUT_REGISTRY_NAME:-$DEFAULT_REGISTRY_NAME}")

if [[ "${INPUT_CLOUD_PROVIDER:-false}" == true ]]; then
rm -f /usr/local/bin/cloud-provider-kind || true
rm -rf cloud-provider-kind || true
rm -f /tmp/cloud-provider.log || true
rm -f cloud-provider-kind_*_checksums.txt || true
fi

docker rm -f "${registry_args[@]}" || "${INPUT_IGNORE_FAILED_CLEAN}"

kind delete cluster "${args[@]}" || "${INPUT_IGNORE_FAILED_CLEAN}"
Expand Down
34 changes: 34 additions & 0 deletions kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set -o pipefail
DEFAULT_KIND_VERSION=v0.26.0
DEFAULT_CLUSTER_NAME=chart-testing
DEFAULT_KUBECTL_VERSION=v1.31.4
DEFAULT_CLOUD_PROVIDER_KIND_VERSION=0.6.0

show_help() {
cat << EOF
Expand All @@ -37,6 +38,7 @@ Usage: $(basename "$0") <options>
-k, --kubectl-version The kubectl version to use (default: $DEFAULT_KUBECTL_VERSION)
-o, --install-only Skips cluster creation, only install kind (default: false)
--with-registry Enables registry config dir for the cluster (default: false)
--cloud-provider Enables cloud provider for the cluster (default: false)

EOF
}
Expand All @@ -53,6 +55,7 @@ main() {
local install_only=false
local with_registry=false
local config_with_registry_path="/etc/kind-registry/config.yaml"
local cloud_provider=

parse_command_line "$@"

Expand Down Expand Up @@ -198,6 +201,14 @@ parse_command_line() {
with_registry=true
fi
;;
--cloud-provider)
if [[ -n "${2:-}" ]]; then
cloud_provider="$2"
shift
else
cloud_provider=true
fi
;;
*)
break
;;
Expand Down Expand Up @@ -245,6 +256,25 @@ EOF
sudo chmod a+r "$config_with_registry_path"
}

install_cloud_provider(){
echo "Setting up cloud-provider-kind..."
curl -sSLo cloud-provider-kind_${DEFAULT_CLOUD_PROVIDER_KIND_VERSION}_linux_amd64.tar.gz https://github.com/kubernetes-sigs/cloud-provider-kind/releases/download/v${DEFAULT_CLOUD_PROVIDER_KIND_VERSION}/cloud-provider-kind_${DEFAULT_CLOUD_PROVIDER_KIND_VERSION}_linux_amd64.tar.gz > /dev/null 2>&1
curl -sSLo cloud-provider-kind_${DEFAULT_CLOUD_PROVIDER_KIND_VERSION}_checksums.txt https://github.com/kubernetes-sigs/cloud-provider-kind/releases/download/v${DEFAULT_CLOUD_PROVIDER_KIND_VERSION}/cloud-provider-kind_${DEFAULT_CLOUD_PROVIDER_KIND_VERSION}_checksums.txt

grep "cloud-provider-kind_${DEFAULT_CLOUD_PROVIDER_KIND_VERSION}_linux_amd64.tar.gz" < "cloud-provider-kind_${DEFAULT_CLOUD_PROVIDER_KIND_VERSION}_checksums.txt" | sha256sum -c

mkdir -p cloud-provider-kind-tmp
tar -xzf cloud-provider-kind_${DEFAULT_CLOUD_PROVIDER_KIND_VERSION}_linux_amd64.tar.gz -C cloud-provider-kind-tmp
chmod +x cloud-provider-kind-tmp/cloud-provider-kind
sudo mv cloud-provider-kind-tmp/cloud-provider-kind /usr/local/bin/
rm -rf cloud-provider-kind-tmp cloud-provider-kind_${DEFAULT_CLOUD_PROVIDER_KIND_VERSION}_linux_amd64.tar.gz

echo "cloud-provider-kind set up successfully ✅"

cloud-provider-kind > /tmp/cloud-provider.log 2>&1 &
echo "cloud-provider-kind started ✅"
}

create_kind_cluster() {
echo 'Creating kind cluster...'
local args=(create cluster "--name=${cluster_name}" "--wait=${wait}")
Expand Down Expand Up @@ -274,6 +304,10 @@ create_kind_cluster() {
fi
fi

if [[ "${cloud_provider}" == true ]]; then
install_cloud_provider
fi

"${kind_dir}/kind" "${args[@]}"
}

Expand Down
4 changes: 4 additions & 0 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ main() {
registry_args+=(--enable-delete "${INPUT_REGISTRY_ENABLE_DELETE}")
fi

if [[ -n "${INPUT_CLOUD_PROVIDER:-}" ]]; then
args+=(--cloud-provider "${INPUT_CLOUD_PROVIDER}")
fi

"${SCRIPT_DIR}/kind.sh" ${args[@]+"${args[@]}"}

if [[ "${INPUT_REGISTRY:-}" == true ]]; then
Expand Down
0