Skip to content

Commit 345b902

Browse files
make test-extension config compliant with the clusterctl contract
1 parent 1917d52 commit 345b902

16 files changed

+73
-59
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,8 @@ docker-capd-build-all: $(addprefix docker-capd-build-,$(ALL_ARCH)) ## Build capd
612612
.PHONY: docker-build-test-extension
613613
docker-build-test-extension: ## Build the docker image for core controller manager
614614
DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) --build-arg ARCH=$(ARCH) --build-arg ldflags="$(LDFLAGS)" . -t $(TEST_EXTENSION_IMG)-$(ARCH):$(TAG) --file ./test/extension/Dockerfile
615-
$(MAKE) set-manifest-image MANIFEST_IMG=$(TEST_EXTENSION_IMG)-$(ARCH) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./test/extension/config/default/extension_image_patch.yaml"
616-
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./test/extension/config/default/extension_pull_policy.yaml"
615+
$(MAKE) set-manifest-image MANIFEST_IMG=$(TEST_EXTENSION_IMG)-$(ARCH) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./test/extension/config/default/manager_image_patch.yaml"
616+
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./test/extension/config/default/manager_pull_policy.yaml"
617617

618618
.PHONY: e2e-framework
619619
e2e-framework: ## Builds the CAPI e2e framework
@@ -710,6 +710,7 @@ tilt-up: kind-cluster ## Start tilt and build kind cluster if needed.
710710
docker-build-e2e: ## Rebuild all Cluster API provider images to be used in the e2e tests
711711
$(MAKE) docker-build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent
712712
$(MAKE) docker-capd-build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent
713+
$(MAKE) docker-build-test-extension REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent
713714

714715
## --------------------------------------
715716
## Release

docs/book/src/clusterctl/provider-contract.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ It is strongly recommended that:
160160
* Infrastructure providers release a file called `infrastructure-components.yaml`
161161
* Bootstrap providers release a file called ` bootstrap-components.yaml`
162162
* Control plane providers release a file called `control-plane-components.yaml`
163+
* IPAM providers release a file called `ipam-components.yaml`
164+
* Runtime extensions providers release a file called `runtime-extension-components.yaml`
163165

164166
#### Target namespace
165167

@@ -183,15 +185,17 @@ the provider installation.
183185

184186
#### Controllers & Watching namespace
185187

186-
Each provider is expected to deploy controllers using a Deployment.
188+
Each provider is expected to deploy controllers/runtime extension server using a Deployment.
187189

188-
While defining the Deployment Spec, the container that executes the controller binary MUST be called `manager`.
190+
While defining the Deployment Spec, the container that executes the controller/runtime extension server binary MUST be called `manager`.
189191

190-
The manager MUST support a `--namespace` flag for specifying the namespace where the controller
192+
For controllers only, the manager MUST support a `--namespace` flag for specifying the namespace where the controller
191193
will look for objects to reconcile; however, clusterctl will always install providers watching for all namespaces
192194
(`--namespace=""`); for more details see [support for multiple instances](../developer/architecture/controllers/support-multiple-instances.md)
193195
for more context.
194196

197+
While defining Pods for Deployments, canonical names should be used for images.
198+
195199
#### Variables
196200

197201
The components YAML can contain environment variables matching the format ${VAR}; it is highly

test/extension/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
6363
--mount=type=cache,target=/go/pkg/mod \
6464
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \
6565
go build -trimpath -ldflags "${ldflags} -extldflags '-static'" \
66-
-o /workspace/extension ${package}
66+
-o /workspace/manager ${package}
6767

6868
# Production image
6969
FROM gcr.io/distroless/static:nonroot-${ARCH}
7070
WORKDIR /
71-
COPY --from=builder /workspace/extension .
71+
COPY --from=builder /workspace/manager .
7272
# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies
7373
USER 65532
74-
ENTRYPOINT ["/extension"]
74+
ENTRYPOINT ["/manager"]

