-
Notifications
You must be signed in to change notification settings - Fork 432
/
Justfile
195 lines (141 loc) · 5.89 KB
/
Justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
set positional-arguments
[private]
alias align := check-structalign
timestamp := `date +%s`
alias c := create
alias d := delete
_default:
@just --list
# --- Build ---
# Build the vcluster binary
build-snapshot:
TELEMETRY_PRIVATE_KEY="" goreleaser build --snapshot --clean --single-target
# Build the vcluster release binary in snapshot mode
release-snapshot: gen-license-report
TELEMETRY_PRIVATE_KEY="" goreleaser release --snapshot --clean
# --- Code quality ---
# Run golangci-lint for all packages
lint *ARGS:
[ -f ./custom-gcl ] || golangci-lint custom
./custom-gcl cache clean
./custom-gcl run {{ARGS}}
# Check struct memory alignment and print potential improvements
[no-exit-message]
check-structalign *ARGS:
go run github.com/dkorunic/betteralign/cmd/betteralign@latest {{ARGS}} ./...
# --- Kind ---
# Create a kubernetes cluster using the specified distro
create distro="kind":
just create-{{distro}}
# Create a kubernetes cluster for the specified distro
delete distro="kind":
just delete-{{distro}}
# Create a local kind cluster
create-kind:
kind create cluster -n vcluster
# Delete the local kind cluster
delete-kind:
kind delete cluster -n vcluster
# --- Build ---
# Clean the release folder
[private]
clean-release:
rm -rf ./release
# Copy the assets to the release folder
[private]
copy-assets:
mkdir -p ./release
cp -a assets/. release/
# Generate the vcluster images file
[private]
generate-vcluster-images version="0.0.0":
go run -mod vendor ./hack/assets/main.go {{ version }} > ./release/vcluster-images.txt
# Generate versioned vCluster image files for multiple versions and distros
[private]
generate-matrix-specific-images version="0.0.0":
#!/usr/bin/env bash
distros=("k8s" "k3s" "k0s")
versions=("1.30" "1.29" "1.28")
for distro in "${distros[@]}"; do
for version in "${versions[@]}"; do
go run -mod vendor ./hack/assets/separate/main.go -kubernetes-distro=$distro -kubernetes-version=$version -vcluster-version={{ version }} > ./release/vcluster-images-$distro-$version.txt
done
done
# Generate the CLI docs
generate-cli-docs:
go run -mod vendor -tags pro ./hack/docs/main.go
# Generate the vcluster.yaml config schema
generate-config-schema:
go run -mod vendor ./hack/schema/main.go
# Embed the chart into the vcluster binary
[private]
embed-chart version="0.0.0":
RELEASE_VERSION={{ version }} go generate -tags embed_chart ./...
# Run e2e tests
e2e distribution="k3s" path="./test/e2e" multinamespace="false": create-kind && delete-kind
echo "Execute test suites ({{ distribution }}, {{ path }}, {{ multinamespace }})"
TELEMETRY_PRIVATE_KEY="" goreleaser build --snapshot --clean
cp dist/vcluster_linux_$(go env GOARCH | sed s/amd64/amd64_v1/g)/vcluster ./vcluster
docker build -t vcluster:e2e-latest -f Dockerfile.release --build-arg TARGETARCH=$(uname -m) --build-arg TARGETOS=linux .
rm ./vcluster
kind load docker-image vcluster:e2e-latest -n vcluster
cp test/commonValues.yaml dist/commonValues.yaml
sed -i.bak "s|REPLACE_REPOSITORY_NAME|vcluster|g" dist/commonValues.yaml
sed -i.bak "s|REPLACE_TAG_NAME|e2e-latest|g" dist/commonValues.yaml
yq eval -i '.controlPlane.distro.{{distribution}}.enabled = true' dist/commonValues.yaml
rm dist/commonValues.yaml.bak
sed -i.bak "s|kind-control-plane|vcluster-control-plane|g" dist/commonValues.yaml
rm dist/commonValues.yaml.bak
./dist/vcluster-cli_$(go env GOOS)_$(go env GOARCH | sed s/amd64/amd64_v1/g)/vcluster \
create vcluster -n vcluster \
--create-namespace \
--debug \
--connect=false \
--local-chart-dir ./chart/ \
-f ./dist/commonValues.yaml \
-f {{ path }}/values.yaml \
$([[ "{{ multinamespace }}" = "true" ]] && echo "-f ./test/multins_values.yaml" || echo "")
kubectl wait --for=condition=ready pod -l app=vcluster -n vcluster --timeout=300s
cd {{path}} && VCLUSTER_SUFFIX=vcluster \
VCLUSTER_NAME=vcluster \
VCLUSTER_NAMESPACE=vcluster \
MULTINAMESPACE_MODE={{ multinamespace }} \
KIND_NAME=vcluster \
go test -v -ginkgo.v -ginkgo.skip='.*NetworkPolicy.*' -ginkgo.fail-fast
cli version="0.0.0" *ARGS="":
RELEASE_VERSION={{ version }} go generate -tags embed_chart ./...
go run -tags embed_chart -mod vendor -ldflags "-X main.version={{ version }}" ./cmd/vclusterctl/main.go {{ ARGS }}
# --- Docs ---
# Version the docs for the given version
docs-version id="pro" version="1.0.0":
yarn docusaurus docs:version {{version}}
generate-compatibility:
go run hack/compat-matrix/main.go generate docs/pages/deploying-vclusters/compat-matrix.mdx
validate-compat-matrix:
go run hack/compat-matrix/main.go validate docs/pages/deploying-vclusters/compat-matrix.mdx
gen-license-report:
rm -rf ./licenses
(cd ./cmd/vclusterctl/cmd/credits/licenses && find . -type d -exec rm -rf "{}" \;) || true
go-licenses save --save_path=./licenses --ignore github.com/loft-sh ./...
cp -r ./licenses ./cmd/vclusterctl/cmd/credits
build-dev-image tag="":
TELEMETRY_PRIVATE_KEY="" goreleaser build --snapshot --clean
cp dist/vcluster_linux_$(go env GOARCH | sed s/amd64/amd64_v1/g)/vcluster ./vcluster
docker build -t vcluster:dev-{{tag}} -f Dockerfile.release --build-arg TARGETARCH=$(uname -m) --build-arg TARGETOS=linux .
rm ./vcluster
run-conformance k8s_version="1.31.1" mode="conformance-lite" tag="conf": (create-conformance k8s_version) (build-dev-image tag)
minikube image load vcluster:dev-{{tag}}
vcluster create vcluster -n vcluster -f ./conformance/v1.31/vcluster.yaml
sonobuoy run --mode={{mode}} --level=debug
conformance-status:
sonobuoy status
conformance-logs:
sonobuoy logs
dev-conformance *ARGS:
devspace dev --profile test-conformance --namespace vcluster {{ARGS}}
create-conformance k8s_version="1.31.1":
minikube start --kubernetes-version {{k8s_version}} --nodes=2
minikube addons enable metrics-server
delete-conformance:
-minikube delete
recreate-conformance: delete-conformance create-conformance