Kubernetes实战(十二)-使用kubeconfig文件管理多套kubernetes(k8s)集群

本文主要是介绍Kubernetes实战(十二)-使用kubeconfig文件管理多套kubernetes(k8s)集群,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1 概述

在生产环境中可能不止有一套kubernetes(k8s)集群,面对多套集群,运维人员可以使用kubeconfig文件管理多套kubernetes(k8s)集群,使用 kubeconfig 文件,可以组织集群、用户和命名空间,还可以定义上下文,以便在集群和命名空间之间快速轻松地切换。

2 kubeconfig文件

用于配置集群访问的文件称为“kubeconfig 文件”。 这是引用配置文件的通用方法,并不意味着有一个名为 kubeconfig 的文件。

使用 kubeconfig 文件来组织有关集群、用户、命名空间和身份认证机制的信息。 kubectl 命令行工具使用 kubeconfig 文件来查找选择集群所需的信息,并与集群的 API 服务器进行通信。

默认情况下,kubectl 在 $HOME/.kube 目录下查找名为 config 的文件。 你可以通过设置 KUBECONFIG 环境变量或者设置 --kubeconfig参数来指定其他 kubeconfig 文件。

kubeconfig文件由3部分组成:clusters,users,contexts。clusters是kubernetes(k8s)集群信息,users是连接kubernetes(k8s)集群的用户信息,contexts上下文综合了clusters信息和users信息。

apiVersion: v1
clusters:
- cluster:certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM1ekNDQWMrZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJek1USXhNVEV6TVRVeE5Wb1hEVE16TVRJd09ERXpNVFV4TlZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTkdaCmR5N0J6Q1ZOYVZmeXJvN1k3Qm1JZ2lla3ZtSWpjUFpUdWp1UXlNMk43clZiQS9IcWh2eGQ2cmZtczM5a2IvSnYKOVpScWp5MUlGRTdsc3B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ubernetes-adminname: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-adminuser:client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lJUnhnQ1p1bzlWUVl3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TXpFeU1URXhNekUxTVRWYUZ3MHlOREV5TVRBeE16RTFNVGRhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQTNrTS80NWlwZXpaN3Q5SjEKNzlHWHJCSlpaWUJ1KzFuTUE2dVpEOFBpNzhuYVJqNE96NG9vRUc1NXdvWG85cUJYL2Iwd0lPUU1WRFRrbXVaNApEbG5KOEhwdzJQTWR3REIzUW14U1Fzb1VjN0paVjZxb0ZyaVZ1blRMSzZGMnF5M3BWM044bnVxam1CQ3JuRGJFClg4STBoaUVKZ3VNenVFZFZ4NU0xcFdJdU50MkRMdS9WWGFhV3J5R2NqN250YVFSbmRzWkd4b3hycURtTEY5UDcKY3J4bHF6TkVVeTNJMnkySU9mci9kcjVGbkZZa0V3d3p1TnRvdGdHaW1MYXkzOXVwR25wMkNKdm1QQVNQcHpzbQpkNzZrYzJ4Q1ByTFVuR2ZDTlNHbGlsaHVoOUVKSVNESmpoMHJKTFdBeGUwajRmZWdLU241bjJSbmRWeklvcUxVCkZHTnB5UUlEQVFBQm8xWXdWREFPQmdOVkhROEJBZjhFQkFNQ0JhQXdFd1lEVlIwbEJBd3dDZ1lJS3dZQkJRVUgKQXdJd0RBWURWUjBUQVFIL0JBSXdBREFmQmdOVkhTTUVHREFXZ0JSYUhMZ3dvU0JYR1plZ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enJhc0NvRUN0WnE4T2xnT3Q1T2F1Q0hVbQpBdStMdUdpQ3gyRmN6VkFSMFFuaVh5Ly9oS0Z2d09wYUR4MTVNWHRjWENRNG1NTDdEeFV3MUdhQXhQQlBQdVpWCmJxbWpnNTNRRlpNVUdnNGxKSHVDNmVrQ2dZRUF6Ry9KeWZqa282bkVGSHBFY2ZMN3hvVTg2NTEveENUMmVjNnQKYXVnZWJjYmhObTUwSjJRRkxLZUdQZzFrcnJNaHhYV2YxZno1MDRFdzBPVmJnWE9nckNndVBPMzRXT2loeXRLZgpmdXBuVDdxdGRUQUhaZ0ZVTGQxbmJwQjhiL3duR2Z5Qmk0RlRyb1NGcjlRb01oeW9jTmhyUUd2NGUrSStBTzVxCjg2NXlpVlVDZ1lFQXN1QWtlL01nMndKMnhLUzhWdE9rUHArSGpReVhFeW9mM09STGRPSEtXcFFoZzl0WGdZZjUKRmJVVW1WME5KQ3RqUm9tMnkrRHk1bCtsSTQ3UjlBWkRLRHVYTTg4b2NIY1FkR0FhdjZ3c1JMSmpmbkpsaVU3bgp5WFhZaVVVZUQyaUljVTlFa25aZU14MGVIQkFvOEdPQ3hWakZlWEl5ODF6aHNkN3BqZnNJWDhVPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=

