Skip to content

Commit 3ac9dd8

Browse files
sbueringerk8s-ci-robot
authored andcommitted
[v1alpha2 Migration] add v1alpha2 controllers (#446)
* migrate types & controllers to v1alpha2 * fix kubelet version
1 parent 6dee8c7 commit 3ac9dd8

File tree

1,797 files changed

+77261
-119176
lines changed

Some content is hidden

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

1,797 files changed

+77261
-119176
lines changed

.gitignore

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,32 @@
11

2+
# Binaries for programs and plugins
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
bin
9+
10+
# Test binary, build with `go test -c`
11+
*.test
12+
13+
# Output of the go coverage tool, specifically when used with LiteIDE
14+
*.out
15+
16+
# Kubernetes Generated files - skip generated files, except for vendored files
17+
18+
!vendor/**/zz_generated.*
19+
20+
# editor and IDE paraphernalia
21+
.idea
22+
*.swp
23+
*.swo
24+
*~
25+
26+
227
*.json
328
*.sublime-project
429
*.sublime-workspace
5-
*.swp
6-
.idea
730
.DS_Store
831

932
# OSX leaves these everywhere on SMB shares

Dockerfile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright 2019 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Build the manager binary
16+
#FROM golang:1.12.7 as builder
17+
#
18+
## Copy in the go src
19+
#WORKDIR ${GOPATH}/src/sigs.k8s.io/cluster-api-provider-openstack
20+
#COPY pkg/ pkg/
21+
#COPY cmd/ cmd/
22+
#COPY vendor/ vendor/
23+
#COPY api/ api/
24+
#COPY controllers/ controllers/
25+
#COPY main.go main.go
26+
#COPY go.mod go.mod
27+
#COPY go.sum go.sum
28+
#
29+
## Build
30+
#RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on GOFLAGS="-mod=vendor" \
31+
# go build -a -ldflags '-extldflags "-static"' \
32+
# -o manager sigs.k8s.io/cluster-api-provider-openstack
33+
#
34+
## Copy the controller-manager into a thin image
35+
#FROM gcr.io/distroless/static:latest
36+
#WORKDIR /
37+
#COPY --from=builder /go/src/sigs.k8s.io/cluster-api-provider-openstack/manager .
38+
#USER nobody
39+
#ENTRYPOINT ["/manager"]
40+
41+
# Build the manager binary
42+
FROM golang:1.12.7
43+
44+
# default the go proxy
45+
ARG goproxy=https://proxy.golang.org
46+
47+
# run this with docker build --build_arg $(go env GOPROXY) to override the goproxy
48+
ENV GOPROXY=$goproxy
49+
50+
WORKDIR /workspace
51+
COPY go.mod go.mod
52+
COPY go.sum go.sum
53+
# cache deps before building and copying source so that we don't need to re-download as much
54+
# and so that source changes don't invalidate our downloaded layer
55+
RUN go mod download
56+
57+
# Copy the go source
58+
COPY main.go main.go
59+
COPY api/ api/
60+
COPY controllers/ controllers/
61+
COPY pkg/ pkg/
62+
63+
# Allow containerd to restart pods by calling /restart.sh (mostly for tilt + fast dev cycles)
64+
# TODO: Remove this on prod and use a multi-stage build
65+
COPY third_party/forked/rerun-process-wrapper/start.sh .
66+
COPY third_party/forked/rerun-process-wrapper/restart.sh .
67+
68+
# Build and run
69+
RUN go install -v .
70+
RUN mv /go/bin/cluster-api-provider-openstack /manager
71+
ENTRYPOINT ["./start.sh", "/manager"]

Makefile

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11

2+
3+
# Allow overriding manifest generation destination directory
4+
MANIFEST_ROOT ?= "config"
5+
CRD_ROOT ?= "$(MANIFEST_ROOT)/crd/bases"
6+
WEBHOOK_ROOT ?= "$(MANIFEST_ROOT)/webhook"
7+
RBAC_ROOT ?= "$(MANIFEST_ROOT)/rbac"
8+
9+
10+
211
GIT_HOST = sigs.k8s.io
312
PWD := $(shell pwd)
413
BASE_DIR := $(shell basename $(PWD))
@@ -12,7 +21,7 @@ GOX_PARALLEL ?= 3
1221
TARGETS ?= darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le
1322
DIST_DIRS = find * -type d -exec
1423

15-
GENERATE_YAML_PATH=cmd/clusterctl/examples/openstack
24+
GENERATE_YAML_PATH=samples
1625
GENERATE_YAML_EXEC=generate-yaml.sh
1726
GENERATE_YAML_TEST_FOLDER=dummy-make-auto-test
1827

@@ -24,6 +33,13 @@ TAGS :=
2433
LDFLAGS := "-w -s -X 'main.version=${VERSION}'"
2534
REGISTRY ?= k8scloudprovider
2635

36+
MANAGER_IMAGE_NAME ?= cluster-api-provider-openstack
37+
MANAGER_IMAGE_TAG ?= dev
38+
PULL_POLICY ?= Always
39+
40+
# Used in docker-* targets.
41+
MANAGER_IMAGE ?= $(REGISTRY)/$(MANAGER_IMAGE_NAME):$(MANAGER_IMAGE_TAG)
42+
2743
.PHONY: vendor
2844
vendor: ## Runs go mod to ensure proper vendoring.
2945
./hack/update-vendor.sh
@@ -115,20 +131,12 @@ realclean: clean
115131
shell:
116132
$(SHELL) -i
117133

118-
# Generate code
119-
generate: manifests
120-
go generate ./pkg/... ./cmd/...
121-
122-
manifests:
123-
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd
124-
125-
images: openstack-cluster-api-controller clusterctl-image
134+
images: docker-build
126135

127-
openstack-cluster-api-controller: generate manifests
128-
docker build . -f cmd/manager/Dockerfile --network=host -t "$(REGISTRY)/openstack-cluster-api-controller:$(VERSION)"
129-
130-
clusterctl-image: generate manifests
131-
docker build . -f cmd/clusterctl/Dockerfile --network=host -t "$(REGISTRY)/openstack-cluster-api-clusterctl:$(VERSION)"
136+
# Build the docker image
137+
.PHONY: docker-build
138+
docker-build:
139+
docker build . -t ${MANAGER_IMAGE}
132140

133141
upload-images: images
134142
@echo "push images to $(REGISTRY)"
@@ -157,5 +165,32 @@ dist: build-cross
157165
$(DIST_DIRS) zip -r cluster-api-provider-openstack-$(VERSION)-{}.zip {} \; \
158166
)
159167

