mirror of
https://gitea.com/gitea/helm-actions.git
synced 2026-04-05 09:10:46 +00:00
104 lines
3.1 KiB
YAML
104 lines
3.1 KiB
YAML
on: pull_request
|
|
jobs:
|
|
k8s-test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Docker CLI, kind, and kubectl
|
|
run: |
|
|
# Install Docker CLI (to talk to the host daemon via the mounted socket)
|
|
apt-get update && apt-get install -y docker.io jq
|
|
|
|
# Install kind
|
|
curl -Lo /usr/local/bin/kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-amd64
|
|
chmod +x /usr/local/bin/kind
|
|
|
|
# Install kubectl
|
|
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
|
install kubectl /usr/local/bin/
|
|
|
|
- name: Debug All
|
|
run: |
|
|
docker ps -a
|
|
docker network ls
|
|
docker volume ls
|
|
|
|
- name: Delete Kind Cluster
|
|
run: |
|
|
kind delete cluster --name test-cluster-2
|
|
|
|
- name: Sleep 5s
|
|
run: sleep 5
|
|
|
|
- name: Debug All
|
|
run: |
|
|
docker ps -a
|
|
docker network ls
|
|
docker volume ls
|
|
|
|
- name: Create kind cluster
|
|
run: |
|
|
cat > cluster.yml << 'EOF'
|
|
# three node (two workers) cluster config
|
|
kind: Cluster
|
|
apiVersion: kind.x-k8s.io/v1alpha4
|
|
nodes:
|
|
- role: control-plane
|
|
- role: worker
|
|
- role: worker
|
|
EOF
|
|
kind create cluster --name test-cluster-2 --config cluster.yml
|
|
|
|
- name: Attach kind control-plane to job network and wait
|
|
run: |
|
|
apt-get update && apt-get install -y jq docker.io
|
|
|
|
JOB_CONTAINER_ID="$(hostname)"
|
|
NETWORK_NAME="$(docker inspect "$JOB_CONTAINER_ID" --format '{{range $k, $v := .NetworkSettings.Networks}}{{$k}}{{end}}')"
|
|
echo "Job network: $NETWORK_NAME"
|
|
|
|
CONTROL_PLANE="test-cluster-2-control-plane"
|
|
docker network connect "$NETWORK_NAME" "$CONTROL_PLANE" || true
|
|
|
|
KIND_IP="$(docker inspect "$CONTROL_PLANE" --format "{{(index .NetworkSettings.Networks \"$NETWORK_NAME\").IPAddress}}")"
|
|
echo "Kind IP: $KIND_IP"
|
|
|
|
# Point kubectl at the control-plane directly
|
|
kubectl config set-cluster kind-test-cluster-2 --server="https://${KIND_IP}:6443"
|
|
kubectl config set-cluster kind-test-cluster-2 --insecure-skip-tls-verify=true
|
|
|
|
# Wait for API and nodes
|
|
for i in $(seq 1 120); do
|
|
if kubectl get nodes >/dev/null 2>&1; then
|
|
break
|
|
fi
|
|
echo "Waiting for kind API... ($i/120)"
|
|
sleep 2
|
|
done
|
|
kubectl get nodes
|
|
|
|
- name: Verify cluster access
|
|
run: |
|
|
kubectl cluster-info
|
|
kubectl get nodes
|
|
kubectl get pods -A
|
|
|
|
- name: Debug All
|
|
if: always()
|
|
run: |
|
|
docker ps -a
|
|
docker network ls
|
|
docker volume ls
|
|
|
|
- name: Delete Kind Cluster
|
|
if: always()
|
|
run: |
|
|
kind delete cluster --name test-cluster-2
|
|
|
|
- name: Debug All
|
|
if: always()
|
|
run: |
|
|
docker ps -a
|
|
docker network ls
|
|
docker volume ls |