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
38fe6865
Commit
38fe6865
authored
Apr 02, 2019
by
PingWang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract Method for kubeadm
Signed-off-by:
PingWang
<
wang.ping5@zte.com.cn
>
parent
90e9f29b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
19 deletions
+11
-19
pki_helpers.go
cmd/kubeadm/app/util/pkiutil/pki_helpers.go
+11
-19
No files found.
cmd/kubeadm/app/util/pkiutil/pki_helpers.go
View file @
38fe6865
...
...
@@ -404,29 +404,18 @@ func GetAPIServerAltNames(cfg *kubeadmapi.InitConfiguration) (*certutil.AltNames
// `advertise address` and localhost are included in the SAN since this is the interfaces the etcd static pod listens on.
// The user can override the listen address with `Etcd.ExtraArgs` and add SANs with `Etcd.ServerCertSANs`.
func
GetEtcdAltNames
(
cfg
*
kubeadmapi
.
InitConfiguration
)
(
*
certutil
.
AltNames
,
error
)
{
// advertise address
advertiseAddress
:=
net
.
ParseIP
(
cfg
.
LocalAPIEndpoint
.
AdvertiseAddress
)
if
advertiseAddress
==
nil
{
return
nil
,
errors
.
Errorf
(
"error parsing LocalAPIEndpoint AdvertiseAddress %q: is not a valid textual representation of an IP address"
,
cfg
.
LocalAPIEndpoint
.
AdvertiseAddress
)
}
// create AltNames with defaults DNSNames/IPs
altNames
:=
&
certutil
.
AltNames
{
DNSNames
:
[]
string
{
cfg
.
NodeRegistration
.
Name
,
"localhost"
},
IPs
:
[]
net
.
IP
{
advertiseAddress
,
net
.
IPv4
(
127
,
0
,
0
,
1
),
net
.
IPv6loopback
},
}
if
cfg
.
Etcd
.
Local
!=
nil
{
appendSANsToAltNames
(
altNames
,
cfg
.
Etcd
.
Local
.
ServerCertSANs
,
kubeadmconstants
.
EtcdServerCertName
)
}
return
altNames
,
nil
return
getAltNames
(
cfg
,
kubeadmconstants
.
EtcdServerCertName
)
}
// GetEtcdPeerAltNames builds an AltNames object for generating the etcd peer certificate.
// Hostname and `API.AdvertiseAddress` are included if the user chooses to promote the single node etcd cluster into a multi-node one (stacked etcd).
// The user can override the listen address with `Etcd.ExtraArgs` and add SANs with `Etcd.PeerCertSANs`.
func
GetEtcdPeerAltNames
(
cfg
*
kubeadmapi
.
InitConfiguration
)
(
*
certutil
.
AltNames
,
error
)
{
return
getAltNames
(
cfg
,
kubeadmconstants
.
EtcdPeerCertName
)
}
// getAltNames builds an AltNames object with the cfg and certName.
func
getAltNames
(
cfg
*
kubeadmapi
.
InitConfiguration
,
certName
string
)
(
*
certutil
.
AltNames
,
error
)
{
// advertise address
advertiseAddress
:=
net
.
ParseIP
(
cfg
.
LocalAPIEndpoint
.
AdvertiseAddress
)
if
advertiseAddress
==
nil
{
...
...
@@ -441,9 +430,12 @@ func GetEtcdPeerAltNames(cfg *kubeadmapi.InitConfiguration) (*certutil.AltNames,
}
if
cfg
.
Etcd
.
Local
!=
nil
{
appendSANsToAltNames
(
altNames
,
cfg
.
Etcd
.
Local
.
PeerCertSANs
,
kubeadmconstants
.
EtcdPeerCertName
)
if
certName
==
kubeadmconstants
.
EtcdServerCertName
{
appendSANsToAltNames
(
altNames
,
cfg
.
Etcd
.
Local
.
ServerCertSANs
,
kubeadmconstants
.
EtcdServerCertName
)
}
else
if
certName
==
kubeadmconstants
.
EtcdPeerCertName
{
appendSANsToAltNames
(
altNames
,
cfg
.
Etcd
.
Local
.
PeerCertSANs
,
kubeadmconstants
.
EtcdPeerCertName
)
}
}
return
altNames
,
nil
}
...
...
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