168+
# Generate code
169+
.PHONY: generate
170+
generate:
171+
$(MAKE) generate-manifests
172+
#TODO(sbueringer) will work after we migrated to kubeadm (because there are problems generating structs with kubeadm structs embedded)
173+
# $(MAKE) generate-kubebuilder-code
174+
175+
# Generate manifests e.g. CRD, RBAC etc.
176+
.PHONY: generate-manifests
177+
#generate-manifests: $(CONTROLLER_GEN)
178+
# go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go \
179+
# paths=./api/... \
180+
# crd:trivialVersions=true \
181+
# output:crd:dir=$(CRD_ROOT) \
182+
# output:webhook:dir=$(WEBHOOK_ROOT) \
183+
# webhook
184+
# go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go \
185+
# paths=./controllers/... \
186+
# output:rbac:dir=$(RBAC_ROOT) \
187+
# rbac:roleName=manager-role
188+
189+
.PHONY: generate-kubebuilder-code
190+
generate-kubebuilder-code: ## Runs controller-gen
191+
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go \
192+
paths=./api/... \
193+
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt
194+
160195
.PHONY: build clean cover vendor docs fmt functional lint realclean \
161196
relnotes test translation version build-cross dist manifests

PROJECT

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
version: "1"
2-
domain: k8s.io
1+
version: "2"
2+
domain: cluster.x-k8s.io
33
repo: sigs.k8s.io/cluster-api-provider-openstack
4+
resources:
5+
- group: infrastructure
6+
version: v1alpha2
7+
kind: OpenStackCluster
8+
- group: infrastructure
9+
version: v1alpha2
10+
kind: OpenStackMachine

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ policy may be made to more closely align with other providers in the Cluster API
7272
## Getting Started
7373

7474
### Notice
75-
Currenlty `cluster-api-provider-openstack` project is evolving into `cluster-api v1alpha2`, please use `release-0.1` branch for `cluster-api v1alpha1` development as it provides function workable code and configurations.
75+
Currently `cluster-api-provider-openstack` project is evolving into `cluster-api v1alpha2`, please use `release-0.1` branch for `cluster-api v1alpha1` development as it provides function workable code and configurations.
7676

7777
For more information, please refer to [v1alpha2](https://github.com/kubernetes-sigs/cluster-api-provider-openstack/issues/380)
7878

api/v1alpha2/groupversion_info.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1alpha2 contains API Schema definitions for the infrastructure v1alpha2 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=infrastructure.cluster.x-k8s.io
20+
package v1alpha2
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects
29+
GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha2"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)

0 commit comments

Comments
 (0)