Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
e11916da
Commit
e11916da
authored
Feb 24, 2019
by
ducnv
Committed by
vanduc95
Feb 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubeadm cleanup: master -> control-plane (cont.4)
parent
139a13d3
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
110 additions
and
110 deletions
+110
-110
dns.go
cmd/kubeadm/app/phases/addons/dns/dns.go
+13
-13
dns_test.go
cmd/kubeadm/app/phases/addons/dns/dns_test.go
+26
-26
manifests.go
cmd/kubeadm/app/phases/addons/dns/manifests.go
+3
-3
manifests.go
cmd/kubeadm/app/phases/addons/proxy/manifests.go
+1
-1
proxy.go
cmd/kubeadm/app/phases/addons/proxy/proxy.go
+8
-8
proxy_test.go
cmd/kubeadm/app/phases/addons/proxy/proxy_test.go
+19
-19
kubeconfig.go
cmd/kubeadm/app/phases/kubeconfig/kubeconfig.go
+9
-9
kubeconfig_test.go
cmd/kubeadm/app/phases/kubeconfig/kubeconfig_test.go
+2
-2
markcontrolplane.go
cmd/kubeadm/app/phases/markcontrolplane/markcontrolplane.go
+2
-2
podspec_mutation.go
cmd/kubeadm/app/phases/selfhosting/podspec_mutation.go
+6
-6
podspec_mutation_test.go
cmd/kubeadm/app/phases/selfhosting/podspec_mutation_test.go
+3
-3
health.go
cmd/kubeadm/app/phases/upgrade/health.go
+10
-10
postupgrade.go
cmd/kubeadm/app/phases/upgrade/postupgrade.go
+4
-4
prepull.go
cmd/kubeadm/app/phases/upgrade/prepull.go
+1
-1
uploadconfig_test.go
cmd/kubeadm/app/phases/uploadconfig/uploadconfig_test.go
+3
-3
No files found.
cmd/kubeadm/app/phases/addons/dns/dns.go
View file @
e11916da
...
...
@@ -101,15 +101,15 @@ func kubeDNSAddon(cfg *kubeadmapi.ClusterConfiguration, client clientset.Interfa
}
dnsDeploymentBytes
,
err
:=
kubeadmutil
.
ParseTemplate
(
KubeDNSDeployment
,
struct
{
DeploymentName
,
KubeDNSImage
,
DNSMasqImage
,
SidecarImage
,
DNSBindAddr
,
DNSProbeAddr
,
DNSDomain
,
Master
TaintKey
string
}{
DeploymentName
:
kubeadmconstants
.
KubeDNSDeploymentName
,
KubeDNSImage
:
images
.
GetDNSImage
(
cfg
,
kubeadmconstants
.
KubeDNSKubeDNSImageName
),
DNSMasqImage
:
images
.
GetDNSImage
(
cfg
,
kubeadmconstants
.
KubeDNSDnsMasqNannyImageName
),
SidecarImage
:
images
.
GetDNSImage
(
cfg
,
kubeadmconstants
.
KubeDNSSidecarImageName
),
DNSBindAddr
:
dnsBindAddr
,
DNSProbeAddr
:
dnsProbeAddr
,
DNSDomain
:
cfg
.
Networking
.
DNSDomain
,
Master
TaintKey
:
kubeadmconstants
.
LabelNodeRoleMaster
,
struct
{
DeploymentName
,
KubeDNSImage
,
DNSMasqImage
,
SidecarImage
,
DNSBindAddr
,
DNSProbeAddr
,
DNSDomain
,
ControlPlane
TaintKey
string
}{
DeploymentName
:
kubeadmconstants
.
KubeDNSDeploymentName
,
KubeDNSImage
:
images
.
GetDNSImage
(
cfg
,
kubeadmconstants
.
KubeDNSKubeDNSImageName
),
DNSMasqImage
:
images
.
GetDNSImage
(
cfg
,
kubeadmconstants
.
KubeDNSDnsMasqNannyImageName
),
SidecarImage
:
images
.
GetDNSImage
(
cfg
,
kubeadmconstants
.
KubeDNSSidecarImageName
),
DNSBindAddr
:
dnsBindAddr
,
DNSProbeAddr
:
dnsProbeAddr
,
DNSDomain
:
cfg
.
Networking
.
DNSDomain
,
ControlPlane
TaintKey
:
kubeadmconstants
.
LabelNodeRoleMaster
,
})
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"error when parsing kube-dns deployment template"
)
...
...
@@ -157,10 +157,10 @@ func createKubeDNSAddon(deploymentBytes, serviceBytes []byte, client clientset.I
func
coreDNSAddon
(
cfg
*
kubeadmapi
.
ClusterConfiguration
,
client
clientset
.
Interface
)
error
{
// Get the YAML manifest
coreDNSDeploymentBytes
,
err
:=
kubeadmutil
.
ParseTemplate
(
CoreDNSDeployment
,
struct
{
DeploymentName
,
Image
,
Master
TaintKey
string
}{
DeploymentName
:
kubeadmconstants
.
CoreDNSDeploymentName
,
Image
:
images
.
GetDNSImage
(
cfg
,
kubeadmconstants
.
CoreDNSImageName
),
Master
TaintKey
:
kubeadmconstants
.
LabelNodeRoleMaster
,
coreDNSDeploymentBytes
,
err
:=
kubeadmutil
.
ParseTemplate
(
CoreDNSDeployment
,
struct
{
DeploymentName
,
Image
,
ControlPlane
TaintKey
string
}{
DeploymentName
:
kubeadmconstants
.
CoreDNSDeploymentName
,
Image
:
images
.
GetDNSImage
(
cfg
,
kubeadmconstants
.
CoreDNSImageName
),
ControlPlane
TaintKey
:
kubeadmconstants
.
LabelNodeRoleMaster
,
})
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"error when parsing CoreDNS deployment template"
)
...
...
cmd/kubeadm/app/phases/addons/dns/dns_test.go
View file @
e11916da
...
...
@@ -98,15 +98,15 @@ func TestCompileManifests(t *testing.T) {
}{
{
manifest
:
KubeDNSDeployment
,
data
:
struct
{
DeploymentName
,
KubeDNSImage
,
DNSMasqImage
,
SidecarImage
,
DNSBindAddr
,
DNSProbeAddr
,
DNSDomain
,
Master
TaintKey
string
}{
DeploymentName
:
"foo"
,
KubeDNSImage
:
"foo"
,
DNSMasqImage
:
"foo"
,
SidecarImage
:
"foo"
,
DNSBindAddr
:
"foo"
,
DNSProbeAddr
:
"foo"
,
DNSDomain
:
"foo"
,
Master
TaintKey
:
"foo"
,
data
:
struct
{
DeploymentName
,
KubeDNSImage
,
DNSMasqImage
,
SidecarImage
,
DNSBindAddr
,
DNSProbeAddr
,
DNSDomain
,
ControlPlane
TaintKey
string
}{
DeploymentName
:
"foo"
,
KubeDNSImage
:
"foo"
,
DNSMasqImage
:
"foo"
,
SidecarImage
:
"foo"
,
DNSBindAddr
:
"foo"
,
DNSProbeAddr
:
"foo"
,
DNSDomain
:
"foo"
,
ControlPlane
TaintKey
:
"foo"
,
},
expected
:
true
,
},
...
...
@@ -119,10 +119,10 @@ func TestCompileManifests(t *testing.T) {
},
{
manifest
:
CoreDNSDeployment
,
data
:
struct
{
DeploymentName
,
Image
,
Master
TaintKey
string
}{
DeploymentName
:
"foo"
,
Image
:
"foo"
,
Master
TaintKey
:
"foo"
,
data
:
struct
{
DeploymentName
,
Image
,
ControlPlane
TaintKey
string
}{
DeploymentName
:
"foo"
,
Image
:
"foo"
,
ControlPlane
TaintKey
:
"foo"
,
},
expected
:
true
,
},
...
...
@@ -436,23 +436,23 @@ func TestDeploymentsHaveSystemClusterCriticalPriorityClassName(t *testing.T) {
}{
{
manifest
:
KubeDNSDeployment
,
data
:
struct
{
DeploymentName
,
KubeDNSImage
,
DNSMasqImage
,
SidecarImage
,
DNSBindAddr
,
DNSProbeAddr
,
DNSDomain
,
Master
TaintKey
string
}{
DeploymentName
:
"foo"
,
KubeDNSImage
:
"foo"
,
DNSMasqImage
:
"foo"
,
SidecarImage
:
"foo"
,
DNSBindAddr
:
"foo"
,
DNSProbeAddr
:
"foo"
,
DNSDomain
:
"foo"
,
Master
TaintKey
:
"foo"
,
data
:
struct
{
DeploymentName
,
KubeDNSImage
,
DNSMasqImage
,
SidecarImage
,
DNSBindAddr
,
DNSProbeAddr
,
DNSDomain
,
ControlPlane
TaintKey
string
}{
DeploymentName
:
"foo"
,
KubeDNSImage
:
"foo"
,
DNSMasqImage
:
"foo"
,
SidecarImage
:
"foo"
,
DNSBindAddr
:
"foo"
,
DNSProbeAddr
:
"foo"
,
DNSDomain
:
"foo"
,
ControlPlane
TaintKey
:
"foo"
,
},
},
{
manifest
:
CoreDNSDeployment
,
data
:
struct
{
DeploymentName
,
Image
,
Master
TaintKey
string
}{
DeploymentName
:
"foo"
,
Image
:
"foo"
,
Master
TaintKey
:
"foo"
,
data
:
struct
{
DeploymentName
,
Image
,
ControlPlane
TaintKey
string
}{
DeploymentName
:
"foo"
,
Image
:
"foo"
,
ControlPlane
TaintKey
:
"foo"
,
},
},
}
...
...
cmd/kubeadm/app/phases/addons/dns/manifests.go
View file @
e11916da
...
...
@@ -77,7 +77,7 @@ spec:
path: /readiness
port: 8081
scheme: HTTP
# we poll on pod startup for the Kubernetes
master
service and
# we poll on pod startup for the Kubernetes
control-plane
service and
# only setup the /readiness HTTP server once that's available.
initialDelaySeconds: 3
timeoutSeconds: 5
...
...
@@ -173,7 +173,7 @@ spec:
tolerations:
- key: CriticalAddonsOnly
operator: Exists
- key: {{ .
Master
TaintKey }}
- key: {{ .
ControlPlane
TaintKey }}
effect: NoSchedule
`
...
...
@@ -241,7 +241,7 @@ spec:
tolerations:
- key: CriticalAddonsOnly
operator: Exists
- key: {{ .
Master
TaintKey }}
- key: {{ .
ControlPlane
TaintKey }}
effect: NoSchedule
nodeSelector:
beta.kubernetes.io/os: linux
...
...
cmd/kubeadm/app/phases/addons/proxy/manifests.go
View file @
e11916da
...
...
@@ -33,7 +33,7 @@ data:
clusters:
- cluster:
certificate-authority: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
server: {{ .
Master
Endpoint }}
server: {{ .
ControlPlane
Endpoint }}
name: default
contexts:
- context:
...
...
cmd/kubeadm/app/phases/addons/proxy/proxy.go
View file @
e11916da
...
...
@@ -67,15 +67,15 @@ func EnsureProxyAddon(cfg *kubeadmapi.ClusterConfiguration, localEndpoint *kubea
var
proxyConfigMapBytes
,
proxyDaemonSetBytes
[]
byte
proxyConfigMapBytes
,
err
=
kubeadmutil
.
ParseTemplate
(
KubeProxyConfigMap19
,
struct
{
MasterEndpoint
string
ProxyConfig
string
ProxyConfigMap
string
ProxyConfigMapKey
string
ControlPlaneEndpoint
string
ProxyConfig
string
ProxyConfigMap
string
ProxyConfigMapKey
string
}{
MasterEndpoint
:
controlPlaneEndpoint
,
ProxyConfig
:
prefixBytes
.
String
(),
ProxyConfigMap
:
constants
.
KubeProxyConfigMap
,
ProxyConfigMapKey
:
constants
.
KubeProxyConfigMapKey
,
ControlPlaneEndpoint
:
controlPlaneEndpoint
,
ProxyConfig
:
prefixBytes
.
String
(),
ProxyConfigMap
:
constants
.
KubeProxyConfigMap
,
ProxyConfigMapKey
:
constants
.
KubeProxyConfigMapKey
,
})
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"error when parsing kube-proxy configmap template"
)
...
...
cmd/kubeadm/app/phases/addons/proxy/proxy_test.go
View file @
e11916da
...
...
@@ -103,12 +103,12 @@ func TestCompileManifests(t *testing.T) {
{
manifest
:
KubeProxyConfigMap19
,
data
:
struct
{
Master
Endpoint
,
ProxyConfig
,
ProxyConfigMap
,
ProxyConfigMapKey
string
ControlPlane
Endpoint
,
ProxyConfig
,
ProxyConfigMap
,
ProxyConfigMapKey
string
}{
MasterEndpoint
:
"foo"
,
ProxyConfig
:
" bindAddress: 0.0.0.0
\n
clusterCIDR: 192.168.1.1
\n
enableProfiling: false"
,
ProxyConfigMap
:
"bar"
,
ProxyConfigMapKey
:
"baz"
,
ControlPlaneEndpoint
:
"foo"
,
ProxyConfig
:
" bindAddress: 0.0.0.0
\n
clusterCIDR: 192.168.1.1
\n
enableProfiling: false"
,
ProxyConfigMap
:
"bar"
,
ProxyConfigMapKey
:
"baz"
,
},
expected
:
true
,
},
...
...
@@ -140,7 +140,7 @@ func TestEnsureProxyAddon(t *testing.T) {
const
(
NoError
SimulatedError
=
iota
ServiceAccountError
Invalid
Master
Endpoint
Invalid
ControlPlane
Endpoint
IPv6SetBindAddress
)
...
...
@@ -177,7 +177,7 @@ func TestEnsureProxyAddon(t *testing.T) {
// Create a fake client and set up default test configuration
client
:=
clientsetfake
.
NewSimpleClientset
()
// TODO: Consider using a YAML file instead for this that makes it possible to specify YAML documents for the ComponentConfigs
master
Config
:=
&
kubeadmapiv1beta1
.
InitConfiguration
{
controlPlane
Config
:=
&
kubeadmapiv1beta1
.
InitConfiguration
{
LocalAPIEndpoint
:
kubeadmapiv1beta1
.
APIEndpoint
{
AdvertiseAddress
:
"1.2.3.4"
,
BindPort
:
1234
,
...
...
@@ -197,19 +197,19 @@ func TestEnsureProxyAddon(t *testing.T) {
client
.
PrependReactor
(
"create"
,
"serviceaccounts"
,
func
(
action
core
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
return
true
,
nil
,
apierrors
.
NewUnauthorized
(
""
)
})
case
Invalid
Master
Endpoint
:
master
Config
.
LocalAPIEndpoint
.
AdvertiseAddress
=
"1.2.3"
case
Invalid
ControlPlane
Endpoint
:
controlPlane
Config
.
LocalAPIEndpoint
.
AdvertiseAddress
=
"1.2.3"
case
IPv6SetBindAddress
:
master
Config
.
LocalAPIEndpoint
.
AdvertiseAddress
=
"1:2::3:4"
master
Config
.
Networking
.
PodSubnet
=
"2001:101::/96"
controlPlane
Config
.
LocalAPIEndpoint
.
AdvertiseAddress
=
"1:2::3:4"
controlPlane
Config
.
Networking
.
PodSubnet
=
"2001:101::/96"
}
int
Master
,
err
:=
configutil
.
DefaultedInitConfiguration
(
master
Config
)
int
ControlPlane
,
err
:=
configutil
.
DefaultedInitConfiguration
(
controlPlane
Config
)
if
err
!=
nil
{
t
.
Errorf
(
"test failed to convert external to internal version"
)
break
}
int
Master
.
ComponentConfigs
.
KubeProxy
=
&
kubeproxyconfig
.
KubeProxyConfiguration
{
int
ControlPlane
.
ComponentConfigs
.
KubeProxy
=
&
kubeproxyconfig
.
KubeProxyConfiguration
{
BindAddress
:
""
,
HealthzBindAddress
:
"0.0.0.0:10256"
,
MetricsBindAddress
:
"127.0.0.1:10249"
,
...
...
@@ -222,11 +222,11 @@ func TestEnsureProxyAddon(t *testing.T) {
},
}
// Run dynamic defaulting again as we changed the internal cfg
if
err
:=
configutil
.
SetInitDynamicDefaults
(
int
Master
);
err
!=
nil
{
if
err
:=
configutil
.
SetInitDynamicDefaults
(
int
ControlPlane
);
err
!=
nil
{
t
.
Errorf
(
"test failed to set dynamic defaults: %v"
,
err
)
break
}
err
=
EnsureProxyAddon
(
&
int
Master
.
ClusterConfiguration
,
&
intMaster
.
LocalAPIEndpoint
,
client
)
err
=
EnsureProxyAddon
(
&
int
ControlPlane
.
ClusterConfiguration
,
&
intControlPlane
.
LocalAPIEndpoint
,
client
)
// Compare actual to expected errors
actErr
:=
"No error"
...
...
@@ -244,17 +244,17 @@ func TestEnsureProxyAddon(t *testing.T) {
expErr
,
actErr
)
}
if
int
Master
.
ComponentConfigs
.
KubeProxy
.
BindAddress
!=
tc
.
expBindAddr
{
if
int
ControlPlane
.
ComponentConfigs
.
KubeProxy
.
BindAddress
!=
tc
.
expBindAddr
{
t
.
Errorf
(
"%s test failed, expected: %s, got: %s"
,
tc
.
name
,
tc
.
expBindAddr
,
int
Master
.
ComponentConfigs
.
KubeProxy
.
BindAddress
)
int
ControlPlane
.
ComponentConfigs
.
KubeProxy
.
BindAddress
)
}
if
int
Master
.
ComponentConfigs
.
KubeProxy
.
ClusterCIDR
!=
tc
.
expClusterCIDR
{
if
int
ControlPlane
.
ComponentConfigs
.
KubeProxy
.
ClusterCIDR
!=
tc
.
expClusterCIDR
{
t
.
Errorf
(
"%s test failed, expected: %s, got: %s"
,
tc
.
name
,
tc
.
expClusterCIDR
,
int
Master
.
ComponentConfigs
.
KubeProxy
.
ClusterCIDR
)
int
ControlPlane
.
ComponentConfigs
.
KubeProxy
.
ClusterCIDR
)
}
}
}
...
...
cmd/kubeadm/app/phases/kubeconfig/kubeconfig.go
View file @
e11916da
...
...
@@ -136,7 +136,7 @@ func getKubeConfigSpecs(cfg *kubeadmapi.InitConfiguration) (map[string]*kubeConf
return
nil
,
errors
.
Wrap
(
err
,
"couldn't create a kubeconfig; the CA files couldn't be loaded"
)
}
master
Endpoint
,
err
:=
kubeadmutil
.
GetControlPlaneEndpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
controlPlane
Endpoint
,
err
:=
kubeadmutil
.
GetControlPlaneEndpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -144,7 +144,7 @@ func getKubeConfigSpecs(cfg *kubeadmapi.InitConfiguration) (map[string]*kubeConf
var
kubeConfigSpec
=
map
[
string
]
*
kubeConfigSpec
{
kubeadmconstants
.
AdminKubeConfigFileName
:
{
CACert
:
caCert
,
APIServer
:
master
Endpoint
,
APIServer
:
controlPlane
Endpoint
,
ClientName
:
"kubernetes-admin"
,
ClientCertAuth
:
&
clientCertAuth
{
CAKey
:
caKey
,
...
...
@@ -153,7 +153,7 @@ func getKubeConfigSpecs(cfg *kubeadmapi.InitConfiguration) (map[string]*kubeConf
},
kubeadmconstants
.
KubeletKubeConfigFileName
:
{
CACert
:
caCert
,
APIServer
:
master
Endpoint
,
APIServer
:
controlPlane
Endpoint
,
ClientName
:
fmt
.
Sprintf
(
"%s%s"
,
kubeadmconstants
.
NodesUserPrefix
,
cfg
.
NodeRegistration
.
Name
),
ClientCertAuth
:
&
clientCertAuth
{
CAKey
:
caKey
,
...
...
@@ -162,7 +162,7 @@ func getKubeConfigSpecs(cfg *kubeadmapi.InitConfiguration) (map[string]*kubeConf
},
kubeadmconstants
.
ControllerManagerKubeConfigFileName
:
{
CACert
:
caCert
,
APIServer
:
master
Endpoint
,
APIServer
:
controlPlane
Endpoint
,
ClientName
:
kubeadmconstants
.
ControllerManagerUser
,
ClientCertAuth
:
&
clientCertAuth
{
CAKey
:
caKey
,
...
...
@@ -170,7 +170,7 @@ func getKubeConfigSpecs(cfg *kubeadmapi.InitConfiguration) (map[string]*kubeConf
},
kubeadmconstants
.
SchedulerKubeConfigFileName
:
{
CACert
:
caCert
,
APIServer
:
master
Endpoint
,
APIServer
:
controlPlane
Endpoint
,
ClientName
:
kubeadmconstants
.
SchedulerUser
,
ClientCertAuth
:
&
clientCertAuth
{
CAKey
:
caKey
,
...
...
@@ -290,14 +290,14 @@ func WriteKubeConfigWithClientCert(out io.Writer, cfg *kubeadmapi.InitConfigurat
return
errors
.
Wrap
(
err
,
"couldn't create a kubeconfig; the CA files couldn't be loaded"
)
}
master
Endpoint
,
err
:=
kubeadmutil
.
GetControlPlaneEndpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
controlPlane
Endpoint
,
err
:=
kubeadmutil
.
GetControlPlaneEndpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
if
err
!=
nil
{
return
err
}
spec
:=
&
kubeConfigSpec
{
ClientName
:
clientName
,
APIServer
:
master
Endpoint
,
APIServer
:
controlPlane
Endpoint
,
CACert
:
caCert
,
ClientCertAuth
:
&
clientCertAuth
{
CAKey
:
caKey
,
...
...
@@ -317,14 +317,14 @@ func WriteKubeConfigWithToken(out io.Writer, cfg *kubeadmapi.InitConfiguration,
return
errors
.
Wrap
(
err
,
"couldn't create a kubeconfig; the CA files couldn't be loaded"
)
}
master
Endpoint
,
err
:=
kubeadmutil
.
GetControlPlaneEndpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
controlPlane
Endpoint
,
err
:=
kubeadmutil
.
GetControlPlaneEndpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
if
err
!=
nil
{
return
err
}
spec
:=
&
kubeConfigSpec
{
ClientName
:
clientName
,
APIServer
:
master
Endpoint
,
APIServer
:
controlPlane
Endpoint
,
CACert
:
caCert
,
TokenAuth
:
&
tokenAuth
{
Token
:
token
,
...
...
cmd/kubeadm/app/phases/kubeconfig/kubeconfig_test.go
View file @
e11916da
...
...
@@ -162,11 +162,11 @@ func TestGetKubeConfigSpecs(t *testing.T) {
}
// Asserts InitConfiguration values injected into spec
master
Endpoint
,
err
:=
kubeadmutil
.
GetControlPlaneEndpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
controlPlane
Endpoint
,
err
:=
kubeadmutil
.
GetControlPlaneEndpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
if
spec
.
APIServer
!=
master
Endpoint
{
if
spec
.
APIServer
!=
controlPlane
Endpoint
{
t
.
Errorf
(
"getKubeConfigSpecs didn't injected cfg.APIServer endpoint into spec for %s"
,
assertion
.
kubeConfigFile
)
}
...
...
cmd/kubeadm/app/phases/markcontrolplane/markcontrolplane.go
View file @
e11916da
...
...
@@ -39,7 +39,7 @@ func MarkControlPlane(client clientset.Interface, controlPlaneName string, taint
}
return
apiclient
.
PatchNode
(
client
,
controlPlaneName
,
func
(
n
*
v1
.
Node
)
{
mark
Master
Node
(
n
,
taints
)
mark
ControlPlane
Node
(
n
,
taints
)
})
}
...
...
@@ -53,7 +53,7 @@ func taintExists(taint v1.Taint, taints []v1.Taint) bool {
return
false
}
func
mark
Master
Node
(
n
*
v1
.
Node
,
taints
[]
v1
.
Taint
)
{
func
mark
ControlPlane
Node
(
n
*
v1
.
Node
,
taints
[]
v1
.
Taint
)
{
n
.
ObjectMeta
.
Labels
[
constants
.
LabelNodeRoleMaster
]
=
""
for
_
,
nt
:=
range
n
.
Spec
.
Taints
{
...
...
cmd/kubeadm/app/phases/selfhosting/podspec_mutation.go
View file @
e11916da
...
...
@@ -40,18 +40,18 @@ func GetDefaultMutators() map[string][]PodSpecMutatorFunc {
return
map
[
string
][]
PodSpecMutatorFunc
{
kubeadmconstants
.
KubeAPIServer
:
{
addNodeSelectorToPodSpec
,
set
Master
TolerationOnPodSpec
,
set
ControlPlane
TolerationOnPodSpec
,
setRightDNSPolicyOnPodSpec
,
setHostIPOnPodSpec
,
},
kubeadmconstants
.
KubeControllerManager
:
{
addNodeSelectorToPodSpec
,
set
Master
TolerationOnPodSpec
,
set
ControlPlane
TolerationOnPodSpec
,
setRightDNSPolicyOnPodSpec
,
},
kubeadmconstants
.
KubeScheduler
:
{
addNodeSelectorToPodSpec
,
set
Master
TolerationOnPodSpec
,
set
ControlPlane
TolerationOnPodSpec
,
setRightDNSPolicyOnPodSpec
,
},
}
...
...
@@ -82,7 +82,7 @@ func mutatePodSpec(mutators map[string][]PodSpecMutatorFunc, name string, podSpe
}
}
// addNodeSelectorToPodSpec makes Pod require to be scheduled on a node marked with the
master
label
// addNodeSelectorToPodSpec makes Pod require to be scheduled on a node marked with the
control-plane
label
func
addNodeSelectorToPodSpec
(
podSpec
*
v1
.
PodSpec
)
{
if
podSpec
.
NodeSelector
==
nil
{
podSpec
.
NodeSelector
=
map
[
string
]
string
{
kubeadmconstants
.
LabelNodeRoleMaster
:
""
}
...
...
@@ -92,8 +92,8 @@ func addNodeSelectorToPodSpec(podSpec *v1.PodSpec) {
podSpec
.
NodeSelector
[
kubeadmconstants
.
LabelNodeRoleMaster
]
=
""
}
// set
MasterTolerationOnPodSpec makes the Pod tolerate the master
taint
func
set
Master
TolerationOnPodSpec
(
podSpec
*
v1
.
PodSpec
)
{
// set
ControlPlaneTolerationOnPodSpec makes the Pod tolerate the control-plane
taint
func
set
ControlPlane
TolerationOnPodSpec
(
podSpec
*
v1
.
PodSpec
)
{
if
podSpec
.
Tolerations
==
nil
{
podSpec
.
Tolerations
=
[]
v1
.
Toleration
{
kubeadmconstants
.
ControlPlaneToleration
}
return
...
...
cmd/kubeadm/app/phases/selfhosting/podspec_mutation_test.go
View file @
e11916da
...
...
@@ -157,7 +157,7 @@ func TestAddNodeSelectorToPodSpec(t *testing.T) {
}
}
func
TestSet
Master
TolerationOnPodSpec
(
t
*
testing
.
T
)
{
func
TestSet
ControlPlane
TolerationOnPodSpec
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
name
string
podSpec
*
v1
.
PodSpec
...
...
@@ -190,10 +190,10 @@ func TestSetMasterTolerationOnPodSpec(t *testing.T) {
for
_
,
rt
:=
range
tests
{
t
.
Run
(
rt
.
name
,
func
(
t
*
testing
.
T
)
{
set
Master
TolerationOnPodSpec
(
rt
.
podSpec
)
set
ControlPlane
TolerationOnPodSpec
(
rt
.
podSpec
)
if
!
reflect
.
DeepEqual
(
*
rt
.
podSpec
,
rt
.
expected
)
{
t
.
Errorf
(
"failed set
Master
TolerationOnPodSpec:
\n
expected:
\n
%v
\n
saw:
\n
%v"
,
rt
.
expected
,
*
rt
.
podSpec
)
t
.
Errorf
(
"failed set
ControlPlane
TolerationOnPodSpec:
\n
expected:
\n
%v
\n
saw:
\n
%v"
,
rt
.
expected
,
*
rt
.
podSpec
)
}
})
}
...
...
cmd/kubeadm/app/phases/upgrade/health.go
View file @
e11916da
...
...
@@ -56,7 +56,7 @@ func (c *healthCheck) Name() string {
// CheckClusterHealth makes sure:
// - the API /healthz endpoint is healthy
// - all
master
Nodes are Ready
// - all
control-plane
Nodes are Ready
// - (if self-hosted) that there are DaemonSets with at least one Pod for all control plane components
// - (if static pod-hosted) that all required Static Pod manifests exist on disk
func
CheckClusterHealth
(
client
clientset
.
Interface
,
ignoreChecksErrors
sets
.
String
)
error
{
...
...
@@ -69,9 +69,9 @@ func CheckClusterHealth(client clientset.Interface, ignoreChecksErrors sets.Stri
f
:
apiServerHealthy
,
},
&
healthCheck
{
name
:
"
Master
NodesReady"
,
name
:
"
ControlPlane
NodesReady"
,
client
:
client
,
f
:
master
NodesReady
,
f
:
controlPlane
NodesReady
,
},
// TODO: Add a check for ComponentStatuses here?
}
...
...
@@ -100,25 +100,25 @@ func apiServerHealthy(client clientset.Interface) error {
return
nil
}
//
masterNodesReady checks whether all master
Nodes in the cluster are in the Running state
func
master
NodesReady
(
client
clientset
.
Interface
)
error
{
//
controlPlaneNodesReady checks whether all control-plane
Nodes in the cluster are in the Running state
func
controlPlane
NodesReady
(
client
clientset
.
Interface
)
error
{
selector
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
constants
.
LabelNodeRoleMaster
:
""
,
}))
master
s
,
err
:=
client
.
CoreV1
()
.
Nodes
()
.
List
(
metav1
.
ListOptions
{
controlPlane
s
,
err
:=
client
.
CoreV1
()
.
Nodes
()
.
List
(
metav1
.
ListOptions
{
LabelSelector
:
selector
.
String
(),
})
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"couldn't list control-planes in cluster"
)
}
if
len
(
master
s
.
Items
)
==
0
{
if
len
(
controlPlane
s
.
Items
)
==
0
{
return
errors
.
New
(
"failed to find any nodes with a control-plane role"
)
}
notReady
Masters
:=
getNotReadyNodes
(
master
s
.
Items
)
if
len
(
notReady
Master
s
)
!=
0
{
return
errors
.
Errorf
(
"there are NotReady control-planes in the cluster: %v"
,
notReady
Master
s
)
notReady
ControlPlanes
:=
getNotReadyNodes
(
controlPlane
s
.
Items
)
if
len
(
notReady
ControlPlane
s
)
!=
0
{
return
errors
.
Errorf
(
"there are NotReady control-planes in the cluster: %v"
,
notReady
ControlPlane
s
)
}
return
nil
}
...
...
cmd/kubeadm/app/phases/upgrade/postupgrade.go
View file @
e11916da
...
...
@@ -49,7 +49,7 @@ import (
var
expiry
=
180
*
24
*
time
.
Hour
// PerformPostUpgradeTasks runs nearly the same functions as 'kubeadm init' would do
// Note that the mark
master
phase is left out, not needed, and no token is created as that doesn't belong to the upgrade
// Note that the mark
-control-plane
phase is left out, not needed, and no token is created as that doesn't belong to the upgrade
func
PerformPostUpgradeTasks
(
client
clientset
.
Interface
,
cfg
*
kubeadmapi
.
InitConfiguration
,
newK8sVer
*
version
.
Version
,
dryRun
bool
)
error
{
errs
:=
[]
error
{}
...
...
@@ -207,9 +207,9 @@ func writeKubeletConfigFiles(client clientset.Interface, cfg *kubeadmapi.InitCon
envFilePath
:=
filepath
.
Join
(
kubeadmconstants
.
KubeletRunDirectory
,
kubeadmconstants
.
KubeletEnvFileName
)
if
_
,
err
:=
os
.
Stat
(
envFilePath
);
os
.
IsNotExist
(
err
)
{
// Write env file with flags for the kubelet to use. We do not need to write the --register-with-taints for the
master
,
// as we handle that ourselves in the mark
master
phase
// TODO: Maybe we want to do that some time in the future, in order to remove some logic from the mark
master
phase?
// Write env file with flags for the kubelet to use. We do not need to write the --register-with-taints for the
control-plane
,
// as we handle that ourselves in the mark
-control-plane
phase
// TODO: Maybe we want to do that some time in the future, in order to remove some logic from the mark
-control-plane
phase?
if
err
:=
kubeletphase
.
WriteKubeletDynamicEnvFile
(
&
cfg
.
ClusterConfiguration
,
&
cfg
.
NodeRegistration
,
false
,
kubeletDir
);
err
!=
nil
{
errs
=
append
(
errs
,
errors
.
Wrap
(
err
,
"error writing a dynamic environment file for the kubelet"
))
}
...
...
cmd/kubeadm/app/phases/upgrade/prepull.go
View file @
e11916da
...
...
@@ -42,7 +42,7 @@ type Prepuller interface {
DeleteFunc
(
string
)
error
}
// DaemonSetPrepuller makes sure the control-plane images are available on all
master
s
// DaemonSetPrepuller makes sure the control-plane images are available on all
control-plane
s
type
DaemonSetPrepuller
struct
{
client
clientset
.
Interface
cfg
*
kubeadmapi
.
ClusterConfiguration
...
...
cmd/kubeadm/app/phases/uploadconfig/uploadconfig_test.go
View file @
e11916da
...
...
@@ -120,11 +120,11 @@ func TestUploadConfiguration(t *testing.T) {
}
}
if
tt
.
verifyResult
{
master
Cfg
,
err
:=
client
.
CoreV1
()
.
ConfigMaps
(
metav1
.
NamespaceSystem
)
.
Get
(
kubeadmconstants
.
KubeadmConfigConfigMap
,
metav1
.
GetOptions
{})
controlPlane
Cfg
,
err
:=
client
.
CoreV1
()
.
ConfigMaps
(
metav1
.
NamespaceSystem
)
.
Get
(
kubeadmconstants
.
KubeadmConfigConfigMap
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
t2
.
Fatalf
(
"Fail to query ConfigMap error = %v"
,
err
)
}
configData
:=
master
Cfg
.
Data
[
kubeadmconstants
.
ClusterConfigurationConfigMapKey
]
configData
:=
controlPlane
Cfg
.
Data
[
kubeadmconstants
.
ClusterConfigurationConfigMapKey
]
if
configData
==
""
{
t2
.
Fatal
(
"Fail to find ClusterConfigurationConfigMapKey key"
)
}
...
...
@@ -138,7 +138,7 @@ func TestUploadConfiguration(t *testing.T) {
t2
.
Errorf
(
"the initial and decoded ClusterConfiguration didn't match"
)
}
statusData
:=
master
Cfg
.
Data
[
kubeadmconstants
.
ClusterStatusConfigMapKey
]
statusData
:=
controlPlane
Cfg
.
Data
[
kubeadmconstants
.
ClusterStatusConfigMapKey
]
if
statusData
==
""
{
t2
.
Fatal
(
"failed to find ClusterStatusConfigMapKey key"
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment