Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to CRDs - WIP #67

Merged
merged 20 commits into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
985 changes: 383 additions & 602 deletions Gopkg.lock

Large diffs are not rendered by default.

85 changes: 29 additions & 56 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,70 +1,43 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true

required = [
"k8s.io/code-generator/cmd/deepcopy-gen",
]
"github.com/emicklei/go-restful",
"github.com/onsi/ginkgo", # for test framework
"github.com/onsi/gomega", # for test matchers
"k8s.io/client-go/plugin/pkg/client/auth/gcp", # for development against gcp
"k8s.io/code-generator/cmd/deepcopy-gen", # for go generate
"sigs.k8s.io/controller-tools/cmd/controller-gen", # for crd/rbac generation
"sigs.k8s.io/controller-runtime/pkg/client/config",
"sigs.k8s.io/controller-runtime/pkg/controller",
"sigs.k8s.io/controller-runtime/pkg/handler",
"sigs.k8s.io/controller-runtime/pkg/manager",
"sigs.k8s.io/controller-runtime/pkg/runtime/signals",
"sigs.k8s.io/controller-runtime/pkg/source",
"sigs.k8s.io/testing_frameworks/integration", # for integration testing
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1",
]

[prune]
go-tests = true

[[constraint]]
name = "sigs.k8s.io/cluster-api"
revision = "f31486484d5b33c785540eeaffd47fe57832aef5"

[[constraint]]
name = "k8s.io/code-generator"
branch = "release-1.9"
branch = "master"

[[constraint]]
name = "github.com/aws/aws-sdk-go"
version = "v1.15.5"

# We need to specify fsnotify source to avoid dep panic
[[override]]
name = "gopkg.in/fsnotify.v1"
source = "https://github.com/fsnotify/fsnotify.git"

[[constraint]]
name = "k8s.io/kube-aggregator"
branch = "release-1.9"

[[constraint]]
name = "k8s.io/apiextensions-apiserver"
branch = "release-1.9"

[[constraint]]
name = "k8s.io/apimachinery"
branch = "release-1.9"
# STANZAS BELOW ARE GENERATED AND MAY BE WRITTEN - DO NOT MODIFY BELOW THIS LINE.

[[constraint]]
name = "k8s.io/apiserver"
branch = "release-1.9"
name="sigs.k8s.io/controller-runtime"
version="v0.1.1"

[[constraint]]
name = "k8s.io/client-go"
branch = "release-6.0"
name="sigs.k8s.io/controller-tools"
version="v0.1.1"

[[constraint]]
name = "k8s.io/api"
branch = "release-1.9"
# For dependency below: Refer to issue https://github.com/golang/dep/issues/1799
[[override]]
name = "gopkg.in/fsnotify.v1"
source = "https://github.com/fsnotify/fsnotify.git"
version="v1.4.7"
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

DBG ?= 0

ifeq ($(DBG),1)
GOGCFLAGS ?= -gcflags=all="-N -l"
endif

VERSION ?= $(shell git describe --always --abbrev=7)
MUTABLE_TAG ?= latest
IMAGE = origin-libvirt-machine-controllers
Expand Down Expand Up @@ -64,12 +70,11 @@ bin:
@mkdir $@

.PHONY: build
build: | bin ## build binary
$(DOCKER_CMD) go install -ldflags '-extldflags "-static"' sigs.k8s.io/cluster-api-provider-aws/cmd/cluster-controller
$(DOCKER_CMD) go install -ldflags '-extldflags "-static"' sigs.k8s.io/cluster-api-provider-aws/cmd/machine-controller
build: ## build binary
$(DOCKER_CMD) go install $(GOGCFLAGS) -ldflags '-extldflags "-static"' sigs.k8s.io/cluster-api-provider-aws/cmd/machine-controller

aws-actuator:
$(DOCKER_CMD) go build -o bin/aws-actuator sigs.k8s.io/cluster-api-provider-aws/cmd/aws-actuator
$(DOCKER_CMD) go build $(GOGCFLAGS) -o bin/aws-actuator sigs.k8s.io/cluster-api-provider-aws/cmd/aws-actuator

.PHONY: images
images: ## Create images
Expand Down
2 changes: 1 addition & 1 deletion cmd/aws-actuator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import (
"text/template"

"k8s.io/apimachinery/pkg/util/wait"
"sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/fake"
//"sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/fake"
)

const (
Expand Down
29 changes: 0 additions & 29 deletions cmd/cluster-controller/Dockerfile

This file was deleted.

38 changes: 0 additions & 38 deletions cmd/cluster-controller/Makefile

This file was deleted.

47 changes: 0 additions & 47 deletions cmd/cluster-controller/main.go

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/machine-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset"
"sigs.k8s.io/cluster-api/pkg/controller/config"
"sigs.k8s.io/cluster-api/pkg/controller/machine"
"sigs.k8s.io/cluster-api/pkg/controller/sharedinformers"
// "sigs.k8s.io/cluster-api/pkg/controller/sharedinformers"
)

var (
Expand Down
59 changes: 59 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright 2018 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 main

import (
"log"

_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"sigs.k8s.io/cluster-api-provider-aws/migration/pkg/apis"
"sigs.k8s.io/cluster-api-provider-aws/migration/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
)

func main() {
// Get a config to talk to the apiserver
cfg, err := config.GetConfig()
if err != nil {
log.Fatal(err)
}

// Create a new Cmd to provide shared dependencies and start components
mgr, err := manager.New(cfg, manager.Options{})
if err != nil {
log.Fatal(err)
}

log.Printf("Registering Components.")

// Setup Scheme for all resources
if err := apis.AddToScheme(mgr.GetScheme()); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice.

log.Fatal(err)
}

// Setup all Controllers
if err := controller.AddToManager(mgr); err != nil {
log.Fatal(err)
}

log.Printf("Starting the Cmd.")

// Start the Cmd
log.Fatal(mgr.Start(signals.SetupSignalHandler()))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If SIGTERM is received does Start() return? If so, I wouldn't expect that to print a fatal error.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
labels:
controller-tools.k8s.io: "1.0"
name: awsmachineproviderconfigs.awsproviderconfig.k8s.io
spec:
group: awsproviderconfig.k8s.io
names:
kind: AWSMachineProviderConfig
plural: awsmachineproviderconfigs
scope: Namespaced
validation:
openAPIV3Schema:
properties:
apiVersion:
type: string
kind:
type: string
metadata:
type: object
spec:
type: object
status:
type: object
version: v1alpha1
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
26 changes: 26 additions & 0 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Adds namespace to all resources.
namespace: migration-system

# Value of this field is prepended to the
# names of all resources, e.g. a deployment named
# "wordpress" becomes "alices-wordpress".
# Note that it should also match with the prefix (text before '-') of the namespace
# field above.
namePrefix: migration-

# Labels to add to all resources and selectors.
#commonLabels:
# someName: someValue

# Each entry in this list must resolve to an existing
# resource definition in YAML. These are the resource
# files that kustomize reads, modifies and emits as a
# YAML string, with resources separated by document
# markers ("---").
resources:
- ../rbac/rbac_role.yaml
- ../rbac/rbac_role_binding.yaml
- ../manager/manager.yaml

patches:
- manager_image_patch.yaml
12 changes: 12 additions & 0 deletions config/default/manager_image_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
containers:
# Change the value of image field below to your controller image URL
- image: IMAGE_URL
name: manager
Loading