Skip to content

Commit ee46c70

Browse files
author
Naadir Jeewa
committed
flavorgen: Adds a generator for clusterctl template flavors
Signed-off-by: Naadir Jeewa <jeewan@vmware.com>
1 parent 499ec39 commit ee46c70

25 files changed

+1177
-358
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,6 @@ out/
5757

5858
# Ignore Goland files
5959
.idea/
60+
61+
.build
62+
.tiltbuild

Makefile

Lines changed: 102 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ SHELL := /usr/bin/env bash
2020

2121
.DEFAULT_GOAL := help
2222

23+
VERSION ?= $(shell cat clusterctl-settings.json | jq .config.nextVersion -r)
24+
2325
# Use GOPROXY environment variable if set
2426
GOPROXY := $(shell go env GOPROXY)
2527
ifeq (,$(strip $(GOPROXY)))
@@ -31,8 +33,11 @@ export GOPROXY
3133
export GO111MODULE := on
3234

3335
# Directories
34-
BIN_DIR := bin
35-
TOOLS_DIR := hack/tools
36+
37+
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
38+
39+
BIN_DIR := $(ROOT_DIR)/bin
40+
TOOLS_DIR := $(ROOT_DIR)/hack/tools
3641
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
3742

3843
# Binaries
@@ -52,6 +57,25 @@ WEBHOOK_ROOT ?= $(MANIFEST_ROOT)/webhook
5257
RBAC_ROOT ?= $(MANIFEST_ROOT)/rbac
5358
GC_KIND ?= true
5459

60+
RELEASE_DIR := out
61+
BUILD_DIR := .build
62+
OVERRIDES_DIR := $(HOME)/.cluster-api/overrides/infrastructure-vsphere/$(VERSION)
63+
64+
# Define Docker related variables. Releases should modify and double check these vars.
65+
REGISTRY ?= gcr.io/$(shell gcloud config get-value project)
66+
PROD_REGISTRY := gcr.io/cluster-api-provider-vsphere/release
67+
IMAGE_NAME ?= manager
68+
DEV_CONTROLLER_IMG ?= $(REGISTRY)/vsphere-$(IMAGE_NAME)
69+
RELEASE_CONTROLLER_IMG := gcr.io/cluster-api-provider-vsphere/release/$(IMAGE_NAME)
70+
DEV_TAG ?= dev
71+
ARCH ?= amd64
72+
DEV_MANIFEST_IMG=$(DEV_CONTROLLER_IMG)-$(ARCH)
73+
ALL_ARCH = amd64 arm arm64 ppc64le s390x
74+
# Allow overriding the imagePullPolicy
75+
PULL_POLICY ?= Always
76+
77+
78+
5579
## --------------------------------------
5680
## Help
5781
## --------------------------------------
@@ -179,24 +203,82 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
179203
## Release
180204
## --------------------------------------
181205

