Skip to content

Commit af3407a

Browse files
committed
🏃 support multiple release manifests with/without kubeadm
This PR will aim to separate out the kubeadm-specific manifests with those that are part of the base capi deployment. The goal here is to allow for the publishing of four separate release yamls, one called `cluster-api-components.yaml` (no kubeadm components), one called `bootstrap-components.yaml` (kubeadm-specific bootstrap only), one called `controlplane-components.yaml` (kubeadm-specific controlplane only), and one called `cluster-api-and-bootstrap-components.yaml` (with kubeadm components and base capi components). The important bits are the new config/bootstrap directory, config/controlplane directory, the new config/core directory, and the existing config/default directory. The config/[bootstrap,controlplane] directory houses a new kustomization.yaml file. This file builds all required patches and creates all new files that are specific to the kubeadm bootstrap or controlplane needs. The config/core directory is a move of the previous config/default directory and bulds all the core, vanilla capi bits. The existing config/default directory becomes a wrapper around the directories mentioned above and produces the "batteries included" manifests. Signed-off-by: Spencer Smith <[email protected]>
1 parent 8536f42 commit af3407a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+496
-171
lines changed

Makefile

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,28 @@ generate-bindata: $(KUSTOMIZE) $(GOBINDATA) clean-bindata ## Generate code for e
184184
generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
185185
$(CONTROLLER_GEN) \
186186
paths=./api/... \
187-
paths=./bootstrap/kubeadm/api/... \
188-
paths=./controlplane/kubeadm/api/... \
189187
paths=./controllers/... \
190-
paths=./bootstrap/kubeadm/controllers/... \
191-
paths=./controlplane/kubeadm/controllers/... \
192188
crd:preserveUnknownFields=false \
193189
rbac:roleName=manager-role \
194190
output:crd:dir=./config/crd/bases \
195191
output:webhook:dir=./config/webhook \
196192
webhook
193+
$(CONTROLLER_GEN) \
194+
paths=./bootstrap/kubeadm/api/... \
195+
paths=./bootstrap/kubeadm/controllers/... \
196+
crd:preserveUnknownFields=false \
197+
rbac:roleName=bootstrap-manager-role \
198+
output:crd:dir=./config/bootstrap/crd/bases \
199+
output:rbac:dir=./config/bootstrap/rbac
200+
$(CONTROLLER_GEN) \
201+
paths=./controlplane/kubeadm/api/... \
202+
paths=./controlplane/kubeadm/controllers/... \
203+
crd:preserveUnknownFields=false \
204+
rbac:roleName=controlplane-manager-role \
205+
output:crd:dir=./config/controlplane/crd/bases \
206+
output:rbac:dir=./config/controlplane/rbac \
207+
output:webhook:dir=./config/controlplane/webhook \
208+
webhook
197209
$(CONTROLLER_GEN) \
198210
paths=./cmd/clusterctl/api/... \
199211
crd:trivialVersions=true,preserveUnknownFields=false \
@@ -252,12 +264,12 @@ docker-push-manifest: ## Push the fat manifest docker image.
252264
.PHONY: set-manifest-image
253265
set-manifest-image:
254266
$(info Updating kustomize image patch file for manager resource)
255-
sed -i'' -e 's@image: .*@image: '"${MANIFEST_IMG}:$(MANIFEST_TAG)"'@' ./config/default/manager_image_patch.yaml
267+
sed -i'' -e 's@image: .*@image: '"${MANIFEST_IMG}:$(MANIFEST_TAG)"'@' ./config/core/manager_image_patch.yaml
256268

257269
.PHONY: set-manifest-pull-policy
258270
set-manifest-pull-policy:
259271
$(info Updating kustomize pull policy file for manager resource)
260-
sed -i'' -e 's@imagePullPolicy: .*@imagePullPolicy: '"$(PULL_POLICY)"'@' ./config/default/manager_pull_policy.yaml
272+
sed -i'' -e 's@imagePullPolicy: .*@imagePullPolicy: '"$(PULL_POLICY)"'@' ./config/core/manager_pull_policy.yaml
261273

262274
## --------------------------------------
263275
## Release
@@ -283,6 +295,9 @@ release: clean-release ## Builds and push container images using the latest git
283295

284296
.PHONY: release-manifests
285297
release-manifests: $(RELEASE_DIR) ## Builds the manifests to publish with a release
298+
$(KUSTOMIZE) build config/core > $(RELEASE_DIR)/core-components.yaml
299+
$(KUSTOMIZE) build config/bootstrap > $(RELEASE_DIR)/bootstrap-components.yaml
300+
$(KUSTOMIZE) build config/controlplane > $(RELEASE_DIR)/controlplane-components.yaml
286301
$(KUSTOMIZE) build config/default > $(RELEASE_DIR)/cluster-api-components.yaml
287302

288303
release-binaries: ## Builds the binaries to publish with a release

