mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
k8s: Use cloud provider ip as kubelet node-ip (if available)
This commit is contained in:
parent
f5eddf8af0
commit
78d2358b9c
@ -33,6 +33,9 @@ func (c *Core) InitCluster(autoscalingNodeGroups []string, cloudServiceAccountUR
|
|||||||
}
|
}
|
||||||
nodeName = instance.Name
|
nodeName = instance.Name
|
||||||
providerID = instance.ProviderID
|
providerID = instance.ProviderID
|
||||||
|
if len(instance.IPs) > 0 {
|
||||||
|
nodeIP = instance.IPs[0]
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
nodeName = coordinatorVPNIP.String()
|
nodeName = coordinatorVPNIP.String()
|
||||||
}
|
}
|
||||||
@ -117,6 +120,7 @@ func (c *Core) JoinCluster(args kubeadm.BootstrapTokenDiscovery) error {
|
|||||||
}
|
}
|
||||||
var nodeName string
|
var nodeName string
|
||||||
var providerID string
|
var providerID string
|
||||||
|
nodeIP := nodeVPNIP
|
||||||
if c.metadata.Supported() {
|
if c.metadata.Supported() {
|
||||||
instance, err := c.metadata.Self(context.TODO())
|
instance, err := c.metadata.Self(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -125,6 +129,9 @@ func (c *Core) JoinCluster(args kubeadm.BootstrapTokenDiscovery) error {
|
|||||||
}
|
}
|
||||||
providerID = instance.ProviderID
|
providerID = instance.ProviderID
|
||||||
nodeName = instance.Name
|
nodeName = instance.Name
|
||||||
|
if len(instance.IPs) > 0 {
|
||||||
|
nodeIP = instance.IPs[0]
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
nodeName = nodeVPNIP
|
nodeName = nodeVPNIP
|
||||||
}
|
}
|
||||||
@ -136,7 +143,7 @@ func (c *Core) JoinCluster(args kubeadm.BootstrapTokenDiscovery) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.kube.JoinCluster(&args, k8sCompliantHostname(nodeName), nodeVPNIP, providerID); err != nil {
|
if err := c.kube.JoinCluster(&args, k8sCompliantHostname(nodeName), nodeIP, providerID); err != nil {
|
||||||
c.zaplogger.Error("Joining kubernetes cluster failed", zap.Error(err))
|
c.zaplogger.Error("Joining kubernetes cluster failed", zap.Error(err))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ func TestInitCluster(t *testing.T) {
|
|||||||
autoscalingNodeGroups: []string{"someNodeGroup"},
|
autoscalingNodeGroups: []string{"someNodeGroup"},
|
||||||
expectedInitClusterInput: kubernetes.InitClusterInput{
|
expectedInitClusterInput: kubernetes.InitClusterInput{
|
||||||
APIServerAdvertiseIP: "10.118.0.1",
|
APIServerAdvertiseIP: "10.118.0.1",
|
||||||
|
NodeIP: "10.118.0.1",
|
||||||
NodeName: "10.118.0.1",
|
NodeName: "10.118.0.1",
|
||||||
SupportsCloudControllerManager: false,
|
SupportsCloudControllerManager: false,
|
||||||
SupportClusterAutoscaler: false,
|
SupportClusterAutoscaler: false,
|
||||||
@ -56,6 +57,7 @@ func TestInitCluster(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedInitClusterInput: kubernetes.InitClusterInput{
|
expectedInitClusterInput: kubernetes.InitClusterInput{
|
||||||
APIServerAdvertiseIP: "10.118.0.1",
|
APIServerAdvertiseIP: "10.118.0.1",
|
||||||
|
NodeIP: "10.118.0.1",
|
||||||
NodeName: "some-name",
|
NodeName: "some-name",
|
||||||
ProviderID: "fake://providerid",
|
ProviderID: "fake://providerid",
|
||||||
SupportsCloudControllerManager: false,
|
SupportsCloudControllerManager: false,
|
||||||
@ -85,6 +87,7 @@ func TestInitCluster(t *testing.T) {
|
|||||||
autoscalingNodeGroups: []string{"someNodeGroup"},
|
autoscalingNodeGroups: []string{"someNodeGroup"},
|
||||||
expectedInitClusterInput: kubernetes.InitClusterInput{
|
expectedInitClusterInput: kubernetes.InitClusterInput{
|
||||||
APIServerAdvertiseIP: "10.118.0.1",
|
APIServerAdvertiseIP: "10.118.0.1",
|
||||||
|
NodeIP: "10.118.0.1",
|
||||||
NodeName: "10.118.0.1",
|
NodeName: "10.118.0.1",
|
||||||
SupportsCloudControllerManager: false,
|
SupportsCloudControllerManager: false,
|
||||||
SupportClusterAutoscaler: true,
|
SupportClusterAutoscaler: true,
|
||||||
@ -106,6 +109,7 @@ func TestInitCluster(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedInitClusterInput: kubernetes.InitClusterInput{
|
expectedInitClusterInput: kubernetes.InitClusterInput{
|
||||||
APIServerAdvertiseIP: "10.118.0.1",
|
APIServerAdvertiseIP: "10.118.0.1",
|
||||||
|
NodeIP: "10.118.0.1",
|
||||||
NodeName: "10.118.0.1",
|
NodeName: "10.118.0.1",
|
||||||
SupportsCloudControllerManager: true,
|
SupportsCloudControllerManager: true,
|
||||||
SupportClusterAutoscaler: false,
|
SupportClusterAutoscaler: false,
|
||||||
@ -142,7 +146,8 @@ func TestInitCluster(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectErr: false,
|
expectErr: false,
|
||||||
expectedInitClusterInput: kubernetes.InitClusterInput{
|
expectedInitClusterInput: kubernetes.InitClusterInput{
|
||||||
APIServerAdvertiseIP: "10.118.0.1",
|
APIServerAdvertiseIP: "10.118.0.1",
|
||||||
|
NodeIP: "10.118.0.1",
|
||||||
CloudControllerManagerEnv: []k8s.EnvVar{},
|
CloudControllerManagerEnv: []k8s.EnvVar{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -49,7 +49,7 @@ func New(clusterUtil k8sapi.ClusterUtil, configProvider configurationProvider, c
|
|||||||
func (k *KubeWrapper) InitCluster(in InitClusterInput) (*kubeadm.BootstrapTokenDiscovery, error) {
|
func (k *KubeWrapper) InitCluster(in InitClusterInput) (*kubeadm.BootstrapTokenDiscovery, error) {
|
||||||
initConfig := k.configProvider.InitConfiguration()
|
initConfig := k.configProvider.InitConfiguration()
|
||||||
initConfig.SetApiServerAdvertiseAddress(in.APIServerAdvertiseIP)
|
initConfig.SetApiServerAdvertiseAddress(in.APIServerAdvertiseIP)
|
||||||
initConfig.SetNodeIP(in.APIServerAdvertiseIP)
|
initConfig.SetNodeIP(in.NodeIP)
|
||||||
initConfig.SetNodeName(in.NodeName)
|
initConfig.SetNodeName(in.NodeName)
|
||||||
initConfig.SetPodNetworkCIDR(podNetworkCidr)
|
initConfig.SetPodNetworkCIDR(podNetworkCidr)
|
||||||
initConfig.SetServiceCIDR(serviceCidr)
|
initConfig.SetServiceCIDR(serviceCidr)
|
||||||
|
Loading…
Reference in New Issue
Block a user