Skip to content

Commit

Permalink
feat(platform): add default kubernetes topology zone lable (tkestack#…
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielXLee committed Oct 26, 2022
1 parent d5025f8 commit 1b870e1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
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 @@ -69,6 +69,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")

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

0 comments on commit 1b870e1

Please sign in to comment.