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
ae1ec882
Commit
ae1ec882
authored
Feb 14, 2019
by
vanduc95
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubeadm cleanup: master -> control-plane (cont.2)
parent
3baab4dc
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
60 additions
and
61 deletions
+60
-61
preflight.go
cmd/kubeadm/app/cmd/phases/init/preflight.go
+1
-1
waitcontrolplane.go
cmd/kubeadm/app/cmd/phases/init/waitcontrolplane.go
+1
-1
preflight.go
cmd/kubeadm/app/cmd/phases/join/preflight.go
+1
-1
apply.go
cmd/kubeadm/app/cmd/upgrade/apply.go
+2
-2
constants.go
cmd/kubeadm/app/constants/constants.go
+14
-14
certlist.go
cmd/kubeadm/app/phases/certs/certlist.go
+3
-3
kubeconfig.go
cmd/kubeadm/app/phases/kubeconfig/kubeconfig.go
+1
-1
kubeconfig_test.go
cmd/kubeadm/app/phases/kubeconfig/kubeconfig_test.go
+1
-1
markcontrolplane_test.go
...eadm/app/phases/markcontrolplane/markcontrolplane_test.go
+7
-7
podspec_mutation.go
cmd/kubeadm/app/phases/selfhosting/podspec_mutation.go
+2
-2
podspec_mutation_test.go
cmd/kubeadm/app/phases/selfhosting/podspec_mutation_test.go
+5
-5
selfhosting.go
cmd/kubeadm/app/phases/selfhosting/selfhosting.go
+1
-1
health.go
cmd/kubeadm/app/phases/upgrade/health.go
+2
-2
prepull.go
cmd/kubeadm/app/phases/upgrade/prepull.go
+2
-2
prepull_test.go
cmd/kubeadm/app/phases/upgrade/prepull_test.go
+1
-1
staticpods.go
cmd/kubeadm/app/phases/upgrade/staticpods.go
+1
-1
checks.go
cmd/kubeadm/app/preflight/checks.go
+3
-3
checks_test.go
cmd/kubeadm/app/preflight/checks_test.go
+4
-4
wait.go
cmd/kubeadm/app/util/apiclient/wait.go
+1
-1
cluster.go
cmd/kubeadm/app/util/config/cluster.go
+0
-1
cluster_test.go
cmd/kubeadm/app/util/config/cluster_test.go
+3
-3
initconfiguration.go
cmd/kubeadm/app/util/config/initconfiguration.go
+4
-4
No files found.
cmd/kubeadm/app/cmd/phases/init/preflight.go
View file @
ae1ec882
...
...
@@ -68,7 +68,7 @@ func runPreflight(c workflow.RunData) error {
}
fmt
.
Println
(
"[preflight] Running pre-flight checks"
)
if
err
:=
preflight
.
RunInit
Master
Checks
(
utilsexec
.
New
(),
data
.
Cfg
(),
data
.
IgnorePreflightErrors
());
err
!=
nil
{
if
err
:=
preflight
.
RunInit
Node
Checks
(
utilsexec
.
New
(),
data
.
Cfg
(),
data
.
IgnorePreflightErrors
());
err
!=
nil
{
return
err
}
...
...
cmd/kubeadm/app/cmd/phases/init/waitcontrolplane.go
View file @
ae1ec882
...
...
@@ -126,7 +126,7 @@ func printFilesIfDryRunning(data waitControlPlaneData) error {
// Print the contents of the upgraded manifests and pretend like they were in /etc/kubernetes/manifests
files
:=
[]
dryrunutil
.
FileToPrint
{}
// Print static pod manifests
for
_
,
component
:=
range
kubeadmconstants
.
Master
Components
{
for
_
,
component
:=
range
kubeadmconstants
.
ControlPlane
Components
{
realPath
:=
kubeadmconstants
.
GetStaticPodFilepath
(
component
,
manifestDir
)
outputPath
:=
kubeadmconstants
.
GetStaticPodFilepath
(
component
,
kubeadmconstants
.
GetStaticPodDirectory
())
files
=
append
(
files
,
dryrunutil
.
NewFileToPrint
(
realPath
,
outputPath
))
...
...
cmd/kubeadm/app/cmd/phases/join/preflight.go
View file @
ae1ec882
...
...
@@ -125,7 +125,7 @@ func runPreflight(c workflow.RunData) error {
// run kubeadm init preflight checks for checking all the prequisites
fmt
.
Println
(
"[preflight] Running pre-flight checks before initializing the new control plane instance"
)
if
err
:=
preflight
.
RunInit
Master
Checks
(
utilsexec
.
New
(),
initCfg
,
j
.
IgnorePreflightErrors
());
err
!=
nil
{
if
err
:=
preflight
.
RunInit
Node
Checks
(
utilsexec
.
New
(),
initCfg
,
j
.
IgnorePreflightErrors
());
err
!=
nil
{
return
err
}
...
...
cmd/kubeadm/app/cmd/upgrade/apply.go
View file @
ae1ec882
...
...
@@ -196,7 +196,7 @@ func runApply(flags *applyFlags) error {
// and block until all DaemonSets are ready; then we know for sure that all control plane images are cached locally
klog
.
V
(
1
)
.
Infof
(
"[upgrade/apply] creating prepuller"
)
prepuller
:=
upgrade
.
NewDaemonSetPrepuller
(
client
,
waiter
,
&
cfg
.
ClusterConfiguration
)
componentsToPrepull
:=
constants
.
Master
Components
componentsToPrepull
:=
constants
.
ControlPlane
Components
if
cfg
.
Etcd
.
External
==
nil
&&
flags
.
etcdUpgrade
{
componentsToPrepull
=
append
(
componentsToPrepull
,
constants
.
Etcd
)
}
...
...
@@ -310,7 +310,7 @@ func DryRunStaticPodUpgrade(internalcfg *kubeadmapi.InitConfiguration) error {
// Print the contents of the upgraded manifests and pretend like they were in /etc/kubernetes/manifests
files
:=
[]
dryrunutil
.
FileToPrint
{}
for
_
,
component
:=
range
constants
.
Master
Components
{
for
_
,
component
:=
range
constants
.
ControlPlane
Components
{
realPath
:=
constants
.
GetStaticPodFilepath
(
component
,
dryRunManifestDir
)
outputPath
:=
constants
.
GetStaticPodFilepath
(
component
,
constants
.
GetStaticPodDirectory
())
files
=
append
(
files
,
dryrunutil
.
NewFileToPrint
(
realPath
,
outputPath
))
...
...
cmd/kubeadm/app/constants/constants.go
View file @
ae1ec882
...
...
@@ -143,7 +143,7 @@ const (
// the TLS bootstrap to get itself an unique credential
KubeletBootstrapKubeConfigFileName
=
"bootstrap-kubelet.conf"
// KubeletKubeConfigFileName defines the file name for the kubeconfig that the
master
kubelet will use for talking
// KubeletKubeConfigFileName defines the file name for the kubeconfig that the
control-plane
kubelet will use for talking
// to the API server
KubeletKubeConfigFileName
=
"kubelet.conf"
// ControllerManagerKubeConfigFileName defines the file name for the controller manager's kubeconfig file
...
...
@@ -157,9 +157,9 @@ const (
ControllerManagerUser
=
"system:kube-controller-manager"
// SchedulerUser defines the well-known user the scheduler should be authenticated as
SchedulerUser
=
"system:kube-scheduler"
//
Masters
Group defines the well-known group for the apiservers. This group is also superuser by default
//
SystemPrivileged
Group defines the well-known group for the apiservers. This group is also superuser by default
// (i.e. bound to the cluster-admin ClusterRole)
Masters
Group
=
"system:masters"
SystemPrivileged
Group
=
"system:masters"
// NodesGroup defines the well-known group for all nodes.
NodesGroup
=
"system:nodes"
// NodesUserPrefix defines the user name prefix as requested by the Node authorizer.
...
...
@@ -171,9 +171,9 @@ const (
// APICallRetryInterval defines how long kubeadm should wait before retrying a failed API operation
APICallRetryInterval
=
500
*
time
.
Millisecond
// DiscoveryRetryInterval specifies how long kubeadm should wait before retrying to connect to the
master
when doing discovery
// DiscoveryRetryInterval specifies how long kubeadm should wait before retrying to connect to the
control-plane
when doing discovery
DiscoveryRetryInterval
=
5
*
time
.
Second
// PatchNodeTimeout specifies how long kubeadm should wait for applying the label and taint on the
master
before timing out
// PatchNodeTimeout specifies how long kubeadm should wait for applying the label and taint on the
control-plane
before timing out
PatchNodeTimeout
=
2
*
time
.
Minute
// UpdateNodeTimeout specifies how long kubeadm should wait for updating node with the initial remote configuration of kubelet before timing out
UpdateNodeTimeout
=
2
*
time
.
Minute
...
...
@@ -198,7 +198,7 @@ const (
// CertificateKeySize specifies the size of the key used to encrypt certificates on uploadcerts phase
CertificateKeySize
=
32
// LabelNodeRoleMaster specifies that a node is a
master
// LabelNodeRoleMaster specifies that a node is a
control-plane
// This is a duplicate definition of the constant in pkg/controller/service/service_controller.go
LabelNodeRoleMaster
=
"node-role.kubernetes.io/master"
...
...
@@ -357,22 +357,22 @@ const (
// DefaultAPIServerBindAddress is the default bind address for the API Server
DefaultAPIServerBindAddress
=
"0.0.0.0"
//
MasterNumCPU is the number of CPUs required on master
Master
NumCPU
=
2
//
ControlPlaneNumCPU is the number of CPUs required on control-plane
ControlPlane
NumCPU
=
2
// KubeadmCertsSecret specifies in what Secret in the kube-system namespace the certificates should be stored
KubeadmCertsSecret
=
"kubeadm-certs"
)
var
(
//
MasterTaint is the taint to apply on the PodSpec for being able to run that Pod on the master
Master
Taint
=
v1
.
Taint
{
//
ControlPlaneTaint is the taint to apply on the PodSpec for being able to run that Pod on the control-plane
ControlPlane
Taint
=
v1
.
Taint
{
Key
:
LabelNodeRoleMaster
,
Effect
:
v1
.
TaintEffectNoSchedule
,
}
//
MasterToleration is the toleration to apply on the PodSpec for being able to run that Pod on the master
Master
Toleration
=
v1
.
Toleration
{
//
ControlPlaneToleration is the toleration to apply on the PodSpec for being able to run that Pod on the control-plane
ControlPlane
Toleration
=
v1
.
Toleration
{
Key
:
LabelNodeRoleMaster
,
Effect
:
v1
.
TaintEffectNoSchedule
,
}
...
...
@@ -383,8 +383,8 @@ var (
// DefaultTokenGroups specifies the default groups that this token will authenticate as when used for authentication
DefaultTokenGroups
=
[]
string
{
NodeBootstrapTokenAuthGroup
}
//
MasterComponents defines the master
component names
Master
Components
=
[]
string
{
KubeAPIServer
,
KubeControllerManager
,
KubeScheduler
}
//
ControlPlaneComponents defines the control-plane
component names
ControlPlane
Components
=
[]
string
{
KubeAPIServer
,
KubeControllerManager
,
KubeScheduler
}
// MinimumControlPlaneVersion specifies the minimum control plane version kubeadm can deploy
MinimumControlPlaneVersion
=
version
.
MustParseSemantic
(
"v1.12.0"
)
...
...
cmd/kubeadm/app/phases/certs/certlist.go
View file @
ae1ec882
...
...
@@ -265,7 +265,7 @@ var (
CAName
:
"ca"
,
config
:
certutil
.
Config
{
CommonName
:
kubeadmconstants
.
APIServerKubeletClientCertCommonName
,
Organization
:
[]
string
{
kubeadmconstants
.
Masters
Group
},
Organization
:
[]
string
{
kubeadmconstants
.
SystemPrivileged
Group
},
Usages
:
[]
x509
.
ExtKeyUsage
{
x509
.
ExtKeyUsageClientAuth
},
},
}
...
...
@@ -341,7 +341,7 @@ var (
CAName
:
"etcd-ca"
,
config
:
certutil
.
Config
{
CommonName
:
kubeadmconstants
.
EtcdHealthcheckClientCertCommonName
,
Organization
:
[]
string
{
kubeadmconstants
.
Masters
Group
},
Organization
:
[]
string
{
kubeadmconstants
.
SystemPrivileged
Group
},
Usages
:
[]
x509
.
ExtKeyUsage
{
x509
.
ExtKeyUsageClientAuth
},
},
}
...
...
@@ -353,7 +353,7 @@ var (
CAName
:
"etcd-ca"
,
config
:
certutil
.
Config
{
CommonName
:
kubeadmconstants
.
APIServerEtcdClientCertCommonName
,
Organization
:
[]
string
{
kubeadmconstants
.
Masters
Group
},
Organization
:
[]
string
{
kubeadmconstants
.
SystemPrivileged
Group
},
Usages
:
[]
x509
.
ExtKeyUsage
{
x509
.
ExtKeyUsageClientAuth
},
},
}
...
...
cmd/kubeadm/app/phases/kubeconfig/kubeconfig.go
View file @
ae1ec882
...
...
@@ -147,7 +147,7 @@ func getKubeConfigSpecs(cfg *kubeadmapi.InitConfiguration) (map[string]*kubeConf
ClientName
:
"kubernetes-admin"
,
ClientCertAuth
:
&
clientCertAuth
{
CAKey
:
caKey
,
Organizations
:
[]
string
{
kubeadmconstants
.
Masters
Group
},
Organizations
:
[]
string
{
kubeadmconstants
.
SystemPrivileged
Group
},
},
},
kubeadmconstants
.
KubeletKubeConfigFileName
:
{
...
...
cmd/kubeadm/app/phases/kubeconfig/kubeconfig_test.go
View file @
ae1ec882
...
...
@@ -118,7 +118,7 @@ func TestGetKubeConfigSpecs(t *testing.T) {
{
kubeConfigFile
:
kubeadmconstants
.
AdminKubeConfigFileName
,
clientName
:
"kubernetes-admin"
,
organizations
:
[]
string
{
kubeadmconstants
.
Masters
Group
},
organizations
:
[]
string
{
kubeadmconstants
.
SystemPrivileged
Group
},
},
{
kubeConfigFile
:
kubeadmconstants
.
KubeletKubeConfigFileName
,
...
...
cmd/kubeadm/app/phases/markcontrolplane/markcontrolplane_test.go
View file @
ae1ec882
...
...
@@ -49,7 +49,7 @@ func TestMarkControlPlane(t *testing.T) {
"control-plane label and taint missing"
,
""
,
nil
,
[]
v1
.
Taint
{
kubeadmconstants
.
Master
Taint
},
[]
v1
.
Taint
{
kubeadmconstants
.
ControlPlane
Taint
},
"{
\"
metadata
\"
:{
\"
labels
\"
:{
\"
node-role.kubernetes.io/master
\"
:
\"\"
}},
\"
spec
\"
:{
\"
taints
\"
:[{
\"
effect
\"
:
\"
NoSchedule
\"
,
\"
key
\"
:
\"
node-role.kubernetes.io/master
\"
}]}}"
,
},
{
...
...
@@ -62,22 +62,22 @@ func TestMarkControlPlane(t *testing.T) {
{
"control-plane label missing"
,
""
,
[]
v1
.
Taint
{
kubeadmconstants
.
Master
Taint
},
[]
v1
.
Taint
{
kubeadmconstants
.
Master
Taint
},
[]
v1
.
Taint
{
kubeadmconstants
.
ControlPlane
Taint
},
[]
v1
.
Taint
{
kubeadmconstants
.
ControlPlane
Taint
},
"{
\"
metadata
\"
:{
\"
labels
\"
:{
\"
node-role.kubernetes.io/master
\"
:
\"\"
}}}"
,
},
{
"control-plane taint missing"
,
kubeadmconstants
.
LabelNodeRoleMaster
,
nil
,
[]
v1
.
Taint
{
kubeadmconstants
.
Master
Taint
},
[]
v1
.
Taint
{
kubeadmconstants
.
ControlPlane
Taint
},
"{
\"
spec
\"
:{
\"
taints
\"
:[{
\"
effect
\"
:
\"
NoSchedule
\"
,
\"
key
\"
:
\"
node-role.kubernetes.io/master
\"
}]}}"
,
},
{
"nothing missing"
,
kubeadmconstants
.
LabelNodeRoleMaster
,
[]
v1
.
Taint
{
kubeadmconstants
.
Master
Taint
},
[]
v1
.
Taint
{
kubeadmconstants
.
Master
Taint
},
[]
v1
.
Taint
{
kubeadmconstants
.
ControlPlane
Taint
},
[]
v1
.
Taint
{
kubeadmconstants
.
ControlPlane
Taint
},
"{}"
,
},
{
...
...
@@ -101,7 +101,7 @@ func TestMarkControlPlane(t *testing.T) {
Effect
:
v1
.
TaintEffectNoSchedule
,
},
},
[]
v1
.
Taint
{
kubeadmconstants
.
Master
Taint
},
[]
v1
.
Taint
{
kubeadmconstants
.
ControlPlane
Taint
},
"{
\"
spec
\"
:{
\"
taints
\"
:[{
\"
effect
\"
:
\"
NoSchedule
\"
,
\"
key
\"
:
\"
node-role.kubernetes.io/master
\"
},{
\"
effect
\"
:
\"
NoSchedule
\"
,
\"
key
\"
:
\"
node.cloudprovider.kubernetes.io/uninitialized
\"
}]}}"
,
},
}
...
...
cmd/kubeadm/app/phases/selfhosting/podspec_mutation.go
View file @
ae1ec882
...
...
@@ -95,11 +95,11 @@ func addNodeSelectorToPodSpec(podSpec *v1.PodSpec) {
// setMasterTolerationOnPodSpec makes the Pod tolerate the master taint
func
setMasterTolerationOnPodSpec
(
podSpec
*
v1
.
PodSpec
)
{
if
podSpec
.
Tolerations
==
nil
{
podSpec
.
Tolerations
=
[]
v1
.
Toleration
{
kubeadmconstants
.
Master
Toleration
}
podSpec
.
Tolerations
=
[]
v1
.
Toleration
{
kubeadmconstants
.
ControlPlane
Toleration
}
return
}
podSpec
.
Tolerations
=
append
(
podSpec
.
Tolerations
,
kubeadmconstants
.
Master
Toleration
)
podSpec
.
Tolerations
=
append
(
podSpec
.
Tolerations
,
kubeadmconstants
.
ControlPlane
Toleration
)
}
// setHostIPOnPodSpec sets the environment variable HOST_IP using downward API
...
...
cmd/kubeadm/app/phases/selfhosting/podspec_mutation_test.go
View file @
ae1ec882
...
...
@@ -69,7 +69,7 @@ func TestMutatePodSpec(t *testing.T) {
kubeadmconstants
.
LabelNodeRoleMaster
:
""
,
},
Tolerations
:
[]
v1
.
Toleration
{
kubeadmconstants
.
Master
Toleration
,
kubeadmconstants
.
ControlPlane
Toleration
,
},
DNSPolicy
:
v1
.
DNSClusterFirstWithHostNet
,
},
...
...
@@ -83,7 +83,7 @@ func TestMutatePodSpec(t *testing.T) {
kubeadmconstants
.
LabelNodeRoleMaster
:
""
,
},
Tolerations
:
[]
v1
.
Toleration
{
kubeadmconstants
.
Master
Toleration
,
kubeadmconstants
.
ControlPlane
Toleration
,
},
DNSPolicy
:
v1
.
DNSClusterFirstWithHostNet
,
},
...
...
@@ -97,7 +97,7 @@ func TestMutatePodSpec(t *testing.T) {
kubeadmconstants
.
LabelNodeRoleMaster
:
""
,
},
Tolerations
:
[]
v1
.
Toleration
{
kubeadmconstants
.
Master
Toleration
,
kubeadmconstants
.
ControlPlane
Toleration
,
},
DNSPolicy
:
v1
.
DNSClusterFirstWithHostNet
,
},
...
...
@@ -168,7 +168,7 @@ func TestSetMasterTolerationOnPodSpec(t *testing.T) {
podSpec
:
&
v1
.
PodSpec
{},
expected
:
v1
.
PodSpec
{
Tolerations
:
[]
v1
.
Toleration
{
kubeadmconstants
.
Master
Toleration
,
kubeadmconstants
.
ControlPlane
Toleration
,
},
},
},
...
...
@@ -182,7 +182,7 @@ func TestSetMasterTolerationOnPodSpec(t *testing.T) {
expected
:
v1
.
PodSpec
{
Tolerations
:
[]
v1
.
Toleration
{
{
Key
:
"foo"
,
Value
:
"bar"
},
kubeadmconstants
.
Master
Toleration
,
kubeadmconstants
.
ControlPlane
Toleration
,
},
},
},
...
...
cmd/kubeadm/app/phases/selfhosting/selfhosting.go
View file @
ae1ec882
...
...
@@ -75,7 +75,7 @@ func CreateSelfHostedControlPlane(manifestsDir, kubeConfigDir string, cfg *kubea
}
}
for
_
,
componentName
:=
range
kubeadmconstants
.
Master
Components
{
for
_
,
componentName
:=
range
kubeadmconstants
.
ControlPlane
Components
{
start
:=
time
.
Now
()
manifestPath
:=
kubeadmconstants
.
GetStaticPodFilepath
(
componentName
,
manifestsDir
)
...
...
cmd/kubeadm/app/phases/upgrade/health.go
View file @
ae1ec882
...
...
@@ -126,7 +126,7 @@ func masterNodesReady(client clientset.Interface) error {
// staticPodManifestHealth makes sure the required static pods are presents
func
staticPodManifestHealth
(
_
clientset
.
Interface
)
error
{
nonExistentManifests
:=
[]
string
{}
for
_
,
component
:=
range
constants
.
Master
Components
{
for
_
,
component
:=
range
constants
.
ControlPlane
Components
{
manifestFile
:=
constants
.
GetStaticPodFilepath
(
component
,
constants
.
GetStaticPodDirectory
())
if
_
,
err
:=
os
.
Stat
(
manifestFile
);
os
.
IsNotExist
(
err
)
{
nonExistentManifests
=
append
(
nonExistentManifests
,
manifestFile
)
...
...
@@ -152,7 +152,7 @@ func IsControlPlaneSelfHosted(client clientset.Interface) bool {
// getNotReadyDaemonSets gets the amount of Ready control plane DaemonSets
func
getNotReadyDaemonSets
(
client
clientset
.
Interface
)
([]
error
,
error
)
{
notReadyDaemonSets
:=
[]
error
{}
for
_
,
component
:=
range
constants
.
Master
Components
{
for
_
,
component
:=
range
constants
.
ControlPlane
Components
{
dsName
:=
constants
.
AddSelfHostedPrefix
(
component
)
ds
,
err
:=
client
.
AppsV1
()
.
DaemonSets
(
metav1
.
NamespaceSystem
)
.
Get
(
dsName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
...
...
cmd/kubeadm/app/phases/upgrade/prepull.go
View file @
ae1ec882
...
...
@@ -42,7 +42,7 @@ type Prepuller interface {
DeleteFunc
(
string
)
error
}
// DaemonSetPrepuller makes sure the control
plane images are available on all masters
// DaemonSetPrepuller makes sure the control
-
plane images are available on all masters
type
DaemonSetPrepuller
struct
{
client
clientset
.
Interface
cfg
*
kubeadmapi
.
ClusterConfiguration
...
...
@@ -181,7 +181,7 @@ func buildPrePullDaemonSet(component, image string) *apps.DaemonSet {
NodeSelector
:
map
[
string
]
string
{
constants
.
LabelNodeRoleMaster
:
""
,
},
Tolerations
:
[]
v1
.
Toleration
{
constants
.
Master
Toleration
},
Tolerations
:
[]
v1
.
Toleration
{
constants
.
ControlPlane
Toleration
},
TerminationGracePeriodSeconds
:
&
gracePeriodSecs
,
},
},
...
...
cmd/kubeadm/app/phases/upgrade/prepull_test.go
View file @
ae1ec882
...
...
@@ -141,7 +141,7 @@ func TestPrepullImagesInParallel(t *testing.T) {
for
_
,
rt
:=
range
tests
{
t
.
Run
(
rt
.
name
,
func
(
t
*
testing
.
T
)
{
actualErr
:=
PrepullImagesInParallel
(
rt
.
p
,
rt
.
timeout
,
append
(
constants
.
Master
Components
,
constants
.
Etcd
))
actualErr
:=
PrepullImagesInParallel
(
rt
.
p
,
rt
.
timeout
,
append
(
constants
.
ControlPlane
Components
,
constants
.
Etcd
))
if
(
actualErr
!=
nil
)
!=
rt
.
expectedErr
{
t
.
Errorf
(
"failed TestPrepullImagesInParallel
\n\t
expected error: %t
\n\t
got: %t"
,
...
...
cmd/kubeadm/app/phases/upgrade/staticpods.go
View file @
ae1ec882
...
...
@@ -436,7 +436,7 @@ func StaticPodControlPlane(client clientset.Interface, waiter apiclient.Waiter,
return
errors
.
Wrap
(
err
,
"error creating init static pod manifest files"
)
}
for
_
,
component
:=
range
constants
.
Master
Components
{
for
_
,
component
:=
range
constants
.
ControlPlane
Components
{
if
err
=
upgradeComponent
(
component
,
waiter
,
pathMgr
,
cfg
,
beforePodHashMap
[
component
],
recoverManifests
);
err
!=
nil
{
return
err
}
...
...
cmd/kubeadm/app/preflight/checks.go
View file @
ae1ec882
...
...
@@ -871,8 +871,8 @@ func (ncc NumCPUCheck) Check() (warnings, errorList []error) {
return
warnings
,
errorList
}
// RunInit
MasterChecks executes all individual, applicable to Master
node checks.
func
RunInit
Master
Checks
(
execer
utilsexec
.
Interface
,
cfg
*
kubeadmapi
.
InitConfiguration
,
ignorePreflightErrors
sets
.
String
)
error
{
// RunInit
NodeChecks executes all individual, applicable to control-plane
node checks.
func
RunInit
Node
Checks
(
execer
utilsexec
.
Interface
,
cfg
*
kubeadmapi
.
InitConfiguration
,
ignorePreflightErrors
sets
.
String
)
error
{
// First, check if we're root separately from the other preflight checks and fail fast
if
err
:=
RunRootCheckOnly
(
ignorePreflightErrors
);
err
!=
nil
{
return
err
...
...
@@ -880,7 +880,7 @@ func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigu
manifestsDir
:=
filepath
.
Join
(
kubeadmconstants
.
KubernetesDir
,
kubeadmconstants
.
ManifestsSubDirName
)
checks
:=
[]
Checker
{
NumCPUCheck
{
NumCPU
:
kubeadmconstants
.
Master
NumCPU
},
NumCPUCheck
{
NumCPU
:
kubeadmconstants
.
ControlPlane
NumCPU
},
KubernetesVersionCheck
{
KubernetesVersion
:
cfg
.
KubernetesVersion
,
KubeadmVersion
:
kubeadmversion
.
Get
()
.
GitVersion
},
FirewalldCheck
{
ports
:
[]
int
{
int
(
cfg
.
LocalAPIEndpoint
.
BindPort
),
10250
}},
PortOpenCheck
{
port
:
int
(
cfg
.
LocalAPIEndpoint
.
BindPort
)},
...
...
cmd/kubeadm/app/preflight/checks_test.go
View file @
ae1ec882
...
...
@@ -184,7 +184,7 @@ func (pfct preflightCheckTest) Check() (warning, errorList []error) {
return
}
func
TestRunInit
Master
Checks
(
t
*
testing
.
T
)
{
func
TestRunInit
Node
Checks
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
name
string
cfg
*
kubeadmapi
.
InitConfiguration
...
...
@@ -231,11 +231,11 @@ func TestRunInitMasterChecks(t *testing.T) {
},
}
for
_
,
rt
:=
range
tests
{
// TODO: Make RunInit
Master
Checks accept a ClusterConfiguration object instead of InitConfiguration
actual
:=
RunInit
Master
Checks
(
exec
.
New
(),
rt
.
cfg
,
sets
.
NewString
())
// TODO: Make RunInit
Node
Checks accept a ClusterConfiguration object instead of InitConfiguration
actual
:=
RunInit
Node
Checks
(
exec
.
New
(),
rt
.
cfg
,
sets
.
NewString
())
if
(
actual
==
nil
)
!=
rt
.
expected
{
t
.
Errorf
(
"failed RunInit
Master
Checks:
\n\t
expected: %t
\n\t
actual: %t
\n\t
error: %v"
,
"failed RunInit
Node
Checks:
\n\t
expected: %t
\n\t
actual: %t
\n\t
error: %v"
,
rt
.
expected
,
(
actual
==
nil
),
actual
,
...
...
cmd/kubeadm/app/util/apiclient/wait.go
View file @
ae1ec882
...
...
@@ -187,7 +187,7 @@ func (w *KubeWaiter) WaitForStaticPodControlPlaneHashes(nodeName string) (map[st
componentHash
:=
""
var
err
error
mirrorPodHashes
:=
map
[
string
]
string
{}
for
_
,
component
:=
range
constants
.
Master
Components
{
for
_
,
component
:=
range
constants
.
ControlPlane
Components
{
err
=
wait
.
PollImmediate
(
constants
.
APICallRetryInterval
,
w
.
timeout
,
func
()
(
bool
,
error
)
{
componentHash
,
err
=
getStaticPodSingleHash
(
w
.
client
,
nodeName
,
component
)
if
err
!=
nil
{
...
...
cmd/kubeadm/app/util/config/cluster.go
View file @
ae1ec882
...
...
@@ -59,7 +59,6 @@ func FetchInitConfigurationFromCluster(client clientset.Interface, w io.Writer,
// getInitConfigurationFromCluster is separate only for testing purposes, don't call it directly, use FetchInitConfigurationFromCluster instead
func
getInitConfigurationFromCluster
(
kubeconfigDir
string
,
client
clientset
.
Interface
,
newControlPlane
bool
)
(
*
kubeadmapi
.
InitConfiguration
,
error
)
{
// TODO: This code should support reading the MasterConfiguration key as well for backwards-compat
// Also, the config map really should be KubeadmConfigConfigMap...
configMap
,
err
:=
client
.
CoreV1
()
.
ConfigMaps
(
metav1
.
NamespaceSystem
)
.
Get
(
constants
.
KubeadmConfigConfigMap
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
...
...
cmd/kubeadm/app/util/config/cluster_test.go
View file @
ae1ec882
...
...
@@ -268,7 +268,7 @@ func TestGetNodeRegistration(t *testing.T) {
},
},
Spec
:
v1
.
NodeSpec
{
Taints
:
[]
v1
.
Taint
{
kubeadmconstants
.
Master
Taint
},
Taints
:
[]
v1
.
Taint
{
kubeadmconstants
.
ControlPlane
Taint
},
},
},
},
...
...
@@ -551,7 +551,7 @@ func TestGetInitConfigurationFromCluster(t *testing.T) {
},
},
Spec
:
v1
.
NodeSpec
{
Taints
:
[]
v1
.
Taint
{
kubeadmconstants
.
Master
Taint
},
Taints
:
[]
v1
.
Taint
{
kubeadmconstants
.
ControlPlane
Taint
},
},
},
},
...
...
@@ -611,7 +611,7 @@ func TestGetInitConfigurationFromCluster(t *testing.T) {
},
},
Spec
:
v1
.
NodeSpec
{
Taints
:
[]
v1
.
Taint
{
kubeadmconstants
.
Master
Taint
},
Taints
:
[]
v1
.
Taint
{
kubeadmconstants
.
ControlPlane
Taint
},
},
},
},
...
...
cmd/kubeadm/app/util/config/initconfiguration.go
View file @
ae1ec882
...
...
@@ -85,16 +85,16 @@ func SetBootstrapTokensDynamicDefaults(cfg *[]kubeadmapi.BootstrapToken) error {
}
// SetNodeRegistrationDynamicDefaults checks and sets configuration values for the NodeRegistration object
func
SetNodeRegistrationDynamicDefaults
(
cfg
*
kubeadmapi
.
NodeRegistrationOptions
,
master
Taint
bool
)
error
{
func
SetNodeRegistrationDynamicDefaults
(
cfg
*
kubeadmapi
.
NodeRegistrationOptions
,
ControlPlane
Taint
bool
)
error
{
var
err
error
cfg
.
Name
,
err
=
nodeutil
.
GetHostname
(
cfg
.
Name
)
if
err
!=
nil
{
return
err
}
// Only if the slice is nil, we should append the
master taint. This allows the user to specify an empty slice for no default master
taint
if
master
Taint
&&
cfg
.
Taints
==
nil
{
cfg
.
Taints
=
[]
v1
.
Taint
{
kubeadmconstants
.
Master
Taint
}
// Only if the slice is nil, we should append the
control-plane taint. This allows the user to specify an empty slice for no default control-plane
taint
if
ControlPlane
Taint
&&
cfg
.
Taints
==
nil
{
cfg
.
Taints
=
[]
v1
.
Taint
{
kubeadmconstants
.
ControlPlane
Taint
}
}
if
cfg
.
CRISocket
==
""
{
...
...
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