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
return
errors
.
Wrap
(
err
,
"error when creating kube-proxy service account"
)
}
// Generate
Master
Enpoint kubeconfig file
masterEndpoint
,
err
:=
kubeadmutil
.
GetMaster
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
localEndpoint
)
// Generate
ControlPlane
Enpoint kubeconfig file
controlPlaneEndpoint
,
err
:=
kubeadmutil
.
GetControlPlane
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
localEndpoint
)
if
err
!=
nil
{
return
err
}
...
...
@@ -72,7 +72,7 @@ func EnsureProxyAddon(cfg *kubeadmapi.ClusterConfiguration, localEndpoint *kubea
ProxyConfigMap
string
ProxyConfigMapKey
string
}{
MasterEndpoint
:
master
Endpoint
,
MasterEndpoint
:
controlPlane
Endpoint
,
ProxyConfig
:
prefixBytes
.
String
(),
ProxyConfigMap
:
constants
.
KubeProxyConfigMap
,
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
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
{
return
nil
,
err
}
...
...
@@ -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"
)
}
masterEndpoint
,
err
:=
kubeadmutil
.
Get
Master
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
masterEndpoint
,
err
:=
kubeadmutil
.
Get
ControlPlane
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
if
err
!=
nil
{
return
err
}
...
...
@@ -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"
)
}
masterEndpoint
,
err
:=
kubeadmutil
.
Get
Master
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
masterEndpoint
,
err
:=
kubeadmutil
.
Get
ControlPlane
Endpoint
(
cfg
.
ControlPlaneEndpoint
,
&
cfg
.
LocalAPIEndpoint
)
if
err
!=
nil
{
return
err
}
...
...
cmd/kubeadm/app/phases/kubeconfig/kubeconfig_test.go
View file @
57d04caf
...
...
@@ -162,7 +162,7 @@ func TestGetKubeConfigSpecs(t *testing.T) {
}
// 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
{
t
.
Error
(
err
)
}
...
...
cmd/kubeadm/app/util/apiclient/init_dryrun.go
View file @
57d04caf
...
...
@@ -40,18 +40,18 @@ import (
// - GET /nodes/<node-name> -- must return a valid Node
// - ...all other, unknown GETs/LISTs will be logged
type
InitDryRunGetter
struct
{
masterName
string
serviceSubnet
string
controlPlaneName
string
serviceSubnet
string
}
// InitDryRunGetter should implement the DryRunGetter interface
var
_
DryRunGetter
=
&
InitDryRunGetter
{}
// 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
{
masterName
:
master
Name
,
serviceSubnet
:
serviceSubnet
,
controlPlaneName
:
controlPlane
Name
,
serviceSubnet
:
serviceSubnet
,
}
}
...
...
@@ -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.
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
return
false
,
nil
,
nil
}
return
true
,
&
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
idr
.
master
Name
,
Name
:
idr
.
controlPlane
Name
,
Labels
:
map
[
string
]
string
{
"kubernetes.io/hostname"
:
idr
.
master
Name
,
"kubernetes.io/hostname"
:
idr
.
controlPlane
Name
,
},
Annotations
:
map
[
string
]
string
{},
},
...
...
cmd/kubeadm/app/util/apiclient/init_dryrun_test.go
View file @
57d04caf
...
...
@@ -27,9 +27,9 @@ import (
)
func
TestHandleGetAction
(
t
*
testing
.
T
)
{
masterName
:=
"master
-foo"
controlPlaneName
:=
"control-plane
-foo"
serviceSubnet
:=
"10.96.0.1/12"
idr
:=
NewInitDryRunGetter
(
master
Name
,
serviceSubnet
)
idr
:=
NewInitDryRunGetter
(
controlPlane
Name
,
serviceSubnet
)
var
tests
=
[]
struct
{
name
string
...
...
@@ -47,9 +47,9 @@ func TestHandleGetAction(t *testing.T) {
},
{
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
,
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
,
},
{
...
...
@@ -80,7 +80,7 @@ func TestHandleGetAction(t *testing.T) {
expectedObjectJSON
:
[]
byte
(
``
),
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"
,
action
:
core
.
NewRootGetAction
(
schema
.
GroupVersionResource
{
Version
:
"v1"
,
Resource
:
"nodes"
},
"other-node"
),
expectedHandled
:
false
,
...
...
cmd/kubeadm/app/util/config/joinconfiguration.go
View file @
57d04caf
...
...
@@ -34,11 +34,11 @@ import (
// SetJoinDynamicDefaults checks and sets configuration values for the JoinConfiguration object
func
SetJoinDynamicDefaults
(
cfg
*
kubeadmapi
.
JoinConfiguration
)
error
{
add
Master
Taint
:=
false
add
ControlPlane
Taint
:=
false
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
}
...
...
cmd/kubeadm/app/util/endpoint.go
View file @
57d04caf
...
...
@@ -28,11 +28,11 @@ import (
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 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.
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
bindPortString
:=
strconv
.
Itoa
(
int
(
localEndpoint
.
BindPort
))
if
_
,
err
:=
ParsePort
(
bindPortString
);
err
!=
nil
{
...
...
@@ -45,8 +45,8 @@ func GetMasterEndpoint(controlPlaneEndpoint string, localEndpoint *kubeadmapi.AP
return
""
,
errors
.
Errorf
(
"invalid value `%s` given for api.advertiseAddress"
,
localEndpoint
.
AdvertiseAddress
)
}
// set the
master
url using localEndpoint.AdvertiseAddress + the localEndpoint.BindPort
master
URL
:=
&
url
.
URL
{
// set the
control-plane
url using localEndpoint.AdvertiseAddress + the localEndpoint.BindPort
controlPlane
URL
:=
&
url
.
URL
{
Scheme
:
"https"
,
Host
:
net
.
JoinHostPort
(
ip
.
String
(),
bindPortString
),
}
...
...
@@ -69,14 +69,14 @@ func GetMasterEndpoint(controlPlaneEndpoint string, localEndpoint *kubeadmapi.AP
port
=
bindPortString
}
// overrides the
master
url using the controlPlaneAddress (and eventually the bindport)
master
URL
=
&
url
.
URL
{
// overrides the
control-plane
url using the controlPlaneAddress (and eventually the bindport)
controlPlane
URL
=
&
url
.
URL
{
Scheme
:
"https"
,
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;
...
...
cmd/kubeadm/app/util/endpoint_test.go
View file @
57d04caf
...
...
@@ -22,7 +22,7 @@ import (
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
{
name
string
cfg
*
kubeadmapi
.
InitConfiguration
...
...
@@ -198,7 +198,7 @@ func TestGetMasterEndpoint(t *testing.T) {
for
_
,
rt
:=
range
tests
{
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
{
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