Skip to content

Commit

Permalink
Separate e2e for agent-initiated and make non-default
Browse files Browse the repository at this point in the history
- Add support for building arm64

Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
  • Loading branch information
Danil-Grigorev committed Jun 1, 2024
1 parent b9bfa6d commit f623bcb
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 37 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ jobs:
- uses: actions/checkout@v4
- name: Test
run: just test-cluster-class-import
- name: Collect artifacts
if: always()
run: just collect-test-cluster-class-import
- name: Store run artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: artifacts
path: _out/gather
100 changes: 63 additions & 37 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ TAG := "dev"
HOME_DIR := env_var('HOME')
YQ_VERSION := "v4.43.1"
CLUSTERCTL_VERSION := "v1.7.1"
YQ_BIN := "_out/yq"
OUT_DIR := "_out"
KOPIUM_BIN := "_out/bin/kopium"
KUSTOMIZE_VERSION := "v5.4.1"
KUSTOMIZE_BIN := "_out/kustomize"
CLUSTERCTL_BIN := "_out/clusterctl"
ARCH := if arch() == "aarch64" { "arm64"} else { "amd64" }
DIST := os()

export PATH := "_out:_out/bin:" + env_var('PATH')

[private]
default:
@just --list --unsorted --color=always
Expand All @@ -25,15 +23,15 @@ generate features="":

# generates files for CRDS
generate-crds: _create-out-dir _install-kopium _download-yq
just _generate-kopium-url {{KOPIUM_BIN}} "https://raw.githubusercontent.com/kubernetes-sigs/cluster-api/main/config/crd/bases/cluster.x-k8s.io_clusters.yaml" "src/api/capi_cluster.rs" ""
just _generate-kopium-url {{KOPIUM_BIN}} "https://raw.githubusercontent.com/kubernetes-sigs/cluster-api/main/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml" "src/api/capi_clusterclass.rs" ""
just _generate-kopium-url {{KOPIUM_BIN}} "https://raw.githubusercontent.com/rancher/fleet/main/charts/fleet-crd/templates/crds.yaml" "src/api/fleet_cluster.rs" "select(.spec.names.singular==\"cluster\")" "--no-condition"
just _generate-kopium-url {{KOPIUM_BIN}} "https://raw.githubusercontent.com/rancher/fleet/main/charts/fleet-crd/templates/crds.yaml" "src/api/fleet_clustergroup.rs" "select(.spec.names.singular==\"clustergroup\")" "--no-condition"
just _generate-kopium-url {{KOPIUM_BIN}} "https://raw.githubusercontent.com/rancher/fleet/main/charts/fleet-crd/templates/crds.yaml" "src/api/fleet_cluster_registration_token.rs" "select(.spec.names.singular==\"clusterregistrationtoken\")" ""
just _generate-kopium-url kopium "https://raw.githubusercontent.com/kubernetes-sigs/cluster-api/main/config/crd/bases/cluster.x-k8s.io_clusters.yaml" "src/api/capi_cluster.rs" ""
just _generate-kopium-url kopium "https://raw.githubusercontent.com/kubernetes-sigs/cluster-api/main/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml" "src/api/capi_clusterclass.rs" ""
just _generate-kopium-url kopium "https://raw.githubusercontent.com/rancher/fleet/main/charts/fleet-crd/templates/crds.yaml" "src/api/fleet_cluster.rs" "select(.spec.names.singular==\"cluster\")" "--no-condition"
just _generate-kopium-url kopium "https://raw.githubusercontent.com/rancher/fleet/main/charts/fleet-crd/templates/crds.yaml" "src/api/fleet_clustergroup.rs" "select(.spec.names.singular==\"clustergroup\")" "--no-condition"
just _generate-kopium-url kopium "https://raw.githubusercontent.com/rancher/fleet/main/charts/fleet-crd/templates/crds.yaml" "src/api/fleet_cluster_registration_token.rs" "select(.spec.names.singular==\"clusterregistrationtoken\")" ""

[private]
_generate-kopium-url kpath="" source="" dest="" yqexp="." condition="":
curl -sSL {{source}} | {{YQ_BIN}} '{{yqexp}}' | {{kpath}} -D Default {{condition}} -f - > {{dest}}
curl -sSL {{source}} | yq '{{yqexp}}' | {{kpath}} -D Default {{condition}} -f - > {{dest}}

