Skip to content

Commit

Permalink
flavorgen: Adds a generator for clusterctl template flavors
Browse files Browse the repository at this point in the history
Signed-off-by: Naadir Jeewa <[email protected]>
  • Loading branch information
Naadir Jeewa committed Feb 27, 2020
1 parent 93ffc39 commit cd5ed7f
Show file tree
Hide file tree
Showing 32 changed files with 1,129 additions and 566 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ out/

# Ignore Goland files
.idea/

.build
.tiltbuild
119 changes: 109 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ SHELL := /usr/bin/env bash

.DEFAULT_GOAL := help

VERSION ?= $(shell cat clusterctl-settings.json | jq .config.nextVersion -r)

# Use GOPROXY environment variable if set
GOPROXY := $(shell go env GOPROXY)
ifeq (,$(strip $(GOPROXY)))
Expand All @@ -31,8 +33,9 @@ export GOPROXY
export GO111MODULE := on

# Directories
BIN_DIR := bin
TOOLS_DIR := hack/tools
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
BIN_DIR := $(ROOT_DIR)/bin
TOOLS_DIR := $(ROOT_DIR)/hack/tools
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin

# Binaries
Expand All @@ -51,6 +54,35 @@ CRD_ROOT ?= $(MANIFEST_ROOT)/crd/bases
WEBHOOK_ROOT ?= $(MANIFEST_ROOT)/webhook
RBAC_ROOT ?= $(MANIFEST_ROOT)/rbac
GC_KIND ?= true
RELEASE_DIR := out
BUILD_DIR := .build
OVERRIDES_DIR := $(HOME)/.cluster-api/overrides/infrastructure-vsphere/$(VERSION)

# Architecture variables
ARCH ?= amd64
ALL_ARCH = amd64 arm arm64 ppc64le s390x

# Common docker variables
IMAGE_NAME ?= manager
PULL_POLICY ?= Always
# Hosts running SELinux need :z added to volume mounts
SELINUX_ENABLED := $(shell cat /sys/fs/selinux/enforce 2> /dev/null || echo 0)

ifeq ($(SELINUX_ENABLED),1)
DOCKER_VOL_OPTS?=:z
endif


# Release docker variables
RELEASE_REGISTRY := gcr.io/cluster-api-provider-vsphere/release
RELEASE_CONTROLLER_IMG := $(RELEASE_REGISTRY)/$(IMAGE_NAME)

# Development Docker variables
DEV_REGISTRY ?= gcr.io/$(shell gcloud config get-value project)
DEV_CONTROLLER_IMG ?= $(DEV_REGISTRY)/vsphere-$(IMAGE_NAME)
DEV_TAG ?= dev
DEV_MANIFEST_IMG := $(DEV_CONTROLLER_IMG)-$(ARCH)


## --------------------------------------
## Help
Expand All @@ -74,7 +106,7 @@ e2e-image: ## Build the e2e manager image
.PHONY: e2e
e2e: e2e-image
e2e: ## Run e2e tests
time ginkgo -v ./test/e2e -- --e2e.config="$(abspath test/e2e/e2e.conf)" --e2e.teardownKind=$(GC_KIND)
time ginkgo -v ./test/e2e -- --e2e.config="$(abspath test/e2e/e2e.conf)" --e2e.teardownKind=$(GC_KIND) $(E2E_ARGS)

## --------------------------------------
## Binaries
Expand Down Expand Up @@ -122,7 +154,7 @@ lint-go-full: lint-go ## Run slower linters to detect possible issues

.PHONY: lint-markdown
lint-markdown: ## Lint the project's markdown
docker run --rm -v "$$(pwd)":/build gcr.io/cluster-api-provider-vsphere/extra/mdlint:0.17.0 -- /md/lint -i vendor -i contrib/haproxy/openapi .
docker run --rm -v "$$(pwd)":/build$(DOCKER_VOL_OPTS) gcr.io/cluster-api-provider-vsphere/extra/mdlint:0.17.0 -- /md/lint -i vendor -i contrib/haproxy/openapi .

.PHONY: lint-shell
lint-shell: ## Lint the project's shell scripts
Expand Down Expand Up @@ -179,24 +211,79 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
## Release
## --------------------------------------

.PHONY: release-manifests
release-manifests: ## Builds the manifests to publish with a release
$(RELEASE_DIR):
@mkdir -p $(RELEASE_DIR)


$(BUILD_DIR):
@mkdir -p $(BUILD_DIR)

$(OVERRIDES_DIR):
@mkdir -p $(OVERRIDES_DIR)

.PHONY: dev-version-check
dev-version-check:
ifndef VERSION
$(error VERSION is undefined)
$(error VERSION must be set)
endif
@mkdir -p out
cd config/manager/; ../../"$(KUSTOMIZE)" edit set image gcr.io/cluster-api-provider-vsphere/release/manager:"$(VERSION)"
"$(KUSTOMIZE)" build config/default > out/infrastructure-components.yaml

