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
57d04caf
Commit
57d04caf
authored
Feb 22, 2019
by
vanduc95
Committed by
ducnv
Feb 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubeadm cleanup: master -> control-plane (cont.3)
parent
b77e4e24
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
32 additions
and
32 deletions
+32
-32
proxy.go
cmd/kubeadm/app/phases/addons/proxy/proxy.go
+3
-3
kubeconfig.go
cmd/kubeadm/app/phases/kubeconfig/kubeconfig.go
+3
-3
kubeconfig_test.go
cmd/kubeadm/app/phases/kubeconfig/kubeconfig_test.go
+1
-1
init_dryrun.go
cmd/kubeadm/app/util/apiclient/init_dryrun.go
+8
-8
init_dryrun_test.go
cmd/kubeadm/app/util/apiclient/init_dryrun_test.go
+5
-5
joinconfiguration.go
cmd/kubeadm/app/util/config/joinconfiguration.go
+3
-3
endpoint.go
cmd/kubeadm/app/util/endpoint.go
+7
-7
endpoint_test.go
cmd/kubeadm/app/util/endpoint_test.go
+2
-2
No files found.
cmd/kubeadm/app/phases/addons/proxy/proxy.go
View file @
57d04caf
...
@@ -52,8 +52,8 @@ func EnsureProxyAddon(cfg *kubeadmapi.ClusterConfiguration, localEndpoint *kubea
...
@@ -52,8 +52,8 @@ func EnsureProxyAddon(cfg *kubeadmapi.ClusterConfiguration, localEndpoint *kubea
return
errors
.
Wrap
(
err
,
"error when creating kube-proxy service account"
)
return
errors
.
Wrap
(
err
,
"error when creating kube-proxy service account"
)
}
}
// Generate
Master
Enpoint kubeconfig file
// Generate
ControlPlane
Enpoint kubeconfig file
masterEndpoint
,
err
:=
kubeadmutil
.
GetMaster
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
localEndpoint
)
controlPlaneEndpoint
,
err
:=
kubeadmutil
.
GetControlPlane
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
localEndpoint
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -72,7 +72,7 @@ func EnsureProxyAddon(cfg *kubeadmapi.ClusterConfiguration, localEndpoint *kubea
...
@@ -72,7 +72,7 @@ func EnsureProxyAddon(cfg *kubeadmapi.ClusterConfiguration, localEndpoint *kubea
ProxyConfigMap
string
ProxyConfigMap
string
ProxyConfigMapKey
string
ProxyConfigMapKey
string
}{
}{
MasterEndpoint
:
master
Endpoint
,
MasterEndpoint
:
controlPlane
Endpoint
,
ProxyConfig
:
prefixBytes
.
String
(),
ProxyConfig
:
prefixBytes
.
String
(),
ProxyConfigMap
:
constants
.
KubeProxyConfigMap
,
ProxyConfigMap
:
constants
.
KubeProxyConfigMap
,
ProxyConfigMapKey
:
constants
.
KubeProxyConfigMapKey
,
ProxyConfigMapKey
:
constants
.
KubeProxyConfigMapKey
,
...
...
cmd/kubeadm/app/phases/kubeconfig/kubeconfig.go
View file @
57d04caf
...
@@ -135,7 +135,7 @@ func getKubeConfigSpecs(cfg *kubeadmapi.InitConfiguration) (map[string]*kubeConf
...
@@ -135,7 +135,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"
)
return
nil
,
errors
.
Wrap
(
err
,
"couldn't create a kubeconfig; the CA files couldn't be loaded"
)
}
}
masterEndpoint
,
err
:=
kubeadmutil
.
Get
Master
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
masterEndpoint
,
err
:=
kubeadmutil
.
Get
ControlPlane
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -285,7 +285,7 @@ func WriteKubeConfigWithClientCert(out io.Writer, cfg *kubeadmapi.InitConfigurat
...
@@ -285,7 +285,7 @@ func WriteKubeConfigWithClientCert(out io.Writer, cfg *kubeadmapi.InitConfigurat
return
errors
.
Wrap
(
err
,
"couldn't create a kubeconfig; the CA files couldn't be loaded"
)
return
errors
.
Wrap
(
err
,
"couldn't create a kubeconfig; the CA files couldn't be loaded"
)
}
}
masterEndpoint
,
err
:=
kubeadmutil
.
Get
Master
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
masterEndpoint
,
err
:=
kubeadmutil
.
Get
ControlPlane
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -312,7 +312,7 @@ func WriteKubeConfigWithToken(out io.Writer, cfg *kubeadmapi.InitConfiguration,
...
@@ -312,7 +312,7 @@ func WriteKubeConfigWithToken(out io.Writer, cfg *kubeadmapi.InitConfiguration,
return
errors
.
Wrap
(
err
,
"couldn't create a kubeconfig; the CA files couldn't be loaded"
)
return
errors
.
Wrap
(
err
,
"couldn't create a kubeconfig; the CA files couldn't be loaded"
)
}
}
masterEndpoint
,
err
:=
kubeadmutil
.
Get
Master
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
masterEndpoint
,
err
:=
kubeadmutil
.
Get
ControlPlane
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
cmd/kubeadm/app/phases/kubeconfig/kubeconfig_test.go
View file @
57d04caf
...
@@ -162,7 +162,7 @@ func TestGetKubeConfigSpecs(t *testing.T) {
...
@@ -162,7 +162,7 @@ func TestGetKubeConfigSpecs(t *testing.T) {
}
}
// Asserts InitConfiguration values injected into spec
// Asserts InitConfiguration values injected into spec
masterEndpoint
,
err
:=
kubeadmutil
.
Get
Master
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
masterEndpoint
,
err
:=
kubeadmutil
.
Get
ControlPlane
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
(
err
)
t
.
Error
(
err
)
}
}
...
...
cmd/kubeadm/app/util/apiclient/init_dryrun.go
View file @
57d04caf
...
@@ -40,18 +40,18 @@ import (
...
@@ -40,18 +40,18 @@ import (
// - GET /nodes/<node-name> -- must return a valid Node
// - GET /nodes/<node-name> -- must return a valid Node
// - ...all other, unknown GETs/LISTs will be logged
// - ...all other, unknown GETs/LISTs will be logged
type
InitDryRunGetter
struct
{
type
InitDryRunGetter
struct
{
masterName
string
controlPlaneName
string
serviceSubnet
string
serviceSubnet
string
}
}
// InitDryRunGetter should implement the DryRunGetter interface
// InitDryRunGetter should implement the DryRunGetter interface
var
_
DryRunGetter
=
&
InitDryRunGetter
{}
var
_
DryRunGetter
=
&
InitDryRunGetter
{}
// NewInitDryRunGetter creates a new instance of the InitDryRunGetter struct
// NewInitDryRunGetter creates a new instance of the InitDryRunGetter struct
func
NewInitDryRunGetter
(
master
Name
string
,
serviceSubnet
string
)
*
InitDryRunGetter
{
func
NewInitDryRunGetter
(
controlPlane
Name
string
,
serviceSubnet
string
)
*
InitDryRunGetter
{
return
&
InitDryRunGetter
{
return
&
InitDryRunGetter
{
masterName
:
master
Name
,
controlPlaneName
:
controlPlane
Name
,
serviceSubnet
:
serviceSubnet
,
serviceSubnet
:
serviceSubnet
,
}
}
}
}
...
@@ -122,16 +122,16 @@ func (idr *InitDryRunGetter) handleKubernetesService(action core.GetAction) (boo
...
@@ -122,16 +122,16 @@ func (idr *InitDryRunGetter) handleKubernetesService(action core.GetAction) (boo
// handleGetNode returns a fake node object for the purpose of moving kubeadm init forwards.
// handleGetNode returns a fake node object for the purpose of moving kubeadm init forwards.
func
(
idr
*
InitDryRunGetter
)
handleGetNode
(
action
core
.
GetAction
)
(
bool
,
runtime
.
Object
,
error
)
{
func
(
idr
*
InitDryRunGetter
)
handleGetNode
(
action
core
.
GetAction
)
(
bool
,
runtime
.
Object
,
error
)
{
if
action
.
GetName
()
!=
idr
.
master
Name
||
action
.
GetResource
()
.
Resource
!=
"nodes"
{
if
action
.
GetName
()
!=
idr
.
controlPlane
Name
||
action
.
GetResource
()
.
Resource
!=
"nodes"
{
// We can't handle this event
// We can't handle this event
return
false
,
nil
,
nil
return
false
,
nil
,
nil
}
}
return
true
,
&
v1
.
Node
{
return
true
,
&
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
idr
.
master
Name
,
Name
:
idr
.
controlPlane
Name
,
Labels
:
map
[
string
]
string
{
Labels
:
map
[
string
]
string
{
"kubernetes.io/hostname"
:
idr
.
master
Name
,
"kubernetes.io/hostname"
:
idr
.
controlPlane
Name
,
},
},
Annotations
:
map
[
string
]
string
{},
Annotations
:
map
[
string
]
string
{},
},
},
...
...
cmd/kubeadm/app/util/apiclient/init_dryrun_test.go
View file @
57d04caf
...
@@ -27,9 +27,9 @@ import (
...
@@ -27,9 +27,9 @@ import (
)
)
func
TestHandleGetAction
(
t
*
testing
.
T
)
{
func
TestHandleGetAction
(
t
*
testing
.
T
)
{
masterName
:=
"master
-foo"
controlPlaneName
:=
"control-plane
-foo"
serviceSubnet
:=
"10.96.0.1/12"
serviceSubnet
:=
"10.96.0.1/12"
idr
:=
NewInitDryRunGetter
(
master
Name
,
serviceSubnet
)
idr
:=
NewInitDryRunGetter
(
controlPlane
Name
,
serviceSubnet
)
var
tests
=
[]
struct
{
var
tests
=
[]
struct
{
name
string
name
string
...
@@ -47,9 +47,9 @@ func TestHandleGetAction(t *testing.T) {
...
@@ -47,9 +47,9 @@ func TestHandleGetAction(t *testing.T) {
},
},
{
{
name
:
"get nodes"
,
name
:
"get nodes"
,
action
:
core
.
NewRootGetAction
(
schema
.
GroupVersionResource
{
Version
:
"v1"
,
Resource
:
"nodes"
},
master
Name
),
action
:
core
.
NewRootGetAction
(
schema
.
GroupVersionResource
{
Version
:
"v1"
,
Resource
:
"nodes"
},
controlPlane
Name
),
expectedHandled
:
true
,
expectedHandled
:
true
,
expectedObjectJSON
:
[]
byte
(
`{"metadata":{"name":"
master-foo","creationTimestamp":null,"labels":{"kubernetes.io/hostname":"master
-foo"}},"spec":{},"status":{"daemonEndpoints":{"kubeletEndpoint":{"Port":0}},"nodeInfo":{"machineID":"","systemUUID":"","bootID":"","kernelVersion":"","osImage":"","containerRuntimeVersion":"","kubeletVersion":"","kubeProxyVersion":"","operatingSystem":"","architecture":""}}}`
),
expectedObjectJSON
:
[]
byte
(
`{"metadata":{"name":"
control-plane-foo","creationTimestamp":null,"labels":{"kubernetes.io/hostname":"control-plane
-foo"}},"spec":{},"status":{"daemonEndpoints":{"kubeletEndpoint":{"Port":0}},"nodeInfo":{"machineID":"","systemUUID":"","bootID":"","kernelVersion":"","osImage":"","containerRuntimeVersion":"","kubeletVersion":"","kubeProxyVersion":"","operatingSystem":"","architecture":""}}}`
),
expectedErr
:
false
,
expectedErr
:
false
,
},
},
{
{
...
@@ -80,7 +80,7 @@ func TestHandleGetAction(t *testing.T) {
...
@@ -80,7 +80,7 @@ func TestHandleGetAction(t *testing.T) {
expectedObjectJSON
:
[]
byte
(
``
),
expectedObjectJSON
:
[]
byte
(
``
),
expectedErr
:
false
,
expectedErr
:
false
,
},
},
{
// an ask for an other node than the
master
should not be answered
{
// an ask for an other node than the
control-plane
should not be answered
name
:
"get other-node"
,
name
:
"get other-node"
,
action
:
core
.
NewRootGetAction
(
schema
.
GroupVersionResource
{
Version
:
"v1"
,
Resource
:
"nodes"
},
"other-node"
),
action
:
core
.
NewRootGetAction
(
schema
.
GroupVersionResource
{
Version
:
"v1"
,
Resource
:
"nodes"
},
"other-node"
),
expectedHandled
:
false
,
expectedHandled
:
false
,
...
...
cmd/kubeadm/app/util/config/joinconfiguration.go
View file @
57d04caf
...
@@ -34,11 +34,11 @@ import (
...
@@ -34,11 +34,11 @@ import (
// SetJoinDynamicDefaults checks and sets configuration values for the JoinConfiguration object
// SetJoinDynamicDefaults checks and sets configuration values for the JoinConfiguration object
func
SetJoinDynamicDefaults
(
cfg
*
kubeadmapi
.
JoinConfiguration
)
error
{
func
SetJoinDynamicDefaults
(
cfg
*
kubeadmapi
.
JoinConfiguration
)
error
{
add
Master
Taint
:=
false
add
ControlPlane
Taint
:=
false
if
cfg
.
ControlPlane
!=
nil
{
if
cfg
.
ControlPlane
!=
nil
{
add
Master
Taint
=
true
add
ControlPlane
Taint
=
true
}
}
if
err
:=
SetNodeRegistrationDynamicDefaults
(
&
cfg
.
NodeRegistration
,
add
Master
Taint
);
err
!=
nil
{
if
err
:=
SetNodeRegistrationDynamicDefaults
(
&
cfg
.
NodeRegistration
,
add
ControlPlane
Taint
);
err
!=
nil
{
return
err
return
err
}
}
...
...
cmd/kubeadm/app/util/endpoint.go
View file @
57d04caf
...
@@ -28,11 +28,11 @@ import (
...
@@ -28,11 +28,11 @@ import (
kubeadmapi
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
kubeadmapi
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
)
)
// Get
Master
Endpoint returns a properly formatted endpoint for the control plane built according following rules:
// Get
ControlPlane
Endpoint returns a properly formatted endpoint for the control plane built according following rules:
// - If the controlPlaneEndpoint is defined, use it.
// - If the controlPlaneEndpoint is defined, use it.
// - if the controlPlaneEndpoint is defined but without a port number, use the controlPlaneEndpoint + localEndpoint.BindPort is used.
// - if the controlPlaneEndpoint is defined but without a port number, use the controlPlaneEndpoint + localEndpoint.BindPort is used.
// - Otherwise, in case the controlPlaneEndpoint is not defined, use the localEndpoint.AdvertiseAddress + the localEndpoint.BindPort.
// - Otherwise, in case the controlPlaneEndpoint is not defined, use the localEndpoint.AdvertiseAddress + the localEndpoint.BindPort.
func
Get
Master
Endpoint
(
controlPlaneEndpoint
string
,
localEndpoint
*
kubeadmapi
.
APIEndpoint
)
(
string
,
error
)
{
func
Get
ControlPlane
Endpoint
(
controlPlaneEndpoint
string
,
localEndpoint
*
kubeadmapi
.
APIEndpoint
)
(
string
,
error
)
{
// parse the bind port
// parse the bind port
bindPortString
:=
strconv
.
Itoa
(
int
(
localEndpoint
.
BindPort
))
bindPortString
:=
strconv
.
Itoa
(
int
(
localEndpoint
.
BindPort
))
if
_
,
err
:=
ParsePort
(
bindPortString
);
err
!=
nil
{
if
_
,
err
:=
ParsePort
(
bindPortString
);
err
!=
nil
{
...
@@ -45,8 +45,8 @@ func GetMasterEndpoint(controlPlaneEndpoint string, localEndpoint *kubeadmapi.AP
...
@@ -45,8 +45,8 @@ func GetMasterEndpoint(controlPlaneEndpoint string, localEndpoint *kubeadmapi.AP
return
""
,
errors
.
Errorf
(
"invalid value `%s` given for api.advertiseAddress"
,
localEndpoint
.
AdvertiseAddress
)
return
""
,
errors
.
Errorf
(
"invalid value `%s` given for api.advertiseAddress"
,
localEndpoint
.
AdvertiseAddress
)
}
}
// set the
master
url using localEndpoint.AdvertiseAddress + the localEndpoint.BindPort
// set the
control-plane
url using localEndpoint.AdvertiseAddress + the localEndpoint.BindPort
master
URL
:=
&
url
.
URL
{
controlPlane
URL
:=
&
url
.
URL
{
Scheme
:
"https"
,
Scheme
:
"https"
,
Host
:
net
.
JoinHostPort
(
ip
.
String
(),
bindPortString
),
Host
:
net
.
JoinHostPort
(
ip
.
String
(),
bindPortString
),
}
}
...
@@ -69,14 +69,14 @@ func GetMasterEndpoint(controlPlaneEndpoint string, localEndpoint *kubeadmapi.AP
...
@@ -69,14 +69,14 @@ func GetMasterEndpoint(controlPlaneEndpoint string, localEndpoint *kubeadmapi.AP
port
=
bindPortString
port
=
bindPortString
}
}
// overrides the
master
url using the controlPlaneAddress (and eventually the bindport)
// overrides the
control-plane
url using the controlPlaneAddress (and eventually the bindport)
master
URL
=
&
url
.
URL
{
controlPlane
URL
=
&
url
.
URL
{
Scheme
:
"https"
,
Scheme
:
"https"
,
Host
:
net
.
JoinHostPort
(
host
,
port
),
Host
:
net
.
JoinHostPort
(
host
,
port
),
}
}
}
}
return
master
URL
.
String
(),
nil
return
controlPlane
URL
.
String
(),
nil
}
}
// ParseHostPort parses a network address of the form "host:port", "ipv4:port", "[ipv6]:port" into host and port;
// ParseHostPort parses a network address of the form "host:port", "ipv4:port", "[ipv6]:port" into host and port;
...
...
cmd/kubeadm/app/util/endpoint_test.go
View file @
57d04caf
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
kubeadmapi
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
kubeadmapi
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
)
)
func
TestGet
Master
Endpoint
(
t
*
testing
.
T
)
{
func
TestGet
ControlPlane
Endpoint
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
var
tests
=
[]
struct
{
name
string
name
string
cfg
*
kubeadmapi
.
InitConfiguration
cfg
*
kubeadmapi
.
InitConfiguration
...
@@ -198,7 +198,7 @@ func TestGetMasterEndpoint(t *testing.T) {
...
@@ -198,7 +198,7 @@ func TestGetMasterEndpoint(t *testing.T) {
for
_
,
rt
:=
range
tests
{
for
_
,
rt
:=
range
tests
{
t
.
Run
(
rt
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
rt
.
name
,
func
(
t
*
testing
.
T
)
{
actualEndpoint
,
actualError
:=
Get
Master
Endpoint
(
rt
.
cfg
.
ControlPlaneEndpoint
,
&
rt
.
cfg
.
LocalAPIEndpoint
)
actualEndpoint
,
actualError
:=
Get
ControlPlane
Endpoint
(
rt
.
cfg
.
ControlPlaneEndpoint
,
&
rt
.
cfg
.
LocalAPIEndpoint
)
if
(
actualError
!=
nil
)
&&
!
rt
.
expectedError
{
if
(
actualError
!=
nil
)
&&
!
rt
.
expectedError
{
t
.
Errorf
(
"%s unexpected failure: %v"
,
rt
.
name
,
actualError
)
t
.
Errorf
(
"%s unexpected failure: %v"
,
rt
.
name
,
actualError
)
...
...
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