generate-addon-crds features="":
cargo run --features={{features}} --bin crdgen > config/crds/fleet-addon-config.yaml
Expand Down Expand Up @@ -63,7 +61,7 @@ compile features="": _create-out-dir
-w /volume \
-t clux/muslrust:stable \
cargo build --release --features={{features}} --bin controller
cp target/x86_64-unknown-linux-musl/release/controller _out/controller
cp target/{{arch()}}-unknown-linux-musl/release/controller _out/controller
[private]
_build features="":
Expand Down Expand Up @@ -91,12 +89,11 @@ load-base features="":
start-dev: _cleanup-out-dir _create-out-dir
just update-helm-repos
kind delete cluster --name dev || true
export LOCAL_IP=$(ip -4 -j route list default | jq -r .[0].prefsrc)
envsubst < testdata/kind-config.yaml > _out/kind-config.yaml
LOCAL_IP=$(ip -4 -j route list default | jq -r .[0].prefsrc) envsubst < testdata/kind-config.yaml > _out/kind-config.yaml
kind create cluster --config --image=kindest/node:v{{KUBE_VERSION}} --config _out/kind-config.yaml
just install-fleet
just install-capi
kubectl wait pods --for=condition=Ready --timeout=300s --all --all-namespaces
kubectl wait pods --for=condition=Ready --timeout=150s --all --all-namespaces

# Stop the local dev environment
stop-dev:
Expand All @@ -112,6 +109,7 @@ deploy-child-cluster:

# Deploy child cluster-call based cluster using docker & kubeadm
deploy-child-cluster-class:
kind delete cluster --name capi-quickstart || true
kubectl --context kind-dev apply -f testdata/capi-quickstart.yaml

# Add and update helm repos used
Expand All @@ -134,34 +132,55 @@ install-fleet: _create-out-dir
# Install cluster api and any providers
install-capi: _download-clusterctl
EXP_CLUSTER_RESOURCE_SET=true CLUSTER_TOPOLOGY=true {{CLUSTERCTL_BIN}} init -i docker
EXP_CLUSTER_RESOURCE_SET=true CLUSTER_TOPOLOGY=true clusterctl init -i docker

# Deploy will deploy the operator
deploy features="": _download-kustomize
just generate {{features}}
just load-base {{features}}
{{KUSTOMIZE_BIN}} build config/default | kubectl apply -f -
kustomize build config/default | kubectl apply -f -

undeploy: _download-kustomize
{{KUSTOMIZE_BIN}} build config/default | kubectl delete --ignore-not-found=true -f -
kustomize build config/default | kubectl delete --ignore-not-found=true -f -

release-manifests: _create-out-dir _download-kustomize
{{KUSTOMIZE_BIN}} build config/default > _out/addon-components.yaml
kustomize build config/default > _out/addon-components.yaml

# Full e2e test of importing cluster in fleet
test-import: start-dev deploy deploy-child-cluster deploy-crs
kubectl wait pods --for=condition=Ready --timeout=300s --all --all-namespaces
kubectl wait clusters.fleet.cattle.io --timeout=300s --for=condition=Ready docker-demo
test-import: start-dev deploy deploy-child-cluster deploy-crs && collect-test-import
kubectl wait pods --for=condition=Ready --timeout=150s --all --all-namespaces
kubectl wait clusters.fleet.cattle.io --timeout=150s --for=condition=Ready docker-demo

collect-test-import:
-just collect-artifacts dev
-just collect-artifacts docker-demo

# Full e2e test of importing cluster in fleet
test-cluster-class-import: start-dev
test-cluster-class-import: start-dev deploy _test-import-all && collect-test-cluster-class-import

collect-test-cluster-class-import:
-just collect-artifacts dev
-just collect-artifacts capi-quickstart

# Test e2e with agent initiated connection procedure
test-cluster-class-import-agent-initated: start-dev && collect-test-cluster-class-import
just deploy "agent-initiated"
just _test-import-all

collect-artifacts cluster:
kind get kubeconfig --name {{cluster}} > {{OUT_DIR}}/kubeconfig
just crust-gather collect -f {{OUT_DIR}}/gather/{{cluster}} -k {{OUT_DIR}}/kubeconfig

