diff --git a/cluster/images/agent.Dockerfile b/cluster/images/agent.Dockerfile index e80d1c4d8..fda01383b 100644 --- a/cluster/images/agent.Dockerfile +++ b/cluster/images/agent.Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:latest as release-env +FROM ubuntu:latest AS release-env ARG BINARY diff --git a/cluster/images/buildx.agent.Dockerfile b/cluster/images/buildx.agent.Dockerfile index 3e9c78e69..48770fe17 100644 --- a/cluster/images/buildx.agent.Dockerfile +++ b/cluster/images/buildx.agent.Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:latest as release-env +FROM ubuntu:latest AS release-env ARG BINARY ARG TARGETPLATFORM diff --git a/deploy/crds/kosmos.io_kubenestconfigurations.yaml b/deploy/crds/kosmos.io_kubenestconfigurations.yaml index 40c180383..d1f1c02d3 100644 --- a/deploy/crds/kosmos.io_kubenestconfigurations.yaml +++ b/deploy/crds/kosmos.io_kubenestconfigurations.yaml @@ -77,7 +77,7 @@ spec: type: string type: array type: object - useTenantDns: + useTenantDNS: default: false type: boolean type: object diff --git a/deploy/crds/kosmos.io_virtualclusters.yaml b/deploy/crds/kosmos.io_virtualclusters.yaml index 0d53fad43..9321b6fa6 100644 --- a/deploy/crds/kosmos.io_virtualclusters.yaml +++ b/deploy/crds/kosmos.io_virtualclusters.yaml @@ -95,7 +95,7 @@ spec: type: string type: array type: object - useTenantDns: + useTenantDNS: default: false type: boolean type: object diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index ccedfea20..2479f6fb4 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -1983,7 +1983,7 @@ func schema_pkg_apis_kosmos_v1alpha1_KubeInKubeConfig(ref common.ReferenceCallba Format: "", }, }, - "useTenantDns": { + "useTenantDNS": { SchemaProps: spec.SchemaProps{ Type: []string{"boolean"}, Format: "", diff --git a/pkg/kubenest/constants/constant.go b/pkg/kubenest/constants/constant.go index 0613b33e6..678893f52 100644 --- a/pkg/kubenest/constants/constant.go +++ b/pkg/kubenest/constants/constant.go @@ -3,6 +3,8 @@ package constants import ( "time" + corev1 "k8s.io/api/core/v1" + "github.com/kosmos.io/kosmos/pkg/utils" ) @@ -142,8 +144,12 @@ type Action string var APIServerServiceSubnet string var KubeControllerManagerPodSubnet string +var PreferredAddressType corev1.NodeAddressType + func init() { APIServerServiceSubnet = utils.GetEnvWithDefaultValue("SERVICE_SUBNET", "10.237.6.0/18") // fd11:1122:1111::/48, KubeControllerManagerPodSubnet = utils.GetEnvWithDefaultValue("POD_SUBNET", "10.244.0.0/16") + + PreferredAddressType = corev1.NodeAddressType(utils.GetEnvWithDefaultValue("PREFERRED_ADDRESS_TYPE", string(corev1.NodeInternalIP))) } diff --git a/pkg/kubenest/controller/global.node.controller/global_node_controller.go b/pkg/kubenest/controller/global.node.controller/global_node_controller.go index 9f98ce92f..a9dbacdb7 100644 --- a/pkg/kubenest/controller/global.node.controller/global_node_controller.go +++ b/pkg/kubenest/controller/global.node.controller/global_node_controller.go @@ -227,9 +227,9 @@ func (r *GlobalNodeController) Reconcile(ctx context.Context, request reconcile. } globalNode.Name = request.Name globalNode.Spec.State = v1alpha1.NodeReserved - firstNodeIP, err := utils.FindFirstNodeIPAddress(*rootNode, v1.NodeInternalIP) + firstNodeIP, err := utils.FindFirstNodeIPAddress(*rootNode, constants.PreferredAddressType) if err != nil { - klog.Errorf("get first node ip address err: %s %s", v1.NodeInternalIP, err.Error()) + klog.Errorf("get first node ip address err: %s %s", constants.PreferredAddressType, err.Error()) } globalNode.Spec.NodeIP = firstNodeIP if _, err = r.KosmosClient.KosmosV1alpha1().GlobalNodes().Create(ctx, &globalNode, metav1.CreateOptions{}); err != nil { diff --git a/pkg/kubenest/controller/virtualcluster_init_controller.go b/pkg/kubenest/controller/virtualcluster_init_controller.go index 7463ba51d..736a56ed0 100644 --- a/pkg/kubenest/controller/virtualcluster_init_controller.go +++ b/pkg/kubenest/controller/virtualcluster_init_controller.go @@ -778,7 +778,7 @@ func (c *VirtualClusterInitController) findHostAddresses() ([]string, error) { ret := []string{} for _, node := range nodes.Items { - addr, err := utils.FindFirstNodeIPAddress(node, corev1.NodeExternalIP) + addr, err := utils.FindFirstNodeIPAddress(node, constants.PreferredAddressType) if err != nil { return nil, err } diff --git a/pkg/kubenest/controlplane/etcd.go b/pkg/kubenest/controlplane/etcd.go index 3ce484a30..2d7607c7a 100644 --- a/pkg/kubenest/controlplane/etcd.go +++ b/pkg/kubenest/controlplane/etcd.go @@ -37,7 +37,7 @@ func installEtcd(client clientset.Interface, name, namespace string, kubeNestCon var resourceQuantity resource.Quantity var err error - if vc.Spec.KubeInKubeConfig.ETCDUnitSize != "" { + if vc.Spec.KubeInKubeConfig != nil && vc.Spec.KubeInKubeConfig.ETCDUnitSize != "" { resourceQuantity, err = resource.ParseQuantity(vc.Spec.KubeInKubeConfig.ETCDUnitSize) if err != nil { klog.Errorf("Failed to parse etcdSize %s: %v", vc.Spec.KubeInKubeConfig.ETCDUnitSize, err) @@ -56,7 +56,6 @@ func installEtcd(client clientset.Interface, name, namespace string, kubeNestCon return err } resourceQuantity.Set(resourceQuantity.Value() * int64(nodeCount)) - } initialClusters := make([]string, constants.EtcdReplicas)