由于按照睿云智和的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 ];thenecho "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 -yyum 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 -ysystemctl 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 ansiblecat >> /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
EOFsed -ri '/^#host/c\host_key_checking = False' /etc/ansible/ansible.cfgansible 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 && cd breeze-1.13.4 && docker-compose up -d#Checking status after install
docker ps -a

最后上传部署后的日志:

setenforce: SELinux is disabled
Warning: ZONE_ALREADY_SET: trusted
success
success% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed
100   617    0   617    0     0    435      0 --:--:--  0:00:01 --:--:--   435
100 10.3M  100 10.3M    0     0   105k      0  0:01:40  0:01:40 --:--:--  108k
Loaded plugins: fastestmirror
No Match for argument: docker
No Match for argument: docker-client
No Match for argument: docker-client-latest
No Match for argument: docker-common
No Match for argument: docker-latest
No Match for argument: docker-latest-logrotate
No Match for argument: docker-logrotate
No Match for argument: docker-engine
No Packages marked for removal
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.tuna.tsinghua.edu.cn* epel: mirrors.huaweicloud.com* extras: mirrors.tuna.tsinghua.edu.cn* updates: mirrors.huaweicloud.com
Package yum-utils-1.1.31-50.el7.noarch already installed and latest version
Package device-mapper-persistent-data-0.7.3-3.el7.x86_64 already installed and latest version
Package 7:lvm2-2.02.180-10.el7_6.3.x86_64 already installed and latest version
Nothing to do
Loaded plugins: fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.tuna.tsinghua.edu.cn* epel: mirrors.huaweicloud.com* extras: mirrors.tuna.tsinghua.edu.cn* updates: mirrors.huaweicloud.com
Package 3:docker-ce-18.09.4-3.el7.x86_64 already installed and latest version
Package 1:docker-ce-cli-18.09.4-3.el7.x86_64 already installed and latest version
Package containerd.io-1.2.5-3.1.el7.x86_64 already installed and latest version
Nothing to do
docker version >= 1.12
{"registry-mirrors": ["http://f1361db2.m.daocloud.io"]}
Success.
You need to restart docker to take effect: sudo systemctl restart docker
Generating public/private rsa key pair.
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? n
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.tuna.tsinghua.edu.cn* epel: mirrors.huaweicloud.com* extras: mirrors.tuna.tsinghua.edu.cn* updates: mirrors.huaweicloud.com
Package epel-release-7-11.noarch already installed and latest version
Nothing to do
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.tuna.tsinghua.edu.cn* epel: mirrors.huaweicloud.com* extras: mirrors.tuna.tsinghua.edu.cn* updates: mirrors.huaweicloud.com
Package ansible-2.7.9-1.el7.noarch already installed and latest version
Nothing to do
192.168.25.20 | SUCCESS => {"changed": false, "comment": null, "exclusive": false, "follow": false, "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCuBxVR5S5usDFsahBsN8nsfgZprQSr+73kxoE6HNs9tqAYzFf9RdsF5J1WkOORWahFbq0gW6oAwlbfvtwwa/td+9SgFr0zeoZdilzvfNsYJN2GqmrY9yNkBHXlQmoj2kZkYSIR9hJpUqY2FGugQBUa7dJEO9+Go9BMJc1Pxtj7ijn7t7PpEn+EhCl2ZxY/xazqzZ+FEOP6z4P5+KB0+j80Ks2xaHGvlu/1S8jMyGFgbrKntjQbpREDweW8/CvssSBkJqpuif66Oaw75hqLVvlaWuwk6GNOc7l7tTGc06MxS9O8kFo47U+41YmNU00Grx2TiuKp/SNYDbY5b8G6AYyr root@deploy", "key_options": null, "keyfile": "/root/.ssh/authorized_keys", "manage_dir": true, "path": null, "state": "present", "unique": false, "user": "root", "validate_certs": true
}
192.168.25.10 | SUCCESS => {"changed": false, "comment": null, "exclusive": false, "follow": false, "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCuBxVR5S5usDFsahBsN8nsfgZprQSr+73kxoE6HNs9tqAYzFf9RdsF5J1WkOORWahFbq0gW6oAwlbfvtwwa/td+9SgFr0zeoZdilzvfNsYJN2GqmrY9yNkBHXlQmoj2kZkYSIR9hJpUqY2FGugQBUa7dJEO9+Go9BMJc1Pxtj7ijn7t7PpEn+EhCl2ZxY/xazqzZ+FEOP6z4P5+KB0+j80Ks2xaHGvlu/1S8jMyGFgbrKntjQbpREDweW8/CvssSBkJqpuif66Oaw75hqLVvlaWuwk6GNOc7l7tTGc06MxS9O8kFo47U+41YmNU00Grx2TiuKp/SNYDbY5b8G6AYyr root@deploy", "key_options": null, "keyfile": "/root/.ssh/authorized_keys", "manage_dir": true, "path": null, "state": "present", "unique": false, "user": "root", "validate_certs": true
}
192.168.25.12 | SUCCESS => {"changed": false, "comment": null, "exclusive": false, "follow": false, "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCuBxVR5S5usDFsahBsN8nsfgZprQSr+73kxoE6HNs9tqAYzFf9RdsF5J1WkOORWahFbq0gW6oAwlbfvtwwa/td+9SgFr0zeoZdilzvfNsYJN2GqmrY9yNkBHXlQmoj2kZkYSIR9hJpUqY2FGugQBUa7dJEO9+Go9BMJc1Pxtj7ijn7t7PpEn+EhCl2ZxY/xazqzZ+FEOP6z4P5+KB0+j80Ks2xaHGvlu/1S8jMyGFgbrKntjQbpREDweW8/CvssSBkJqpuif66Oaw75hqLVvlaWuwk6GNOc7l7tTGc06MxS9O8kFo47U+41YmNU00Grx2TiuKp/SNYDbY5b8G6AYyr root@deploy", "key_options": null, "keyfile": "/root/.ssh/authorized_keys", "manage_dir": true, "path": null, "state": "present", "unique": false, "user": "root", "validate_certs": true
}
192.168.25.11 | SUCCESS => {"changed": false, "comment": null, "exclusive": false, "follow": false, "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCuBxVR5S5usDFsahBsN8nsfgZprQSr+73kxoE6HNs9tqAYzFf9RdsF5J1WkOORWahFbq0gW6oAwlbfvtwwa/td+9SgFr0zeoZdilzvfNsYJN2GqmrY9yNkBHXlQmoj2kZkYSIR9hJpUqY2FGugQBUa7dJEO9+Go9BMJc1Pxtj7ijn7t7PpEn+EhCl2ZxY/xazqzZ+FEOP6z4P5+KB0+j80Ks2xaHGvlu/1S8jMyGFgbrKntjQbpREDweW8/CvssSBkJqpuif66Oaw75hqLVvlaWuwk6GNOc7l7tTGc06MxS9O8kFo47U+41YmNU00Grx2TiuKp/SNYDbY5b8G6AYyr root@deploy", "key_options": null, "keyfile": "/root/.ssh/authorized_keys", "manage_dir": true, "path": null, "state": "present", "unique": false, "user": "root", "validate_certs": true
}
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.tuna.tsinghua.edu.cn* epel: mirrors.huaweicloud.com* extras: mirrors.tuna.tsinghua.edu.cn* updates: mirrors.huaweicloud.com
Package wget-1.14-18.el7.x86_64 already installed and latest version
Nothing to do
File ‘v1.13.4.tar.gz’ already there; not retrieving.Creating network "breeze-1134_default" with the default driver
Creating volume "breeze-1134_playbook" with default driver
Pulling playbook (wise2c/playbook:v1.13.4)...
v1.13.4: Pulling from wise2c/playbook
697743189b6d: Pull complete
87e261fa033b: Pull complete
c77709860ed9: Pull complete
5f25f28b376f: Pull complete
144e5fd29828: Pull complete
362e7d141286: Pull complete
aa4d63553217: Pull complete
418cbcb23cc6: Pull complete
4783dd8b6f55: Pull complete
6e9fa4e95c6f: Pull complete
Digest: sha256:582bf48cfe007ef38270c4d09c60b0e0cbb1722c530c013d6942f2833d02800e
Status: Downloaded newer image for wise2c/playbook:v1.13.4
Pulling deploy (wise2c/pagoda:v1.1)...
v1.1: Pulling from wise2c/pagoda
a0e0ef996968: Pull complete
9b3014edd871: Pull complete
c5eded658159: Pull complete
c45a1c0c2455: Pull complete
46399003276c: Pull complete
ccac9c54f668: Pull complete
57fd101ecf1c: Pull complete
0f5ba6f34d40: Pull complete
b116f6ac6348: Pull complete
145e9a179549: Pull complete
2209be18dc9e: Pull complete
abc4297bec89: Pull complete
c0c294b79d8d: Pull complete
81b136d4261f: Pull complete
a949dbc55c9b: Pull complete
3936d68676c6: Pull complete
Digest: sha256:7d7c37b80182e3d97e7fb4de339430d5f3f52d64a375e1ced01d28e9bfa72314
Status: Downloaded newer image for wise2c/pagoda:v1.1
Pulling ui (wise2c/deploy-ui:v1.3)...
v1.3: Pulling from wise2c/deploy-ui
407ea412d82c: Pull complete
f1e1d8e69297: Pull complete
8dbb80bd9ddf: Pull complete
189c76f3a269: Pull complete
a772b0dbfb38: Pull complete
28da0ef10bfe: Pull complete
Digest: sha256:a199d1d25b135294ea884d25d4c04dfeb14a3a317a115a384a7b55746dee4045
Status: Downloaded newer image for wise2c/deploy-ui:v1.3
Pulling yum-repo (wise2c/yum-repo:v1.13.4)...
v1.13.4: Pulling from wise2c/yum-repo
6c40cc604d8e: Pull complete
fe449da6d669: Pull complete
bf1473f11cd8: Pull complete
06b03b3b4e39: Pull complete
70c1bbe94218: Pull complete
89aa2d966173: Pull complete
af02dc3cc578: Pull complete
0362d6b0e18e: Pull complete
Digest: sha256:9039a04697bed3e09b20320a481d5731192063ea18b4476689d7fb3fb301ad44
Status: Downloaded newer image for wise2c/yum-repo:v1.13.4
Creating deploy-playbook ... done
Creating deploy-yumrepo  ... done
Creating deploy-main     ... done
Creating deploy-ui       ... doneCONTAINER ID        IMAGE                     COMMAND                  CREATED                  STATUS                    PORTS                                        NAMES
4a7447fce196        wise2c/deploy-ui:v1.3     "/root/entrypoint.sh"    Less than a second ago   Up Less than a second                                                  deploy-ui
feed3a63a121        wise2c/pagoda:v1.1        "sh -c '/root/pagoda…"   1 second ago             Up Less than a second     0.0.0.0:88->80/tcp, 0.0.0.0:8088->8080/tcp   deploy-main
bbc97623a7d0        wise2c/yum-repo:v1.13.4   "nginx -g 'daemon of…"   4 seconds ago            Up 2 seconds              80/tcp, 0.0.0.0:2009->2009/tcp               deploy-yumrepo
248a4e66149b        wise2c/playbook:v1.13.4   "sh"                     4 seconds ago            Exited (0) 1 second ago                                                deploy-playbook

