chore: add workflow to replace vcluster chart version #237
Workflow file for this run
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
name: Tests | |
on: | |
workflow_dispatch: | |
inputs: | |
debug_enabled: | |
type: boolean | |
description: Run the build with upterm debugging enabled | |
(https://github.com/lhotari/action-upterm/) | |
required: false | |
default: false | |
push: | |
tags: | |
- v* | |
branches: | |
- main | |
paths: | |
- "**/*.go" | |
pull_request: | |
concurrency: | |
group: e2e-${{ github.head_ref || github.ref_name }} | |
cancel-in-progress: true | |
jobs: | |
unit-test: | |
runs-on: ubuntu-latest | |
name: Unit Test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
cache: false | |
- name: Run Unit Tests | |
run: go test ./test/controllerstest | |
e2e: | |
runs-on: ubuntu-latest | |
name: E2E Test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
cache: false | |
- name: Install Prerequisites | |
run: | | |
# Install clusterctl | |
curl -L https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.9.3/clusterctl-linux-amd64 -o clusterctl | |
chmod +x clusterctl | |
sudo mv clusterctl /usr/local/bin/ | |
#Install Kind | |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.26.0/kind-linux-amd64 | |
chmod +x ./kind | |
sudo mv ./kind /usr/local/bin/kind | |
# Install envsubst | |
GOBIN="$(pwd)/bin" go install -tags tools github.com/drone/envsubst/v2/cmd/envsubst@v2.0.0-20210730161058-179042472c46 | |
# Install kubectl | |
curl -LO "https://dl.k8s.io/release/v1.31.4/bin/linux/amd64/kubectl" | |
chmod +x ./kubectl | |
sudo mv ./kubectl /usr/local/bin/kubectl | |
# Install vcluster | |
curl -Lo vcluster https://github.com/loft-sh/vcluster/releases/download/v0.22.3/vcluster-linux-amd64 | |
chmod +x ./vcluster | |
sudo mv ./vcluster /usr/local/bin/vcluster | |
# Install DevSpace | |
curl -fsSL -o /tmp/devspace https://github.com/devspace-cloud/devspace/releases/latest/download/devspace-linux-amd64 | |
chmod +x /tmp/devspace | |
sudo mv /tmp/devspace /usr/local/bin/devspace | |
- name: Create and Start Kind Cluster | |
run: | | |
kind create cluster --image=kindest/node:v1.31.4@sha256:2cb39f7295fe7eafee0842b1052a599a4fb0f8bcf3f83d96c7f4864c357c6c30 | |
echo "=== cluster-info ===" | |
kubectl cluster-info --context kind-kind | |
- name: Init | |
run: | | |
clusterctl init | |
echo "=== config get-contexts ===" | |
kubectl config get-contexts | |
- name: DevSpace Deploy | |
run: | | |
devspace deploy -p deploy | |
- name: Display Kubernetes Env | |
run: | | |
echo "=== Kubectl version ===" | |
kubectl version | |
echo "=== Kubectl config ===" | |
kubectl config view | |
echo "=== Kubectl get pods ===" | |
kubectl get pods -A | |
echo "=== Kubectl get namespaces ===" | |
kubectl get namespaces | |
echo "=== Test get crd ===" | |
kubectl get crd | |
- name: Create Vcluster Custom Resource K3S | |
run: | | |
export CLUSTER_NAME=vcluster-k3s | |
export CLUSTER_NAMESPACE=vcluster-k3s | |
export CHART_VERSION=0.22.1 | |
export VCLUSTER_YAML=$(cat ./test/e2e/k3s-values.yaml | sed -z 's/\n/\\n/g') | |
kubectl create namespace ${CLUSTER_NAMESPACE} | |
cat templates/cluster-template.yaml | ./bin/envsubst | kubectl apply -n ${CLUSTER_NAMESPACE} -f - | |
- name: Validate Resource Ready K3S | |
run: | | |
kubectl wait --for=condition=ready vcluster -n vcluster-k3s vcluster-k3s --timeout=100s | |
- name: Connect to vcluster and install nginx | |
run: | | |
vcluster -n vcluster-k3s connect vcluster-k3s --background-proxy=true | |
kubectl create namespace demo-nginx | |
kubectl -n demo-nginx create deployment nginx-deployment --image=nginx | |
kubectl -n demo-nginx rollout status deployment/nginx-deployment --timeout=100s | |
vcluster disconnect | |
- name: Create Vcluster Custom Resource K0S | |
run: | | |
export CLUSTER_NAME=vcluster-k0s | |
export CLUSTER_NAMESPACE=vcluster-k0s | |
export CHART_VERSION=0.22.1 | |
export CHART_NAME=vcluster | |
export VCLUSTER_YAML=$(cat ./test/e2e/k0s-values.yaml | sed -z 's/\n/\\n/g') | |
kubectl create namespace ${CLUSTER_NAMESPACE} | |
cat templates/cluster-template.yaml | ./bin/envsubst | kubectl apply -n ${CLUSTER_NAMESPACE} -f - | |
- name: Validate Resource Ready K0S | |
run: | | |
kubectl wait --for=condition=ready vcluster -n vcluster-k0s vcluster-k0s --timeout=100s | |
- name: Connect to vcluster and install nginx | |
run: | | |
vcluster -n vcluster-k0s connect vcluster-k0s --background-proxy=true | |
kubectl create namespace demo-nginx | |
kubectl -n demo-nginx create deployment nginx-deployment --image=nginx | |
kubectl -n demo-nginx rollout status deployment/nginx-deployment --timeout=100s | |
vcluster disconnect | |
- name: Create Vcluster Custom Resource K8S | |
run: | | |
export CLUSTER_NAME=vcluster-k8s | |
export CLUSTER_NAMESPACE=vcluster-k8s | |
export CHART_VERSION=0.22.1 | |
export CHART_NAME=vcluster | |
export VCLUSTER_YAML=$(cat ./test/e2e/k8s-values.yaml | sed -z 's/\n/\\n/g') | |
kubectl create namespace ${CLUSTER_NAMESPACE} | |
cat templates/cluster-template.yaml | ./bin/envsubst | kubectl apply -n ${CLUSTER_NAMESPACE} -f - | |
- name: Validate Resource Ready K8S | |
run: | | |
kubectl wait --for=condition=ready vcluster -n vcluster-k8s vcluster-k8s --timeout=100s | |
- name: Connect to vcluster and install nginx | |
run: | | |
vcluster -n vcluster-k8s connect vcluster-k8s --background-proxy=true | |
kubectl create namespace demo-nginx | |
kubectl -n demo-nginx create deployment nginx-deployment --image=nginx | |
kubectl -n demo-nginx rollout status deployment/nginx-deployment --timeout=100s | |
vcluster disconnect |