3 kubernetes(k8s)多集群切换 

默认的kubeconfig文件为:~/.kube/config 文件。

$ ls .kube/
cache  config

编写一个kubeconfig文件来管理两套k8s集群。

$ cp .kube/config config2
$ cat config2 
apiVersion: v1
clusters:
- cluster:certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM1ekNDQWMrZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeU1ERXdPVEE0TVRnd01Wb1hEVE15TURFd056QTRNVGd3TVZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSX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Gw0YkxQNFhOOTZOZit0NDlHdS9LeXBabXpIQkFOMWl0CkYrN0szeXVoamQ4VVNtUE14SVdPR2JEc05sTHMzTmJ5S3RpNgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==server: https://192.168.110.130:6443name: cluster1
- cluster:certificate-authority-data:这里写第二个集群的密钥 server: https://cluster2_ip:6443name: cluster2
contexts:
- context:cluster: cluster1namespace: defaultuser: admin1name: admin1@cluster1
- context:cluster: cluster2namespace: defaultuser: admin2name: admin2@cluster2
current-context: admin1@cluster1
kind: Config
preferences: {}
users:
- name: admin1user:client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lJR0ZpNStHUTdGOGd3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TWpBeE1Ea3dPREU0TURGYUZ3MHlNekF4TURrd09ERTRNRE5hTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXNMUVpScS9BeVF1aDlVdy8KN0craVJqekovdUFjbmtubU9VMHQ1OHNIcUw4b0ZXVlFyeUlDS3djdEtMcEp6RHBMOEZDWUtoejJSekY2VHJtawpzYVcvT2FMRmV2SjR2Y2NIbm1McGR1SWpram1TRnJ0L0R6VCsvSWdacGNlL21SRC9LR0tQUUxSQVVpUGx6NzdhClRvYU1pWGM5Ny9XZGp0Nk9ic091RGVsTnlteU4xRG5ONWJ2NWRFTkRaclh3VTFkQndhQjRXdnliTi9nVm02TUUKSjhRdXJDZ2V5d2swRjRtd3kwcGUyVldBd3Y1VHFxTmVzZ01pWHFacjZ2SjNSV285Z0tCeVhCODNBb1gwTlk4TQptY1JIWG44cWhPZ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OGZsc1hjZWhKS2JlSgpMUU80amFvdVFEUkJIelJiczMwL083R051dXN1UGV0eTk5ODNJYXl2OWtXd045R2FJS3kzSmxRaWdzQ2Fva3NICjlYUEhyOFFqWXJkYWpSVnlkUDhaL0hycGdIRGYxckNOVGtXVjBZcExBb0dBSWFqUWN5WkZURnpKeWRzZ1Z2eVYKUjNpYjIwUXUzQ2Vrd0JoblRwaGNvY0dDNGlLNjBLcGZ0S01xRG1mbEdYVm5GU05HTkNNVENXQ0pkK0d0cDZOKwpNTFhIT3BuUDcydjdlN3RZTDZHY1dxYW1XbjMxbFVpUnNIMTRtYmg3T3ZJeWhDL2VuMjkxTWNqU1YydFFNWVZTCkpjSFh3a0pkVXJ5WXpBQS9IYWhNckVrQ2dZRUFoN3V1WjBrcXFUdmxEY3BzaE1pWmhSbGhwNDZSL2srdWtLbVcKTjJITlk1WGVUdFFDVnhpN3hxQWdLOEN3U0hWSC84YkdUZzFFZ3dnRHB5VURXcEJ1enhBNS9TWlQ3a1Q4OFhvKwptM05CcDZBNE82OUVaU2lvUDFoQndoUHdzT3RwK25hSDdpb0QxNDBMZXh0Q29UdjJqSk5LaEVsL3lEVUdidmEyCklqQmNwbjBDZ1lCZThNTERFK1RCKytYVHFUT29wWGhaL09vRVdlSEp2M2xwdGdmOWg0eVZja3NqVEtNMkpKcEsKNFJFYmJSdUdsY1hOUzg3bEh1dUtCZE9aVzR5Q1hMTCtzcGt4YkY0ZmlFQWFkaTFDOWhZSko3Y2kzZy9jdUxLcQpPdk9EdlhBK2dlRHVaMk9Gakh6RU1XcktKUm1Sd0N1QVdqRld5WndneU16dUp4WWRkRU1raWc9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=
- name: admin2user:client-certificate-data:这里写第二个集群的用户公钥 client-key-data:这里写第二个集群的用户私钥

查看全局上下文,看有几套集群。

