k3s 部署應用

部署k3s

  • 環境
名稱 ip地址 cpu 內存
k3s-master 10.65.91.53 4c 8G
k3s-node 10.65.91.52 4c 8G

master 與 node 節點

# 改國內yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

#安裝 docker-ce
yum remove -y docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
yum install -y yum-utils
yum-config-manager --add-repo  https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
# 解決內核檢查問題 重啓生效
grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)"
systemctl enable docker
systemctl start docker
# 修改 docker 源
cat << EOF > /etc/docker/daemon.json
{
"registry-mirrors": [
     "https://1nj0zren.mirror.aliyuncs.com",
     "https://docker.mirrors.ustc.edu.cn",
     "http://f1361db2.m.daocloud.io",
     "https://registry.docker-cn.com"
    ],
"insecure-registries": ["10.65.91.53:5000"]
}
EOF
systemctl daemon-reload
systemctl restart docker
# 安裝 docker 結束
# 關 firewalld 防火牆
systemctl stop firewalld
systemctl disable firewalld

k3s-master 安裝

# 安裝 k3s
curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -s - --docker

#查看node節點
# kubectl get node
NAME                        STATUS   ROLES                  AGE   VERSION
k3s-master                  Ready    control-plane,master   29h   v1.23.6+k3s1

#查看pod
# kubectl get pod  -n kube-system
NAME                                      READY   STATUS      RESTARTS        AGE
helm-install-traefik-crd-bfnrf            0/1     Completed   0               29h
helm-install-traefik-jhvzm                0/1     Completed   0               29h
coredns-d76bd69b-hwvfh                    1/1     Running     3 (5h47m ago)   29h
local-path-provisioner-6c79684f77-6xhjj   1/1     Running     3 (5h47m ago)   29h
svclb-traefik-n985w                       2/2     Running     6 (5h47m ago)   29h
traefik-df4ff85d6-c7jb8                   1/1     Running     4 (5h47m ago)   29h
metrics-server-7cd5fcb6b7-k8q2h           1/1     Running     3 (5h47m ago)   29h
svclb-traefik-tzndk                       2/2     Running     2 (6h37m ago)   15m

# 查看 token , 用於客戶端安裝
# cat /var/lib/rancher/k3s/server/node-token
K107d1126b89536fd7390971ed6a2343c88adb6a3fe46acce94da2842619dd0f1e3::server:7380c0e2743694653757a4ee0cc3badc

k3s-node 安裝

#拷貝k3s 包
scp -qpr 10.65.91.53:/usr/local/bin/k3s /usr/local/bin/
#安裝node節點
wget https://raw.githubusercontent.com/rancher/k3s/master/install.sh -O install.sh
export K3S_URL=https://10.65.91.53:6443
export K3S_TOKEN=K107d1126b89536fd7390971ed6a2343c88adb6a3fe46acce94da2842619dd0f1e3::server:7380c0e2743694653757a4ee0cc3badc
export INSTALL_K3S_SKIP_DOWNLOAD=true && sh install.sh agent --with-node-id --docker

k3s server

# kubectl get node
NAME                        STATUS   ROLES                  AGE   VERSION
k3s-node                    Ready    <none>                 21m   v1.23.6+k3s1
k3s-master                  Ready    control-plane,master   29h   v1.23.6+k3s1
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章