182-
.PHONY: release-manifests
183-
release-manifests: ## Builds the manifests to publish with a release
206+
$(RELEASE_DIR):
207+
@mkdir -p $(RELEASE_DIR)
208+
209+
210+
$(BUILD_DIR):
211+
@mkdir -p $(BUILD_DIR)
212+
213+
$(OVERRIDES_DIR):
214+
@mkdir -p $(OVERRIDES_DIR)
215+
216+
.PHONY: dev-version-check
217+
dev-version-check:
184218
ifndef VERSION
185-
$(error VERSION is undefined)
219+
$(error VERSION must be set)
186220
endif
187-
@mkdir -p out
188-
cd config/manager/; ../../"$(KUSTOMIZE)" edit set image gcr.io/cluster-api-provider-vsphere/release/manager:"$(VERSION)"
189-
"$(KUSTOMIZE)" build config/default > out/infrastructure-components.yaml
221+
222+
223+
.PHONY: release-version-check
224+
release-version-check:
225+
ifeq ($(VERSION), 0.0.0)
226+
$(error VERSION must be >0.0.0 for release)
227+
endif
228+
229+
.PHONY: release-manifests
230+
release-manifests:
231+
$(MAKE) manifests STAGE=release MANIFEST_DIR=$(RELEASE_DIR) PULL_POLICY=IfNotPresent IMAGE=$(RELEASE_CONTROLLER_IMG):$(VERSION)
232+
233+
.PHONY: release-overrides
234+
release-overrides:
235+
$(MAKE) manifests STAGE=release MANIFEST_DIR=$(OVERRIDES_DIR) PULL_POLICY=IfNotPresent IMAGE=$(RELEASE_CONTROLLER_IMG):$(VERSION)
236+
237+
.PHONY: dev-manifests
238+
dev-manifests:
239+
$(MAKE) manifests STAGE=dev MANIFEST_DIR=$(OVERRIDES_DIR) PULL_POLICY=Always IMAGE=$(DEV_CONTROLLER_IMG):$(DEV_TAG)
240+
241+
.PHONY: manifests
242+
manifests: $(STAGE)-version-check $(STAGE)-flavors $(MANIFEST_DIR) $(BUILD_DIR) $(KUSTOMIZE)
243+
rm -rf $(BUILD_DIR)/config
244+
cp -R config $(BUILD_DIR)
245+
sed -i'' -e 's@imagePullPolicy: .*@imagePullPolicy: '"$(PULL_POLICY)"'@' $(BUILD_DIR)/config/manager/manager_pull_policy.yaml
246+
sed -i'' -e 's@image: .*@image: '"$(IMAGE)"'@' $(BUILD_DIR)/config/manager/manager_image_patch.yaml
247+
"$(KUSTOMIZE)" build $(BUILD_DIR)/config > $(MANIFEST_DIR)/infrastructure-components.yaml
248+
190249
## --------------------------------------
191250
## Cleanup / Verification
192251
## --------------------------------------
193252

253+
.PHONY: flavors
254+
flavors: $(FLAVOR_DIR)
255+
go run ./packaging/flavorgen -f multi-host > $(FLAVOR_DIR)/cluster-template.yaml
256+
go run ./packaging/flavorgen -f single-host > $(FLAVOR_DIR)/cluster-template-singlehostcontrolplane.yaml
257+
258+
.PHONY: release-flavors ## Create release flavor manifests
259+
release-flavors: release-version-check
260+
$(MAKE) flavors FLAVOR_DIR=$(RELEASE_DIR)
261+
262+
.PHONY: dev-flavors ## Create release flavor manifests
263+
dev-flavors:
264+
$(MAKE) flavors FLAVOR_DIR=$(OVERRIDES_DIR)
265+
266+
.PHONY: overrides ## Generates flavors as clusterctl overrides
267+
overrides: version-check $(OVERRIDES_DIR)
268+
go run ./packaging/flavorgen -f multi-host > $(OVERRIDES_DIR)/cluster-template.yaml
269+
go run ./packaging/flavorgen -f single-host > $(OVERRIDES_DIR)/cluster-template-singlehostcontrolplane.yaml
270+
194271
.PHONY: clean
195272
clean: ## Run all the clean targets
196273
$(MAKE) clean-bin
197274
$(MAKE) clean-temporary
198275
$(MAKE) clean-release
199276
$(MAKE) clean-examples
277+
$(MAKE) clean-build
278+
279+
.PHONY: clean-build
280+
clean-build:
281+
rm -rf $(BUILD_DIR)
200282

201283
.PHONY: clean-bin
202284
clean-bin: ## Remove all generated binaries
@@ -238,3 +320,15 @@ verify-crds: ## Verifies the committed CRDs are up-to-date
238320
check: ## Verify and lint the project
239321
$(MAKE) verify
240322
$(MAKE) lint
323+
324+
## --------------------------------------
325+
## Docker
326+
## --------------------------------------
327+
328+
.PHONY: docker-build
329+
docker-build: ## Build the docker image for controller-manager
330+
docker build --pull --build-arg ARCH=$(ARCH) . -t $(DEV_CONTROLLER_IMG):$(DEV_TAG)
331+
332+
.PHONY: docker-push
333+
docker-push: ## Push the docker image
334+
docker push $(DEV_CONTROLLER_IMG):$(DEV_TAG)

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,37 @@ Check out the [getting started guide](./docs/getting_started.md) for launching a
3131

3232
This provider's versions are compatible with the following versions of Cluster API:
3333

34-
||Cluster API v1alpha1 (v0.1)|Cluster API v1alpha2 (v0.2)|
35-
|---|:---:|:---:|
36-
| CAPV v1alpha1 (v0.3)|||
37-
| CAPV v1alpha1 (v0.4)|||
38-
| CAPV v1alpha2 (v0.5, master)|||
39-
40-
||Kubernetes 1.13|Kubernetes 1.14|Kubernetes 1.15|
41-
|-|:---:|:---:|:---:|
42-
| CAPV v1alpha1 (v0.3)||||
43-
| CAPV v1alpha1 (v0.4)||||
44-
| CAPV v1alpha2 (v0.5, master)||||
34+
| | Cluster API v1alpha1 (v0.1) | Cluster API v1alpha2 (v0.2) |
35+
| ---------------------------- | :-------------------------: | :-------------------------: |
36+
| CAPV v1alpha1 (v0.3) |||
37+
| CAPV v1alpha1 (v0.4) |||
38+
| CAPV v1alpha2 (v0.5, master) |||
39+
40+
| | Kubernetes 1.13 | Kubernetes 1.14 | Kubernetes 1.15 |
41+
| ---------------------------- | :-------------: | :-------------: | :-------------: |
42+
| CAPV v1alpha1 (v0.3) ||||
43+
| CAPV v1alpha1 (v0.4) ||||
44+
| CAPV v1alpha2 (v0.5, master) ||||
4545

4646
**NOTE:** As the versioning for this project is tied to the versioning of Cluster API, future modifications to this policy may be made to more closely align with other providers in the Cluster API ecosystem.
4747

4848
## Kubernetes versions with published OVAs
4949

5050
Note: These OVAs are not updated for security fixes and it is recommended to always use the latest patch version for the Kubernetes version you wish to run. For production-like environments, it is highly recommended to build and use your own custom images.
5151

