轻量级 Kubernetes。安装简单,内存只有一半,所有的二进制都不到 100MB。
K3s 是一个完全符合 Kubernetes 的发行版,有以下增强功能。
我们希望安装的 Kubernetes 在内存占用方面只是一半的大小。Kubernetes 是一个 10 个字母的单词,简写为 K8s。所以,有 Kubernetes 一半大的东西就是一个 5 个字母的单词,简写为 K3s。K3s 没有全称,也没有官方的发音。
系统:Centos7 Master:2H2G Node:2H1G
协议 | 端口 | 源 | 描述 | |
---|---|---|---|---|
TCP | 6443 | K3s agent 节点 | Kubernetes API | |
UDP | 8472 | K3s server 和 agent 节点 | R 仅对 Flannel VXLAN 需要 | |
TCP | 10250 | K3s server 和 agent 节点 | kubelet |
*我这边是自己的测试环境,所以就直接把防火墙关了,生产环境请放行上述端口。
systemctl stop firewalld
[root@la ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
hostnamectl set-hostname la.svr.lian.st
hostnamectl set-hostname oracle-jp-1
hostnamectl set-hostname oracle-jp-2
curl -sfL https://get.k3s.io | sh -
systemctl start k3s
systemctl status k3s
两台node分别执行下面的命令加入k3s集群。
k3s_url="https://master-ip:6443/"
k3s_token="K10235c114df226beae70871ab80e94ff02377136e227e075269a12e5a7120a05d6::server:02ba7f8e86c540608ec70f816706c27f"
curl -sfL https://get.k3s.io | K3S_URL=${k3s_url} K3S_TOKEN=${k3s_token} sh -
登陆master执行如下命令查看群集
[root@la ~]# kubectl config get-clusters
NAME
default
[root@la ~]# kubectl cluster-info
Kubernetes master is running at https://127.0.0.1:6443
CoreDNS is running at https://127.0.0.1:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://127.0.0.1:6443/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
[root@la ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
la.svr.lian.st Ready master 23h v1.19.3+k3s3
oracle-jp-1 Ready <none> 23h v1.19.3+k3s3
oracle-jp-2 Ready <none> 23h v1.19.3+k3s3
[root@la ~]# kubectl get namespaces
NAME STATUS AGE
default Active 23h
kube-system Active 23h
kube-public Active 23h
kube-node-lease Active 23h
[root@la ~]# kubectl get endpoints -n kube-system
NAME ENDPOINTS AGE
kube-dns 10.42.0.5:53,10.42.0.5:53,10.42.0.5:9153 23h
metrics-server 10.42.0.3:443 23h
traefik 10.42.0.6:443,10.42.0.6:80 23h
traefik-prometheus 10.42.0.6:9100 23h
rancher.io-local-path <none> 23h
[root@la ~]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-66c464876b-plmpz 1/1 Running 0 23h
local-path-provisioner-7ff9579c6-b2l6h 1/1 Running 5 23h
metrics-server-7b4f8b595-pntrb 1/1 Running 5 23h
helm-install-traefik-mnnc5 0/1 Completed 5 23h
svclb-traefik-l5kkc 2/2 Running 0 23h
traefik-5dd496474-drglt 1/1 Running 0 23h
svclb-traefik-xb5p8 2/2 Running 0 23h
svclb-traefik-tm4mf 2/2 Running 0 23h
[root@la ~]# crictl ps
CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID
a0d277d944f0f aa764f7db3051 24 hours ago Running traefik 0 d901b8d037c60
6a8c2e042b759 897ce3c5fc8ff 24 hours ago Running lb-port-443 0 060080b214c82
fd4ec1592776c 897ce3c5fc8ff 24 hours ago Running lb-port-80 0 060080b214c82
874ef012c371d 9dd718864ce61 24 hours ago Running metrics-server 5 6ebb911f70806
a07c00dbf117a e422121c9c5f9 24 hours ago Running local-path-provisioner 5 da755a84fb168
88090d40c4757 4e797b3234604 24 hours ago Running coredns 0 e4f2d5f67b23d