Skip to content

Commit 9eafc6e

Browse files
authored
Merge pull request #1 from kubernetes-sigs/master
Sync fork to version 0.4.2
2 parents cc16ce1 + 259ffb2 commit 9eafc6e

Some content is hidden

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

56 files changed

+3775
-579
lines changed

.dockerignore

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
.git
2-
.github
3-
.vscode
4-
bin/
5-
config/
6-
hack/
7-
docs/
8-
templates/
9-
scripts/
10-
**/.md
11-
tilt-provider.json
1+
# Ignore everything
2+
**
3+
4+
# Allow only these
5+
!/api/**
6+
!/cloud/**
7+
!/controllers/**
8+
!/pkg/**
9+
!/main.go
10+
!/go.mod
11+
!/go.sum

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ bazel-*
4949

5050
# Tilt files.
5151
.tiltbuild
52+
/tilt.d
53+
tilt-settings.json
5254

5355
# e2e output
5456
test/e2e/junit.e2e_suite.*.xml
55-
test/e2e/logs/*
57+
test/e2e/logs/*
58+
_artifacts

Makefile

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,22 @@ export GO111MODULE=on
3434
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
3535
TOOLS_DIR := hack/tools
3636
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
37+
TEMPLATES_DIR := $(ROOT_DIR)/templates
3738
BIN_DIR := bin
39+
RELEASE_NOTES_BIN := bin/release-notes
3840

3941
# Binaries.
4042
CLUSTERCTL := $(BIN_DIR)/clusterctl
4143
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
44+
CONVERSION_GEN := $(TOOLS_BIN_DIR)/conversion-gen
4245
ENVSUBST := $(TOOLS_BIN_DIR)/envsubst
46+
ETCD=$(TOOLS_BIN_DIR)/etcd
4347
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint
44-
MOCKGEN := $(TOOLS_BIN_DIR)/mockgen
45-
CONVERSION_GEN := $(TOOLS_BIN_DIR)/conversion-gen
46-
KUBECTL=$(TOOLS_BIN_DIR)/kubectl
4748
KUBE_APISERVER=$(TOOLS_BIN_DIR)/kube-apiserver
48-
ETCD=$(TOOLS_BIN_DIR)/etcd
49+
KUBECTL=$(TOOLS_BIN_DIR)/kubectl
50+
KUSTOMIZE := $(abspath $(TOOLS_BIN_DIR)/kustomize)
51+
MOCKGEN := $(TOOLS_BIN_DIR)/mockgen
52+
RELEASE_NOTES := $(TOOLS_DIR)/$(RELEASE_NOTES_BIN)
4953

5054
# Define Docker related variables. Releases should modify and double check these vars.
5155
REGISTRY ?= gcr.io/$(shell gcloud config get-value project)
@@ -66,6 +70,8 @@ RBAC_ROOT ?= $(MANIFEST_ROOT)/rbac
6670
# Allow overriding the imagePullPolicy
6771
PULL_POLICY ?= Always
6872

73+
CLUSTER_TEMPLATE ?= cluster-template.yaml
74+
6975
## --------------------------------------
7076
## Help
7177
## --------------------------------------
@@ -120,18 +126,21 @@ $(CLUSTERCTL): go.mod ## Build clusterctl binary.
120126
$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod # Build controller-gen from tools folder.
121127
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen
122128

129+
$(CONVERSION_GEN): $(TOOLS_DIR)/go.mod
130+
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/conversion-gen k8s.io/code-generator/cmd/conversion-gen
131+
123132
$(ENVSUBST): $(TOOLS_DIR)/go.mod # Build envsubst from tools folder.
124133
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/envsubst github.com/a8m/envsubst/cmd/envsubst
125134

126135
$(GOLANGCI_LINT): $(TOOLS_DIR)/go.mod # Build golangci-lint from tools folder.
127136
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
128137

138+
$(KUSTOMIZE): $(TOOLS_DIR)/go.mod # Build kustomize from tools folder.
139+
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/kustomize sigs.k8s.io/kustomize/kustomize/v3
140+
129141
$(MOCKGEN): $(TOOLS_DIR)/go.mod # Build mockgen from tools folder.
130142
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/mockgen github.com/golang/mock/mockgen
131143

132-
$(CONVERSION_GEN): $(TOOLS_DIR)/go.mod
133-
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/conversion-gen k8s.io/code-generator/cmd/conversion-gen
134-
135144
$(RELEASE_NOTES) : $(TOOLS_DIR)/go.mod
136145
cd $(TOOLS_DIR) && go build -tags tools -o $(BIN_DIR)/release-notes sigs.k8s.io/cluster-api/hack/tools/release
137146

@@ -159,6 +168,7 @@ modules: ## Runs go mod to ensure proper vendoring.
159168
generate: ## Generate code
160169
$(MAKE) generate-go
161170
$(MAKE) generate-manifests
171+
$(MAKE) generate-flavors
162172

163173
.PHONY: generate-go
164174
generate-go: $(CONTROLLER_GEN) $(MOCKGEN) $(CONVERSION_GEN) ## Runs Go related generate targets
@@ -185,6 +195,10 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
185195
output:rbac:dir=$(RBAC_ROOT) \
186196
rbac:roleName=manager-role
187197

198+
.PHONY: generate-flavors ## Generate template flavors
199+
generate-flavors: $(KUSTOMIZE)
200+
./hack/gen-flavors.sh
201+
188202
## --------------------------------------
189203
## Docker
190204
## --------------------------------------
@@ -254,11 +268,16 @@ release: clean-release ## Builds and push container images using the latest git
254268
$(MAKE) set-manifest-image MANIFEST_IMG=$(PROD_REGISTRY)/$(IMAGE_NAME) MANIFEST_TAG=$(RELEASE_TAG)
255269
$(MAKE) set-manifest-pull-policy PULL_POLICY=IfNotPresent
256270
$(MAKE) release-manifests
271+
$(MAKE) release-templates
257272

258273
.PHONY: release-manifests
259-
release-manifests: $(RELEASE_DIR) ## Builds the manifests to publish with a release
274+
release-manifests: $(KUSTOMIZE) $(RELEASE_DIR) ## Builds the manifests to publish with a release
260275
kustomize build config > $(RELEASE_DIR)/infrastructure-components.yaml
261276

277+
.PHONY: release-templates
278+
release-templates: $(RELEASE_DIR)
279+
cp templates/cluster-template* $(RELEASE_DIR)/
280+
262281
.PHONY: release-binary
263282
release-binary: $(RELEASE_DIR)
264283
docker run \
@@ -291,9 +310,9 @@ release-notes: $(RELEASE_NOTES)
291310
## --------------------------------------
292311

293312
.PHONY: create-management-cluster
294-
create-management-cluster: $(ENVSUBST)
313+
create-management-cluster: $(KUSTOMIZE) $(ENVSUBST)
295314
## Create kind management cluster.
296-
kind create cluster --name=clusterapi
315+
$(MAKE) kind-create
297316

298317
# Install cert manager and wait for availability
299318
kubectl create -f https://github.com/jetstack/cert-manager/releases/download/v0.11.1/cert-manager.yaml
@@ -303,7 +322,8 @@ create-management-cluster: $(ENVSUBST)
303322
kubectl apply -f https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.3/cluster-api-components.yaml
304323

305324
# Deploy CAPZ
306-
kustomize build config | $(ENVSUBST) | kubectl apply -f -
325+
kind load docker-image $(CONTROLLER_IMG)-$(ARCH):$(TAG) --name=capz
326+
$(KUSTOMIZE) build config | $(ENVSUBST) | kubectl apply -f -
307327

308328
# Wait for CAPI pods
309329
kubectl wait --for=condition=Ready --timeout=5m -n capi-system pod -l cluster.x-k8s.io/provider=cluster-api
@@ -312,24 +332,24 @@ create-management-cluster: $(ENVSUBST)
312332

313333
# Wait for CAPZ pods
314334
kubectl wait --for=condition=Ready --timeout=5m -n capz-system pod -l cluster.x-k8s.io/provider=infrastructure-azure
315-
316-
# required sleep for when creating management and workload cluster simultaneously
335+
336+
# required sleep for when creating management and workload cluster simultaneously
317337
sleep 10
318-
@echo 'Set kubectl context to the kind management cluster by running "kubectl config set-context kind-clusterapi"'
338+
@echo 'Set kubectl context to the kind management cluster by running "kubectl config set-context kind-capz"'
319339

320340
.PHONY: create-workload-cluster
321-
create-workload-cluster: $(ENVSUBST)
341+
create-workload-cluster: $(KUSTOMIZE) $(ENVSUBST)
322342
# Create workload Cluster.
323-
kustomize build templates | $(ENVSUBST) | kubectl apply -f -
343+
$(ENVSUBST) < $(TEMPLATES_DIR)/$(CLUSTER_TEMPLATE) | kubectl apply -f -
324344

325345
# Wait for the kubeconfig to become available.
326346
timeout 300 bash -c "while ! kubectl get secrets | grep $(CLUSTER_NAME)-kubeconfig; do sleep 1; done"
327347
# Get kubeconfig and store it locally.
328348
kubectl get secrets $(CLUSTER_NAME)-kubeconfig -o json | jq -r .data.value | base64 --decode > ./kubeconfig
329-
timeout 300 bash -c "while ! kubectl --kubeconfig=./kubeconfig get nodes | grep master; do sleep 1; done"
349+
timeout 600 bash -c "while ! kubectl --kubeconfig=./kubeconfig get nodes | grep master; do sleep 1; done"
330350

331351
# Deploy calico
332-
kubectl --kubeconfig=./kubeconfig apply -f https://docs.projectcalico.org/v3.13/manifests/calico.yaml
352+
kubectl --kubeconfig=./kubeconfig apply -f templates/addons/calico.yaml
333353

334354
@echo 'run "kubectl --kubeconfig=./kubeconfig ..." to work with the new target cluster'
335355

@@ -340,14 +360,27 @@ create-cluster: create-management-cluster create-workload-cluster ## Create a wo
340360
delete-workload-cluster: ## Deletes the example workload Kubernetes cluster
341361
@echo 'Your Azure resources will now be deleted, this can take up to 20 minutes'
342362
kubectl delete cluster $(CLUSTER_NAME)
343-
363+
364+
## --------------------------------------
365+
## Tilt / Kind
366+
## --------------------------------------
367+
368+
.PHONY: kind-create
369+
kind-create: ## create capz kind cluster if needed
370+
./scripts/kind-with-registry.sh
371+
372+
.PHONY: tilt-up
373+
tilt-up: kind-create ## start tilt and build kind cluster if needed
374+
tilt up
375+
344376
.PHONY: delete-cluster
345-
delete-cluster: delete-workload-cluster ## Deletes the example kind cluster "clusterapi"
346-
kind delete cluster --name=clusterapi
377+
delete-cluster: delete-workload-cluster ## Deletes the example kind cluster "capz"
378+
kind delete cluster --name=capz
347379

348380
.PHONY: kind-reset
349-
kind-reset: ## Destroys the "clusterapi" kind cluster.
350-
kind delete cluster --name=clusterapi || true
381+
kind-reset: ## Destroys the "capz" kind cluster.
382+
kind delete cluster --name=capz || true
383+
351384

352385
## --------------------------------------
353386
## Cleanup / Verification

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,19 @@ TODO
2929

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

32-
| | Cluster API `v1alpha1` (`v0.1.x`) | Cluster API `v1alpha2` (`v0.2.x`) | Cluster API `v1alpha3` (`v0.3.x`) |
33-
|---|---|---|---|
34-
|Azure Provider `v0.2.x` || | |
35-
|Azure Provider `v0.3.x` | || |
36-
|Azure Provider `v0.4.x` | | ||
32+
| | Cluster API `v1alpha2` (`v0.2.x`) | Cluster API `v1alpha3` (`v0.3.x`) |
33+
|---|---|---|
34+
|Azure Provider `v0.3.x` || |
35+
|Azure Provider `v0.4.x` | ||
3736

3837
This provider's versions are able to install and manage the following versions of Kubernetes:
3938

40-
| | Azure Provider `v0.2.x` | Azure Provider `v0.3.x` | Azure Provider `v0.4.x` |
41-
|---|---|---|---|
42-
| Kubernetes 1.13 || | |
43-
| Kubernetes 1.14 ||| |
44-
| Kubernetes 1.15 ||||
45-
| Kubernetes 1.16 | |||
46-
| Kubernetes 1.17 | | ||
39+
| | Azure Provider `v0.3.x` | Azure Provider `v0.4.x` |
40+
|---|---|---|
41+
| Kubernetes 1.15 || |
42+
| Kubernetes 1.16 |||
43+
| Kubernetes 1.17 | ||
44+
| Kubernetes 1.18 | ||
4745

4846
Each version of Cluster API for Azure will attempt to support at least two Kubernetes versions e.g., Cluster API for Azure `v0.1` may support Kubernetes 1.13 and Kubernetes 1.14.
4947

0 commit comments

Comments
 (0)