当前位置:网站首页>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
边栏推荐
- Weekly Postgres world news 2022w03
- Network security memorabilia - Summary of vulnerability exploitation events in 2021
- Evolution of cloud firewall products
- Reading redis source code (V) master-slave replication and sentinel mechanism
- Flowable refactoring process editor to obtain user information
- Methods for MySQL to avoid inserting duplicate records
- How to configure the domain name with low code of micro build
- How to gracefully solve the problem of platform font adaptation
- Win11 client remote ECS black screen
- "Tianzhou II" successfully docked! Three minutes to understand the shocking black technology on "Tianzhou II"! Headlines
猜你喜欢

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 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 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]
随机推荐
How to gracefully solve the problem of platform font adaptation
Operating wechat cache by using wechat low code
Simple implementation of promise basic method
Reading redis source code (VI) multi threading of redis 6.0
January 31, 2022: Maze III. There is a ball in the maze of open spaces and walls. ball
How to make special labels for books
How to install redis version 5.0.8 on the pagoda panel
Chapter IV open source projects and deployment
Build information query applet by using micro build
Weekly Postgres world news 2022w04
Online signature with canvas
Detailed explanation of label smoothing and implementation of pytorch tenorflow
Integrate Tencent maps with micro build and low code
Enterprise official website applet building tutorial
The primary level of SAP retail uses the transaction code wrfmatcopy to create commodity master data
JSON. Function of the stringify() optional parameter
Methods for MySQL to avoid inserting duplicate records
Copy system disk
JS judge the mobile terminal and PC terminal
JS counts the number of times a string appears in another string