Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Modify node IP selection logic #713

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cluster/images/agent.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:latest as release-env
FROM ubuntu:latest AS release-env

ARG BINARY

Expand Down
2 changes: 1 addition & 1 deletion cluster/images/buildx.agent.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:latest as release-env
FROM ubuntu:latest AS release-env

ARG BINARY
ARG TARGETPLATFORM
Expand Down
2 changes: 1 addition & 1 deletion deploy/crds/kosmos.io_kubenestconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ spec:
type: string
type: array
type: object
useTenantDns:
useTenantDNS:
default: false
type: boolean
type: object
Expand Down
2 changes: 1 addition & 1 deletion deploy/crds/kosmos.io_virtualclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ spec:
type: string
type: array
type: object
useTenantDns:
useTenantDNS:
default: false
type: boolean
type: object
Expand Down
2 changes: 1 addition & 1 deletion pkg/generated/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/kubenest/constants/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package constants
import (
"time"

corev1 "k8s.io/api/core/v1"

"github.com/kosmos.io/kosmos/pkg/utils"
)

Expand Down Expand Up @@ -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)))
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubenest/controller/virtualcluster_init_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/kubenest/controlplane/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Loading