forked from checkpoint-restore/checkpoint-restore-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI Workflow for Building and Deploying Operator
- Add GitHub Actions workflow for building and deploying the checkpoint-restore-operator to the kind kubernetes cluster. - Add ShellCheck and shfmt linting Signed-off-by: Parthiba-Hazra <parthibahazra@gmail.com>
- Loading branch information
1 parent
9a0aa6e
commit 8400d6b
Showing
3 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Build and Deploy | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.21 | ||
|
||
- name: Install dependencies | ||
run: | | ||
# Install kind | ||
curl -sLo kind "$(curl -sL https://github.com/gitapi/repos/kubernetes-sigs/kind/releases/latest | jq -r '[.assets[] | select(.name == "kind-linux-amd64")] | first | .browser_download_url')" | ||
chmod +x kind | ||
sudo mv kind /bin/ | ||
# Install kubectl | ||
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" | ||
chmod +x kubectl | ||
sudo mv kubectl /bin/ | ||
- name: Create Kubernetes cluster | ||
run: | | ||
kind create cluster | ||
kind export kubeconfig | ||
- name: Load Docker image into kind cluster | ||
run: | | ||
make docker-build IMG=checkpoint-restore-operator:ci | ||
kind load docker-image checkpoint-restore-operator:ci | ||
- name: Deploy to Kubernetes | ||
run: | | ||
make install | ||
make deploy IMG=checkpoint-restore-operator:ci | ||
- name: Wait for deployments to be ready | ||
run: ./test/wait_for_deployment.sh checkpoint-restore-operator-controller-manager | ||
|
||
- name: Check resources | ||
run: kubectl get all -n checkpoint-restore-operator-system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
wait_for_deployment() { | ||
local deployment_name="$1" | ||
timeout=60 # 5 minutes (60 * 5 sec) | ||
i=1 | ||
echo "Checking if the ${deployment_name} deployment is ready" | ||
until kubectl -n checkpoint-restore-operator-system get deployment "${deployment_name}" -o jsonpath='{.status.conditions[?(@.status=="True")].type}' | grep "Available" 2>/dev/null; do | ||
((i++)) | ||
if [[ ${i} -gt ${timeout} ]]; then | ||
echo "The ${deployment_name} deployment has not become ready before the timeout period" | ||
echo "Fetching deployment status and describing pods for debugging:" | ||
kubectl -n checkpoint-restore-operator-system get deployment "${deployment_name}" | ||
kubectl -n checkpoint-restore-operator-system describe deployment "${deployment_name}" | ||
kubectl -n checkpoint-restore-operator-system get pods | ||
kubectl -n checkpoint-restore-operator-system describe pods | ||
exit 1 | ||
fi | ||
echo "Waiting for ${deployment_name} deployment to report a ready status" | ||
sleep 5 | ||
done | ||
echo "The ${deployment_name} deployment is ready" | ||
} | ||
|
||
wait_for_deployment "$1" |