Skip to content

Commit 82b903d

Browse files
authored
Merge pull request #787 from devigned/e2e-exp
🌱 Enable experimental features in e2e testing
2 parents 8133094 + 013ad0c commit 82b903d

File tree

7 files changed

+29
-17
lines changed

7 files changed

+29
-17
lines changed

.tiltignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
templates

Makefile

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ SKIP_CREATE_MGMT_CLUSTER ?= false
119119
# Build time versioning details.
120120
LDFLAGS := $(shell hack/version.sh)
121121

122-
# Allow overriding the feature gates
123-
EXP_MACHINE_POOL ?= false
124-
FEATURE_GATES_JSON_PATCH := [{"op": "add", "path": "/spec/template/spec/containers/1/args/-", "value": "--feature-gates=MachinePool=$(EXP_MACHINE_POOL)"}]
125-
126122
CLUSTER_TEMPLATE ?= cluster-template.yaml
127123
MANAGED_CLUSTER_TEMPLATE ?= cluster-template-aks.yaml
128124

@@ -387,18 +383,12 @@ create-management-cluster: $(KUSTOMIZE) $(ENVSUBST)
387383
kubectl wait --for=condition=Available --timeout=5m apiservice v1beta1.webhook.cert-manager.io
388384

389385
# Deploy CAPI
390-
kubectl apply -f https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.7/cluster-api-components.yaml
386+
curl -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.7/cluster-api-components.yaml | $(ENVSUBST) | kubectl apply -f -
391387

392388
# Deploy CAPZ
393389
kind load docker-image $(CONTROLLER_IMG)-$(ARCH):$(TAG) --name=capz
394390
$(KUSTOMIZE) build config | $(ENVSUBST) | kubectl apply -f -
395391

396-
# Patch controllers with feature gates flag
397-
kubectl patch deployment capi-controller-manager -n capi-system --type=json -p='$(FEATURE_GATES_JSON_PATCH)'
398-
kubectl patch deployment capi-kubeadm-bootstrap-controller-manager -n capi-kubeadm-bootstrap-system --type=json -p='$(FEATURE_GATES_JSON_PATCH)'
399-
kubectl patch deployment capz-controller-manager -n capz-system --type=json -p='$(FEATURE_GATES_JSON_PATCH)'
400-
kubectl patch deployment capi-controller-manager -n capi-webhook-system --type=json -p='$(FEATURE_GATES_JSON_PATCH)'
401-
402392
# Wait for CAPI deployments
403393
kubectl wait --for=condition=Available --timeout=5m -n capi-system deployment -l cluster.x-k8s.io/provider=cluster-api
404394
kubectl wait --for=condition=Available --timeout=5m -n capi-kubeadm-bootstrap-system deployment -l cluster.x-k8s.io/provider=bootstrap-kubeadm
@@ -458,7 +448,7 @@ kind-create: ## create capz kind cluster if needed
458448
./scripts/kind-with-registry.sh
459449

460450
.PHONY: tilt-up
461-
tilt-up: kind-create ## start tilt and build kind cluster if needed
451+
tilt-up: $(ENVSUBST) $(KUSTOMIZE) kind-create ## start tilt and build kind cluster if needed
462452
tilt up
463453

464454
.PHONY: delete-cluster

Tiltfile

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# -*- mode: Python -*-
22

3-
# set defaults
3+
kustomize_cmd = "./hack/tools/bin/kustomize"
4+
envsubst_cmd = "./hack/tools/bin/envsubst"
5+
6+
update_settings(k8s_upsert_timeout_secs=60) # on first tilt up, often can take longer than 30 seconds
47

