Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7354bbe

Browse files
committedMar 30, 2018
certs: only append locally discovered addresses when we got none from the cloudprovider
The cloudprovider is right, and only cloudprovider addresses can be verified centrally, so don't add any extra.
1 parent 189a166 commit 7354bbe

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed
 

‎pkg/kubelet/kubelet.go

+15-7
Original file line numberDiff line numberDiff line change
@@ -737,20 +737,28 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
737737
klet.statusManager = status.NewManager(klet.kubeClient, klet.podManager, klet)
738738

739739
if utilfeature.DefaultFeatureGate.Enabled(features.RotateKubeletServerCertificate) && kubeDeps.TLSOptions != nil {
740-
var ips []net.IP
741-
cfgAddress := net.ParseIP(kubeCfg.Address)
742-
if cfgAddress == nil || cfgAddress.IsUnspecified() {
740+
var (
741+
ips []net.IP
742+
names []string
743+
)
744+
745+
// If the address was explicitly configured, use that. Otherwise, try to
746+
// discover addresses from the cloudprovider. Otherwise, make a best guess.
747+
if cfgAddress := net.ParseIP(kubeCfg.Address); cfgAddress != nil && !cfgAddress.IsUnspecified() {
748+
ips = []net.IP{cfgAddress}
749+
names = []string{klet.GetHostname(), hostnameOverride}
750+
} else if len(cloudIPs) != 0 || len(cloudNames) != 0 {
751+
ips = cloudIPs
752+
names = cloudNames
753+
} else {
743754
localIPs, err := allGlobalUnicastIPs()
744755
if err != nil {
745756
return nil, err
746757
}
747758
ips = localIPs
748-
} else {
749-
ips = []net.IP{cfgAddress}
759+
names = []string{klet.GetHostname(), hostnameOverride}
750760
}
751761

752-
ips = append(ips, cloudIPs...)
753-
names := append([]string{klet.GetHostname(), hostnameOverride}, cloudNames...)
754762
klet.serverCertificateManager, err = kubeletcertificate.NewKubeletServerCertificateManager(klet.kubeClient, kubeCfg, klet.nodeName, ips, names, certDirectory)
755763
if err != nil {
756764
return nil, fmt.Errorf("failed to initialize certificate manager: %v", err)

0 commit comments

Comments
 (0)
Please sign in to comment.