当前位置:网站首页>Configuring multi cluster management using kubectl
Configuring multi cluster management using kubectl
2022-06-23 03:18:00 【genesis】
Everybody knows kubectl Mainly used for management kubernetes colony , But when there are multiple sets in our environment kubernetes When the cluster , How to manage , The following is a list of the configuration kubeconfig To achieve kubectl Methods of managing multiple clusters .
One 、 Use kubeclt Merge multiple config
It is assumed that the current client has configured the access credentials of a cluster , namely ~/.kube/config It already contains a set of cluster access credentials , Then we can upload the access credentials of another cluster to /tmp, And named it test-config, Then execute the following command to merge the... Of multiple clusters config.
#KUBECONFIG=~/.kube/config:/tmp/test-config kubectl config view --merge --flatten >> ~/.kube/config #export KUBECONFIG=~/.kube/config
have access to kubectl config view View merged kubeconfig Configuration situation , Under normal circumstances , Two cluster credential information can be displayed .
explain : There is a small problem in the test , The above command does not add >> ~/.kube/config when , You can output the access credentials of two clusters , Under normal circumstances, you should use
> ~/.kube/config Overwrite the output results with config in , After the actual execution is completed ,config Just keep test-config Access credentials for , So instead of using >> ~/.kube/config, Append the access credentials of the two clusters to config In file , But at the same time, the previous access credentials still exist .
Two 、 Will be multiple config Configure to environment variables
We upload the access credentials of another cluster to ~/.kube, And named it test-config, Then execute the following command :
#echo KUBECONFIG=/root/.kube/config:/root/.kube/test-config ~/.bash_profile #source ~/.bash_profile
perform kubectl config view You can also see kubeconfig Contains access credentials for both clusters .
3、 ... and 、 Manual configuration
The manual method is cumbersome , Just list them , I want to observe config Detailed format of , It's good for you kubeconfig Have a clearer understanding , The following for config Detailed format of .
# When an access credential #
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: ***
server: https://192.168.*.*:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: kubernetes-admin
name: [email protected]
current-context: [email protected]
kind: Config
preferences: {}
users:
- name: kubernetes-admin
user:
client-certificate-data: ***
client-key-data: ***
# Two access credentials #
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: ***
server: https://42.194.*.*:443/
name: cls-ec6ymsmo
- cluster:
certificate-authority-data: ***
server: https://192.168.*.*:6443
name: kubernetes
contexts:
- context:
cluster: cls-ec6ymsmo
user: "10000******"
name: cls-ec6ymsmo-10000******
- context:
cluster: kubernetes
user: kubernetes-admin
name: [email protected]
current-context: [email protected]
kind: Config
preferences: {}
users:
- name: "100006621061"
user:
client-certificate-data: ***
client-key-data: ***
- name: kubernetes-admin
user:
client-certificate-data: ***
client-key-data: ***
You can clearly see , We can also manually cluster another set of cluster、context、user Paste it into... According to the format requirements config that will do .
Four 、 summary
I prefer the second of the three configuration methods , When you need to manage multiple clusters, the configuration is also relatively simple , It is worth noting that the first configuration method is used > ~/.kube/config The previous access credentials will be overwritten , In this case, the cluster's /etc/kubernetes/admin.conf Make a new copy of the document .
After configuring the multi cluster access credentials , You can use the following commands to view and switch multi cluster information .
kubectl config get-contexts # View cluster information ,* Indicates the current working environment . kubectl config use-context [email protected] # Switch working environment to [email protected] kubectl config --help # See more config Use command
边栏推荐
- Autowired usage
- [Alibaba middleware technology series] "Nacos technology" service registration and discovery related principle analysis
- CVE-2021-21973 Vmware Vcenter SSRF POC
- Implementation process of the new electronic amplification function of easycvr video fusion cloud platform
- Cve-2021-4034 reappearance
- Section 6: basic configuration I of spingboot
- To implement a task scheduling system, it is enough to read this article
- [SaaS examination certification] apaas_ Tencent Qianfan magic pen
- Quickly understand the development status of secondary nodes of industrial Internet identity analysis
- The logical operators |, & &!
猜你喜欢
![Analysis on development history, industrial chain, output and enterprise layout of medical polypropylene in China in 2020 [figure]](/img/28/ebfc25ec288627706e15a07e6bdb77.jpg)
Analysis on development history, industrial chain, output and enterprise layout of medical polypropylene in China in 2020 [figure]

Analysis on the development of China's satellite navigation industry chain in 2021: satellite navigation is fully integrated into production and life, and the satellite navigation industry is also boo
![Analysis on the development status of China's watch industry in 2021: a large number of electric watches are imported [figure]](/img/ca/672bfe49c8123da8679b2abeb43a2e.jpg)
Analysis on the development status of China's watch industry in 2021: a large number of electric watches are imported [figure]
随机推荐
Eight models of data analysis: detailed explanation of RFM model
Flowable refactoring process editor to obtain user information
Scanning technology (getting started with web security 06)
New uniapp+uniui background management uniuadmin
Exploration on the framework of stream batch integration technology and its practice in kangaroo cloud number stack
Add other view components to the audio and video components of the applet
Build information query applet by using micro build
JS judge the mobile terminal and PC terminal
Easygbs solution to video playback failure caused by tcp/udp configuration problems
2022-01-27: heater. Winter has come. Your task is to design a
Bi skills - authority control
What if the software gets stuck and cannot end the process?
How to gracefully solve the problem of platform font adaptation
The logical operators |, & &!
Operating wechat cache by using wechat low code
Use micro build to realize search function
Use Sakura FRP intranet penetration service to build your own website / game server
Drill down into handler, looper, messagequeue
Reading redis source code (VI) multi threading of redis 6.0
SAP mm initial transaction code MEK1 maintenance pb00 price