Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create Kubernetes Cluster Federation

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to create Kubernetes cluster federation". In daily operation, I believe many people have doubts about how to create Kubernetes cluster federation. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to create Kubernetes cluster federation". Next, please follow the editor to study!

Prepare the domain name

Federation uses domain names to expose the same service in different subclusters, so users are required to provide a configurable domain name. You can purchase a domain name on Aliyun through Wanwang and configure it to your Federation cluster.

Take the domain name spacexnice.xyz as an example, please purchase the domain name according to the purchase domain name document.

Configure domain name

Since Federation sets the TTL of the domain name to 3 minutes and the domain name level to 5 when adding the domain name resolution record, you need to set the domain name you just purchased on Aliyun, so that the minimum TTL value allowed for the domain name is less than 3 minutes, and the domain name level is greater than 5.

Go to the Cloud Resolution console to select the domain name you just purchased, and select "upgrade" or "upgrade VIP" in more.

In the pop-up page, change the minimum TTL value to 60s, the subdomain level to level 7, and then save.

Create multiple subclusters

The Federation cluster created in this example consists of two subclusters, region in Hangzhou and Beijing. First of all, we need to create two available clusters in these two Region. Refer to the documentation for cluster creation steps.

Hangzhou cluster

[root@iZbp1bpj58bdzdosdxxf82Z ~] # kubectl get noNAME STATUS ROLES AGE VERSIONcn-hangzhou.i-bp11ajet2v9o3tp0o2uw Ready master 3D v1.8.4cn-hangzhou.i-bp15pt2475mgw64k72ma Ready master 3D v1.8.4cn-hangzhou.i-bp18fggko6p3vyr0p0ew Ready 3D v1.8.4cn-hangzhou.i-bp18fggko6p3vyr0p0ex Ready 3D v1.8.4cn -hangzhou.i-bp1bpj58bdzdosdxxf82 Ready master 3D v1.8.4

Beijing cluster

[root@iZze7z98ssc50pfzt6be9 ~] # kubectl get noNAME STATUS ROLES AGE VERSIONcn-beijing.i-2ze7z98ssc50pfzt6be9 Ready master 3D v1.8.4cn-beijing.i-2ze8hr6k03ccroopicd2 Ready master 3D v1.8.4cn-beijing.i-2zeipodwz2junslmihqz Ready master 3D v1.8.4cn-beijing.i-2zeipodwz2junyipunrf Ready 3D v1.8.4 deploy federation control plane

Select the subcluster of Hangzhou as the host cluster of Federation and install the control plane of Federation. And configure the local kubeconfig. Initialize the primary cluster by running the kubefed init command. The specific steps are as follows:

Install kubefed

Install kubefed on the master node of the hangzhou cluster

[root@iZze7z98ssc50pfzt6be9 ~] # curl-L http://aliacs-k8s-cn-hangzhou.oss.aliyuncs.com/bin/kubefed-1.8.4-o kubefed [root@iZze7z98ssc50pfzt6be9 ~] # sudo cp kubefed / usr/bin [root@iZze7z98ssc50pfzt6be9] # sudo chmod + x / usr/bin/kubefed [root@iZze7z98ssc50pfzt6be9 ~] # kubefed version configuration kubeconfig

Configure the context of the two hangzhou,beijing clusters in the Hangzhou cluster master node, so that the changed nodes can connect to different subclusters by switching context. The content to be modified is as follows:

Modify the name of the cluster,user,context of kubeconfig of hangzhou cluster to hangzhou

Copy the cluster,user,context content in the beijing cluster kubeconfig to a) step kubeconfig, and change the corresponding cluster,user,context name to beijing

For the convenience of beginners, we provide an automated script that automatically downloads the kubeconfig configuration file from your designated cluster through ssh and merges it into a whole.

The ~ / .kube / config file is automatically generated by executing the script. The script needs to specify which clusters to download the kubeconfig files from and merge them. The format is as follows: python context.py-H hangzhou:1.1.1.1,beijing:2.2.2.2 Note parameters are replaced with your own cluster Region and IP. The script may ask you to enter your login password for ssh.

[root@iZbp1bpj58bdzdosdxxf82Z ~] # curl http://aliacs-k8s-cn-hangzhou.oss.aliyuncs.com/tools/context.py > context.py [root@iZbp1bpj58bdzdosdxxf82Z ~] # sudo pip install pyyaml [root@iZbp1bpj58bdzdosdxxf82Z ~] # unset KUBECONFIG [root@iZbp1bpj58bdzdosdxxf82Z ~] # python context.py-H ${HOST} Info: host, hangzhou:118.31.177.21,beijing:47.95.96.234 .Info: file / root/.kube/config successfully generated.

The configuration results are as follows:

[root@iZbp1bpj58bdzdosdxxf82Z ~] # kubectl config get-contextsCURRENT NAME CLUSTER AUTHINFO NAMESPACE hangzhou kubernetes-hangzhou kubernetes-admin-hangzhou* beijing kubernetes-beijing kubernetes-admin-beijing configuration alidns.yaml file

Zones fill in the domain name you applied for earlier, and note that it ends with a period. And replace your accesskeyid and accesskeysecret.

Cat > alidns.yaml

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report