bootstrap/kubeadm/api/v1alpha2/suite_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ func TestAPIs(t *testing.T) {
5656
var _ = BeforeSuite(func(done Done) {
5757
By("bootstrapping test environment")
5858
testEnv = &envtest.Environment{
59-
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "..", "config", "crd", "bases")},
59+
CRDDirectoryPaths: []string{
60+
filepath.Join("..", "..", "..", "..", "config", "bootstrap", "crd", "bases"),
61+
filepath.Join("..", "..", "..", "..", "config", "controlplane", "crd", "bases"),
62+
filepath.Join("..", "..", "..", "..", "config", "crd", "bases"),
63+
},
6064
}
6165

6266
err := SchemeBuilder.AddToScheme(scheme.Scheme)

bootstrap/kubeadm/api/v1alpha3/suite_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ func TestAPIs(t *testing.T) {
5656
var _ = BeforeSuite(func(done Done) {
5757
By("bootstrapping test environment")
5858
testEnv = &envtest.Environment{
59-
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "..", "config", "crd", "bases")},
59+
CRDDirectoryPaths: []string{
60+
filepath.Join("..", "..", "..", "..", "config", "bootstrap", "crd", "bases"),
61+
filepath.Join("..", "..", "..", "..", "config", "controlplane", "crd", "bases"),
62+
filepath.Join("..", "..", "..", "..", "config", "crd", "bases"),
63+
},
6064
}
6165

6266
err := SchemeBuilder.AddToScheme(scheme.Scheme)

bootstrap/kubeadm/controllers/suite_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ var _ = BeforeSuite(func(done Done) {
5757
By("bootstrapping test environment")
5858
testEnv = &envtest.Environment{
5959
CRDDirectoryPaths: []string{
60+
filepath.Join("..", "..", "..", "config", "bootstrap", "crd", "bases"),
61+
filepath.Join("..", "..", "..", "config", "controlplane", "crd", "bases"),
6062
filepath.Join("..", "..", "..", "config", "crd", "bases"),
6163
},
6264
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This kustomization.yaml is not intended to be run by itself,
2+
# since it depends on service name and namespace that are out of this kustomize package.
3+
# It should be run by config/default
4+
resources:
5+
- bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml
6+
- bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml
7+
# +kubebuilder:scaffold:crdkustomizeresource
8+
9+
10+
patchesStrategicMerge:
11+
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
12+
# patches here are for enabling the conversion webhook for each CRD
13+
- patches/webhook_in_kubeadmconfigs.yaml
14+
- patches/webhook_in_kubeadmconfigtemplates.yaml
15+
# +kubebuilder:scaffold:crdkustomizewebhookpatch
16+
17+
# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
18+
# patches here are for enabling the CA injection for each CRD
19+
- patches/cainjection_in_kubeadmconfigs.yaml
20+
- patches/cainjection_in_kubeadmconfigtemplates.yaml
21+
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
22+
23+
# the following config is for teaching kustomize how to do kustomization for CRDs.
24+
configurations:
25+
- kustomizeconfig.yaml
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file is for teaching kustomize how to substitute name and namespace reference in CRD
2+
nameReference:
3+
- kind: Service
4+
version: v1
5+
fieldSpecs:
6+
- kind: CustomResourceDefinition
7+
group: apiextensions.k8s.io
8+
path: spec/conversion/webhookClientConfig/service/name
9+
10+
namespace:
11+
- kind: CustomResourceDefinition
12+
group: apiextensions.k8s.io
13+
path: spec/conversion/webhookClientConfig/service/namespace
14+
create: false
15+
16+
varReference:
17+
- path: metadata/annotations

config/bootstrap/kustomization.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# The kubeadm kustomization bundles up all the bits that are kubeadm-specific.
2+
# This includes all bootstrap/controlplane components.
3+
4+
# Adds namespace to all resources.
5+
namespace: capi-system
6+
7+
bases:
8+
- crd/
9+
- rbac/

config/bootstrap/kustomizeconfig.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file is for teaching kustomize how to substitute name and namespace reference in CRD
2+
nameReference:
3+
- kind: Service
4+
version: v1
5+
fieldSpecs:
6+
- kind: CustomResourceDefinition
7+
group: apiextensions.k8s.io
8+
path: spec/conversion/webhookClientConfig/service/name
9+
10+
namespace:
11+
- kind: CustomResourceDefinition
12+
group: apiextensions.k8s.io
13+
path: spec/conversion/webhookClientConfig/service/namespace
14+
create: false
15+
16+
varReference:
17+
- path: metadata/annotations
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
# Each entry in this list must resolve to an existing
4+
# resource definition in YAML. These are the resource
5+
# files that kustomize reads, modifies and emits as a
6+
# YAML string, with resources separated by document
7+
# markers ("---").
8+
resources:
9+
- role_binding.yaml
10+
- role.yaml

config/bootstrap/rbac/role.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
---
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
kind: ClusterRole
5+
metadata:
6+
creationTimestamp: null
7+
name: bootstrap-manager-role
8+
rules:
9+
- apiGroups:
10+
- ""
11+
resources:
12+
- configmaps
13+
- events
14+
- secrets
15+
verbs:
16+
- create
17+
- delete
18+
- get
19+
- list
20+
- patch
21+
- update
22+
- watch
23+
- apiGroups:
24+
- bootstrap.cluster.x-k8s.io
25+
resources:
26+
- kubeadmconfigs
27+
- kubeadmconfigs/status
28+
verbs:
29+
- create
30+
- delete
31+
- get
32+
- list
33+
- patch
34+
- update
35+
- watch
36+
- apiGroups:
37+
- cluster.x-k8s.io
38+
resources:
39+
- clusters
40+
- clusters/status
41+
- machines
42+
- machines/status
43+
verbs:
44+
- get
45+
- list
46+
- watch
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
creationTimestamp: null
5+
name: bootstrap-manager-rolebinding
6+
roleRef:
7+
apiGroup: rbac.authorization.k8s.io
8+
kind: ClusterRole
9+
name: bootstrap-manager-role
10+
subjects:
11+
- kind: ServiceAccount
12+
name: default
13+
namespace: system
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This kustomization.yaml is not intended to be run by itself,
2+
# since it depends on service name and namespace that are out of this kustomize package.
3+
# It should be run by config/default
4+
resources:
5+
- bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml
6+
# +kubebuilder:scaffold:crdkustomizeresource
7+
8+
# the following config is for teaching kustomize how to do kustomization for CRDs.
9+
configurations:
10+
- kustomizeconfig.yaml
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file is for teaching kustomize how to substitute name and namespace reference in CRD
2+
nameReference:
3+
- kind: Service
4+
version: v1
5+
fieldSpecs:
6+
- kind: CustomResourceDefinition
7+
group: apiextensions.k8s.io
8+
path: spec/conversion/webhookClientConfig/service/name
9+
10+
namespace:
11+
- kind: CustomResourceDefinition
12+
group: apiextensions.k8s.io
13+
path: spec/conversion/webhookClientConfig/service/namespace
14+
create: false
15+
16+
varReference:
17+
- path: metadata/annotations
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# The kubeadm kustomization bundles up all the bits that are kubeadm-specific.
2+
# This includes all bootstrap/controlplane components.
3+
4+
# Adds namespace to all resources.
5+
namespace: capi-system
6+
7+
bases:
8+
- crd/
9+
- rbac/
10+
- webhook/
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file is for teaching kustomize how to substitute name and namespace reference in CRD
2+
nameReference:
3+
- kind: Service
4+
version: v1
5+
fieldSpecs:
6+
- kind: CustomResourceDefinition
7+
group: apiextensions.k8s.io
8+
path: spec/conversion/webhookClientConfig/service/name
9+
10+
namespace:
11+
- kind: CustomResourceDefinition
12+
group: apiextensions.k8s.io
13+
path: spec/conversion/webhookClientConfig/service/namespace
14+
create: false
15+
16+
varReference:
17+
- path: metadata/annotations
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
# Each entry in this list must resolve to an existing
4+
# resource definition in YAML. These are the resource
5+
# files that kustomize reads, modifies and emits as a
6+
# YAML string, with resources separated by document
7+
# markers ("---").
8+
resources:
9+
- role_binding.yaml
10+
- role.yaml

config/controlplane/rbac/role.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
---
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
kind: ClusterRole
5+
metadata:
6+
creationTimestamp: null
7+
name: controlplane-manager-role
8+
rules:
9+
- apiGroups:
10+
- controlplane.cluster.x-k8s.io
11+
resources:
12+
- kubeadmcontrolplanes
13+
- kubeadmcontrolplanes/status
14+
verbs:
15+
- create
16+
- delete
17+
- get
18+
- list
19+
- patch
20+
- update
21+
- watch
22+
- apiGroups:
23+
- ""
24+
resources:
25+
- events
26+
verbs:
27+
- create
28+
- get
29+
- list
30+
- patch
31+
- watch
32+
- apiGroups:
33+
- ""
34+
resources:
35+
- secrets
36+
verbs:
37+
- create
38+
- get
39+
- list
40+
- patch
41+
- watch
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
creationTimestamp: null
5+
name: controlplane-manager-rolebinding
6+
roleRef:
7+
apiGroup: rbac.authorization.k8s.io
8+
kind: ClusterRole
9+
name: controlplane-manager-role
10+
subjects:
11+
- kind: ServiceAccount
12+
name: default
13+
namespace: system
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Value of this field is prepended to the
2+
# names of all resources, e.g. a deployment named
3+
# "wordpress" becomes "alices-wordpress".
4+
# Note that it should also match with the prefix (text before '-') of the namespace
5+
# field above.
6+
namePrefix: controlplane-
7+
8+
resources:
9+
- manifests.yaml
10+
11+
configurations:
12+
- kustomizeconfig.yaml

0 commit comments

Comments
 (0)