1. 了解namespace

集群逻辑上的资源分类,用于实现多租户的资源隔离。k8s上所有命名空间对应于containerd的k8s.io命名空间。

1.1 查看集群上命名空间

1
2
3
4
5
6
[root@node001 ~]# kubectl get namespaces 
NAME STATUS AGE
default Active 18h
kube-node-lease Active 18h
kube-public Active 18h
kube-system Active 18h

1.2 查看指定ns空间资源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@node001 ~]# kubectl get pod -n kube-system 
NAME READY STATUS RESTARTS AGE
calico-kube-controllers-6799f5f4b4-jfclq 1/1 Running 0 18h
calico-node-kgksh 1/1 Running 0 17h
calico-node-vxdr5 1/1 Running 0 18h
calico-node-wb8pd 1/1 Running 0 18h
coredns-74586cf9b6-224q9 1/1 Running 0 18h
coredns-74586cf9b6-z6nn9 1/1 Running 0 18h
etcd-node001 1/1 Running 0 18h
kube-apiserver-node001 1/1 Running 0 18h
kube-controller-manager-node001 1/1 Running 0 18h
kube-proxy-4mjdp 1/1 Running 0 17h
kube-proxy-b7rmn 1/1 Running 0 18h
kube-proxy-xhhtf 1/1 Running 0 18h
kube-scheduler-node001 1/1 Running 0 18h
metrics-server-9d5bbf85c-6jbkn 1/1 Running 0 17h

1.3 查看所有命名空间资源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@node001 ~]# kubectl get pod -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system calico-kube-controllers-6799f5f4b4-jfclq 1/1 Running 0 18h
kube-system calico-node-kgksh 1/1 Running 0 17h
kube-system calico-node-vxdr5 1/1 Running 0 18h
kube-system calico-node-wb8pd 1/1 Running 0 18h
kube-system coredns-74586cf9b6-224q9 1/1 Running 0 18h
kube-system coredns-74586cf9b6-z6nn9 1/1 Running 0 18h
kube-system etcd-node001 1/1 Running 0 18h
kube-system kube-apiserver-node001 1/1 Running 0 18h
kube-system kube-controller-manager-node001 1/1 Running 0 18h
kube-system kube-proxy-4mjdp 1/1 Running 0 17h
kube-system kube-proxy-b7rmn 1/1 Running 0 18h
kube-system kube-proxy-xhhtf 1/1 Running 0 18h
kube-system kube-scheduler-node001 1/1 Running 0 18h
kube-system metrics-server-9d5bbf85c-6jbkn 1/1 Running 0 17h

1.4 切换名称空间

1
[root@node001 ~]# kubectl config set-context --current --namespace kube-system

查看当前ns下资源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@node001 ~]# kubectl get all
NAME READY STATUS RESTARTS AGE
pod/calico-kube-controllers-6799f5f4b4-jfclq 1/1 Running 0 18h
pod/calico-node-kgksh 1/1 Running 0 18h
pod/calico-node-vxdr5 1/1 Running 0 18h
pod/calico-node-wb8pd 1/1 Running 0 18h
pod/coredns-74586cf9b6-224q9 1/1 Running 0 18h
pod/coredns-74586cf9b6-z6nn9 1/1 Running 0 18h
pod/etcd-node001 1/1 Running 0 18h
pod/kube-apiserver-node001 1/1 Running 0 18h
pod/kube-controller-manager-node001 1/1 Running 0 18h
pod/kube-proxy-4mjdp 1/1 Running 0 18h
pod/kube-proxy-b7rmn 1/1 Running 0 18h
pod/kube-proxy-xhhtf 1/1 Running 0 18h
pod/kube-scheduler-node001 1/1 Running 0 18h
pod/metrics-server-9d5bbf85c-6jbkn 1/1 Running 0 17h

2. 多集群管理

kubeconfig文件是kubectl客户端登录集群的配置文件,包括3个部分:
1、集群信息
 登录集群的地址
 集群的证书
2、上下文
 整合1和3
 默认的ns
3、用户
 用户的私钥
 用户的证书

2.1 获取kubeconfig文件

1
[root@node001 ~]# kubectl config view > kc

