mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 18:54:06 +00:00
kubeadm: add defaulting for kubeadm config api group
This commit is contained in:
parent
edab99bf87
commit
a01b943a7f
@ -13,7 +13,6 @@ load(
|
|||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = [
|
srcs = [
|
||||||
"defaults.go",
|
|
||||||
"doc.go",
|
"doc.go",
|
||||||
"env.go",
|
"env.go",
|
||||||
"register.go",
|
"register.go",
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 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 kubeadm
|
|
||||||
|
|
||||||
const (
|
|
||||||
DefaultServiceDNSDomain = "cluster.local"
|
|
||||||
DefaultServicesSubnet = "10.96.0.0/12"
|
|
||||||
DefaultKubernetesVersion = "v1.4.4"
|
|
||||||
DefaultAPIBindPort = 6443
|
|
||||||
DefaultDiscoveryBindPort = 9898
|
|
||||||
)
|
|
@ -22,17 +22,17 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
|
||||||
AddToScheme = SchemeBuilder.AddToScheme
|
|
||||||
)
|
|
||||||
|
|
||||||
// GroupName is the group name use in this package
|
// GroupName is the group name use in this package
|
||||||
const GroupName = "kubeadm.k8s.io"
|
const GroupName = "kubeadm.k8s.io"
|
||||||
|
|
||||||
// SchemeGroupVersion is group version used to register these objects
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
var SchemeGroupVersion = unversioned.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
|
var SchemeGroupVersion = unversioned.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
|
||||||
|
|
||||||
|
var (
|
||||||
|
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||||
|
AddToScheme = SchemeBuilder.AddToScheme
|
||||||
|
)
|
||||||
|
|
||||||
// Kind takes an unqualified kind and returns a Group qualified GroupKind
|
// Kind takes an unqualified kind and returns a Group qualified GroupKind
|
||||||
func Kind(kind string) unversioned.GroupKind {
|
func Kind(kind string) unversioned.GroupKind {
|
||||||
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||||
|
@ -13,9 +13,11 @@ load(
|
|||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = [
|
srcs = [
|
||||||
|
"defaults.go",
|
||||||
"doc.go",
|
"doc.go",
|
||||||
"register.go",
|
"register.go",
|
||||||
"types.go",
|
"types.go",
|
||||||
|
"zz_generated.defaults.go",
|
||||||
],
|
],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
deps = [
|
deps = [
|
||||||
|
69
cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults.go
Normal file
69
cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults.go
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2016 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 v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultServiceDNSDomain = "cluster.local"
|
||||||
|
DefaultServicesSubnet = "10.96.0.0/12"
|
||||||
|
DefaultKubernetesVersion = "v1.4.4"
|
||||||
|
DefaultAPIBindPort = 6443
|
||||||
|
DefaultDiscoveryBindPort = 9898
|
||||||
|
)
|
||||||
|
|
||||||
|
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||||
|
RegisterDefaults(scheme)
|
||||||
|
return scheme.AddDefaultingFuncs(
|
||||||
|
SetDefaults_MasterConfiguration,
|
||||||
|
SetDefaults_NodeConfiguration,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetDefaults_MasterConfiguration(obj *MasterConfiguration) {
|
||||||
|
if obj.KubernetesVersion == "" {
|
||||||
|
obj.KubernetesVersion = DefaultKubernetesVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.API.BindPort == 0 {
|
||||||
|
obj.API.BindPort = DefaultAPIBindPort
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.Discovery.BindPort == 0 {
|
||||||
|
obj.Discovery.BindPort = DefaultDiscoveryBindPort
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.Networking.ServiceSubnet == "" {
|
||||||
|
obj.Networking.ServiceSubnet = DefaultServicesSubnet
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.Networking.DNSDomain == "" {
|
||||||
|
obj.Networking.DNSDomain = DefaultServiceDNSDomain
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetDefaults_NodeConfiguration(obj *NodeConfiguration) {
|
||||||
|
if obj.APIPort == 0 {
|
||||||
|
obj.APIPort = DefaultAPIBindPort
|
||||||
|
}
|
||||||
|
|
||||||
|
if obj.DiscoveryPort == 0 {
|
||||||
|
obj.DiscoveryPort = DefaultDiscoveryBindPort
|
||||||
|
}
|
||||||
|
}
|
@ -14,5 +14,6 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// +k8s:defaulter-gen=TypeMeta
|
||||||
// +groupName=kubeadm.k8s.io
|
// +groupName=kubeadm.k8s.io
|
||||||
package v1alpha1 // import "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha1"
|
package v1alpha1 // import "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha1"
|
||||||
|
@ -22,17 +22,17 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
|
||||||
AddToScheme = SchemeBuilder.AddToScheme
|
|
||||||
)
|
|
||||||
|
|
||||||
// GroupName is the group name use in this package
|
// GroupName is the group name use in this package
|
||||||
const GroupName = "kubeadm.k8s.io"
|
const GroupName = "kubeadm.k8s.io"
|
||||||
|
|
||||||
// SchemeGroupVersion is group version used to register these objects
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
var SchemeGroupVersion = unversioned.GroupVersion{Group: GroupName, Version: "v1alpha1"}
|
var SchemeGroupVersion = unversioned.GroupVersion{Group: GroupName, Version: "v1alpha1"}
|
||||||
|
|
||||||
|
var (
|
||||||
|
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, addDefaultingFuncs)
|
||||||
|
AddToScheme = SchemeBuilder.AddToScheme
|
||||||
|
)
|
||||||
|
|
||||||
// Kind takes an unqualified kind and returns a Group qualified GroupKind
|
// Kind takes an unqualified kind and returns a Group qualified GroupKind
|
||||||
func Kind(kind string) unversioned.GroupKind {
|
func Kind(kind string) unversioned.GroupKind {
|
||||||
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||||
|
Loading…
Reference in New Issue
Block a user