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

feat(platform): add default kubernetes topology zone label #2126

Merged
merged 1 commit into from
Oct 25, 2022
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: 2 additions & 0 deletions pkg/platform/provider/baremetal/cluster/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ func (p *Provider) getKubeadmJoinConfig(c *v1.Cluster, machineIP string) *kubead
kubeletExtraArgs["node-labels"] = fmt.Sprintf("%s,%s=%s", kubeletExtraArgs["node-labels"], apiclient.LabelSwitchIPCilium, switchIP)
}
}
kubeletExtraArgs["node-labels"] = fmt.Sprintf("%s,%s=%s", kubeletExtraArgs["node-lables"], apiclient.LabelTopologyZone, "default")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may overwrite other node labels args

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leoryu maybe, but this is the original overlay logic


if _, ok := kubeletExtraArgs["hostname-override"]; !ok {
if !c.Spec.HostnameAsNodename {
nodeRegistration.Name = machineIP
Expand Down
1 change: 1 addition & 0 deletions pkg/platform/provider/baremetal/machine/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (p *Provider) getKubeadmJoinConfig(c *v1.Cluster, machineIP string) *kubead
kubeletExtraArgs["node-labels"] = fmt.Sprintf("%s,%s=%s", kubeletExtraArgs["node-labels"], apiclient.LabelSwitchIPCilium, switchIP)
}
}
kubeletExtraArgs["node-labels"] = fmt.Sprintf("%s,%s=%s", kubeletExtraArgs["node-lables"], apiclient.LabelTopologyZone, "default")

// add node ip for single stack ipv6 clusters.
if _, ok := kubeletExtraArgs["node-ip"]; !ok {
Expand Down
5 changes: 3 additions & 2 deletions pkg/util/apiclient/idempotency.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
rbac "k8s.io/api/rbac/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
aaclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
Expand All @@ -48,7 +49,6 @@ import (
kubeaggregatorclientset "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset"
utilsnet "k8s.io/utils/net"
controllerutils "tkestack.io/tke/pkg/controller"
aaclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
)

// PlatformLabel represents the type of platform.tkestack.io related label.
Expand All @@ -63,6 +63,8 @@ const (
UpdateNodeTimeout = 2 * time.Minute
// LabelHostname specifies the label in node.
LabelHostname = "kubernetes.io/hostname"
// LabelTopologyZone represents a logical failure domain. It is common for Kubernetes clusters to span multiple zones for increased availability.
LabelTopologyZone = "topology.kubernetes.io/zone"
// LabelMachineIPV4 specifies the label in node.
LabelMachineIPV4 PlatformLabel = "platform.tkestack.io/machine-ip"
// LabelMachineIPV6Head specifies the label in node.
Expand Down Expand Up @@ -432,7 +434,6 @@ func CreateOrUpdateAPIService(ctx context.Context, client kubeaggregatorclientse
return nil
}


// CreateOrUpdateCustomResourceDefinition creates a CustomResourceDefinition if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.
func CreateOrUpdateCustomResourceDefinition(ctx context.Context, client aaclientset.Interface, crd *apiextensionsv1.CustomResourceDefinition) error {
if _, err := client.ApiextensionsV1().CustomResourceDefinitions().Create(ctx, crd, metav1.CreateOptions{}); err != nil {
Expand Down