Skip to content

Commit 7cdee0d

Browse files
authored
✨ finalize v1alpha3 (#518)
* finalize v1alpha3 * review fixes * review fixes
1 parent e99ddcf commit 7cdee0d

File tree

75 files changed

+2065
-1466
lines changed

Some content is hidden

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

75 files changed

+2065
-1466
lines changed

.dockerignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
.git
22
.github
33
.vscode
4+
_artifacts
45
bin/
56
config/
67
hack/
78
docs/
8-
examples/
9+
templates/
10+
tmp
11+
scripts/
912
**/.md
13+
tilt-provider.json

.golangci.yml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
linters:
2-
enable:
3-
- golint
4-
- govet
5-
- gofmt
6-
- structcheck
7-
- varcheck
8-
- interfacer
9-
- unconvert
10-
- ineffassign
11-
- goconst
12-
- misspell
13-
- nakedret
14-
- prealloc
15-
- deadcode
16-
disable-all: true
2+
enable-all: true
3+
disable:
4+
- dupl
5+
- funlen
6+
- gochecknoglobals
7+
- gochecknoinits
8+
- lll
9+
- maligned
10+
- godox
11+
- wsl
12+
- whitespace
13+
- gocognit
14+
- gomnd
1715
# Run with --fast=false for more extensive checks
1816
fast: true
19-
issue:
17+
issues:
2018
max-same-issues: 0
2119
max-per-linter: 0
20+
# List of regexps of issue texts to exclude, empty list by default.
21+
exclude:
22+
- Using the variable on range scope `(tc)|(rt)|(tt)|(test)|(testcase)|(testCase)` in function literal
23+
- "G108: Profiling endpoint is automatically exposed on /debug/pprof"
2224
run:
23-
deadline: 4m
25+
timeout: 6m
26+
skip-files:
27+
- "zz_generated.*\\.go$"
28+
- ".*_mock\\.go"

CONTRIBUTING.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
2-
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3-
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
4-
5-
- [Contributing guidelines](#contributing-guidelines)
6-
- [Sign the CLA](#sign-the-cla)
7-
- [Contributing A Patch](#contributing-a-patch)
8-
9-
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
10-
111
# Contributing guidelines
122

133
## Sign the CLA
@@ -21,4 +11,4 @@ Kubernetes projects require that you sign a Contributor License Agreement (CLA)
2111
1. If your proposed change is accepted, and you haven't already done so, sign a Contributor License Agreement (see details above).
2212
1. Fork the desired repo, develop and test your code changes.
2313
1. Submit a pull request.
24-
1. All code PR must be labeled with ⚠️ (⚠️, major or breaking changes), ✨ (, minor or feature additions), 🐛 (🐛, patch and bugfixes), 📖 (📖, documentation or proposals), or 🏃 (🏃, other).
14+
1. All code PR must be labeled with ⚠️ (:warning:, major or breaking changes), ✨ (:sparkles:, minor or feature additions), 🐛 (:bug:, patch and bugfixes), 📖 (:book:, documentation or proposals), or 🏃 (:running:, other)

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@
178178
APPENDIX: How to apply the Apache License to your work.
179179

180180
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "{}"
181+
boilerplate notice, with the fields enclosed by brackets "[]"
182182
replaced with your own identifying information. (Don't include
183183
the brackets!) The text should be enclosed in the appropriate
184184
comment syntax for the file format. We also recommend that a
185185
file or class name and description of purpose be included on the
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright {yyyy} {name of copyright owner}
189+
Copyright [yyyy] [name of copyright owner]
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

Makefile

Lines changed: 75 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ RELEASE_NOTES := $(TOOLS_DIR)/$(RELEASE_NOTES_BIN)
4848
GINKGO := $(abspath $(TOOLS_BIN_DIR)/ginkgo)
4949

5050
# 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
5252
STAGING_REGISTRY := gcr.io/k8s-staging-capi-openstack
5353
PROD_REGISTRY := us.gcr.io/k8s-artifacts-prod/capi-openstack
5454
IMAGE_NAME ?= capi-openstack-controller
@@ -64,7 +64,7 @@ WEBHOOK_ROOT ?= $(MANIFEST_ROOT)/webhook
6464
RBAC_ROOT ?= $(MANIFEST_ROOT)/rbac
6565

6666
# Allow overriding the imagePullPolicy
67-
PULL_POLICY ?= Always
67+
PULL_POLICY ?= IfNotPresent
6868

6969
# Hosts running SELinux need :z added to volume mounts
7070
SELINUX_ENABLED := $(shell cat /sys/fs/selinux/enforce 2> /dev/null || echo 0)
@@ -76,9 +76,6 @@ endif
7676
# Set build time variables including version details
7777
LDFLAGS := $(shell source ./hack/version.sh; version::ldflags)
7878

79-
# Check if binaries exist
80-
HAS_YQ := $(shell command -v yq;)
81-
8279
## --------------------------------------
8380
## Help
8481
## --------------------------------------
@@ -95,7 +92,7 @@ help: ## Display this help
9592
images: docker-build ## Build all images
9693

9794
.PHONY: check
98-
check: modules generate lint-full test
95+
check: modules generate lint-full test verify
9996

10097
## --------------------------------------
10198
## Testing
@@ -104,28 +101,11 @@ check: modules generate lint-full test
104101
.PHONY: test
105102
test: generate lint ## Run tests
106103
$(MAKE) test-go
107-
$(MAKE) test-generate-examples
108104

109105
.PHONY: test-go
110106
test-go: ## Run golang tests
111107
go test -v ./...
112108

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-
129109
## --------------------------------------
130110
## Binaries
131111
## --------------------------------------
@@ -217,14 +197,6 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
217197
output:rbac:dir=$(RBAC_ROOT) \
218198
rbac:roleName=manager-role
219199

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-
228200
## --------------------------------------
229201
## Docker
230202
## --------------------------------------
@@ -318,49 +290,93 @@ release-notes: $(RELEASE_NOTES)
318290
## Development
319291
## --------------------------------------
320292

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)
324312

325-
# NOTE: do not add 'generate-exmaples' as a prerequisite of this target. It will break e2e conformance testing.
326313
.PHONY: create-cluster
327314
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+
328328
@if [ -z `kind get clusters | grep clusterapi` ]; then \
329329
kind create cluster --name=clusterapi; \
330330
fi
331331
@if [ ! -z "${LOAD_IMAGE}" ]; then \
332332
echo "loading ${LOAD_IMAGE} into kind cluster ..." && \
333333
kind --name="clusterapi" load docker-image "${LOAD_IMAGE}"; \
334334
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
338335

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
341339

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
344346

345347
# 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
352353

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
357358

358-
# Apply provider-components.
359-
kubectl apply -f examples/_out/provider-components.yaml
360359
# 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 -
364380

365381
# Wait for the kubeconfig to become available.
366382
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
369385
timeout 900 bash -c "while ! kubectl --kubeconfig=./kubeconfig get nodes | grep master; do sleep 1; done"
370386

371387
# 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 -
376390

377391
.PHONY: kind-reset
378392
kind-reset: ## Destroys the "clusterapi" kind cluster.
@@ -401,12 +415,6 @@ clean-temporary: ## Remove all temporary files and folders
401415
clean-release: ## Remove the release folder
402416
rm -rf $(RELEASE_DIR)
403417

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-
410418
.PHONY: verify
411419
verify: verify-boilerplate verify-modules verify-gen
412420

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ previous cluster managers such as [kops][kops] and
2121
## Launching a Kubernetes cluster on OpenStack
2222

2323
- Check out the [Cluster API Quick Start](https://cluster-api.sigs.k8s.io/user/quick-start.html) to create your first Kubernetes cluster on OpenStack using Cluster API.
24-
- Check out the [getting started guide](./docs/getting-started.md) for launching a cluster on OpenStack using `clusterctl`.
2524

2625
## Features
2726

@@ -30,34 +29,37 @@ previous cluster managers such as [kops][kops] and
3029
- Support for single and multi-node control plane clusters
3130
- Deploy clusters with and without LBaaS available
3231
- Support for security groups
33-
- Doesn't use SSH for bootstrapping nodes
32+
- cloud-init based nodes bootstrapping
3433

3534
------
3635

3736
## Compatibility with Cluster API and Kubernetes Versions
3837

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

41-
||Cluster API v1alpha1 (v0.1)|Cluster API v1alpha2 (v0.2)|
42-
|-|-|-|
43-
|OpenStack Provider v1alpha1 (release-0.1 branch)|||
44-
|OpenStack Provider v1alpha2 (v0.2)|||
40+
| | Cluster API v1alpha1 (v0.1) | Cluster API v1alpha2 (v0.2) | Cluster API v1alpha3 (v0.3) |
41+
|-------------------------------------------------|---|---|---|
42+
| OpenStack Provider v1alpha1 (release-0.1 branch)|| | |
43+
| OpenStack Provider v1alpha2 (v0.2) | || |
44+
| OpenStack Provider v1alpha3 (v0.3) | | ||
4545

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

48-
||Kubernetes 1.13|Kubernetes 1.14|Kubernetes 1.15|
49-
|-|-|-|-|
50-
|OpenStack Provider v1alpha1 (release-0.1 branch)||||
51-
|OpenStack Provider v1alpha2 (v0.2)||||
48+
| | Kubernetes 1.13 | Kubernetes 1.14 | Kubernetes 1.15 | Kubernetes 1.16 | Kubernetes 1.17 |
49+
|-------------------------------------------------|---|---|---|---|---|
50+
|OpenStack Provider v1alpha1 (release-0.1 branch) |||| | |
51+
|OpenStack Provider v1alpha2 (v0.2) | | || | |
52+
|OpenStack Provider v1alpha3 (v0.3) | | | |||
5253

5354
This provider's versions are able to install Kubernetes to the following versions of OpenStack:
5455

55-
||OpenStack Pike|OpenStack Queens|OpenStack Rocky|OpenStack Stein|
56-
|-|-|-|-|-|
57-
|OpenStack Provider v1alpha1 (release-0.1 branch)|||||
58-
|OpenStack Provider v1alpha2 (v0.2)|+||+||
56+
| | OpenStack Pike | OpenStack Queens | OpenStack Rocky | OpenStack Stein | OpenStack Train |
57+
|-------------------------------------------------|---|---|---|---|---|
58+
| OpenStack Provider v1alpha1 (release-0.1 branch)||||| + |
59+
| OpenStack Provider v1alpha2 (v0.2) | + || + || + |
60+
| OpenStack Provider v1alpha3 (v0.3) | + | + | + | + ||
5961

60-
Key:
62+
Test status:
6163
* `` tested
6264
* `+` should work, but we weren't able to test it
6365

@@ -80,7 +82,7 @@ Reference images can be found in [kubernetes-sigs/image-builder](https://github.
8082

8183
## Documentation
8284

83-
Documentation is in the `/docs` directory
85+
Documentation can be found in the `/docs` directory
8486

8587
## Getting involved and contributing
8688

0 commit comments

Comments
 (0)