mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
code cleanup for cmd/kubeadm
This commit is contained in:
parent
10ed4502f4
commit
a1452b9115
@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
|
||||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
||||||
@ -111,7 +110,7 @@ func TestValidateNodeRegistrationOptions(t *testing.T) {
|
|||||||
// test cases for criSocket are covered in TestValidateSocketPath
|
// test cases for criSocket are covered in TestValidateSocketPath
|
||||||
}
|
}
|
||||||
for _, rt := range tests {
|
for _, rt := range tests {
|
||||||
nro := kubeadm.NodeRegistrationOptions{Name: rt.nodeName, CRISocket: "/some/path"}
|
nro := kubeadmapi.NodeRegistrationOptions{Name: rt.nodeName, CRISocket: "/some/path"}
|
||||||
actual := ValidateNodeRegistrationOptions(&nro, field.NewPath("nodeRegistration"))
|
actual := ValidateNodeRegistrationOptions(&nro, field.NewPath("nodeRegistration"))
|
||||||
actualErrors := len(actual) > 0
|
actualErrors := len(actual) > 0
|
||||||
if actualErrors != rt.expectedErrors {
|
if actualErrors != rt.expectedErrors {
|
||||||
@ -391,12 +390,12 @@ func TestValidateHostPort(t *testing.T) {
|
|||||||
func TestValidateAPIEndpoint(t *testing.T) {
|
func TestValidateAPIEndpoint(t *testing.T) {
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
name string
|
name string
|
||||||
s *kubeadm.APIEndpoint
|
s *kubeadmapi.APIEndpoint
|
||||||
expected bool
|
expected bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Valid IPv4 address / port",
|
name: "Valid IPv4 address / port",
|
||||||
s: &kubeadm.APIEndpoint{
|
s: &kubeadmapi.APIEndpoint{
|
||||||
AdvertiseAddress: "4.5.6.7",
|
AdvertiseAddress: "4.5.6.7",
|
||||||
BindPort: 6443,
|
BindPort: 6443,
|
||||||
},
|
},
|
||||||
@ -404,7 +403,7 @@ func TestValidateAPIEndpoint(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Valid IPv6 address / port",
|
name: "Valid IPv6 address / port",
|
||||||
s: &kubeadm.APIEndpoint{
|
s: &kubeadmapi.APIEndpoint{
|
||||||
AdvertiseAddress: "2001:db7::2",
|
AdvertiseAddress: "2001:db7::2",
|
||||||
BindPort: 6443,
|
BindPort: 6443,
|
||||||
},
|
},
|
||||||
@ -412,7 +411,7 @@ func TestValidateAPIEndpoint(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Invalid IPv4 address",
|
name: "Invalid IPv4 address",
|
||||||
s: &kubeadm.APIEndpoint{
|
s: &kubeadmapi.APIEndpoint{
|
||||||
AdvertiseAddress: "1.2.34",
|
AdvertiseAddress: "1.2.34",
|
||||||
BindPort: 6443,
|
BindPort: 6443,
|
||||||
},
|
},
|
||||||
@ -420,7 +419,7 @@ func TestValidateAPIEndpoint(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Invalid IPv6 address",
|
name: "Invalid IPv6 address",
|
||||||
s: &kubeadm.APIEndpoint{
|
s: &kubeadmapi.APIEndpoint{
|
||||||
AdvertiseAddress: "2001:db7:1",
|
AdvertiseAddress: "2001:db7:1",
|
||||||
BindPort: 6443,
|
BindPort: 6443,
|
||||||
},
|
},
|
||||||
@ -428,7 +427,7 @@ func TestValidateAPIEndpoint(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Invalid BindPort",
|
name: "Invalid BindPort",
|
||||||
s: &kubeadm.APIEndpoint{
|
s: &kubeadmapi.APIEndpoint{
|
||||||
AdvertiseAddress: "4.5.6.7",
|
AdvertiseAddress: "4.5.6.7",
|
||||||
BindPort: 0,
|
BindPort: 0,
|
||||||
},
|
},
|
||||||
@ -453,49 +452,49 @@ func TestValidateInitConfiguration(t *testing.T) {
|
|||||||
nodename := "valid-nodename"
|
nodename := "valid-nodename"
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
name string
|
name string
|
||||||
s *kubeadm.InitConfiguration
|
s *kubeadmapi.InitConfiguration
|
||||||
expected bool
|
expected bool
|
||||||
}{
|
}{
|
||||||
{"invalid missing InitConfiguration",
|
{"invalid missing InitConfiguration",
|
||||||
&kubeadm.InitConfiguration{}, false},
|
&kubeadmapi.InitConfiguration{}, false},
|
||||||
{"invalid missing token with IPv4 service subnet",
|
{"invalid missing token with IPv4 service subnet",
|
||||||
&kubeadm.InitConfiguration{
|
&kubeadmapi.InitConfiguration{
|
||||||
LocalAPIEndpoint: kubeadm.APIEndpoint{
|
LocalAPIEndpoint: kubeadmapi.APIEndpoint{
|
||||||
AdvertiseAddress: "1.2.3.4",
|
AdvertiseAddress: "1.2.3.4",
|
||||||
BindPort: 6443,
|
BindPort: 6443,
|
||||||
},
|
},
|
||||||
ClusterConfiguration: kubeadm.ClusterConfiguration{
|
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
|
||||||
Networking: kubeadm.Networking{
|
Networking: kubeadmapi.Networking{
|
||||||
ServiceSubnet: "10.96.0.1/12",
|
ServiceSubnet: "10.96.0.1/12",
|
||||||
DNSDomain: "cluster.local",
|
DNSDomain: "cluster.local",
|
||||||
},
|
},
|
||||||
CertificatesDir: "/some/cert/dir",
|
CertificatesDir: "/some/cert/dir",
|
||||||
},
|
},
|
||||||
NodeRegistration: kubeadm.NodeRegistrationOptions{Name: nodename, CRISocket: "/some/path"},
|
NodeRegistration: kubeadmapi.NodeRegistrationOptions{Name: nodename, CRISocket: "/some/path"},
|
||||||
}, false},
|
}, false},
|
||||||
{"invalid missing token with IPv6 service subnet",
|
{"invalid missing token with IPv6 service subnet",
|
||||||
&kubeadm.InitConfiguration{
|
&kubeadmapi.InitConfiguration{
|
||||||
LocalAPIEndpoint: kubeadm.APIEndpoint{
|
LocalAPIEndpoint: kubeadmapi.APIEndpoint{
|
||||||
AdvertiseAddress: "1.2.3.4",
|
AdvertiseAddress: "1.2.3.4",
|
||||||
BindPort: 6443,
|
BindPort: 6443,
|
||||||
},
|
},
|
||||||
ClusterConfiguration: kubeadm.ClusterConfiguration{
|
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
|
||||||
Networking: kubeadm.Networking{
|
Networking: kubeadmapi.Networking{
|
||||||
ServiceSubnet: "2001:db8::1/98",
|
ServiceSubnet: "2001:db8::1/98",
|
||||||
DNSDomain: "cluster.local",
|
DNSDomain: "cluster.local",
|
||||||
},
|
},
|
||||||
CertificatesDir: "/some/cert/dir",
|
CertificatesDir: "/some/cert/dir",
|
||||||
},
|
},
|
||||||
NodeRegistration: kubeadm.NodeRegistrationOptions{Name: nodename, CRISocket: "/some/path"},
|
NodeRegistration: kubeadmapi.NodeRegistrationOptions{Name: nodename, CRISocket: "/some/path"},
|
||||||
}, false},
|
}, false},
|
||||||
{"invalid missing node name",
|
{"invalid missing node name",
|
||||||
&kubeadm.InitConfiguration{
|
&kubeadmapi.InitConfiguration{
|
||||||
LocalAPIEndpoint: kubeadm.APIEndpoint{
|
LocalAPIEndpoint: kubeadmapi.APIEndpoint{
|
||||||
AdvertiseAddress: "1.2.3.4",
|
AdvertiseAddress: "1.2.3.4",
|
||||||
BindPort: 6443,
|
BindPort: 6443,
|
||||||
},
|
},
|
||||||
ClusterConfiguration: kubeadm.ClusterConfiguration{
|
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
|
||||||
Networking: kubeadm.Networking{
|
Networking: kubeadmapi.Networking{
|
||||||
ServiceSubnet: "10.96.0.1/12",
|
ServiceSubnet: "10.96.0.1/12",
|
||||||
DNSDomain: "cluster.local",
|
DNSDomain: "cluster.local",
|
||||||
},
|
},
|
||||||
@ -503,61 +502,61 @@ func TestValidateInitConfiguration(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}, false},
|
}, false},
|
||||||
{"valid InitConfiguration with incorrect IPv4 pod subnet",
|
{"valid InitConfiguration with incorrect IPv4 pod subnet",
|
||||||
&kubeadm.InitConfiguration{
|
&kubeadmapi.InitConfiguration{
|
||||||
LocalAPIEndpoint: kubeadm.APIEndpoint{
|
LocalAPIEndpoint: kubeadmapi.APIEndpoint{
|
||||||
AdvertiseAddress: "1.2.3.4",
|
AdvertiseAddress: "1.2.3.4",
|
||||||
BindPort: 6443,
|
BindPort: 6443,
|
||||||
},
|
},
|
||||||
ClusterConfiguration: kubeadm.ClusterConfiguration{
|
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
|
||||||
Networking: kubeadm.Networking{
|
Networking: kubeadmapi.Networking{
|
||||||
ServiceSubnet: "10.96.0.1/12",
|
ServiceSubnet: "10.96.0.1/12",
|
||||||
DNSDomain: "cluster.local",
|
DNSDomain: "cluster.local",
|
||||||
PodSubnet: "10.0.1.15",
|
PodSubnet: "10.0.1.15",
|
||||||
},
|
},
|
||||||
CertificatesDir: "/some/other/cert/dir",
|
CertificatesDir: "/some/other/cert/dir",
|
||||||
},
|
},
|
||||||
NodeRegistration: kubeadm.NodeRegistrationOptions{Name: nodename, CRISocket: "/some/path"},
|
NodeRegistration: kubeadmapi.NodeRegistrationOptions{Name: nodename, CRISocket: "/some/path"},
|
||||||
}, false},
|
}, false},
|
||||||
{"valid InitConfiguration with IPv4 service subnet",
|
{"valid InitConfiguration with IPv4 service subnet",
|
||||||
&kubeadm.InitConfiguration{
|
&kubeadmapi.InitConfiguration{
|
||||||
LocalAPIEndpoint: kubeadm.APIEndpoint{
|
LocalAPIEndpoint: kubeadmapi.APIEndpoint{
|
||||||
AdvertiseAddress: "1.2.3.4",
|
AdvertiseAddress: "1.2.3.4",
|
||||||
BindPort: 6443,
|
BindPort: 6443,
|
||||||
},
|
},
|
||||||
ClusterConfiguration: kubeadm.ClusterConfiguration{
|
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
|
||||||
Etcd: kubeadm.Etcd{
|
Etcd: kubeadmapi.Etcd{
|
||||||
Local: &kubeadm.LocalEtcd{
|
Local: &kubeadmapi.LocalEtcd{
|
||||||
DataDir: "/some/path",
|
DataDir: "/some/path",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Networking: kubeadm.Networking{
|
Networking: kubeadmapi.Networking{
|
||||||
ServiceSubnet: "10.96.0.1/12",
|
ServiceSubnet: "10.96.0.1/12",
|
||||||
DNSDomain: "cluster.local",
|
DNSDomain: "cluster.local",
|
||||||
PodSubnet: "10.0.1.15/16",
|
PodSubnet: "10.0.1.15/16",
|
||||||
},
|
},
|
||||||
CertificatesDir: "/some/other/cert/dir",
|
CertificatesDir: "/some/other/cert/dir",
|
||||||
},
|
},
|
||||||
NodeRegistration: kubeadm.NodeRegistrationOptions{Name: nodename, CRISocket: "/some/path"},
|
NodeRegistration: kubeadmapi.NodeRegistrationOptions{Name: nodename, CRISocket: "/some/path"},
|
||||||
}, true},
|
}, true},
|
||||||
{"valid InitConfiguration using IPv6 service subnet",
|
{"valid InitConfiguration using IPv6 service subnet",
|
||||||
&kubeadm.InitConfiguration{
|
&kubeadmapi.InitConfiguration{
|
||||||
LocalAPIEndpoint: kubeadm.APIEndpoint{
|
LocalAPIEndpoint: kubeadmapi.APIEndpoint{
|
||||||
AdvertiseAddress: "1:2:3::4",
|
AdvertiseAddress: "1:2:3::4",
|
||||||
BindPort: 3446,
|
BindPort: 3446,
|
||||||
},
|
},
|
||||||
ClusterConfiguration: kubeadm.ClusterConfiguration{
|
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
|
||||||
Etcd: kubeadm.Etcd{
|
Etcd: kubeadmapi.Etcd{
|
||||||
Local: &kubeadm.LocalEtcd{
|
Local: &kubeadmapi.LocalEtcd{
|
||||||
DataDir: "/some/path",
|
DataDir: "/some/path",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Networking: kubeadm.Networking{
|
Networking: kubeadmapi.Networking{
|
||||||
ServiceSubnet: "2001:db8::1/112",
|
ServiceSubnet: "2001:db8::1/112",
|
||||||
DNSDomain: "cluster.local",
|
DNSDomain: "cluster.local",
|
||||||
},
|
},
|
||||||
CertificatesDir: "/some/other/cert/dir",
|
CertificatesDir: "/some/other/cert/dir",
|
||||||
},
|
},
|
||||||
NodeRegistration: kubeadm.NodeRegistrationOptions{Name: nodename, CRISocket: "/some/path"},
|
NodeRegistration: kubeadmapi.NodeRegistrationOptions{Name: nodename, CRISocket: "/some/path"},
|
||||||
}, true},
|
}, true},
|
||||||
}
|
}
|
||||||
for _, rt := range tests {
|
for _, rt := range tests {
|
||||||
@ -575,94 +574,94 @@ func TestValidateInitConfiguration(t *testing.T) {
|
|||||||
|
|
||||||
func TestValidateJoinConfiguration(t *testing.T) {
|
func TestValidateJoinConfiguration(t *testing.T) {
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
s *kubeadm.JoinConfiguration
|
s *kubeadmapi.JoinConfiguration
|
||||||
expected bool
|
expected bool
|
||||||
}{
|
}{
|
||||||
{&kubeadm.JoinConfiguration{}, false},
|
{&kubeadmapi.JoinConfiguration{}, false},
|
||||||
{&kubeadm.JoinConfiguration{
|
{&kubeadmapi.JoinConfiguration{
|
||||||
CACertPath: "/some/cert.crt",
|
CACertPath: "/some/cert.crt",
|
||||||
Discovery: kubeadm.Discovery{
|
Discovery: kubeadmapi.Discovery{
|
||||||
BootstrapToken: &kubeadm.BootstrapTokenDiscovery{
|
BootstrapToken: &kubeadmapi.BootstrapTokenDiscovery{
|
||||||
Token: "abcdef.1234567890123456@foobar",
|
Token: "abcdef.1234567890123456@foobar",
|
||||||
},
|
},
|
||||||
File: &kubeadm.FileDiscovery{
|
File: &kubeadmapi.FileDiscovery{
|
||||||
KubeConfigPath: "foo",
|
KubeConfigPath: "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, false},
|
}, false},
|
||||||
{&kubeadm.JoinConfiguration{ // Pass without JoinControlPlane
|
{&kubeadmapi.JoinConfiguration{ // Pass without JoinControlPlane
|
||||||
CACertPath: "/some/cert.crt",
|
CACertPath: "/some/cert.crt",
|
||||||
Discovery: kubeadm.Discovery{
|
Discovery: kubeadmapi.Discovery{
|
||||||
BootstrapToken: &kubeadm.BootstrapTokenDiscovery{
|
BootstrapToken: &kubeadmapi.BootstrapTokenDiscovery{
|
||||||
Token: "abcdef.1234567890123456",
|
Token: "abcdef.1234567890123456",
|
||||||
APIServerEndpoint: "1.2.3.4:6443",
|
APIServerEndpoint: "1.2.3.4:6443",
|
||||||
CACertHashes: []string{"aaaa"},
|
CACertHashes: []string{"aaaa"},
|
||||||
},
|
},
|
||||||
TLSBootstrapToken: "abcdef.1234567890123456",
|
TLSBootstrapToken: "abcdef.1234567890123456",
|
||||||
},
|
},
|
||||||
NodeRegistration: kubeadm.NodeRegistrationOptions{
|
NodeRegistration: kubeadmapi.NodeRegistrationOptions{
|
||||||
Name: "aaa",
|
Name: "aaa",
|
||||||
CRISocket: "/var/run/dockershim.sock",
|
CRISocket: "/var/run/dockershim.sock",
|
||||||
},
|
},
|
||||||
}, true},
|
}, true},
|
||||||
{&kubeadm.JoinConfiguration{ // Pass with JoinControlPlane
|
{&kubeadmapi.JoinConfiguration{ // Pass with JoinControlPlane
|
||||||
CACertPath: "/some/cert.crt",
|
CACertPath: "/some/cert.crt",
|
||||||
Discovery: kubeadm.Discovery{
|
Discovery: kubeadmapi.Discovery{
|
||||||
BootstrapToken: &kubeadm.BootstrapTokenDiscovery{
|
BootstrapToken: &kubeadmapi.BootstrapTokenDiscovery{
|
||||||
Token: "abcdef.1234567890123456",
|
Token: "abcdef.1234567890123456",
|
||||||
APIServerEndpoint: "1.2.3.4:6443",
|
APIServerEndpoint: "1.2.3.4:6443",
|
||||||
CACertHashes: []string{"aaaa"},
|
CACertHashes: []string{"aaaa"},
|
||||||
},
|
},
|
||||||
TLSBootstrapToken: "abcdef.1234567890123456",
|
TLSBootstrapToken: "abcdef.1234567890123456",
|
||||||
},
|
},
|
||||||
NodeRegistration: kubeadm.NodeRegistrationOptions{
|
NodeRegistration: kubeadmapi.NodeRegistrationOptions{
|
||||||
Name: "aaa",
|
Name: "aaa",
|
||||||
CRISocket: "/var/run/dockershim.sock",
|
CRISocket: "/var/run/dockershim.sock",
|
||||||
},
|
},
|
||||||
ControlPlane: &kubeadm.JoinControlPlane{
|
ControlPlane: &kubeadmapi.JoinControlPlane{
|
||||||
LocalAPIEndpoint: kubeadm.APIEndpoint{
|
LocalAPIEndpoint: kubeadmapi.APIEndpoint{
|
||||||
AdvertiseAddress: "1.2.3.4",
|
AdvertiseAddress: "1.2.3.4",
|
||||||
BindPort: 1234,
|
BindPort: 1234,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, true},
|
}, true},
|
||||||
{&kubeadm.JoinConfiguration{ // Fail JoinControlPlane.AdvertiseAddress validation
|
{&kubeadmapi.JoinConfiguration{ // Fail JoinControlPlane.AdvertiseAddress validation
|
||||||
CACertPath: "/some/cert.crt",
|
CACertPath: "/some/cert.crt",
|
||||||
Discovery: kubeadm.Discovery{
|
Discovery: kubeadmapi.Discovery{
|
||||||
BootstrapToken: &kubeadm.BootstrapTokenDiscovery{
|
BootstrapToken: &kubeadmapi.BootstrapTokenDiscovery{
|
||||||
Token: "abcdef.1234567890123456",
|
Token: "abcdef.1234567890123456",
|
||||||
APIServerEndpoint: "1.2.3.4:6443",
|
APIServerEndpoint: "1.2.3.4:6443",
|
||||||
CACertHashes: []string{"aaaa"},
|
CACertHashes: []string{"aaaa"},
|
||||||
},
|
},
|
||||||
TLSBootstrapToken: "abcdef.1234567890123456",
|
TLSBootstrapToken: "abcdef.1234567890123456",
|
||||||
},
|
},
|
||||||
NodeRegistration: kubeadm.NodeRegistrationOptions{
|
NodeRegistration: kubeadmapi.NodeRegistrationOptions{
|
||||||
Name: "aaa",
|
Name: "aaa",
|
||||||
CRISocket: "/var/run/dockershim.sock",
|
CRISocket: "/var/run/dockershim.sock",
|
||||||
},
|
},
|
||||||
ControlPlane: &kubeadm.JoinControlPlane{
|
ControlPlane: &kubeadmapi.JoinControlPlane{
|
||||||
LocalAPIEndpoint: kubeadm.APIEndpoint{
|
LocalAPIEndpoint: kubeadmapi.APIEndpoint{
|
||||||
AdvertiseAddress: "aaa",
|
AdvertiseAddress: "aaa",
|
||||||
BindPort: 1234,
|
BindPort: 1234,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, false},
|
}, false},
|
||||||
{&kubeadm.JoinConfiguration{ // Fail JoinControlPlane.BindPort validation
|
{&kubeadmapi.JoinConfiguration{ // Fail JoinControlPlane.BindPort validation
|
||||||
CACertPath: "/some/cert.crt",
|
CACertPath: "/some/cert.crt",
|
||||||
Discovery: kubeadm.Discovery{
|
Discovery: kubeadmapi.Discovery{
|
||||||
BootstrapToken: &kubeadm.BootstrapTokenDiscovery{
|
BootstrapToken: &kubeadmapi.BootstrapTokenDiscovery{
|
||||||
Token: "abcdef.1234567890123456",
|
Token: "abcdef.1234567890123456",
|
||||||
APIServerEndpoint: "1.2.3.4:6443",
|
APIServerEndpoint: "1.2.3.4:6443",
|
||||||
CACertHashes: []string{"aaaa"},
|
CACertHashes: []string{"aaaa"},
|
||||||
},
|
},
|
||||||
TLSBootstrapToken: "abcdef.1234567890123456",
|
TLSBootstrapToken: "abcdef.1234567890123456",
|
||||||
},
|
},
|
||||||
NodeRegistration: kubeadm.NodeRegistrationOptions{
|
NodeRegistration: kubeadmapi.NodeRegistrationOptions{
|
||||||
Name: "aaa",
|
Name: "aaa",
|
||||||
CRISocket: "/var/run/dockershim.sock",
|
CRISocket: "/var/run/dockershim.sock",
|
||||||
},
|
},
|
||||||
ControlPlane: &kubeadm.JoinControlPlane{
|
ControlPlane: &kubeadmapi.JoinControlPlane{
|
||||||
LocalAPIEndpoint: kubeadm.APIEndpoint{
|
LocalAPIEndpoint: kubeadmapi.APIEndpoint{
|
||||||
AdvertiseAddress: "1.2.3.4",
|
AdvertiseAddress: "1.2.3.4",
|
||||||
BindPort: -1,
|
BindPort: -1,
|
||||||
},
|
},
|
||||||
@ -830,16 +829,16 @@ func TestValidateIgnorePreflightErrors(t *testing.T) {
|
|||||||
func TestValidateDiscovery(t *testing.T) {
|
func TestValidateDiscovery(t *testing.T) {
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
name string
|
name string
|
||||||
d *kubeadm.Discovery
|
d *kubeadmapi.Discovery
|
||||||
expected bool
|
expected bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid: .BootstrapToken and .File cannot both be set",
|
"invalid: .BootstrapToken and .File cannot both be set",
|
||||||
&kubeadm.Discovery{
|
&kubeadmapi.Discovery{
|
||||||
BootstrapToken: &kubeadm.BootstrapTokenDiscovery{
|
BootstrapToken: &kubeadmapi.BootstrapTokenDiscovery{
|
||||||
Token: "abcdef.1234567890123456",
|
Token: "abcdef.1234567890123456",
|
||||||
},
|
},
|
||||||
File: &kubeadm.FileDiscovery{
|
File: &kubeadmapi.FileDiscovery{
|
||||||
KubeConfigPath: "https://url/file.conf",
|
KubeConfigPath: "https://url/file.conf",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -847,7 +846,7 @@ func TestValidateDiscovery(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"invalid: .BootstrapToken or .File must be set",
|
"invalid: .BootstrapToken or .File must be set",
|
||||||
&kubeadm.Discovery{},
|
&kubeadmapi.Discovery{},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -868,19 +867,19 @@ func TestValidateDiscovery(t *testing.T) {
|
|||||||
func TestValidateDiscoveryBootstrapToken(t *testing.T) {
|
func TestValidateDiscoveryBootstrapToken(t *testing.T) {
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
name string
|
name string
|
||||||
btd *kubeadm.BootstrapTokenDiscovery
|
btd *kubeadmapi.BootstrapTokenDiscovery
|
||||||
expected bool
|
expected bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid: .APIServerEndpoint not set",
|
"invalid: .APIServerEndpoint not set",
|
||||||
&kubeadm.BootstrapTokenDiscovery{
|
&kubeadmapi.BootstrapTokenDiscovery{
|
||||||
Token: "abcdef.1234567890123456",
|
Token: "abcdef.1234567890123456",
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"invalid: using token-based discovery without .BootstrapToken.CACertHashes and .BootstrapToken.UnsafeSkipCAVerification",
|
"invalid: using token-based discovery without .BootstrapToken.CACertHashes and .BootstrapToken.UnsafeSkipCAVerification",
|
||||||
&kubeadm.BootstrapTokenDiscovery{
|
&kubeadmapi.BootstrapTokenDiscovery{
|
||||||
Token: "abcdef.1234567890123456",
|
Token: "abcdef.1234567890123456",
|
||||||
APIServerEndpoint: "192.168.122.100:6443",
|
APIServerEndpoint: "192.168.122.100:6443",
|
||||||
UnsafeSkipCAVerification: false,
|
UnsafeSkipCAVerification: false,
|
||||||
@ -889,7 +888,7 @@ func TestValidateDiscoveryBootstrapToken(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid: using token-based discovery with .BootstrapToken.CACertHashes",
|
"valid: using token-based discovery with .BootstrapToken.CACertHashes",
|
||||||
&kubeadm.BootstrapTokenDiscovery{
|
&kubeadmapi.BootstrapTokenDiscovery{
|
||||||
Token: "abcdef.1234567890123456",
|
Token: "abcdef.1234567890123456",
|
||||||
APIServerEndpoint: "192.168.122.100:6443",
|
APIServerEndpoint: "192.168.122.100:6443",
|
||||||
CACertHashes: []string{"sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc"},
|
CACertHashes: []string{"sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc"},
|
||||||
@ -899,7 +898,7 @@ func TestValidateDiscoveryBootstrapToken(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid: using token-based discovery with .BootstrapToken.CACertHashe but skip ca verification",
|
"valid: using token-based discovery with .BootstrapToken.CACertHashe but skip ca verification",
|
||||||
&kubeadm.BootstrapTokenDiscovery{
|
&kubeadmapi.BootstrapTokenDiscovery{
|
||||||
Token: "abcdef.1234567890123456",
|
Token: "abcdef.1234567890123456",
|
||||||
APIServerEndpoint: "192.168.122.100:6443",
|
APIServerEndpoint: "192.168.122.100:6443",
|
||||||
CACertHashes: []string{"sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc"},
|
CACertHashes: []string{"sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc"},
|
||||||
@ -1052,21 +1051,21 @@ func TestValidateURLs(t *testing.T) {
|
|||||||
func TestValidateEtcd(t *testing.T) {
|
func TestValidateEtcd(t *testing.T) {
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
name string
|
name string
|
||||||
etcd *kubeadm.Etcd
|
etcd *kubeadmapi.Etcd
|
||||||
expectedErrors bool
|
expectedErrors bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "either .Etcd.Local or .Etcd.External is required",
|
name: "either .Etcd.Local or .Etcd.External is required",
|
||||||
etcd: &kubeadm.Etcd{},
|
etcd: &kubeadmapi.Etcd{},
|
||||||
expectedErrors: true,
|
expectedErrors: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: ".Etcd.Local and .Etcd.External are mutually exclusive",
|
name: ".Etcd.Local and .Etcd.External are mutually exclusive",
|
||||||
etcd: &kubeadm.Etcd{
|
etcd: &kubeadmapi.Etcd{
|
||||||
Local: &kubeadm.LocalEtcd{
|
Local: &kubeadmapi.LocalEtcd{
|
||||||
DataDir: "/some/path",
|
DataDir: "/some/path",
|
||||||
},
|
},
|
||||||
External: &kubeadm.ExternalEtcd{
|
External: &kubeadmapi.ExternalEtcd{
|
||||||
Endpoints: []string{"10.100.0.1:2379", "10.100.0.2:2379"},
|
Endpoints: []string{"10.100.0.1:2379", "10.100.0.2:2379"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1074,8 +1073,8 @@ func TestValidateEtcd(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "either both or none of .Etcd.External.CertFile and .Etcd.External.KeyFile must be set",
|
name: "either both or none of .Etcd.External.CertFile and .Etcd.External.KeyFile must be set",
|
||||||
etcd: &kubeadm.Etcd{
|
etcd: &kubeadmapi.Etcd{
|
||||||
External: &kubeadm.ExternalEtcd{
|
External: &kubeadmapi.ExternalEtcd{
|
||||||
Endpoints: []string{"https://external.etcd1:2379", "https://external.etcd2:2379"},
|
Endpoints: []string{"https://external.etcd1:2379", "https://external.etcd2:2379"},
|
||||||
CertFile: "/some/file.crt",
|
CertFile: "/some/file.crt",
|
||||||
},
|
},
|
||||||
@ -1084,8 +1083,8 @@ func TestValidateEtcd(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "setting .Etcd.External.CertFile and .Etcd.External.KeyFile requires .Etcd.External.CAFile",
|
name: "setting .Etcd.External.CertFile and .Etcd.External.KeyFile requires .Etcd.External.CAFile",
|
||||||
etcd: &kubeadm.Etcd{
|
etcd: &kubeadmapi.Etcd{
|
||||||
External: &kubeadm.ExternalEtcd{
|
External: &kubeadmapi.ExternalEtcd{
|
||||||
Endpoints: []string{"https://external.etcd1:2379", "https://external.etcd2:2379"},
|
Endpoints: []string{"https://external.etcd1:2379", "https://external.etcd2:2379"},
|
||||||
CertFile: "/some/file.crt",
|
CertFile: "/some/file.crt",
|
||||||
KeyFile: "/some/file.key",
|
KeyFile: "/some/file.key",
|
||||||
@ -1095,8 +1094,8 @@ func TestValidateEtcd(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "valid external etcd",
|
name: "valid external etcd",
|
||||||
etcd: &kubeadm.Etcd{
|
etcd: &kubeadmapi.Etcd{
|
||||||
External: &kubeadm.ExternalEtcd{
|
External: &kubeadmapi.ExternalEtcd{
|
||||||
Endpoints: []string{"https://external.etcd1:2379", "https://external.etcd2:2379"},
|
Endpoints: []string{"https://external.etcd1:2379", "https://external.etcd2:2379"},
|
||||||
CertFile: "/etcd.crt",
|
CertFile: "/etcd.crt",
|
||||||
KeyFile: "/etcd.key",
|
KeyFile: "/etcd.key",
|
||||||
@ -1107,8 +1106,8 @@ func TestValidateEtcd(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "valid external etcd (no TLS)",
|
name: "valid external etcd (no TLS)",
|
||||||
etcd: &kubeadm.Etcd{
|
etcd: &kubeadmapi.Etcd{
|
||||||
External: &kubeadm.ExternalEtcd{
|
External: &kubeadmapi.ExternalEtcd{
|
||||||
Endpoints: []string{"http://10.100.0.1:2379", "http://10.100.0.2:2379"},
|
Endpoints: []string{"http://10.100.0.1:2379", "http://10.100.0.2:2379"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -33,7 +33,6 @@ import (
|
|||||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||||
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
|
||||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
certsphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/certs"
|
certsphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/certs"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/phases/certs/renewal"
|
"k8s.io/kubernetes/cmd/kubeadm/app/phases/certs/renewal"
|
||||||
@ -100,7 +99,7 @@ func newCmdCertsUtility(out io.Writer) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd.AddCommand(newCmdCertsRenewal(out))
|
cmd.AddCommand(newCmdCertsRenewal(out))
|
||||||
cmd.AddCommand(newCmdCertsExpiration(out, constants.KubernetesDir))
|
cmd.AddCommand(newCmdCertsExpiration(out, kubeadmconstants.KubernetesDir))
|
||||||
cmd.AddCommand(newCmdCertificateKey())
|
cmd.AddCommand(newCmdCertificateKey())
|
||||||
cmd.AddCommand(newCmdGenCSR(out))
|
cmd.AddCommand(newCmdGenCSR(out))
|
||||||
return cmd
|
return cmd
|
||||||
@ -207,7 +206,7 @@ func newCmdCertsRenewal(out io.Writer) *cobra.Command {
|
|||||||
RunE: cmdutil.SubCmdRunE("renew"),
|
RunE: cmdutil.SubCmdRunE("renew"),
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.AddCommand(getRenewSubCommands(out, constants.KubernetesDir)...)
|
cmd.AddCommand(getRenewSubCommands(out, kubeadmconstants.KubernetesDir)...)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
@ -224,7 +223,7 @@ func getRenewSubCommands(out io.Writer, kdir string) []*cobra.Command {
|
|||||||
flags := &renewFlags{
|
flags := &renewFlags{
|
||||||
cfg: kubeadmapiv1beta2.ClusterConfiguration{
|
cfg: kubeadmapiv1beta2.ClusterConfiguration{
|
||||||
// Setting kubernetes version to a default value in order to allow a not necessary internet lookup
|
// Setting kubernetes version to a default value in order to allow a not necessary internet lookup
|
||||||
KubernetesVersion: constants.CurrentKubernetesVersion.String(),
|
KubernetesVersion: kubeadmconstants.CurrentKubernetesVersion.String(),
|
||||||
},
|
},
|
||||||
kubeconfigPath: kubeadmconstants.GetAdminKubeConfigPath(),
|
kubeconfigPath: kubeadmconstants.GetAdminKubeConfigPath(),
|
||||||
}
|
}
|
||||||
@ -367,7 +366,7 @@ func newCmdCertsExpiration(out io.Writer, kdir string) *cobra.Command {
|
|||||||
flags := &expirationFlags{
|
flags := &expirationFlags{
|
||||||
cfg: kubeadmapiv1beta2.ClusterConfiguration{
|
cfg: kubeadmapiv1beta2.ClusterConfiguration{
|
||||||
// Setting kubernetes version to a default value in order to allow a not necessary internet lookup
|
// Setting kubernetes version to a default value in order to allow a not necessary internet lookup
|
||||||
KubernetesVersion: constants.CurrentKubernetesVersion.String(),
|
KubernetesVersion: kubeadmconstants.CurrentKubernetesVersion.String(),
|
||||||
},
|
},
|
||||||
kubeconfigPath: kubeadmconstants.GetAdminKubeConfigPath(),
|
kubeconfigPath: kubeadmconstants.GetAdminKubeConfigPath(),
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ func (kc *kubeletConfig) Default(cfg *kubeadmapi.ClusterConfiguration, _ *kubead
|
|||||||
|
|
||||||
if kc.config.Authentication.Anonymous.Enabled == nil {
|
if kc.config.Authentication.Anonymous.Enabled == nil {
|
||||||
kc.config.Authentication.Anonymous.Enabled = utilpointer.BoolPtr(kubeletAuthenticationAnonymousEnabled)
|
kc.config.Authentication.Anonymous.Enabled = utilpointer.BoolPtr(kubeletAuthenticationAnonymousEnabled)
|
||||||
} else if *kc.config.Authentication.Anonymous.Enabled != kubeletAuthenticationAnonymousEnabled {
|
} else if *kc.config.Authentication.Anonymous.Enabled {
|
||||||
warnDefaultComponentConfigValue(kind, "authentication.anonymous.enabled", kubeletAuthenticationAnonymousEnabled, *kc.config.Authentication.Anonymous.Enabled)
|
warnDefaultComponentConfigValue(kind, "authentication.anonymous.enabled", kubeletAuthenticationAnonymousEnabled, *kc.config.Authentication.Anonymous.Enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ func (kc *kubeletConfig) Default(cfg *kubeadmapi.ClusterConfiguration, _ *kubead
|
|||||||
// Let clients using other authentication methods like ServiceAccount tokens also access the kubelet API
|
// Let clients using other authentication methods like ServiceAccount tokens also access the kubelet API
|
||||||
if kc.config.Authentication.Webhook.Enabled == nil {
|
if kc.config.Authentication.Webhook.Enabled == nil {
|
||||||
kc.config.Authentication.Webhook.Enabled = utilpointer.BoolPtr(kubeletAuthenticationWebhookEnabled)
|
kc.config.Authentication.Webhook.Enabled = utilpointer.BoolPtr(kubeletAuthenticationWebhookEnabled)
|
||||||
} else if *kc.config.Authentication.Webhook.Enabled != kubeletAuthenticationWebhookEnabled {
|
} else if !*kc.config.Authentication.Webhook.Enabled {
|
||||||
warnDefaultComponentConfigValue(kind, "authentication.webhook.enabled", kubeletAuthenticationWebhookEnabled, *kc.config.Authentication.Webhook.Enabled)
|
warnDefaultComponentConfigValue(kind, "authentication.webhook.enabled", kubeletAuthenticationWebhookEnabled, *kc.config.Authentication.Webhook.Enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,10 +36,8 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
clientsetfake "k8s.io/client-go/kubernetes/fake"
|
clientsetfake "k8s.io/client-go/kubernetes/fake"
|
||||||
clienttesting "k8s.io/client-go/testing"
|
clienttesting "k8s.io/client-go/testing"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
|
||||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs"
|
"k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
|
||||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
testresources "k8s.io/kubernetes/cmd/kubeadm/test/resources"
|
testresources "k8s.io/kubernetes/cmd/kubeadm/test/resources"
|
||||||
)
|
)
|
||||||
@ -496,7 +494,7 @@ func TestGetAPIEndpointWithBackoff(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apiEndpoint := kubeadm.APIEndpoint{}
|
apiEndpoint := kubeadmapi.APIEndpoint{}
|
||||||
err := getAPIEndpointWithBackoff(client, rt.nodeName, &apiEndpoint, wait.Backoff{Duration: 0, Jitter: 0, Steps: 1})
|
err := getAPIEndpointWithBackoff(client, rt.nodeName, &apiEndpoint, wait.Backoff{Duration: 0, Jitter: 0, Steps: 1})
|
||||||
if err != nil && !rt.expectedErr {
|
if err != nil && !rt.expectedErr {
|
||||||
t.Errorf("got error %q; was expecting no errors", err)
|
t.Errorf("got error %q; was expecting no errors", err)
|
||||||
@ -859,7 +857,7 @@ func TestGetAPIEndpointFromPodAnnotation(t *testing.T) {
|
|||||||
nodeName: nodeName,
|
nodeName: nodeName,
|
||||||
pods: []testresources.FakeStaticPod{
|
pods: []testresources.FakeStaticPod{
|
||||||
{
|
{
|
||||||
Component: constants.KubeAPIServer,
|
Component: kubeadmconstants.KubeAPIServer,
|
||||||
Annotations: map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234"},
|
Annotations: map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -875,7 +873,7 @@ func TestGetAPIEndpointFromPodAnnotation(t *testing.T) {
|
|||||||
nodeName: nodeName,
|
nodeName: nodeName,
|
||||||
pods: []testresources.FakeStaticPod{
|
pods: []testresources.FakeStaticPod{
|
||||||
{
|
{
|
||||||
Component: constants.KubeAPIServer,
|
Component: kubeadmconstants.KubeAPIServer,
|
||||||
Annotations: map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234"},
|
Annotations: map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -937,7 +935,7 @@ func TestGetRawAPIEndpointFromPodAnnotationWithoutRetry(t *testing.T) {
|
|||||||
nodeName: nodeName,
|
nodeName: nodeName,
|
||||||
pods: []testresources.FakeStaticPod{
|
pods: []testresources.FakeStaticPod{
|
||||||
{
|
{
|
||||||
Component: constants.KubeAPIServer,
|
Component: kubeadmconstants.KubeAPIServer,
|
||||||
Annotations: map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234"},
|
Annotations: map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -948,11 +946,11 @@ func TestGetRawAPIEndpointFromPodAnnotationWithoutRetry(t *testing.T) {
|
|||||||
nodeName: nodeName,
|
nodeName: nodeName,
|
||||||
pods: []testresources.FakeStaticPod{
|
pods: []testresources.FakeStaticPod{
|
||||||
{
|
{
|
||||||
Component: constants.KubeAPIServer,
|
Component: kubeadmconstants.KubeAPIServer,
|
||||||
Annotations: map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234"},
|
Annotations: map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Component: constants.KubeAPIServer,
|
Component: kubeadmconstants.KubeAPIServer,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedErr: true,
|
expectedErr: true,
|
||||||
@ -962,11 +960,11 @@ func TestGetRawAPIEndpointFromPodAnnotationWithoutRetry(t *testing.T) {
|
|||||||
nodeName: nodeName,
|
nodeName: nodeName,
|
||||||
pods: []testresources.FakeStaticPod{
|
pods: []testresources.FakeStaticPod{
|
||||||
{
|
{
|
||||||
Component: constants.KubeAPIServer,
|
Component: kubeadmconstants.KubeAPIServer,
|
||||||
Annotations: map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234"},
|
Annotations: map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Component: constants.KubeAPIServer,
|
Component: kubeadmconstants.KubeAPIServer,
|
||||||
Annotations: map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.5:1234"},
|
Annotations: map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.5:1234"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -977,10 +975,10 @@ func TestGetRawAPIEndpointFromPodAnnotationWithoutRetry(t *testing.T) {
|
|||||||
nodeName: nodeName,
|
nodeName: nodeName,
|
||||||
pods: []testresources.FakeStaticPod{
|
pods: []testresources.FakeStaticPod{
|
||||||
{
|
{
|
||||||
Component: constants.KubeAPIServer,
|
Component: kubeadmconstants.KubeAPIServer,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Component: constants.KubeAPIServer,
|
Component: kubeadmconstants.KubeAPIServer,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedErr: true,
|
expectedErr: true,
|
||||||
@ -990,7 +988,7 @@ func TestGetRawAPIEndpointFromPodAnnotationWithoutRetry(t *testing.T) {
|
|||||||
nodeName: nodeName,
|
nodeName: nodeName,
|
||||||
pods: []testresources.FakeStaticPod{
|
pods: []testresources.FakeStaticPod{
|
||||||
{
|
{
|
||||||
Component: constants.KubeAPIServer,
|
Component: kubeadmconstants.KubeAPIServer,
|
||||||
Annotations: map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234"},
|
Annotations: map[string]string{kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -36,7 +36,6 @@ import (
|
|||||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation"
|
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs"
|
"k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
|
||||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/config/strict"
|
"k8s.io/kubernetes/cmd/kubeadm/app/util/config/strict"
|
||||||
@ -186,12 +185,12 @@ func DefaultedStaticInitConfiguration() (*kubeadmapi.InitConfiguration, error) {
|
|||||||
LocalAPIEndpoint: kubeadmapiv1beta2.APIEndpoint{AdvertiseAddress: "1.2.3.4"},
|
LocalAPIEndpoint: kubeadmapiv1beta2.APIEndpoint{AdvertiseAddress: "1.2.3.4"},
|
||||||
BootstrapTokens: []kubeadmapiv1beta2.BootstrapToken{PlaceholderToken},
|
BootstrapTokens: []kubeadmapiv1beta2.BootstrapToken{PlaceholderToken},
|
||||||
NodeRegistration: kubeadmapiv1beta2.NodeRegistrationOptions{
|
NodeRegistration: kubeadmapiv1beta2.NodeRegistrationOptions{
|
||||||
CRISocket: constants.DefaultDockerCRISocket, // avoid CRI detection
|
CRISocket: kubeadmconstants.DefaultDockerCRISocket, // avoid CRI detection
|
||||||
Name: "node",
|
Name: "node",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
versionedClusterCfg := &kubeadmapiv1beta2.ClusterConfiguration{
|
versionedClusterCfg := &kubeadmapiv1beta2.ClusterConfiguration{
|
||||||
KubernetesVersion: constants.CurrentKubernetesVersion.String(), // avoid going to the Internet for the current Kubernetes version
|
KubernetesVersion: kubeadmconstants.CurrentKubernetesVersion.String(), // avoid going to the Internet for the current Kubernetes version
|
||||||
}
|
}
|
||||||
|
|
||||||
internalcfg := &kubeadmapi.InitConfiguration{}
|
internalcfg := &kubeadmapi.InitConfiguration{}
|
||||||
|
@ -34,7 +34,6 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
|
||||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/patches"
|
"k8s.io/kubernetes/cmd/kubeadm/app/util/patches"
|
||||||
@ -246,7 +245,7 @@ func ReadinessProbe(host, path string, port int, scheme v1.URIScheme) *v1.Probe
|
|||||||
|
|
||||||
// StartupProbe creates a Probe object with a HTTPGet handler
|
// StartupProbe creates a Probe object with a HTTPGet handler
|
||||||
func StartupProbe(host, path string, port int, scheme v1.URIScheme, timeoutForControlPlane *metav1.Duration) *v1.Probe {
|
func StartupProbe(host, path string, port int, scheme v1.URIScheme, timeoutForControlPlane *metav1.Duration) *v1.Probe {
|
||||||
periodSeconds, timeoutForControlPlaneSeconds := int32(10), constants.DefaultControlPlaneTimeout.Seconds()
|
periodSeconds, timeoutForControlPlaneSeconds := int32(10), kubeadmconstants.DefaultControlPlaneTimeout.Seconds()
|
||||||
if timeoutForControlPlane != nil {
|
if timeoutForControlPlane != nil {
|
||||||
timeoutForControlPlaneSeconds = timeoutForControlPlane.Seconds()
|
timeoutForControlPlaneSeconds = timeoutForControlPlane.Seconds()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user