52+
<<<<<<< HEAD
5253
| Kubernetes | CentOS 7 | Ubuntu 18.04 | Photon 3 |
5354
|:-:|:-:|:-:|:-:|
5455
| v1.15.10 | [ova](http://storage.googleapis.com/capv-images/release/v1.15.10/centos-7-kube-v1.15.10.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.15.10/centos-7-kube-v1.15.10.ova.sha256) | [ova](http://storage.googleapis.com/capv-images/release/v1.15.10/ubuntu-1804-kube-v1.15.10.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.15.10/ubuntu-1804-kube-v1.15.10.ova.sha256) | [ova](http://storage.googleapis.com/capv-images/release/v1.15.10/photon-3-kube-v1.15.10.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.15.10/photon-3-kube-v1.15.10.ova.sha256) |
5556
| v1.16.7 | [ova](http://storage.googleapis.com/capv-images/release/v1.16.7/centos-7-kube-v1.16.7.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.16.7/centos-7-kube-v1.16.7.ova.sha256) | [ova](http://storage.googleapis.com/capv-images/release/v1.16.7/ubuntu-1804-kube-v1.16.7.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.16.7/ubuntu-1804-kube-v1.16.7.ova.sha256) | [ova](http://storage.googleapis.com/capv-images/release/v1.16.7/photon-3-kube-v1.16.7.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.16.7/photon-3-kube-v1.16.7.ova.sha256) |
5657
| v1.17.4 | [ova](http://storage.googleapis.com/capv-images/release/v1.17.4/centos-7-kube-v1.17.4.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.17.4/centos-7-kube-v1.17.4.ova.sha256) | [ova](http://storage.googleapis.com/capv-images/release/v1.17.4/ubuntu-1804-kube-v1.17.4.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.17.4/ubuntu-1804-kube-v1.17.4.ova.sha256) | [ova](http://storage.googleapis.com/capv-images/release/v1.17.4/photon-3-kube-v1.17.4.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.17.4/photon-3-1804-kube-v1.17.4.ova.sha256) |
58+
=======
59+
| Kubernetes | CentOS 7 | Ubuntu 18.04 | Photon 3 |
60+
| :--------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
61+
| v1.14.9 | [ova](http://storage.googleapis.com/capv-images/release/v1.14.9/centos-7-kube-v1.14.9.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.14.9/centos-7-kube-v1.14.9.ova.sha256) | [ova](http://storage.googleapis.com/capv-images/release/v1.14.9/ubuntu-1804-kube-v1.14.9.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.14.9/ubuntu-1804-kube-v1.14.9.ova.sha256) | [ova](http://storage.googleapis.com/capv-images/release/v1.14.9/photon-3-kube-v1.14.9.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.14.9/photon-3-1804-kube-v1.14.9.ova.sha256) |
62+
| v1.15.6 | [ova](http://storage.googleapis.com/capv-images/release/v1.15.6/centos-7-kube-v1.15.6.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.15.6/centos-7-kube-v1.15.6.ova.sha256) | [ova](http://storage.googleapis.com/capv-images/release/v1.15.6/ubuntu-1804-kube-v1.15.6.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.15.6/ubuntu-1804-kube-v1.15.6.ova.sha256) | [ova](http://storage.googleapis.com/capv-images/release/v1.15.6/photon-3-kube-v1.15.6.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.15.6/photon-3-kube-v1.15.6.ova.sha256) |
63+
| v1.16.3 | [ova](http://storage.googleapis.com/capv-images/release/v1.16.3/centos-7-kube-v1.16.3.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.16.3/centos-7-kube-v1.16.3.ova.sha256) | [ova](http://storage.googleapis.com/capv-images/release/v1.16.3/ubuntu-1804-kube-v1.16.3.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.16.3/ubuntu-1804-kube-v1.16.3.ova.sha256) | [ova](http://storage.googleapis.com/capv-images/release/v1.16.3/photon-3-kube-v1.16.3.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.16.3/photon-3-kube-v1.16.3.ova.sha256) |
64+
>>>>>>> wip
5765
5866
A full list of the published machine images for CAPV may be obtained with the following command:
5967

config/default/credentials.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: manager-bootstrap-credentials
5+
namespace: system
6+
type: Opaque
7+
stringData:
8+
username: ${VSPHERE_USERNAME}
9+
password: ${VSPHERE_PASSWORD}

config/default/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace: capv-system
66

77
resources:
88
- namespace.yaml
9+
- credentials.yaml
910
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in crd/kustomization.yaml
1011
#- ../webhook
1112
# [CERTMANAGER] To enable cert-manager, uncomment next line. 'WEBHOOK' components are required.

config/default/manager_credentials_patch.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ spec:
1212
- name: VSPHERE_USERNAME
1313
valueFrom:
1414
secretKeyRef:
15-
name: capv-manager-bootstrap-credentials
15+
name: manager-bootstrap-credentials
1616
key: username
1717
- name: VSPHERE_PASSWORD
1818
valueFrom:
1919
secretKeyRef:
20-
name: capv-manager-bootstrap-credentials
20+
name: manager-bootstrap-credentials
2121
key: password
2222

config/manager/kustomization.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ resources:
44
- manager.yaml
55

66
patchesStrategicMerge:
7-
- manager_auth_proxy_patch.yaml
7+
- manager_auth_proxy_patch.yaml
8+
- manager_image_patch.yaml
9+
- manager_pull_policy.yaml
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: controller-manager
5+
namespace: system
6+
spec:
7+
template:
8+
spec:
9+
containers:
10+
- image: gcr.io/cluster-api-provider-vsphere/release/manager:latest
11+
name: manager
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: controller-manager
5+
namespace: system
6+
spec:
7+
template:
8+
spec:
9+
containers:
10+
- name: manager
11+
imagePullPolicy: IfNotPresent
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
varReference:
2+
- path: metadata/annotations
23
- kind: Deployment
34
path: spec/template/spec/volumes/secret/secretName
5+
- kind: Deployment
6+
path: spec/template/spec/volumes/0/secret/secretName
7+
- kind: Deployment
8+
path: spec/template/spec/volumes/1/secret/secretName

0 commit comments

Comments
 (0)