.PHONY: release-version-check
release-version-check:
ifeq ($(VERSION), 0.0.0)
$(error VERSION must be >0.0.0 for release)
endif

.PHONY: release-manifests
release-manifests:
$(MAKE) manifests STAGE=release MANIFEST_DIR=$(RELEASE_DIR) PULL_POLICY=IfNotPresent IMAGE=$(RELEASE_CONTROLLER_IMG):$(VERSION)

.PHONY: release-overrides
release-overrides:
$(MAKE) manifests STAGE=release MANIFEST_DIR=$(OVERRIDES_DIR) PULL_POLICY=IfNotPresent IMAGE=$(RELEASE_CONTROLLER_IMG):$(VERSION)

.PHONY: dev-manifests
dev-manifests:
$(MAKE) manifests STAGE=dev MANIFEST_DIR=$(OVERRIDES_DIR) PULL_POLICY=Always IMAGE=$(DEV_CONTROLLER_IMG):$(DEV_TAG)

.PHONY: manifests
manifests: $(STAGE)-version-check $(STAGE)-flavors $(MANIFEST_DIR) $(BUILD_DIR) $(KUSTOMIZE)
rm -rf $(BUILD_DIR)/config
cp -R config $(BUILD_DIR)
sed -i'' -e 's@imagePullPolicy: .*@imagePullPolicy: '"$(PULL_POLICY)"'@' $(BUILD_DIR)/config/manager/manager_pull_policy.yaml
sed -i'' -e 's@image: .*@image: '"$(IMAGE)"'@' $(BUILD_DIR)/config/manager/manager_image_patch.yaml
"$(KUSTOMIZE)" build $(BUILD_DIR)/config > $(MANIFEST_DIR)/infrastructure-components.yaml

## --------------------------------------
## Cleanup / Verification
## --------------------------------------

.PHONY: flavors
flavors: $(FLAVOR_DIR)
go run ./packaging/flavorgen -f multi-host > $(FLAVOR_DIR)/cluster-template.yaml

.PHONY: release-flavors ## Create release flavor manifests
release-flavors: release-version-check
$(MAKE) flavors FLAVOR_DIR=$(RELEASE_DIR)

.PHONY: dev-flavors ## Create release flavor manifests
dev-flavors:
$(MAKE) flavors FLAVOR_DIR=$(OVERRIDES_DIR)

.PHONY: overrides ## Generates flavors as clusterctl overrides
overrides: version-check $(OVERRIDES_DIR)
go run ./packaging/flavorgen -f multi-host > $(OVERRIDES_DIR)/cluster-template.yaml

.PHONY: clean
clean: ## Run all the clean targets
$(MAKE) clean-bin
$(MAKE) clean-temporary
$(MAKE) clean-release
$(MAKE) clean-examples
$(MAKE) clean-build

.PHONY: clean-build
clean-build:
rm -rf $(BUILD_DIR)

.PHONY: clean-bin
clean-bin: ## Remove all generated binaries
Expand Down Expand Up @@ -238,3 +325,15 @@ verify-crds: ## Verifies the committed CRDs are up-to-date
check: ## Verify and lint the project
$(MAKE) verify
$(MAKE) lint

## --------------------------------------
## Docker
## --------------------------------------

.PHONY: docker-build
docker-build: ## Build the docker image for controller-manager
docker build --pull --build-arg ARCH=$(ARCH) . -t $(DEV_CONTROLLER_IMG):$(DEV_TAG)

.PHONY: docker-push
docker-push: ## Push the docker image
docker push $(DEV_CONTROLLER_IMG):$(DEV_TAG)
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,29 @@ Check out the [getting started guide](./docs/getting_started.md) for launching a

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

||Cluster API v1alpha1 (v0.1)|Cluster API v1alpha2 (v0.2)|
|---|:---:|:---:|
| CAPV v1alpha1 (v0.3)|||
| CAPV v1alpha1 (v0.4)|||
| CAPV v1alpha2 (v0.5, master)|||

||Kubernetes 1.13|Kubernetes 1.14|Kubernetes 1.15|
|-|:---:|:---:|:---:|
| CAPV v1alpha1 (v0.3)||||
| CAPV v1alpha1 (v0.4)||||
| CAPV v1alpha2 (v0.5, master)||||
| | Cluster API v1alpha1 (v0.1) | Cluster API v1alpha2 (v0.2) |
| ---------------------------- | :-------------------------: | :-------------------------: |
| CAPV v1alpha1 (v0.3) |||
| CAPV v1alpha1 (v0.4) |||
| CAPV v1alpha2 (v0.5, master) |||

