使用ansible一键安装 k8s

提兵百万西湖上,立马吴山第一峰!这篇文章主要讲述使用ansible一键安装 k8s相关的知识,希望能为你提供帮助。
使用ansible一键安装 k8s

环境需求:
centos7系统
ansible已安装
  • 项目地址:https://github.com/chang-123-cmd/Install-k8s-with-ansible
  • ?? project describe function ??
  • ?? Instructions ??
项目功能1.准备工作
* ntp* chrony* disable selinux* set firewalld* set swap* set kernel
2.安装yum源
* install httpd* unzip rpm package
3.安装docker
* set config* install docker
4.安装docker镜像仓库
* unzip package* run registry service
5.安装k8s
* Install kubeadm/kubelet/kubectl* master init* add node* appply ingress* appply dashboard
6.安装ceph
* install ceph
安装步骤1.导入所需要的包
【使用ansible一键安装 k8s】Baidu cloud address:
leave a message in issue
把所有下载的包放入如下目录: \\ {{ projectname }}/artifacts/
containerd-selinux-v2.119.2.tar \\
docker-ce-stable-v20.10.7.tar \\
kubernetes-v1.21.2.tar \\
registry-1.21.2.tar.gz
百度网盘:链接:https://pan.baidu.com/s/1XF-W3R-E6pWK2st-k1r3Qg提取码:jsth
2.编写 hosts.ini
lombok.config
[all:vars]
ansible_connection=ssh
ansible_user=zhangsan
ansible_password=9876557
# same as `ansible_ssh_pass`
ansible_become_pass=9876557
[kubernetes:children]
kubernetes_master
kubernetes_master_slaves
kubernetes_slaves
[kubernetes_master_all:children]
kubernetes_master
kubernetes_master_slaves
[kubernetes_master]
172.16.< strong> .< /strong> *
[kubernetes_master_slaves]
[kubernetes_slaves]
172.16.< strong> .< /strong> *
172.16.< strong> .< /strong> *
[docker:children]
kubernetes
registry
[registry]
172.16.< strong> .< /strong> *
[repo]
172.16.< strong> .< /strong>

3.编写 shared.yml

#---------------------------------
## Docker imagerepo
##---------------------------------
docker_repo_ip: "172.20.< strong> .< /strong> *"
docker_repo_address: "*< strong> k8s-registry-address< /strong> *:< strong> port< /strong> "
docker_repo_domain_name: "*< strong> k8s-registry-address< /strong> *"
master_ip: "172.20.< strong> .< /strong> *"
kubernetes_api: "apiserver.***< strong> .local"
#---------------------------------
###packagerepo
###---------------------------------
#
repo: "172.20.< /strong> .***

4.检查各个role目录下的参数配置是否正确 defult/main.yml file

check eack roles defult/main.yml file ,set paramete

5. 安装
{{projectname}} is project name ,is k8s-ansible/

cd {{projectname}}
执行如下指令:
ansible-playbook ./playbooks/01_prepare.yml
ansible-playbook ./playbooks/02_yum_repo.yml
ansible-playbook ./playbooks/03_docker_install.yml
ansible-playbook ./playbooks/04_install_docker_register.yml
ansible-playbook ./playbooks/05_install_k8s.yml
ansible-playbook ./playbooks/06_install_ceph.ym

f you want to test whether the configuration file is correct first, as in the above steps, add -C after the instruction, for example:

ansible-playbook ./playbooks/01_prepare.yml -

6. 问题:
1.When the running is interrupted, you want to repeat it.2.ceph安装用简单的块设备就可以识别版本列表kubeadm v1.21.2\\ cni:v3.20.2\\ pod2daemon-flexvol:v3.20.2\\ node:v3.20.2\\ kube-controllers:v3.20.2\\ ingress-nginx-controller:0.30.0\\ metrics-scraper:v1.0.6\\ dashboard:v2.2.0\\ metrics-server:0.4.4\\\\ coredns:1.8.0\\ etcd:3.4.13-0\\ pause:3.4.1\\ kube-proxy:v1.21.2\\ kube-scheduler:v1.21.2\\ kube-controller-manager:v1.21.2\\ kube-apiserver:v1.21.2\\\\\\ ceph:v1.6.7\\ cephcsi:v3.3.1\\ csi-node-driver-registrar:v2.2.0\\ csi-resizer:v1.2.0\\ csi-provisioner:v2.2.2\\ csi-snapshotter:v4.1.1\\ csi-attacher:v3.2.1\\ ceph:v15.2.13

    推荐阅读