test/extension/config/certmanager/certificate.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ kind: Certificate
1212
metadata:
1313
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
1414
spec:
15-
# $(TEST_EXTENSION_SERVICE_NAMESPACE) will be substituted by kustomize
16-
# $(TEST_EXTENSION_SERVICE_NAMESPACE) will be substituted on deployment
15+
# $(SERVICE_NAMESPACE) will be substituted by kustomize
1716
dnsNames:
18-
- $(SERVICE_NAME).${TEST_EXTENSION_SERVICE_NAMESPACE}.svc
19-
- $(SERVICE_NAME).${TEST_EXTENSION_SERVICE_NAMESPACE}.svc.cluster.local
17+
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
18+
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local
2019
# for local testing.
2120
- localhost
2221
issuerRef:

test/extension/config/default/kustomization.yaml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
1+
namespace: test-extension-system
2+
3+
namePrefix: test-extension-
4+
15
commonLabels:
6+
# Label to identify all the providers objects; As per the clusterctl contract the value should be unique.
7+
cluster.x-k8s.io/provider: "runtime-extension-test"
28

39
resources:
4-
- extension.yaml
10+
- namespace.yaml
11+
- manager.yaml
512
- service.yaml
13+
- service_account.yaml
14+
# Note: resources specific of the CAPI test-extension, other Runtime extensions provider might want to drop this
615
- role.yaml
716
- rolebinding.yaml
8-
- service_account.yaml
917

1018
bases:
1119
- ../certmanager
1220

1321
patchesStrategicMerge:
22+
# Enable webhook with corresponding certificate mount.
23+
- manager_webhook_patch.yaml
1424
# Provide customizable hook for make targets.
15-
- extension_image_patch.yaml
16-
- extension_pull_policy.yaml
17-
# Enable webhook.
18-
- extension_webhook_patch.yaml
25+
- manager_image_patch.yaml
26+
- manager_pull_policy.yaml
1927

2028
vars:
29+
- name: SERVICE_NAMESPACE
30+
objref:
31+
kind: Service
32+
version: v1
33+
name: webhook-service
34+
fieldref:
35+
fieldpath: metadata.namespace
2136
- name: SERVICE_NAME
2237
objref:
2338
kind: Service

test/extension/config/default/extension.yaml renamed to test/extension/config/default/manager.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
apiVersion: apps/v1
33
kind: Deployment
44
metadata:
5-
name: test-extension
5+
name: manager
66
spec:
77
selector:
88
matchLabels:
9-
app: test-extension
9+
app: test-extension-manager
1010
replicas: 1
1111
template:
1212
metadata:
1313
labels:
14-
app: test-extension
14+
app: test-extension-manager
1515
spec:
1616
containers:
1717
- command:
18-
- /extension
18+
- /manager
1919
image: controller:latest
20-
name: extension
20+
name: manager
2121
terminationGracePeriodSeconds: 10
22-
serviceAccountName: test-extension
22+
serviceAccountName: manager
2323
tolerations:
2424
- effect: NoSchedule
2525
key: node-role.kubernetes.io/master
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: test-extension
4+
name: manager
55
spec:
66
template:
77
spec:
88
containers:
99
- image: gcr.io/k8s-staging-cluster-api/test-extension:main
10-
name: extension
10+
name: manager
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: test-extension
4+
name: manager
55
spec:
66
template:
77
spec:
88
containers:
9-
- name: extension
9+
- name: manager
1010
imagePullPolicy: Always

test/extension/config/default/extension_webhook_patch.yaml renamed to test/extension/config/default/manager_webhook_patch.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: test-extension
4+
name: manager
55
spec:
66
template:
77
spec:
88
containers:
9-
- name: extension
9+
- name: manager
1010
ports:
1111
- containerPort: 9443
1212
name: webhook-server
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: system

0 commit comments

Comments
 (0)