8+
# set defaults
59
settings = {
610
"allowed_contexts": [
711
"kind-capz"
@@ -53,7 +57,9 @@ def deploy_cert_manager():
5357
# deploy CAPI
5458
def deploy_capi():
5559
version = settings.get("capi_version")
56-
local("kubectl apply -f https://github.com/kubernetes-sigs/cluster-api/releases/download/{}/cluster-api-components.yaml".format(version))
60+
capi_uri = "https://github.com/kubernetes-sigs/cluster-api/releases/download/{}/cluster-api-components.yaml".format(version)
61+
cmd = "curl -sSL {} | {} | kubectl apply -f -".format(capi_uri, envsubst_cmd)
62+
local(cmd, quiet=True)
5763
if settings.get("extra_args"):
5864
extra_args = settings.get("extra_args")
5965
if extra_args.get("core"):
@@ -142,6 +148,7 @@ COPY --from=tilt-helper /restart.sh .
142148
COPY manager .
143149
"""
144150

151+
145152
# Build CAPZ and add feature gates
146153
def capz():
147154
# Apply the kustomized yaml for this provider
@@ -164,7 +171,7 @@ def capz():
164171
local_resource(
165172
"manager",
166173
cmd = 'mkdir -p .tiltbuild;CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags \'-extldflags "-static"\' -o .tiltbuild/manager',
167-
deps = ["./api", "./main.go", "./pkg", "./controllers", "./cloud", "./exp"]
174+
deps = ["api", "cloud", "config", "controllers", "exp", "feature", "pkg", "go.mod", "go.sum", "main.go"]
168175
)
169176

170177
dockerfile_contents = "\n".join([
@@ -187,11 +194,13 @@ def capz():
187194
entrypoint = entrypoint,
188195
only = "manager",
189196
live_update = [
190-
sync("./.tiltbuild/manager", "/manager"),
197+
sync(".tiltbuild/manager", "/manager"),
191198
run("sh /restart.sh"),
192199
],
200+
ignore = ["templates"]
193201
)
194202

203+
yaml = envsubst(yaml)
195204
k8s_yaml(blob(yaml))
196205

197206

@@ -270,11 +279,12 @@ def deploy_worker_templates(flavor, substitutions):
270279
value = substitutions[substitution]
271280
yaml = yaml.replace("${" + substitution + "}", value)
272281

282+
yaml = envsubst(yaml)
273283
yaml = yaml.replace('"', '\\"') # add escape character to double quotes in yaml
274284

275285
local_resource(
276286
"worker-" + flavor,
277-
cmd = "make generate-flavors; echo \"" + yaml + "\" > ./.tiltbuild/worker-" + flavor + ".yaml; kubectl apply -f ./.tiltbuild/worker-" + flavor + ".yaml",
287+
cmd = "make generate-flavors; echo \"" + yaml + "\" > ./.tiltbuild/worker-" + flavor + ".yaml; cat ./.tiltbuild/worker-" + flavor + ".yaml | " + envsubst_cmd + " | kubectl apply -f -",
278288
auto_init = False,
279289
trigger_mode = TRIGGER_MODE_MANUAL
280290
)
@@ -323,6 +333,11 @@ def base64_decode(to_decode):
323333
decode_blob = local("echo '{}' | base64 --decode -".format(to_decode), quiet=True)
324334
return str(decode_blob)
325335

336+
337+
def envsubst(yaml):
338+
yaml = yaml.replace('"', '\\"')
339+
return str(local("echo \"{}\" | {}".format(yaml, envsubst_cmd), quiet=True))
340+
326341
##############################
327342
# Actual work happens here
328343
##############################

config/manager/manager.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ spec:
1818
containers:
1919
- args:
2020
- --enable-leader-election
21+
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=false},AKS=${EXP_AKS:=false}"
2122
image: controller:latest
2223
imagePullPolicy: Always
2324
name: manager

config/manager/manager_auth_proxy_patch.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ spec:
2323
args:
2424
- "--metrics-addr=127.0.0.1:8080"
2525
- "--enable-leader-election"
26+
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=false},AKS=${EXP_AKS:=false}"

config/webhook/manager_webhook_patch.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ spec:
1111
args:
1212
- "--metrics-addr=127.0.0.1:8080"
1313
- "--webhook-port=9443"
14+
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=false},AKS=${EXP_AKS:=false}"
1415
ports:
1516
- containerPort: 9443
1617
name: webhook-server

test/e2e/config/azure-dev.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ variables:
5555
KUBERNETES_VERSION_UPGRADE_FROM: "${KUBERNETES_VERSION_UPGRADE_FROM:-v1.17.4}"
5656
CNI: "${PWD}/templates/addons/calico.yaml"
5757
REDACT_LOG_SCRIPT: "${PWD}/hack/log/redact.sh"
58+
EXP_CLUSTER_RESOURCE_SET: "true"
59+
EXP_AKS: "true"
60+
EXP_MACHINE_POOL: "true"
5861

5962
intervals:
6063
default/wait-controllers: ["3m", "10s"]

0 commit comments

Comments
 (0)