@@ -48,7 +48,7 @@ RELEASE_NOTES := $(TOOLS_DIR)/$(RELEASE_NOTES_BIN)
48
48
GINKGO := $(abspath $(TOOLS_BIN_DIR ) /ginkgo)
49
49
50
50
# Define Docker related variables. Releases should modify and double check these vars.
51
- REGISTRY ?= gcr.io/$( shell gcloud config get-value project)
51
+ REGISTRY ?= gcr.io/k8s-staging-capi-openstack
52
52
STAGING_REGISTRY := gcr.io/k8s-staging-capi-openstack
53
53
PROD_REGISTRY := us.gcr.io/k8s-artifacts-prod/capi-openstack
54
54
IMAGE_NAME ?= capi-openstack-controller
@@ -64,7 +64,7 @@ WEBHOOK_ROOT ?= $(MANIFEST_ROOT)/webhook
64
64
RBAC_ROOT ?= $(MANIFEST_ROOT ) /rbac
65
65
66
66
# Allow overriding the imagePullPolicy
67
- PULL_POLICY ?= Always
67
+ PULL_POLICY ?= IfNotPresent
68
68
69
69
# Hosts running SELinux need :z added to volume mounts
70
70
SELINUX_ENABLED := $(shell cat /sys/fs/selinux/enforce 2> /dev/null || echo 0)
76
76
# Set build time variables including version details
77
77
LDFLAGS := $(shell source ./hack/version.sh; version::ldflags)
78
78
79
- # Check if binaries exist
80
- HAS_YQ := $(shell command -v yq;)
81
-
82
79
# # --------------------------------------
83
80
# # Help
84
81
# # --------------------------------------
@@ -95,7 +92,7 @@ help: ## Display this help
95
92
images : docker-build # # Build all images
96
93
97
94
.PHONY : check
98
- check : modules generate lint-full test
95
+ check : modules generate lint-full test verify
99
96
100
97
# # --------------------------------------
101
98
# # Testing
@@ -104,28 +101,11 @@ check: modules generate lint-full test
104
101
.PHONY : test
105
102
test : generate lint # # Run tests
106
103
$(MAKE ) test-go
107
- $(MAKE ) test-generate-examples
108
104
109
105
.PHONY : test-go
110
106
test-go : # # Run golang tests
111
107
go test -v ./...
112
108
113
- .PHONY : test-generate-examples
114
- # See:
115
- # * https://github.com/mikefarah/yq/issues/291
116
- # * https://github.com/mikefarah/yq/issues/289
117
- test-generate-examples : $(KUSTOMIZE ) $(ENVSUBST )
118
- ifndef HAS_YQ
119
- echo "installing yq"
120
- GO111MODULE=on go get github.com/mikefarah/yq/v2
121
- endif
122
- # Create a dummy file for test only
123
- mkdir -p tmp/dummy-make-auto-test
124
- echo 'clouds' > tmp/dummy-make-auto-test/dummy-clouds-test.yaml
125
- PATH=$(TOOLS_DIR)/$(BIN_DIR):${PATH} examples/generate.sh -f tmp/dummy-make-auto-test/dummy-clouds-test.yaml openstack tmp/dummy-make-auto-test/_out
126
- # the folder will be generated under same folder of examples
127
- rm -rf tmp/dummy-make-auto-test
128
-
129
109
# # --------------------------------------
130
110
# # Binaries
131
111
# # --------------------------------------
@@ -217,14 +197,6 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
217
197
output:rbac:dir=$(RBAC_ROOT ) \
218
198
rbac:roleName=manager-role
219
199
220
- .PHONY : generate-examples
221
- generate-examples : clean-examples # # Generate examples configurations to run a cluster.
222
- ifndef HAS_YQ
223
- echo "installing yq"
224
- GO111MODULE=on go get github.com/mikefarah/yq/v2
225
- endif
226
- ./examples/generate.sh -f ${OPENSTACK_CONFIG_FILE} ${CLUSTER_NAME} ./examples/_out single-node
227
-
228
200
# # --------------------------------------
229
201
# # Docker
230
202
# # --------------------------------------
@@ -318,49 +290,93 @@ release-notes: $(RELEASE_NOTES)
318
290
# # Development
319
291
# # --------------------------------------
320
292
321
- # This is used in the get-kubeconfig call below in the create-cluster target. It may be overridden by the
322
- # e2e-conformance.sh script, which is why we need it as a variable here.
323
- CLUSTER_NAME ?= test1
293
+ # Properties for create-cluster
294
+ OPENSTACK_CONTROLPLANE_IP ?= "192.168.200.195"
295
+ OPENSTACK_FAILURE_DOMAIN ?= "nova"
296
+ OPENSTACK_CLOUD ?= "capi-quickstart"
297
+ OPENSTACK_CLOUD_CACERT_B64 ?= "Cg=="
298
+ OPENSTACK_CLOUD_PROVIDER_CONF_B64 ?= ""
299
+ OPENSTACK_CLOUD_YAML_B64 ?= ""
300
+ OPENSTACK_EXTERNAL_NETWORK_ID ?= ""
301
+ OPENSTACK_DNS_NAMESERVERS ?= "192.168.200.1"
302
+ OPENSTACK_IMAGE_NAME ?= "ubuntu-1910-kube-v1.17.3"
303
+ OPENSTACK_SSH_AUTHORIZED_KEY ?= ""
304
+ OPENSTACK_NODE_MACHINE_FLAVOR ?= "m1.medium"
305
+ OPENSTACK_CONTROL_PLANE_MACHINE_FLAVOR ?= "m1.medium"
306
+ CLUSTER_NAME ?= "capi-quickstart"
307
+ OPENSTACK_CLUSTER_TEMPLATE ?= "./templates/cluster-template-without-lb.yaml"
308
+ KUBERNETES_VERSION ?= "v1.17.3"
309
+ CONTROL_PLANE_MACHINE_COUNT ?= "1"
310
+ WORKER_MACHINE_COUNT ?= "3"
311
+ LOAD_IMAGE =$(CONTROLLER_IMG ) -$(ARCH ) :$(TAG )
324
312
325
- # NOTE: do not add 'generate-exmaples' as a prerequisite of this target. It will break e2e conformance testing.
326
313
.PHONY : create-cluster
327
314
create-cluster : $(CLUSTERCTL ) $(ENVSUBST ) # # Create a development Kubernetes cluster on OpenStack in a KIND management cluster.
315
+
316
+ # Create clusterctl.yaml to use local OpenStack provider
317
+ mkdir -p ./out/infrastructure-openstack/v0.3.0
318
+ echo "providers:" > ./out/clusterctl.yaml
319
+ echo "- name: openstack" >> ./out/clusterctl.yaml
320
+ echo " url: $(PWD)/out/infrastructure-openstack/v0.3.0/infrastructure-components.yaml" >> ./out/clusterctl.yaml
321
+ echo " type: InfrastructureProvider" >> ./out/clusterctl.yaml
322
+
323
+ echo "releaseSeries:" > ./out/infrastructure-openstack/v0.3.0/metadata.yaml
324
+ echo "- major: 0" >> ./out/infrastructure-openstack/v0.3.0/metadata.yaml
325
+ echo " minor: 3" >> ./out/infrastructure-openstack/v0.3.0/metadata.yaml
326
+ echo " contract: v1alpha3" >> ./out/infrastructure-openstack/v0.3.0/metadata.yaml
327
+
328
328
@if [ -z `kind get clusters | grep clusterapi` ]; then \
329
329
kind create cluster --name=clusterapi; \
330
330
fi
331
331
@if [ ! -z "${LOAD_IMAGE}" ]; then \
332
332
echo "loading ${LOAD_IMAGE} into kind cluster ..." && \
333
333
kind --name="clusterapi" load docker-image "${LOAD_IMAGE}"; \
334
334
fi
335
- # Install cert manager and wait for availability
336
- kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v0.11.1/cert-manager.yaml
337
- kubectl wait --for=condition=Available --timeout=5m apiservice v1beta1.webhook.cert-manager.io
338
335
339
- # Deploy CAPI
340
- kubectl apply -f https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.0/cluster-api-components.yaml
336
+ # (Re-)install Core providers
337
+ $(CLUSTERCTL) delete --all
338
+ $(CLUSTERCTL) init --core cluster-api:v0.3.0 --bootstrap kubeadm:v0.3.0 --control-plane kubeadm:v0.3.0
341
339
342
- # Deploy CAPO
343
- kustomize build config | $(ENVSUBST) | kubectl apply -f -
340
+ # (Re-)deploy CAPO provider
341
+ MANIFEST_IMG=$(CONTROLLER_IMG)-$(ARCH) MANIFEST_TAG=$(TAG) $(MAKE) set-manifest-image
342
+ kustomize build config > ./out/infrastructure-openstack/v0.3.0/infrastructure-components.yaml
343
+ $(CLUSTERCTL) delete --infrastructure openstack --include-namespace --namespace capo-system || true
344
+ kubectl wait --for=delete ns/capo-system || true
345
+ $(CLUSTERCTL) init --config ./out/clusterctl.yaml --infrastructure openstack
344
346
345
347
# Wait for CAPI pods
346
- kubectl wait --for=condition=Ready --timeout=5m -n capi-system pod -l cluster.x-k8s.io/provider=cluster-api
347
- kubectl wait --for=condition=Ready --timeout=5m -n capi-kubeadm-bootstrap-system pod -l cluster.x-k8s.io/provider=bootstrap-kubeadm
348
- kubectl wait --for=condition=Ready --timeout=5m -n capi-kubeadm-control-plane-system pod -l cluster.x-k8s.io/provider=control-plane-kubeadm
349
-
350
- # Wait for CAPO pods
351
- kubectl wait --for=condition=Ready --timeout=5m -n capo-system pod -l cluster.x-k8s.io/provider=infrastructure-openstack
348
+ kubectl wait --for=condition=Ready --timeout=5m -n capi-system pod --all
349
+ kubectl wait --for=condition=Ready --timeout=5m -n capi-webhook-system pod --all
350
+ kubectl wait --for=condition=Ready --timeout=5m -n capi-kubeadm-bootstrap-system pod --all
351
+ kubectl wait --for=condition=Ready --timeout=5m -n capi-kubeadm-control-plane-system pod --all
352
+ kubectl wait --for=condition=Ready --timeout=5m -n capo-system pod --all
352
353
353
- # FIXME:
354
- # Create Cluster.
355
- # sleep 10
356
- # kustomize build templates | $(ENVSUBST) | kubectl apply -f -
354
+ # Wait for CAPO CRDs
355
+ kubectl wait --for condition=established --timeout=60s crds/openstackmachines.infrastructure.cluster.x-k8s.io
356
+ kubectl wait --for condition=established --timeout=60s crds/openstackmachinetemplates.infrastructure.cluster.x-k8s.io
357
+ kubectl wait --for condition=established --timeout=60s crds/openstackclusters.infrastructure.cluster.x-k8s.io
357
358
358
- # Apply provider-components.
359
- kubectl apply -f examples/_out/provider-components.yaml
360
359
# Create Cluster.
361
- kubectl apply -f examples/_out/cluster.yaml
362
- # Create control plane machine.
363
- kubectl apply -f examples/_out/controlplane.yaml
360
+ kubectl create ns $(CLUSTER_NAME) || true
361
+ PULL_POLICY=$(PULL_POLICY) \
362
+ OPENSTACK_CONTROLPLANE_IP=$(OPENSTACK_CONTROLPLANE_IP) \
363
+ OPENSTACK_FAILURE_DOMAIN=$(OPENSTACK_FAILURE_DOMAIN) \
364
+ OPENSTACK_CLOUD=$(OPENSTACK_CLOUD) \
365
+ OPENSTACK_CLOUD_CACERT_B64=$(OPENSTACK_CLOUD_CACERT_B64) \
366
+ OPENSTACK_CLOUD_PROVIDER_CONF_B64=$(OPENSTACK_CLOUD_PROVIDER_CONF_B64) \
367
+ OPENSTACK_CLOUD_YAML_B64=$(OPENSTACK_CLOUD_YAML_B64) \
368
+ OPENSTACK_EXTERNAL_NETWORK_ID=$(OPENSTACK_EXTERNAL_NETWORK_ID) \
369
+ OPENSTACK_DNS_NAMESERVERS=$(OPENSTACK_DNS_NAMESERVERS) \
370
+ OPENSTACK_IMAGE_NAME=$(OPENSTACK_IMAGE_NAME) \
371
+ OPENSTACK_SSH_AUTHORIZED_KEY="$(OPENSTACK_SSH_AUTHORIZED_KEY)" \
372
+ OPENSTACK_NODE_MACHINE_FLAVOR=$(OPENSTACK_NODE_MACHINE_FLAVOR) \
373
+ OPENSTACK_CONTROL_PLANE_MACHINE_FLAVOR=$(OPENSTACK_CONTROL_PLANE_MACHINE_FLAVOR) \
374
+ $(CLUSTERCTL) config cluster $(CLUSTER_NAME) \
375
+ --from=$(OPENSTACK_CLUSTER_TEMPLATE) \
376
+ --kubernetes-version $(KUBERNETES_VERSION) \
377
+ --control-plane-machine-count=$(CONTROL_PLANE_MACHINE_COUNT) \
378
+ --worker-machine-count=$(WORKER_MACHINE_COUNT) \
379
+ --target-namespace=$(CLUSTER_NAME) | kubectl apply -f -
364
380
365
381
# Wait for the kubeconfig to become available.
366
382
timeout 300 bash -c "while ! kubectl -n $(CLUSTER_NAME) get secrets | grep $(CLUSTER_NAME)-kubeconfig; do sleep 1; done"
@@ -369,10 +385,8 @@ create-cluster: $(CLUSTERCTL) $(ENVSUBST) ## Create a development Kubernetes clu
369
385
timeout 900 bash -c "while ! kubectl --kubeconfig=./kubeconfig get nodes | grep master; do sleep 1; done"
370
386
371
387
# Deploy calico
372
- kubectl --kubeconfig=./kubeconfig apply -f https://docs.projectcalico.org/manifests/calico.yaml
373
-
374
- # Create a worker node with MachineDeployment.
375
- kubectl apply -f examples/_out/machinedeployment.yaml
388
+ curl https://docs.projectcalico.org/manifests/calico.yaml | sed "s/veth_mtu:.*/veth_mtu: \"1400\"/g" | \
389
+ kubectl --kubeconfig=./kubeconfig apply -f -
376
390
377
391
.PHONY : kind-reset
378
392
kind-reset : # # Destroys the "clusterapi" kind cluster.
@@ -401,12 +415,6 @@ clean-temporary: ## Remove all temporary files and folders
401
415
clean-release : # # Remove the release folder
402
416
rm -rf $(RELEASE_DIR )
403
417
404
- # FIXME:
405
- .PHONY : clean-examples
406
- clean-examples : # # Remove all the temporary files generated in the examples folder
407
- rm -rf examples/_out/
408
- rm -f examples/provider-components/provider-components-* .yaml
409
-
410
418
.PHONY : verify
411
419
verify : verify-boilerplate verify-modules verify-gen
412
420
0 commit comments