breeze配置K8S deploy机的shell自动化脚本

由于按照睿云智和的breeze图形化部署K8S仍然需要准备配置deploy机,所以细化了一下脚本直接完成deploy机器的自动化配置:

使用cobbler或者kickstart安装一台纯净的minimal的deploy机器步骤省略,直接贴deploy机器的配置;

个人懒得写注释了,这是一个母版雏形,可以直接使用,但是不含任何变量,东西都是写死的,所以可以适当扩展增加变量使脚本变得更灵活,例如把版本或者ansible配置都变成传参,在此就不再深入些了,亲测有效:

#!/bin/sh

#Firewall & selinux preparation
#Pdf provides
setenforce 0
sed -ri '/SELINUX=/c\SELINUX=disabled' /etc/selinux/config
firewall-cmd --set-default-zone=trusted
firewall-cmd --complete-reload


#Install docker-compose
if [ -e /usr/local/bin/docker-compose ];then
    echo "docker-compose exists~"
else
curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose
fi

#Install docker
yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine -y

yum install -y yum-utils device-mapper-persistent-data lvm2 && yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo && yum install docker-ce docker-ce-cli containerd.io -y

systemctl enable docker && systemctl start docker

#Config Daocloud accelarate
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io && systemctl restart docker

#Install ansible
ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
yum -y install epel-release && yum -y install ansible

cat >> /etc/ansible/hosts <<-EOF
[k8s]           #change into the name you wanna change
192.168.25.10 ansible_ssh_user="root" ansible_ssh_pass="root" ansible_ssh_port=22
192.168.25.11 ansible_ssh_user="root" ansible_ssh_pass="root" ansible_ssh_port=22 
192.168.25.12 ansible_ssh_user="root" ansible_ssh_pass="root" ansible_ssh_port=22 
192.168.25.20 ansible_ssh_user="root" ansible_ssh_pass="root" ansible_ssh_port=22
EOF

sed -ri '/^#host/c\host_key_checking = False' /etc/ansible/ansible.cfg

ansible k8s -m authorized_key -a "user=root key='{
  { lookup('file','/root/.ssh/id_rsa.pub') }}'"

#Download breeze and install
yum -y install wget && wget -nc https://github.com/wise2c-devops/breeze/archive/v1.13.4.tar.gz && tar -xf v1.13.4.tar.gz &&a
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值