赞
踩
root@master1:~# tree k8s_kubeadm_install/
k8s_kubeadm_install/
├── README.md
├── files
│ ├── ansible
│ │ ├── ansible.cfg
│ │ └── hosts
│ ├── calico
│ │ ├── custom-resources_v3.26.4.yaml
│ │ ├── custom-resources_v3.27.0.yaml
│ │ ├── tigera-operator_v3.26.4.yaml
│ │ └── tigera-operator_v3.27.0.yaml
│ ├── ingress
│ │ ├── deploy_v1.9.4.yaml
│ │ └── deploy_v1.9.5.yaml
│ ├── k8s_pkgs
│ │ ├── kubernetes-apt-keyring.gpg
│ │ └── source.list
│ ├── metrics
│ │ └── components.yaml
│ ├── test-ingress.yaml
│ └── vars.yaml
└── playbooks
├── dashboard_install.yaml
├── harbor_install.yaml
├── main.yaml
├── metrics_server_install.yaml
└── prometheus_install.yaml
root@master1:~/k8s_kubeadm_install# ping pkgs.k8s.io
PING redirect.k8s.io (34.107.204.206) 56(84) bytes of data.
64 bytes from 206.204.107.34.bc.googleusercontent.com (34.107.204.206): icmp_seq=1 ttl=128 time=159 ms
64 bytes from 206.204.107.34.bc.googleusercontent.com (34.107.204.206): icmp_seq=2 ttl=128 time=159 ms
root@master1:~/k8s_kubeadm_install# ping registry.aliyuncs.com
PING registry.aliyuncs.com (120.55.105.209) 56(84) bytes of data.
64 bytes from 120.55.105.209 (120.55.105.209): icmp_seq=1 ttl=128 time=30.8 ms
64 bytes from 120.55.105.209 (120.55.105.209): icmp_seq=2 ttl=128 time=30.2 ms
https://help.mirrors.cernet.edu.cn/ubuntu/
apt update
# 在操作节点上安装
apt install ansible
mkdir /etc/ansible
# 复制整个k8s_kubeadm_install到管理机
sudo su
cd k8s_kubeadm_install
# 修改hosts节点名,分组不能修改(请注意: 主机名,ansible节点,/etc/hosts要保持一致)
vim files/ansible/hosts
cp -r files/ansible /etc/
sudo hostnamectl set-hostname master1
sudo hostnamectl set-hostname node1
sudo hostnamectl set-hostname node2
...
x.x.x.x master1
y.y.y.y node1
z.z.z.z node2
...
ssh root@master1
ssh root@node1
ssh root@node2
...
ansible k8s -m copy -a "src=/etc/hosts dest=/etc/hosts"
ansible k8s -m copy -a "src=/etc/apt/sources.list dest=/etc/apt/sources.list"
ansible k8s -m apt -a "update_cache=yes"
# calico官网地址,查看对应版本
https://docs.tigera.io/calico/latest/about
https://docs.tigera.io/calico/latest/getting-started/kubernetes/requirements#kubernetes-requirements
# 快速部署
https://docs.tigera.io/calico/latest/getting-started/kubernetes/quickstart
# 需要提前下载对应版本tigera-operator.yaml到files目录,其他操作不用做
https://raw.githubusercontent.com/projectcalico/calico/v3.26.4/manifests/tigera-operator.yaml
# 需要提前下载对应版本custom-resources.yaml到files目录,其他操作不用做
https://raw.githubusercontent.com/projectcalico/calico/v3.26.4/manifests/custom-resources.yaml
# 将下载的文件放至files/calico,并按"文件名_version"格式命名
# 查看支持版本
https://github.com/kubernetes/ingress-nginx/blob/main/README.md#readme
version=v1.9.4
# 快速部署
https://kubernetes.github.io/ingress-nginx/deploy/#quick-start
# 单独下载deploy.yaml文件
wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-${version}/deploy/static/provider/baremetal/deploy.yaml
# deploy.yaml源码文件包下载
https://github.com/kubernetes/ingress-nginx/releases
wget https://github.com/kubernetes/ingress-nginx/archive/refs/tags/controller-${version}.tar.gz
tar -xf controller-${version}.tar.gz
vim ingress-nginx-controller-v1.9.4/deploy/static/provider/baremetal/deploy.yaml
# 需要提前下载对应版本deploy.yaml到files目录,手动修改镜像名称,有三处(v1.9.4,其余版本在这附近)
445 image: registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller:v1.9.4
542 image: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen:v20231011-8b53cabe0
591 image: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen:v20231011-8b53cabe0
把 kind: Deployment 改为 kind: DaemonSet 模式,这样每台node上都有
ingress-nginx-controller pod 副本。
使用hostNetwork: true,默认 ingress-nginx 随机提供 nodeport 端口,
开启 hostNetwork 启用80、443端口。
如果不关心 ingressClass 或者很多没有 ingressClass 配置的 ingress 对象,
添加参数 --watch-ingress-without-class=true
# 位置为v1.9.4,其余版本行号在这附近
391 kind: DaemonSet
409 #strategy:
410 #rollingUpdate:
411 #maxUnavailable: 1
412 #type: RollingUpdate
422 hostNetwork: true
433 - --watch-ingress-without-class=true
# 将下载的文件放至files/ingress,并按"文件名_version"格式命名
root@master1:/etc/apt/sources.list.d# apt-cache madison kubeadm
kubeadm | 1.29.0-1.1 | https://pkgs.k8s.io/core:/stable:/v1.29/deb Packages
kubeadm | 1.28.5-1.1 | https://pkgs.k8s.io/core:/stable:/v1.28/deb Packages
kubeadm | 1.28.4-1.1 | https://pkgs.k8s.io/core:/stable:/v1.28/deb Packages
kubeadm | 1.28.3-1.1 | https://pkgs.k8s.io/core:/stable:/v1.28/deb Packages
kubeadm | 1.28.2-1.1 | https://pkgs.k8s.io/core:/stable:/v1.28/deb Packages
kubeadm | 1.28.1-1.1 | https://pkgs.k8s.io/core:/stable:/v1.28/deb Packages
kubeadm | 1.28.0-1.1 | https://pkgs.k8s.io/core:/stable:/v1.28/deb Packages
kubeadm | 1.27.9-1.1 | https://pkgs.k8s.io/core:/stable:/v1.27/deb Packages
kubeadm | 1.27.8-1.1 | https://pkgs.k8s.io/core:/stable:/v1.27/deb Packages
kubeadm | 1.27.7-1.1 | https://pkgs.k8s.io/core:/stable:/v1.27/deb Packages
kubeadm | 1.27.6-1.1 | https://pkgs.k8s.io/core:/stable:/v1.27/deb Packages
kubeadm | 1.27.5-1.1 | https://pkgs.k8s.io/core:/stable:/v1.27/deb Packages
kubeadm | 1.27.4-1.1 | https://pkgs.k8s.io/core:/stable:/v1.27/deb Packages
kubeadm | 1.27.3-1.1 | https://pkgs.k8s.io/core:/stable:/v1.27/deb Packages
kubeadm | 1.27.2-1.1 | https://pkgs.k8s.io/core:/stable:/v1.27/deb Packages
kubeadm | 1.27.1-1.1 | https://pkgs.k8s.io/core:/stable:/v1.27/deb Packages
kubeadm | 1.27.0-2.1 | https://pkgs.k8s.io/core:/stable:/v1.27/deb Packages
kubeadm | 1.26.12-1.1 | https://pkgs.k8s.io/core:/stable:/v1.26/deb Packages
kubeadm | 1.26.11-1.1 | https://pkgs.k8s.io/core:/stable:/v1.26/deb Packages
kubeadm | 1.26.10-1.1 | https://pkgs.k8s.io/core:/stable:/v1.26/deb Packages
kubeadm | 1.26.9-1.1 | https://pkgs.k8s.io/core:/stable:/v1.26/deb Packages
kubeadm | 1.26.8-1.1 | https://pkgs.k8s.io/core:/stable:/v1.26/deb Packages
kubeadm | 1.26.7-1.1 | https://pkgs.k8s.io/core:/stable:/v1.26/deb Packages
kubeadm | 1.26.6-1.1 | https://pkgs.k8s.io/core:/stable:/v1.26/deb Packages
kubeadm | 1.26.5-1.1 | https://pkgs.k8s.io/core:/stable:/v1.26/deb Packages
kubeadm | 1.26.4-1.1 | https://pkgs.k8s.io/core:/stable:/v1.26/deb Packages
kubeadm | 1.26.3-1.1 | https://pkgs.k8s.io/core:/stable:/v1.26/deb Packages
kubeadm | 1.26.2-1.1 | https://pkgs.k8s.io/core:/stable:/v1.26/deb Packages
kubeadm | 1.26.1-1.1 | https://pkgs.k8s.io/core:/stable:/v1.26/deb Packages
kubeadm | 1.26.0-2.1 | https://pkgs.k8s.io/core:/stable:/v1.26/deb Packages
kubeadm | 1.25.16-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.15-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.14-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.13-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.12-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.11-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.10-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.9-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.8-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.7-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.6-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.5-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.4-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.3-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.2-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.1-1.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
kubeadm | 1.25.0-2.1 | https://pkgs.k8s.io/core:/stable:/v1.25/deb Packages
必须确认vars.yaml变量是否修改control_plane_endpoint需要与hosts文件格式一致
# 默认只安装集群基础功能(安装过程分为三步,第一步会重启所有节点,重启后再次进入目录运行相同命令)
sudo su
cd k8s_kubeadm_install
ansible-playbook playbooks/main.yaml
# 选装其他插件,harbor需要修改ansible/hosts中分组和/etc/hosts解析(暂未实现)
ansible-playbook playbooks/main.yaml -t [dashboard | harbor | metrics | primetheus]
root@master1:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master1 Ready control-plane 18h v1.25.0
master2 Ready control-plane 18h v1.25.0
node1 Ready node 18h v1.25.0
node2 Ready node 18h v1.25.0
root@master1:~# kubectl get pod,svc,ing
NAME READY STATUS RESTARTS AGE
pod/nginx-statefulset-0 1/1 Running 0 18h
pod/nginx-statefulset-1 1/1 Running 0 18h
pod/nginx-statefulset-2 1/1 Running 0 18h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 18h
service/nginx-cp ClusterIP 10.101.68.111 <none> 80/TCP 18h
NAME CLASS HOSTS ADDRESS PORTS AGE
ingress.networking.k8s.io/app-nginx-ing nginx foo.bar.com 192.168.152.210,192.168.152.211 80 18h
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。