breeze配置K8S deploy机的shell自动化脚本相关推荐

  1. APPium+Python编写真机移动端自动化脚本

    前置条件 完成软件和环境的安装后就可以开始移动端自动化脚本的编写了. 连接设备 手机打开USB调试模式,连接手机.此时去命令窗口查看自己的设备是否已经连接. 让后打开Appium Server,进行配 ...

  2. Shell自动化脚本学习

    目录 – – (1.6) Linux Shell脚本的自动化编程之shell:命令排序 (1.7) Linux Shell脚本的自动化编程之shell:通配符 (2.1) Linux Shell脚本的 ...

  3. linux运维脚本编写,最强Linux自动化运维 Shell高级脚本编程实战 带习题+项目实战案例+全套配置脚本...

    最强Linux自动化运维 Shell高级脚本编程实战 带习题+项目实战案例+全套配置脚本 大家可以通过参考下面的课程学习目录,就会发现单单只从目录上来分析就知道这是一部非常系统的Shell自动化脚本运 ...

  4. linux集群自动化脚本和增量复制

    linux集群自动化脚本和增量复制 Linux集群shell自动化脚本和集群增量增量复制 xcall.sh代码: xcall.sh脚本解释: xsync.sh代码: xsync.sh脚本解释: 自定义 ...

  5. [shell实战脚本]脚本监控一些ip是否某个端口开放,测试是否能连通

    作者简介:电子科技大学毕业,位列国家"双一流"."985工程"."211工程",参加上市公司达内时代科技集团有限公司Linux云计算培训,参 ...

  6. 如何将功能测试用例转为自动化脚本?

    如何设计自动化测试用例或脚本? 自动化始终遵循手动测试.通常,将在AUT上执行一轮或多轮手动测试.这意味着手动测试用例已经存在并且已经执行了至少一次. 例如,假设以下是您的手动测试用例.它只是登录到G ...

  7. linux 运维高级脚本生成器,Linux运维系列,Shell高级脚本自动化编程实战

    课程文件目录: Linux自动化运维系列 Shell高级脚本自动化编程实战 [6.1G] ┣━━01.Shell基础概述 [315.1M] ┃ ┣━━1-1 Shell脚本体系概述.mp4 [154. ...

  8. SHELL自动化运维

    第1章 shell脚本 1.1 shell 简介 shell 的定义: 1. 在计算机科学中,Shell就是一个命令解释器. 2. shell是位于操作系统和应用程序之间,是他们二者最主要的接口,sh ...

  9. 二进制搭建kubernetes多master集群【三、配置k8s master及高可用】

    前面两篇文章已经配置好了etcd和flannel的网络,现在开始配置k8s master集群. etcd集群配置参考:二进制搭建kubernetes多master集群[一.使用TLS证书搭建etcd集 ...

最新文章

  1. ryu和mysql实现控制_openflow的初步认识及RYU控制器实践
  2. U盘安装openSuse
  3. 【物联网】 ESP8266 Ubuntu开发环境的搭建
  4. 数据结构(单链表的相关操作)
  5. 【MFC系列-第9天】MFC消息映射机制的原理
  6. 华为手机云闪付付款码如何截图_云闪付乘车码,它带着优惠又来了
  7. linux 查看防火墙对应的进程,Linux系统防火墙进程查看的实用方法
  8. 邹城的关于机器人教育_【喜报】我校机器人队问鼎全国大学生机器人大赛冠军!...
  9. ThreadPoolExecutor运转机制详解
  10. 欧拉函数、欧拉定理、费马小定理(附例题)
  11. 数据库系统工程师怎么备考?
  12. 基于UDP的网络对战五子棋
  13. 猫眼电影排行榜前100爬取案例学习笔记
  14. 仿微信语音输入页面(讯飞语音)
  15. linux afs3服务,AFS配置3
  16. Python包镜像网站
  17. Challenge Growth —— 从这里开始
  18. 摄像头poe供电原理_带你简单了解一下什么是POE供电
  19. 卡西欧计算机的闹铃怎么取消,卡西欧g-shock怎么关闹钟
  20. 因为删除 c:\windows\Installer目录下的文件, SQL Server 2014 SP2 打补丁失败

热门文章

  1. win10计算器rsh_Win10系统有哪些计算器快捷键?快捷键的介绍
  2. webdriver模仿ie_使IE8模仿IE7
  3. ViewPager2的使用
  4. 「接口汇总」APISpace 常用的免费API 整理
  5. 电脑系统win8计算机在哪里设置开机密码,w8系统怎么设置开机密码 w8系统操作须知【图文】...
  6. MySQL拾遗之distinct用法
  7. 第三十二章 三更雪压飞狐城(一之全)
  8. Spring(六):AOP
  9. 儿知错父之过下一句_谚语父之过的上一句是什么,“子不孝父之过”的下半句是什么?...
  10. 敏感词检测库ToolGood.Words中IllegalWordsSearch类使用简介