# Full e2e test of importing cluster and ClusterClass in fleet
[private]
_test-import-all:
just deploy-child-cluster-class
just deploy-crs
kubectl wait pods --for=condition=Ready --timeout=300s --all --all-namespaces
kubectl wait clustergroups.fleet.cattle.io --timeout=300s --for=jsonpath='{.status.clusterCount}=1' quick-start
kubectl wait clustergroups.fleet.cattle.io --timeout=300s --for=condition=Ready quick-start
kubectl wait clusters.fleet.cattle.io --timeout=300s --for=condition=Ready capi-quickstart
kubectl wait pods --for=condition=Ready --timeout=150s --all --all-namespaces
kubectl wait clustergroups.fleet.cattle.io --timeout=150s --for=jsonpath='{.status.clusterCount}=1' quick-start
kubectl wait clustergroups.fleet.cattle.io --timeout=150s --for=condition=Ready=true quick-start
kubectl wait clusters.fleet.cattle.io --timeout=150s --for=condition=Ready=false capi-quickstart
kubectl wait clusters.fleet.cattle.io --timeout=150s --for=condition=Ready=true capi-quickstart

# Install kopium
[private]
Expand All @@ -173,34 +192,34 @@ _install-kopium:
[linux]
[macos]
_download-kustomize:
curl -sSL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/{{KUSTOMIZE_VERSION}}/kustomize_{{KUSTOMIZE_VERSION}}_{{DIST}}_{{ARCH}}.tar.gz -o {{KUSTOMIZE_BIN}}.tar.gz
tar -xzf {{KUSTOMIZE_BIN}}.tar.gz -C _out
chmod +x {{KUSTOMIZE_BIN}}
curl -sSL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/{{KUSTOMIZE_VERSION}}/kustomize_{{KUSTOMIZE_VERSION}}_{{DIST}}_{{ARCH}}.tar.gz -o {{OUT_DIR}}/kustomize.tar.gz
tar -xzf {{OUT_DIR}}/kustomize.tar.gz -C _out
chmod +x {{OUT_DIR}}/kustomize

[private]
[linux]
_download-clusterctl:
curl -L https://github.com/kubernetes-sigs/cluster-api/releases/download/{{CLUSTERCTL_VERSION}}/clusterctl-linux-amd64 -o {{CLUSTERCTL_BIN}}
chmod +x {{CLUSTERCTL_BIN}}
curl -L https://github.com/kubernetes-sigs/cluster-api/releases/download/{{CLUSTERCTL_VERSION}}/clusterctl-linux-{{ARCH}} -o {{OUT_DIR}}/clusterctl
chmod +x {{OUT_DIR}}/clusterctl

[private]
[macos]
_download-clusterctl:
curl -L https://github.com/kubernetes-sigs/cluster-api/releases/download/{{CLUSTERCTL_VERSION}}/clusterctl-darwin-amd64 -o {{CLUSTERCTL_BIN}}
chmod +x {{CLUSTERCTL_BIN}}
curl -L https://github.com/kubernetes-sigs/cluster-api/releases/download/{{CLUSTERCTL_VERSION}}/clusterctl-darwin-{{ARCH}} -o {{OUT_DIR}}/clusterctl
chmod +x {{OUT_DIR}}/clusterctl

# Download yq
[private]
[linux]
_download-yq:
curl -sSL https://github.com/mikefarah/yq/releases/download/{{YQ_VERSION}}/yq_linux_{{ARCH}} -o {{YQ_BIN}}
chmod +x {{YQ_BIN}}
curl -sSL https://github.com/mikefarah/yq/releases/download/{{YQ_VERSION}}/yq_linux_{{ARCH}} -o {{OUT_DIR}}/yq
chmod +x {{OUT_DIR}}/yq

[private]
[macos]
_download-yq:
curl -sSL https://github.com/mikefarah/yq/releases/download/{{YQ_VERSION}}/yq_darwin_{{ARCH}} -o {{YQ_BIN}}
chmod +x {{YQ_BIN}}
curl -sSL https://github.com/mikefarah/yq/releases/download/{{YQ_VERSION}}/yq_darwin_{{ARCH}} -o {{OUT_DIR}}/yq
chmod +x {{OUT_DIR}}/yq

[private]
_create-out-dir:
Expand All @@ -210,3 +229,10 @@ _create-out-dir:
_cleanup-out-dir:
rm -rf _out/ || true

crust-gather *flags: _download-crust-gather
crust-gather {{flags}}

[private]
_download-crust-gather: _create-out-dir
[ -f {{OUT_DIR}}/crust-gather ] || curl -sSfL https://github.com/crust-gather/crust-gather/raw/main/install.sh | sh -s - -f -b {{OUT_DIR}}

1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pkgs.mkShell {
rustfmt # Formatter
clippy # Linter
just
fzf
kind
kubernetes-helm
clusterctl
Expand Down

0 comments on commit f623bcb

Please sign in to comment.