Skip to content

Commit

Permalink
local act ci and github actions working
Browse files Browse the repository at this point in the history
  • Loading branch information
usrbinkat committed Jan 27, 2024
1 parent 7505b5b commit 5e17f9b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/kind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@ jobs:
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
ACTIONS_STEP_DEBUG: false
KUBECONFIG: .kube/config
KINDCONFIG: ./hack/kind.yaml
run: |
set -ex;
direnv allow
make kind-cluster
sudo kind create cluster -v7 --wait 1m --retain --config=$KINDCONFIG
sudo kind get kubeconfig --name kind | tee $KUBECONFIG
sudo chown -R $(id -u):$(id -g) $KUBECONFIG
# - id: wait-kind-ready
# name: Wait for Kind Kubernetes API to be Ready
Expand Down
47 changes: 23 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,33 +139,30 @@ talos: clean-all talos-cluster talos-ready wait-all-pods

# --- Kind Cluster ---
kind-cluster:
echo "Creating Kind Cluster..."
direnv allow
mkdir -p ${HOME}/.kube .kube || true
touch ${HOME}/.kube/config .kube/config || true
sudo docker volume create cilium-worker-n01
sudo docker volume create cilium-worker-n02
sudo docker volume create cilium-control-plane-n01
# sudo kind create cluster --config hack/kind.yaml
# sudo kind get kubeconfig --name cilium \
# | tee ${KUBE_CONFIG_FILE} >/dev/null
sudo chown -R $(shell id -u):$(shell id -g) ${HOME}/.kube .kube
pulumi config set kubernetes kind
echo "Created Kind Cluster."
@echo "Creating Kind Cluster..."
@direnv allow
@mkdir -p ${HOME}/.kube .kube || true
@touch ${HOME}/.kube/config .kube/config || true
@sudo docker volume create cilium-worker-n01
@sudo docker volume create cilium-worker-n02
@sudo docker volume create cilium-control-plane-n01
@sudo kind create cluster --wait 3m --retain --config=hack/kind.yaml
@sudo kind get clusters
@sudo kind get kubeconfig --name kind | tee ${KUBE_CONFIG_FILE}
@sudo kind get kubeconfig --name cilium | tee ${KUBE_CONFIG_FILE}
@sudo kind get kubeconfig --name kind-cilium | tee ${KUBE_CONFIG_FILE}
@sudo chown -R $(id -u):$(id -g) ${KUBE_CONFIG_FILE}
@sudo chown -R $(shell id -u):$(shell id -g) ${HOME}/.kube .kube
@pulumi config set kubernetes kind
@echo "Created Kind Cluster."

# --- Wait for Kind Cluster Ready ---
kind-ready:
@echo "Waiting for Kind Kubernetes API to be ready..."
sleep 15
kubectl get all --all-namespaces --show-labels --kubeconfig ${KUBE_CONFIG_FILE} || true
sleep 5
kubectl get all --all-namespaces --show-labels --kubeconfig ${KUBE_CONFIG_FILE} || true
sleep 5
kubectl get all --all-namespaces --show-labels --kubeconfig ${KUBE_CONFIG_FILE} || true
sleep 5
bash -c 'until kubectl --kubeconfig ${KUBE_CONFIG_FILE} wait --for=condition=Ready pod -l component=kube-apiserver --namespace=kube-system --timeout=180s; do echo "Waiting for kube-apiserver to be ready..."; sleep 5; done'
bash -c 'until kubectl --kubeconfig ${KUBE_CONFIG_FILE} wait --for=condition=Ready pod -l component=kube-scheduler --namespace=kube-system --timeout=180s; do echo "Waiting for kube-scheduler to be ready..."; sleep 5; done'
bash -c 'until kubectl --kubeconfig ${KUBE_CONFIG_FILE} wait --for=condition=Ready pod -l component=kube-controller-manager --namespace=kube-system --timeout=180s; do echo "Waiting for kube-controller-manager to be ready..."; sleep 5; done'
@kubectl get all --all-namespaces --show-labels --kubeconfig ${KUBE_CONFIG_FILE} || sleep 5
@bash -c 'until kubectl --kubeconfig ${KUBE_CONFIG_FILE} wait --for=condition=Ready pod -l component=kube-apiserver --namespace=kube-system --timeout=180s; do echo "Waiting for kube-apiserver to be ready..."; sleep 5; done'
@bash -c 'until kubectl --kubeconfig ${KUBE_CONFIG_FILE} wait --for=condition=Ready pod -l component=kube-scheduler --namespace=kube-system --timeout=180s; do echo "Waiting for kube-scheduler to be ready..."; sleep 5; done'
@bash -c 'until kubectl --kubeconfig ${KUBE_CONFIG_FILE} wait --for=condition=Ready pod -l component=kube-controller-manager --namespace=kube-system --timeout=180s; do echo "Waiting for kube-controller-manager to be ready..."; sleep 5; done'
@echo "Kind Cluster is ready."

kind: kind-cluster kind-ready
Expand All @@ -179,6 +176,8 @@ clean: login down
@echo "Cleaning up resources..."
@sudo kind delete cluster --name cilium \
|| echo "Kind cluster not found."
@sudo kind delete cluster --name kind \
|| echo "Kind cluster not found."
@sudo talosctl cluster destroy \
|| echo "Talos cluster not found."
@echo "Cleanup complete."
Expand All @@ -194,7 +193,7 @@ clean-all: clean
act:
@echo "Testing GitHub Workflows locally..."
@direnv allow
@set -ex; GITHUB_TOKEN=${GITHUB_TOKEN} PULUMI_ACCESS_TOKEN=${PULUMI_ACCESS_TOKEN} \
@GITHUB_TOKEN=${GITHUB_TOKEN} PULUMI_ACCESS_TOKEN=${PULUMI_ACCESS_TOKEN} \
act --container-options "--privileged" --rm \
--var GITHUB_TOKEN=${GITHUB_TOKEN} \
--var PULUMI_ACCESS_TOKEN=${PULUMI_ACCESS_TOKEN} \
Expand Down
2 changes: 1 addition & 1 deletion hack/kind.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: "kind.x-k8s.io/v1alpha4"
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: cilium
networking:
######################################################################
Expand Down

0 comments on commit 5e17f9b

Please sign in to comment.