| | Kubernetes 1.13 | Kubernetes 1.14 | Kubernetes 1.15 |
| ---------------------------- | :-------------: | :-------------: | :-------------: |
| CAPV v1alpha1 (v0.3) ||||
| CAPV v1alpha1 (v0.4) ||||
| CAPV v1alpha2 (v0.5, master) ||||

**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.

## Kubernetes versions with published OVAs

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.

| Kubernetes | CentOS 7 | Ubuntu 18.04 | Photon 3 |
|:-:|:-:|:-:|:-:|
| 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) |
| 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) |
| 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) |
| Kubernetes | CentOS 7 | Ubuntu 18.04 | Photon 3 |
| :--------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| 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) |
| 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) |
| v1.17.3 | [ova](http://storage.googleapis.com/capv-images/release/v1.17.3/centos-7-kube-v1.17.3.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.17.3/centos-7-kube-v1.17.3.ova.sha256) | [ova](http://storage.googleapis.com/capv-images/release/v1.17.3/ubuntu-1804-kube-v1.17.3.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.17.3/ubuntu-1804-kube-v1.17.3.ova.sha256) | [ova](http://storage.googleapis.com/capv-images/release/v1.17.3/photon-3-kube-v1.17.3.ova), [sha256](http://storage.googleapis.com/capv-images/release/v1.17.3/photon-3-1804-kube-v1.17.3.ova.sha256) |

A full list of the published machine images for CAPV may be obtained with the following command:

Expand Down
9 changes: 9 additions & 0 deletions config/default/credentials.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: manager-bootstrap-credentials
namespace: system
type: Opaque
stringData:
username: ${VSPHERE_USERNAME}
password: ${VSPHERE_PASSWORD}
1 change: 1 addition & 0 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace: capv-system

resources:
- namespace.yaml
- credentials.yaml
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in crd/kustomization.yaml
#- ../webhook
# [CERTMANAGER] To enable cert-manager, uncomment next line. 'WEBHOOK' components are required.
Expand Down
4 changes: 2 additions & 2 deletions config/default/manager_credentials_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ spec:
- name: VSPHERE_USERNAME
valueFrom:
secretKeyRef:
name: capv-manager-bootstrap-credentials
name: manager-bootstrap-credentials
key: username
- name: VSPHERE_PASSWORD
valueFrom:
secretKeyRef:
name: capv-manager-bootstrap-credentials
name: manager-bootstrap-credentials
key: password

4 changes: 3 additions & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ resources:
- manager.yaml

patchesStrategicMerge:
- manager_auth_proxy_patch.yaml
- manager_auth_proxy_patch.yaml
- manager_image_patch.yaml
- manager_pull_policy.yaml
11 changes: 11 additions & 0 deletions config/manager/manager_image_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
containers:
- image: gcr.io/cluster-api-provider-vsphere/release/manager:latest
name: manager
11 changes: 11 additions & 0 deletions config/manager/manager_pull_policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
containers:
- name: manager
imagePullPolicy: IfNotPresent
1 change: 0 additions & 1 deletion config/webhook/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ vars:
kind: Service
version: v1
name: webhook-service

3 changes: 2 additions & 1 deletion config/webhook/manager_webhook_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spec:
args:
- "--metrics-addr=127.0.0.1:8080"
- "--webhook-port=9443"
- "--enable-leader-election=false"
ports:
- containerPort: 443
name: webhook-server
Expand All @@ -23,4 +24,4 @@ spec:
- name: cert
secret:
defaultMode: 420
secretName: $(SERVICE_NAME)-cert
secretName: capv-webhook-service-cert
Empty file removed config/webhook/manifests.yaml
Empty file.
4 changes: 2 additions & 2 deletions controllers/vspherecluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,14 @@ func (r clusterReconciler) reconcileLoadBalancer(ctx *context.ClusterContext) (b
loadBalancer.SetKind(loadBalancerRef.Kind)
loadBalancer.SetAPIVersion(loadBalancerRef.APIVersion)
loadBalancerKey := types.NamespacedName{
Namespace: loadBalancerRef.Namespace,
Namespace: ctx.VSphereCluster.GetNamespace(),
Name: loadBalancerRef.Name,
}
if err := ctx.Client.Get(ctx, loadBalancerKey, loadBalancer); err != nil {
if apierrors.IsNotFound(err) {
ctx.Logger.Info("resource specified by LoadBalancerRef not found",
"load-balancer-gvk", loadBalancerRef.APIVersion,
"load-balancer-namespace", loadBalancerRef.Namespace,
"load-balancer-namespace", ctx.VSphereCluster.GetNamespace(),
"load-balancer-name", loadBalancerRef.Name)
return false, nil
}
Expand Down
Loading

0 comments on commit cd5ed7f

Please sign in to comment.