Skip to content

Commit

Permalink
[v1alpha2 Migration] add v1alpha2 controllers (kubernetes-sigs#446)
Browse files Browse the repository at this point in the history
* migrate types & controllers to v1alpha2

* fix kubelet version
  • Loading branch information
sbueringer authored and k8s-ci-robot committed Aug 23, 2019
1 parent 6dee8c7 commit 3ac9dd8
Show file tree
Hide file tree
Showing 1,797 changed files with 77,261 additions and 119,176 deletions.
27 changes: 25 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Kubernetes Generated files - skip generated files, except for vendored files

!vendor/**/zz_generated.*

# editor and IDE paraphernalia
.idea
*.swp
*.swo
*~


*.json
*.sublime-project
*.sublime-workspace
*.swp
.idea
.DS_Store

# OSX leaves these everywhere on SMB shares
Expand Down
71 changes: 71 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright 2019 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Build the manager binary
#FROM golang:1.12.7 as builder
#
## Copy in the go src
#WORKDIR ${GOPATH}/src/sigs.k8s.io/cluster-api-provider-openstack
#COPY pkg/ pkg/
#COPY cmd/ cmd/
#COPY vendor/ vendor/
#COPY api/ api/
#COPY controllers/ controllers/
#COPY main.go main.go
#COPY go.mod go.mod
#COPY go.sum go.sum
#
## Build
#RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on GOFLAGS="-mod=vendor" \
# go build -a -ldflags '-extldflags "-static"' \
# -o manager sigs.k8s.io/cluster-api-provider-openstack
#
## Copy the controller-manager into a thin image
#FROM gcr.io/distroless/static:latest
#WORKDIR /
#COPY --from=builder /go/src/sigs.k8s.io/cluster-api-provider-openstack/manager .
#USER nobody
#ENTRYPOINT ["/manager"]

# Build the manager binary
FROM golang:1.12.7

# default the go proxy
ARG goproxy=https://proxy.golang.org

# run this with docker build --build_arg $(go env GOPROXY) to override the goproxy
ENV GOPROXY=$goproxy

WORKDIR /workspace
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY pkg/ pkg/

# Allow containerd to restart pods by calling /restart.sh (mostly for tilt + fast dev cycles)
# TODO: Remove this on prod and use a multi-stage build
COPY third_party/forked/rerun-process-wrapper/start.sh .
COPY third_party/forked/rerun-process-wrapper/restart.sh .

# Build and run
RUN go install -v .
RUN mv /go/bin/cluster-api-provider-openstack /manager
ENTRYPOINT ["./start.sh", "/manager"]
63 changes: 49 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@


# Allow overriding manifest generation destination directory
MANIFEST_ROOT ?= "config"
CRD_ROOT ?= "$(MANIFEST_ROOT)/crd/bases"
WEBHOOK_ROOT ?= "$(MANIFEST_ROOT)/webhook"
RBAC_ROOT ?= "$(MANIFEST_ROOT)/rbac"



GIT_HOST = sigs.k8s.io
PWD := $(shell pwd)
BASE_DIR := $(shell basename $(PWD))
Expand All @@ -12,7 +21,7 @@ GOX_PARALLEL ?= 3
TARGETS ?= darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le
DIST_DIRS = find * -type d -exec

GENERATE_YAML_PATH=cmd/clusterctl/examples/openstack
GENERATE_YAML_PATH=samples
GENERATE_YAML_EXEC=generate-yaml.sh
GENERATE_YAML_TEST_FOLDER=dummy-make-auto-test

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

MANAGER_IMAGE_NAME ?= cluster-api-provider-openstack
MANAGER_IMAGE_TAG ?= dev
PULL_POLICY ?= Always

# Used in docker-* targets.
MANAGER_IMAGE ?= $(REGISTRY)/$(MANAGER_IMAGE_NAME):$(MANAGER_IMAGE_TAG)

.PHONY: vendor
vendor: ## Runs go mod to ensure proper vendoring.
./hack/update-vendor.sh
Expand Down Expand Up @@ -115,20 +131,12 @@ realclean: clean
shell:
$(SHELL) -i

# Generate code
generate: manifests
go generate ./pkg/... ./cmd/...

manifests:
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd

images: openstack-cluster-api-controller clusterctl-image
images: docker-build

openstack-cluster-api-controller: generate manifests
docker build . -f cmd/manager/Dockerfile --network=host -t "$(REGISTRY)/openstack-cluster-api-controller:$(VERSION)"

clusterctl-image: generate manifests
docker build . -f cmd/clusterctl/Dockerfile --network=host -t "$(REGISTRY)/openstack-cluster-api-clusterctl:$(VERSION)"
# Build the docker image
.PHONY: docker-build
docker-build:
docker build . -t ${MANAGER_IMAGE}

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

# Generate code
.PHONY: generate
generate:
$(MAKE) generate-manifests
#TODO(sbueringer) will work after we migrated to kubeadm (because there are problems generating structs with kubeadm structs embedded)
# $(MAKE) generate-kubebuilder-code

# Generate manifests e.g. CRD, RBAC etc.
.PHONY: generate-manifests
#generate-manifests: $(CONTROLLER_GEN)
# go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go \
# paths=./api/... \
# crd:trivialVersions=true \
# output:crd:dir=$(CRD_ROOT) \
# output:webhook:dir=$(WEBHOOK_ROOT) \
# webhook
# go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go \
# paths=./controllers/... \
# output:rbac:dir=$(RBAC_ROOT) \
# rbac:roleName=manager-role

.PHONY: generate-kubebuilder-code
generate-kubebuilder-code: ## Runs controller-gen
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go \
paths=./api/... \
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt

.PHONY: build clean cover vendor docs fmt functional lint realclean \
relnotes test translation version build-cross dist manifests
11 changes: 9 additions & 2 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
version: "1"
domain: k8s.io
version: "2"
domain: cluster.x-k8s.io
repo: sigs.k8s.io/cluster-api-provider-openstack
resources:
- group: infrastructure
version: v1alpha2
kind: OpenStackCluster
- group: infrastructure
version: v1alpha2
kind: OpenStackMachine
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ policy may be made to more closely align with other providers in the Cluster API
## Getting Started

### Notice
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.
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.

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

Expand Down
36 changes: 36 additions & 0 deletions api/v1alpha2/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha2 contains API Schema definitions for the infrastructure v1alpha2 API group
// +kubebuilder:object:generate=true
// +groupName=infrastructure.cluster.x-k8s.io
package v1alpha2

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha2"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
Loading

0 comments on commit 3ac9dd8

Please sign in to comment.