Skip to content

Commit

Permalink
add configuration for controller migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiahuif committed Sep 29, 2020
1 parent b9d2df8 commit 5e4f445
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 2 deletions.
3 changes: 3 additions & 0 deletions staging/publishing/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,9 @@ rules:
branch: master
dir: staging/src/k8s.io/controller-manager
name: master
dependencies:
- repository: apimachinery
branch: master
- source:
branch: release-1.19
dir: staging/src/k8s.io/controller-manager
Expand Down
5 changes: 4 additions & 1 deletion staging/src/k8s.io/controller-manager/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ filegroup(

filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
srcs = [
":package-srcs",
"//staging/src/k8s.io/controller-manager/config:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
27 changes: 27 additions & 0 deletions staging/src/k8s.io/controller-manager/config/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["types.go"],
importmap = "k8s.io/kubernetes/vendor/k8s.io/controller-manager/config",
importpath = "k8s.io/controller-manager/config",
visibility = ["//visibility:public"],
deps = ["//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library"],
)

filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)

filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//staging/src/k8s.io/controller-manager/config/v1alpha1:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
49 changes: 49 additions & 0 deletions staging/src/k8s.io/controller-manager/config/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Copyright 2020 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 config

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// LeaderMigrationConfiguration provides versioned configuration for all migrating leader locks.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type LeaderMigrationConfiguration struct {
metav1.TypeMeta

// LeaderName is the name of the leader election resource that protects the migration
// E.g. 1-20-KCM-to-1-21-CCM
LeaderName string

// ResourceLock indicates the resource object type that will be used to lock
// Should be "leases" or "endpoints"
ResourceLock string

// ControllerLeaders contains a list of migrating leader lock configurations
ControllerLeaders []ControllerLeaderConfiguration
}

// ControllerLeaderConfiguration provides the configuration for a migrating leader lock.
type ControllerLeaderConfiguration struct {
// Name is the name of the controller being migrated
// E.g. service-controller, route-controller, cloud-node-controller, etc
Name string

// Component is the name of the component in which the controller should be running.
// E.g. kube-controller-manager, cloud-controller-manager, etc
Component string
}
24 changes: 24 additions & 0 deletions staging/src/k8s.io/controller-manager/config/v1alpha1/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["types.go"],
importmap = "k8s.io/kubernetes/vendor/k8s.io/controller-manager/config/v1alpha1",
importpath = "k8s.io/controller-manager/config/v1alpha1",
visibility = ["//visibility:public"],
deps = ["//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library"],
)

filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)

filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
49 changes: 49 additions & 0 deletions staging/src/k8s.io/controller-manager/config/v1alpha1/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Copyright 2020 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 config

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// LeaderMigrationConfiguration provides versioned configuration for all migrating leader locks.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type LeaderMigrationConfiguration struct {
metav1.TypeMeta `json:",inline"`

// LeaderName is the name of the leader election resource that protects the migration
// E.g. 1-20-KCM-to-1-21-CCM
LeaderName string `json:"leaderName"`

// ResourceLock indicates the resource object type that will be used to lock
// Should be "leases" or "endpoints"
ResourceLock string `json:"resourceLock"`

// ControllerLeaders contains a list of migrating leader lock configurations
ControllerLeaders []ControllerLeaderConfiguration `json:"controllerLeaders"`
}

// ControllerLeaderConfiguration provides the configuration for a migrating leader lock.
type ControllerLeaderConfiguration struct {
// Name is the name of the controller being migrated
// E.g. service-controller, route-controller, cloud-node-controller, etc
Name string `json:"name"`

// Component is the name of the component in which the controller should be running.
// E.g. kube-controller-manager, cloud-controller-manager, etc
Component string `json:"component"`
}
7 changes: 6 additions & 1 deletion staging/src/k8s.io/controller-manager/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ module k8s.io/controller-manager

go 1.15

replace k8s.io/controller-manager => ../controller-manager
require k8s.io/apimachinery v0.0.0

replace (
k8s.io/apimachinery => ../apimachinery
k8s.io/controller-manager => ../controller-manager
)
Loading

0 comments on commit 5e4f445

Please sign in to comment.