1 Star 0 Fork 13

刘春阳/k8s 高可用集群 ansible 剧本部署

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
k8s_cri_deploy.yaml 2.91 KB
一键复制 编辑 原始数据 按行查看 历史
山河已无恙 提交于 2023-02-05 23:52 . init
# ansible 2.9.27
# # config file = /root/ansible/ansible.cfg
# # configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
# # ansible python module location = /usr/lib/python2.7/site-packages/ansible
# # executable location = /usr/bin/ansible
# # python version = 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
#
# #@File : k8s_cri_deploy.yaml
# #@Time : 2023/01/19 22:32:47
# #@Author : Li Ruilong
# #@Version : 1.0
# #@Desc : 安装 CRI , 这里我们选择 Docker,需要安装 cri-docker
# #@Contact : liruilonger@gmail.com
---
# 转发 IPv4 并让 iptables 看到桥接流量
- name: Forwarding IPv4 and letting iptables see bridged traffic 1
copy:
src: ./file/modules-load.d/k8s.conf
dest: /etc/modules-load.d/k8s.conf
- name: Forwarding IPv4 and letting iptables see bridged traffic 2
shell: modprobe overlay && modprobe br_netfilter
# 永久设置所需的 sysctl 参数
- name: sysctl params required by setup, params persist across reboots
copy:
src: ./file/sysctl.d/k8s.conf
dest: /etc/sysctl.d/k8s.conf
# 刷新内核参数
- name: Apply sysctl params without reboot
shell: sysctl --system
# 安装 docker
- name: install docker-ce docker-ce-cli containerd.io
yum:
name:
- docker-ce
- docker-ce-cli
- containerd.io
state: present
# 创建 dockers 数据目录
- name: create docker data dir
file:
path: /docker/data
state: directory
# 创建 docker 配置目录
- name: create docker data dir
file:
path: /etc/docker
state: directory
# 修改 dockers 配置
- name: modify docker config
copy:
src: ./file/daemon.json
dest: /etc/docker/daemon.json
# 复制 cri-docker rpm 安装包
- name: copy install cri-docker rpm
# https://github.com/Mirantis/cri-dockerd/releases/download/v0.3.0/cri-dockerd-0.3.0-3.el7.x86_64.rpm
copy:
src: ./install_package/cri-dockerd-0.3.0-3.el7.x86_64.rpm
dest: /tmp/cri-dockerd-0.3.0-3.el7.x86_64.rpm
# 安装 cri-docker
- name: install cri-docker
yum:
name: /tmp/cri-dockerd-0.3.0-3.el7.x86_64.rpm
state: present
# 修改 cri-docker service 文件,否则 沙箱会从谷歌的仓库拉去
- name: modify cri-dockerd service file
copy:
src: ./file/cri-docker.service
dest: /usr/lib/systemd/system/cri-docker.service
# 配置开机自启,启动 docker
- name: start docker, setting enable
service:
name: docker
state: restarted
enabled: yes
# 配置开机自启,启动 cri-docker
- name: start cri-docker, setting enable
service:
name: cri-docker
state: restarted
enabled: yes
# 配置开机自启,启动 cri-docker.socket
- name: start cri-docker,socket setting enable
service:
name: cri-docker.socket
enabled: yes
# 配置校验
- name: check init cri
include_tasks:
file: k8s_cri_deploy_check.yaml
tags: cri_check
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lcy993492649_admin/k8s_deploy_ansible.git
git@gitee.com:lcy993492649_admin/k8s_deploy_ansible.git
lcy993492649_admin
k8s_deploy_ansible
k8s 高可用集群 ansible 剧本部署
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385