$ kubectl config get-contexts 
CURRENT   NAME                          CLUSTER      AUTHINFO           NAMESPACE
*         kubernetes-admin@kubernetes   kubernetes   kubernetes-admin   

切换k8s集群。

$ kubectl config use-context kubernetes-admin@kubernetes
Switched to context "kubernetes-admin@kubernetes".

这篇关于Kubernetes实战(十二)-使用kubeconfig文件管理多套kubernetes(k8s)集群的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/483589

相关文章

网页解析 lxml 库--实战

lxml库使用流程 lxml 是 Python 的第三方解析库,完全使用 Python 语言编写,它对 XPath表达式提供了良好的支 持,因此能够了高效地解析 HTML/XML 文档。本节讲解如何通过 lxml 库解析 HTML 文档。 pip install lxml lxm| 库提供了一个 etree 模块,该模块专门用来解析 HTML/XML 文档,下面来介绍一下 lxml 库

服务器集群同步时间手记

1.时间服务器配置(必须root用户) (1)检查ntp是否安装 [root@node1 桌面]# rpm -qa|grep ntpntp-4.2.6p5-10.el6.centos.x86_64fontpackages-filesystem-1.41-1.1.el6.noarchntpdate-4.2.6p5-10.el6.centos.x86_64 (2)修改ntp配置文件 [r

中文分词jieba库的使用与实景应用(一)

知识星球:https://articles.zsxq.com/id_fxvgc803qmr2.html 目录 一.定义: 精确模式(默认模式): 全模式: 搜索引擎模式: paddle 模式(基于深度学习的分词模式): 二 自定义词典 三.文本解析   调整词出现的频率 四. 关键词提取 A. 基于TF-IDF算法的关键词提取 B. 基于TextRank算法的关键词提取

使用SecondaryNameNode恢复NameNode的数据

1)需求: NameNode进程挂了并且存储的数据也丢失了,如何恢复NameNode 此种方式恢复的数据可能存在小部分数据的丢失。 2)故障模拟 (1)kill -9 NameNode进程 [lytfly@hadoop102 current]$ kill -9 19886 (2)删除NameNode存储的数据(/opt/module/hadoop-3.1.4/data/tmp/dfs/na

HDFS—集群扩容及缩容

白名单:表示在白名单的主机IP地址可以,用来存储数据。 配置白名单步骤如下: 1)在NameNode节点的/opt/module/hadoop-3.1.4/etc/hadoop目录下分别创建whitelist 和blacklist文件 (1)创建白名单 [lytfly@hadoop102 hadoop]$ vim whitelist 在whitelist中添加如下主机名称,假如集群正常工作的节

Hadoop集群数据均衡之磁盘间数据均衡

生产环境,由于硬盘空间不足,往往需要增加一块硬盘。刚加载的硬盘没有数据时,可以执行磁盘数据均衡命令。(Hadoop3.x新特性) plan后面带的节点的名字必须是已经存在的,并且是需要均衡的节点。 如果节点不存在,会报如下错误: 如果节点只有一个硬盘的话,不会创建均衡计划: (1)生成均衡计划 hdfs diskbalancer -plan hadoop102 (2)执行均衡计划 hd

Hadoop数据压缩使用介绍

一、压缩原则 (1)运算密集型的Job,少用压缩 (2)IO密集型的Job,多用压缩 二、压缩算法比较 三、压缩位置选择 四、压缩参数配置 1)为了支持多种压缩/解压缩算法,Hadoop引入了编码/解码器 2)要在Hadoop中启用压缩,可以配置如下参数

Makefile简明使用教程

文章目录 规则makefile文件的基本语法:加在命令前的特殊符号:.PHONY伪目标: Makefilev1 直观写法v2 加上中间过程v3 伪目标v4 变量 make 选项-f-n-C Make 是一种流行的构建工具,常用于将源代码转换成可执行文件或者其他形式的输出文件(如库文件、文档等)。Make 可以自动化地执行编译、链接等一系列操作。 规则 makefile文件

性能分析之MySQL索引实战案例

文章目录 一、前言二、准备三、MySQL索引优化四、MySQL 索引知识回顾五、总结 一、前言 在上一讲性能工具之 JProfiler 简单登录案例分析实战中已经发现SQL没有建立索引问题,本文将一起从代码层去分析为什么没有建立索引? 开源ERP项目地址:https://gitee.com/jishenghua/JSH_ERP 二、准备 打开IDEA找到登录请求资源路径位置

使用opencv优化图片(画面变清晰)

文章目录 需求影响照片清晰度的因素 实现降噪测试代码 锐化空间锐化Unsharp Masking频率域锐化对比测试 对比度增强常用算法对比测试 需求 对图像进行优化,使其看起来更清晰,同时保持尺寸不变,通常涉及到图像处理技术如锐化、降噪、对比度增强等 影响照片清晰度的因素 影响照片清晰度的因素有很多,主要可以从以下几个方面来分析 1. 拍摄设备 相机传感器:相机传