二進位制部署K8s集群 二 docker部署

2021-10-22 01:20:26 字數 3801 閱讀 2741

etcd集群部署

#proxy

cd web_site

vim hostlist

====

====

====

====

====

=[docker2]

192.168.1.[40:42]

[docker3]

192.168.1.[39:42]

====

====

====

====

====

====

====

vim ansible.cfg # cat ansible.cfg | grep -v "^$" | grep -v "#"

====

====

====

====

====

=[defaults]

inventory = hostlist

host_key_checking = false

[inventory]

[privilege_escalation]

[paramiko_connection]

[ssh_connection]

[persistent_connection]

[accelerate]

[selinux]

[colors]

[diff]

====

====

====

====

====

====

====

vim docker_install.yaml #修安裝劇本 應該寫角色更好的

====

====

====

====

====

====

=---

- hosts: docker3

tasks:

- name: 建立目錄

file: path=/root/docker_install state=directory

- name: 解壓到目標目錄

unarchive: src=docker-19.03.9.tgz dest=/root/docker_install copy=yes

- name: 移動docker程式到/usr/bin下

shell: "mv /root/docker_install/docker/* /usr/bin/"

- name: unit檔案管理docker

copy: src=docker.service dest=/usr/lib/systemd/system/docker.service

- name: docker配置檔案

copy: src=daemon.json dest=/etc/

- name: 服務過載

shell: systemctl daemon-reload

- name: 開機自啟docker

service: name=docker state=restarted enabled=yes

====

====

====

====

====

====

====

====

====

=wget

#寫unit docker檔案

vim docker.service

====

====

====

====

====

====

==[unit]

documentation=

after=network-online.target firewalld.service

wants=network-online.target

[service]

type=notify

execstart=/usr/bin/dockerd

execreload=/bin/kill -s hup $mainpid

limitnofile=infinity

limitnproc=infinity

limitcore=infinity

timeoutstartsec=0

delegate=yes

killmode=process

restart=on-failure

startlimitburst=3

startlimitinterval=60s

[install]

wantedby=multi-user.target

====

====

====

====

====

====

====

====

=#寫倉庫配置檔案

vim daemon.json

====

====

====

====

====

====

====

====

====

====

====

====

====

====

=#執行劇本

ansible-playbook docker_install.yaml

#驗證ansible docker3 -m shell -a "docker version"

192.168.1.40 | changed | rc=0 >>

client: docker engine - community

version: 19.03.9

api version: 1.40

go version: go1.13.10

git commit: 9d988398e7

built: fri may 15 00:22:47 2020

os/arch: linux/amd64

experimental: false

server: docker engine - community

engine:

version: 19.03.9

api version: 1.40 (minimum version 1.12)

go version: go1.13.10

git commit: 9d988398e7

built: fri may 15 00:28:17 2020

os/arch: linux/amd64

experimental: false

containerd:

version: v1.2.13

gitcommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429

runc:

version: 1.0.0-rc10

gitcommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd

docker-init:

version: 0.18.0

gitcommit: fec3683

....

..#成功

K8S集群二進位制搭建2 docker搭建

本次採用二進位制安裝,若使用yum安裝也是同樣效果 root k8s master wget root k8s master opt tar zxvf docker 19.03.9.tgz root k8s master docker mv opt docker usr bin 使用systemd管...

解決 k8s 二進位制安裝etcd 啟動失敗

關閉防火牆 所有節點 systemctl stop firewalld systemctl disable firewalld 重置iptables 所有節點 iptables f iptables x iptables f t nat iptables x t nat iptables p for...

二進位制安裝K8S(四) 部署flannel網路

執行指令碼 sh root scripts flannel.sh 檢視新增的子網 如果返回error 100 key not found coreos.com 11 則代表沒有設定網路 二 node節點編寫flannel指令碼 三颱node節點指令碼內容相同 vim root scripts fla...