2.2 编辑kc支持2套集群

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[root@node001 ~]# cat kc 
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRY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cluster
contexts:
- context:
cluster: kubeadm-cluster
namespace: default
user: admin1
name: ek8s
- context:
cluster: ansible-cluster
namespace: default
user: admin2
name: ok8s
current-context: ek8s
kind: Config
preferences: {}
users:
- name: admin1
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lJQ2R6SFZKcWZEWHd3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TWpBNU1EVXhORFF3TURkYUZ3MHlNekE1TURVeE5EUXdNRGhhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQTBkb1o1MHZ4WnF1M0FROVUKUlNjWVA0Q3RveFl3MUtpOUhldWIyZU9QMjNwYXFkdUcxN3QzZkJxMjJudldFS2VCWnlGM1RpYkY1dUFUZTlNRQpBWGJYcEZnSzRYNlRPSHdNYWtWM0ZFQjJhRElHVXRkd3poMkZxTnZKRWVURjMrWWJuQUNTUm1tclgvV2d4QWVKCkJBVkwwN05GTVJlcE5FelhONjBCT2hxMTlRZHhjOGoyYTBBbjRxYXFHcm9WUlNkNWRuMlU4U3pXbkZpUmE3Yk8KMjczVk40Y2V4eWdrV3Y1aFZtNjJOVDA3czZUOFo1MVAwMmVMejNXYkJTTmVjbUt6bmJCYXczNDFoTlpUTlJmbQpjbkZ5czJDV0t0ZEFoL0MzbTRLZW1jRE5ia3VBZ1crL0tNcExKbXRFV0pqNy9BUjJsWk9QQzZwai9vV1RsaDNCClREcGFWd0lEQVFBQm8xWXdWREFPQmdOVkhROEJBZjhFQkFNQ0JhQXdFd1lEVlIwbEJBd3dDZ1lJS3dZQkJRVUgKQXdJd0RBWURWUjBUQVFIL0JBS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DZHeWpMcUs2am1CT1QrZEFudVNLc2p4MmNiMW9WYmhNb2dCNnNMV1V2bnNOSENLdHA4VURFRXpJS3c5CmdaczI0RVZCNk5RSUxidEZBQ2JiRXhrQ2dZRUF2aklSbTNlcDFIMUZJN1ZieHdSZndUZzZlbXFQb2JRR0tOMHQKK01LWmtvZUJEaHlFQkxNSEM4MlVST2tnRmdVbzJpQ1k5ZWQxY2tmUEx1VENSNjRmZlprcThQN3d5U2VXK1JUaQpub3dmZEs0STZEUDNqK0lqRFo2bUQ4cWJ0Mm9tM3BnUXlrRUlCZHM2U2ZSdzR4Vm1xc1RXV0gxRzhVSzhablB1ClBkUXVpaTBDZ1lFQW1uNlpjYVZFTzd5MThyZnlPWDYvM0ExRXl4MUxHYzBqbVVESENEVnhFRzE4OVgvT3E5RVcKK2c3Z0pDWFVSbEp0T29za0Q0WTFYa0tPM2ZyV09TbjNyTkJaNTR6K3p3WmcxWksraEZja2M1UGJ2Q3NFcjBxRwpEaUF5T1ZlaG5Fb1FmSkhkYSs1djNEeHBxMWwrTi9FcGN2U0xBcGJ5TkFTL3ZIL014TnYxek13PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=

2.3 查看当前有几套集群

1
2
3
4
[root@node001 ~]# kubectl --kubeconfig=kc config get-contexts 
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* ek8s kubeadm-cluster admin1 default
ok8s ansible-cluster admin2 default

2.4 切换集群

1
2
[root@node001 ~]# kubectl --kubeconfig=kc config use-context ok8s
Switched to context "ok8s".

查看集群node

1
2
3
4
5
6
7
8
[root@node001 ~]# kubectl --kubeconfig=kc get nodes
NAME STATUS ROLES AGE VERSION
192.168.10.11 Ready,SchedulingDisabled master 19d v1.24.2
192.168.10.12 Ready,SchedulingDisabled master 19d v1.24.2
192.168.10.13 Ready,SchedulingDisabled master 19d v1.24.2
192.168.10.14 Ready node 19d v1.24.2
192.168.10.15 Ready node 19d v1.24.2
192.168.10.16 Ready node 18d v1.24.2