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
|
||||
providerID = instance.ProviderID
|
||||
if len(instance.IPs) > 0 {
|
||||
nodeIP = instance.IPs[0]
|
||||
}
|
||||
} else {
|
||||
nodeName = coordinatorVPNIP.String()
|
||||
}
|
||||
@ -117,6 +120,7 @@ func (c *Core) JoinCluster(args kubeadm.BootstrapTokenDiscovery) error {
|
||||
}
|
||||
var nodeName string
|
||||
var providerID string
|
||||
nodeIP := nodeVPNIP
|
||||
if c.metadata.Supported() {
|
||||
instance, err := c.metadata.Self(context.TODO())
|
||||
if err != nil {
|
||||
@ -125,6 +129,9 @@ func (c *Core) JoinCluster(args kubeadm.BootstrapTokenDiscovery) error {
|
||||
}
|
||||
providerID = instance.ProviderID
|
||||
nodeName = instance.Name
|
||||
if len(instance.IPs) > 0 {
|
||||
nodeIP = instance.IPs[0]
|
||||
}
|
||||
} else {
|
||||
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))
|
||||
return err
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ func TestInitCluster(t *testing.T) {
|
||||
autoscalingNodeGroups: []string{"someNodeGroup"},
|
||||
expectedInitClusterInput: kubernetes.InitClusterInput{
|
||||
APIServerAdvertiseIP: "10.118.0.1",
|
||||
NodeIP: "10.118.0.1",
|
||||
NodeName: "10.118.0.1",
|
||||
SupportsCloudControllerManager: false,
|
||||
SupportClusterAutoscaler: false,
|
||||
@ -56,6 +57,7 @@ func TestInitCluster(t *testing.T) {
|
||||
},
|
||||
expectedInitClusterInput: kubernetes.InitClusterInput{
|
||||
APIServerAdvertiseIP: "10.118.0.1",
|
||||
NodeIP: "10.118.0.1",
|
||||
NodeName: "some-name",
|
||||
ProviderID: "fake://providerid",
|
||||
SupportsCloudControllerManager: false,
|
||||
@ -85,6 +87,7 @@ func TestInitCluster(t *testing.T) {
|
||||
autoscalingNodeGroups: []string{"someNodeGroup"},
|
||||
expectedInitClusterInput: kubernetes.InitClusterInput{
|
||||
APIServerAdvertiseIP: "10.118.0.1",
|
||||
NodeIP: "10.118.0.1",
|
||||
NodeName: "10.118.0.1",
|
||||
SupportsCloudControllerManager: false,
|
||||
SupportClusterAutoscaler: true,
|
||||
@ -106,6 +109,7 @@ func TestInitCluster(t *testing.T) {
|
||||
},
|
||||
expectedInitClusterInput: kubernetes.InitClusterInput{
|
||||
APIServerAdvertiseIP: "10.118.0.1",
|
||||
NodeIP: "10.118.0.1",
|
||||
NodeName: "10.118.0.1",
|
||||
SupportsCloudControllerManager: true,
|
||||
SupportClusterAutoscaler: false,
|
||||
@ -143,6 +147,7 @@ func TestInitCluster(t *testing.T) {
|
||||
expectErr: false,
|
||||
expectedInitClusterInput: kubernetes.InitClusterInput{
|
||||
APIServerAdvertiseIP: "10.118.0.1",
|
||||
NodeIP: "10.118.0.1",
|
||||
CloudControllerManagerEnv: []k8s.EnvVar{},
|
||||
},
|
||||
},
|
||||
|
@ -49,7 +49,7 @@ func New(clusterUtil k8sapi.ClusterUtil, configProvider configurationProvider, c
|
||||
func (k *KubeWrapper) InitCluster(in InitClusterInput) (*kubeadm.BootstrapTokenDiscovery, error) {
|
||||
initConfig := k.configProvider.InitConfiguration()
|
||||
initConfig.SetApiServerAdvertiseAddress(in.APIServerAdvertiseIP)
|
||||
initConfig.SetNodeIP(in.APIServerAdvertiseIP)
|
||||
initConfig.SetNodeIP(in.NodeIP)
|
||||
initConfig.SetNodeName(in.NodeName)
|
||||
initConfig.SetPodNetworkCIDR(podNetworkCidr)
|
||||
initConfig.SetServiceCIDR(serviceCidr)
|
||||
|
Loading…
Reference in New Issue
Block a user