commit 53b3f4f1392c8f44a11040bafc64bf16d40bc9d1 Author: Alan Peng Date: Mon May 28 12:41:02 2018 -0400 Created by Huaxiang & Ann & Alan diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cc135f3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +*.retry +*.tar +*.tar.bz2 +*.tgz +*.pyc + +# ===== mian ===== +hosts +hosts.yml +all.yml +admin.conf +controller.yml +registry.yml +registry-playbook/file/source/ +cluster-* +!cluster-template diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..24f1a11 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +sudo: required + +services: +- docker + +before_install: +- sudo apt-get -qq update +- sudo apt-get install -y bzip2 +- docker pull ymian/kube-version:1.10 + +script: +- bash init.sh +- docker build -t wise2c/playbook:$TRAVIS_BRANCH . + +deploy: + provider: script + script: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD && docker push wise2c/playbook:$TRAVIS_BRANCH + on: + all_branches: true + condition: "$TRAVIS_BRANCH =~ ^v[0-9]+\\.[0-9]+(\\.[0-9]+)?(-\\S*)?$" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..47f5843 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM busybox:latest + +WORKDIR /workspace + +COPY callback_plugins /workspace/callback_plugins +COPY docker-playbook /workspace/docker-playbook +COPY etcd-playbook /workspace/etcd-playbook +COPY kubernetes-playbook /workspace/kubernetes-playbook +COPY registry-playbook /workspace/registry-playbook +COPY components_order.conf /workspace \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5eef15b --- /dev/null +++ b/README.md @@ -0,0 +1,190 @@ +# Deploy Kubernetes Cluster with Web UI +[![Build Status](https://travis-ci.org/wise2c-devops/playbook.svg?branch=master)](https://travis-ci.org/wise2c-devops/playbook) + +Deploy Kubernetes Cluster with Web UI + +欢迎使用睿云智合提供的图形化Kubernetes部署工具 + +使用该工具,将抹平普通用户学习复杂的kubeadm部署技能学习曲线,体会到一键式部署Kubernetes集群的乐趣! + +适用操作系统为RHEL 7.4/7.5 或 CentOS 7.4/7.5 + +操作步骤如下: + +1. 软件的使用非常简单,只需要下载某个版本的docker-compose.yml文件即可。确保您的Linux主机已经安装好了docker以及docker-compose,具体步骤参考以下内容。 + +(1)对部署机取消SELINUX设定及放开防火墙 + +``` +setenforce 0 +sed --follow-symlinks -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config +firewall-cmd --set-default-zone=trusted +firewall-cmd --complete-reload +``` + +(2)安装docker-compose命令 + +``` +sudo 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 +``` + +(3) 安装docker-io 1.13.1 + +``` +yum install docker +``` + +(4) 下载用于部署某个Kubernetes版本的docker-compose文件并使部署程序运行起来: + +[![asciicast](https://asciinema.org/a/vFYiMG3ptzdYPkS68rcuj4AKK.png)](https://asciinema.org/a/vFYiMG3ptzdYPkS68rcuj4AKK) + +例如: + +``` +curl -L https://raw.githubusercontent.com/wise2c-devops/playbook/v1.10.3/docker-compose.yml -o docker-compose.yml +``` + +``` +docker-compose up -d +``` + +如果一切正常,部署机的88端口将能够被正常访问。 + +2. 在部署机上做好对集群内其它所有服务器的ssh免密登录,命令为: + +   (1) 生成秘钥 ssh-keygen -t rsa + + (2) 针对目标服务器做ssh免密登录 + + ssh-copy-id 192.168.9.11 + + ssh-copy-id 192.168.9.12 + + ssh-copy-id 192.168.9.13 + + ... + +3. 打开浏览器,访问部署程序的图形界面,添加主机列表、添加服务角色并将加入的主机进行角色分配,然后开始部署: + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-001.png) + +点击 + 号添加一个集群: + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-002.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-003.png) + +点击“添加主机”,输入主机名、主机IP、描述信息(主机用途),点击确定。 + +重复该步骤直至将集群所需的全部节点服务器加入: + +(k8s master服务器、k8s minion node服务器、registry服务器等等): + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-004.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-005.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-006.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-007.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-008.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-009.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-010.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-011.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-012.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-013.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-014.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-015.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-016.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-017.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-018.png) + +点击“添加组件”按钮,对每个组件进行设置和分配服务器: + +(Docker角色、etcd角色、registry角色、kubernetes角色) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-019.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-020.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-021.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-022.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-023.png) + +镜像仓库设置这里的registy entry point是指用户端访问镜像仓库的URL,一般可以直接写IP地址或写对应的域名: + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-024.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-025.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-026.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-027.png) + +kubernetes entry point是指高可用的一个设定值,如果生产环境有硬件或软件负载均衡指向这里的k8s master所有节点,那么就可以在这里填写负载均衡的统一入口地址。 + +相对于昂贵的F5专业硬件设备,我们也可以使用HAProxy和Keepalived的组合轻松完成这个设置,详情请参考此处: + +https://github.com/wise2c-devops/haproxy-k8s + +https://github.com/wise2c-devops/keepalived-k8s + +例如下图的 192.168.9.101:6444 就是k8s集群高可用的统一入口,k8s的minion node会使用这个地址访问API Server。 + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-028.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-029.png) + +点击“下一步”开始安装部署: + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-030.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-031.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-032.png) + +如果界面上所有角色图标全部变为绿色,则表示部署任务结束。可以登录任一k8s节点运行命令 kubectl get nodes 查看结果。 + +以上例子是3台etcd、3台k8s master、3台k8s minion node、1台镜像仓库的环境。实际可以增减规模。 + +Kubernetes Dashboard的访问入口我们采用了NodePort:30300的方式暴露端口,因此可以通过 https://node-ip:30300 来访问Dashboard页面。 + +新版本Dashboard引入了验证模式,可以通过以下命令获取admin-user的访问令牌: + +``` +kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}') +``` + +将返回的token字串粘贴至登录窗口即可实现登录。 + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-034.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-035.png) + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-036.png) + + +########################################################################################### + +补充说明: + +对于Kubernetes集群的HA架构解决方案,我们暂时不放出图形化解决方案,待我们将其从内部版本剥离出来后再贡献给社区: + +![Alt text](https://github.com/wise2c-devops/playbook/raw/master/manual/KubernetesDeployUI-033.png) diff --git a/callback_plugins/log_back.py b/callback_plugins/log_back.py new file mode 100644 index 0000000..7e77278 --- /dev/null +++ b/callback_plugins/log_back.py @@ -0,0 +1,128 @@ +# (C) 2012, Michael DeHaan, + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import time +import json +import httplib +from collections import MutableMapping + +from ansible.module_utils._text import to_bytes +from ansible.plugins.callback import CallbackBase + + +# NOTE: in Ansible 1.2 or later general logging is available without +# this plugin, just set ANSIBLE_LOG_PATH as an environment variable +# or log_path in the DEFAULTS section of your ansible configuration +# file. This callback is an example of per hosts logging for those +# that want it. + + +class CallbackModule(CallbackBase): + """ + logs playbook results, per host, in /var/log/ansible/hosts + """ + CALLBACK_VERSION = 2.0 + CALLBACK_TYPE = 'notification' + CALLBACK_NAME = 'log_plays' + CALLBACK_NEEDS_WHITELIST = True + + TIME_FORMAT = "%b %d %Y %H:%M:%S" + MSG_FORMAT = "%(now)s - %(category)s - %(data)s\n\n" + + def __init__(self): + super(CallbackModule, self).__init__() + + self.task = dict() + self.data = dict() + self.stage = "" + + def log(self, host, category, data): + state = "processing" + if isinstance(data, MutableMapping): + if "state" in data.keys(): + state = data["state"] + + if "changed" in data.keys(): + self.data["changed"] = data["changed"] + else: + self.data["changed"] = False + + if "msg" in data.keys(): + self.data["msg"] = data["msg"] + else: + self.data["msg"] = "" + + now = time.strftime(self.TIME_FORMAT, time.localtime()) + self.task["state"] = category + + h1 = httplib.HTTPConnection('127.0.0.1:8080') + h1.request( + "POST", + "/v1/notify", + json.dumps( + dict( + time=now, + data=self.data, + task=self.task, + host=host, + state=state, + stage=self.stage + ) + ) + ) + + def runner_on_failed(self, host, res, ignore_errors=False): + self.log(host, 'failed', res) + + def runner_on_ok(self, host, res): + self.log(host, 'ok', res) + + def runner_on_skipped(self, host, item=None): + self.log(host, 'skipped', '...') + + def runner_on_unreachable(self, host, res): + self.log(host, 'unreachable', res) + + def runner_on_async_failed(self, host, res, jid): + self.log(host, 'ASYNC_FAILED', res) + + def v2_playbook_on_start(self, playbook): + name, suffix = os.path.basename(os.path.dirname(playbook._basedir)).split('-') + self.stage = name + + def playbook_on_import_for_host(self, host, imported_file): + self.log(host, 'IMPORTED', imported_file) + + def playbook_on_not_import_for_host(self, host, missing_file): + self.log(host, 'NOTIMPORTED', missing_file) + + def playbook_on_task_start(self, name, is_conditional): + self.task['name'] = name + + def playbook_on_stats(self, stats): + state = "" + if len(stats.failures) > 0 or len(stats.dark) > 0: + state = "failed" + else: + state = "ok" + self.task['name'] = "ending" + self.log("all", state, dict(state=state)) \ No newline at end of file diff --git a/components_order.conf b/components_order.conf new file mode 100644 index 0000000..51dd392 --- /dev/null +++ b/components_order.conf @@ -0,0 +1,4 @@ +docker +registry +etcd +kubernetes diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d1d636d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,37 @@ +version: '2' +services: + deploy: + container_name: deploy-main + image: wise2c/pagoda:v0.4.1 + restart: always + entrypoint: sh + command: + - -c + - "/root/pagoda -logtostderr -v 4 -w /workspace" + ports: + - 88:80 + - 8088:8080 + volumes: + - /root/.ssh:/root/.ssh + - $PWD/deploy:/deploy + volumes_from: + - playbook + ui: + container_name: deploy-ui + image: wise2c/deploy-ui + restart: always + network_mode: "service:deploy" + playbook: + container_name: deploy-playbook + image: wise2c/playbook:v1.10.3 + volumes: + - playbook:/workspace + yum-repo: + container_name: deploy-yumrepo + image: wise2c/yum-repo:v1.10.3 + ports: + - 2009:2009 + restart: always +volumes: + playbook: + external: false diff --git a/docker-playbook/1.13.1/ansible.cfg b/docker-playbook/1.13.1/ansible.cfg new file mode 100644 index 0000000..87f0107 --- /dev/null +++ b/docker-playbook/1.13.1/ansible.cfg @@ -0,0 +1,5 @@ +[defaults] +inventory=hosts +callback_plugins = ../../callback_plugins +callback_whitelist = log_back +retry_files_enabled = false \ No newline at end of file diff --git a/docker-playbook/1.13.1/file/README.md b/docker-playbook/1.13.1/file/README.md new file mode 100644 index 0000000..e69de29 diff --git a/docker-playbook/1.13.1/group_vars/README.md b/docker-playbook/1.13.1/group_vars/README.md new file mode 100644 index 0000000..e69de29 diff --git a/docker-playbook/1.13.1/install.ansible b/docker-playbook/1.13.1/install.ansible new file mode 100644 index 0000000..6e7dddc --- /dev/null +++ b/docker-playbook/1.13.1/install.ansible @@ -0,0 +1,129 @@ +- name: init host + hosts: hosts + user: root + any_errors_fatal: true + vars: + path: /var/tmp/wise2c/docker + tasks: + - name: set hostname + hostname: + name: '{{ hostname }}' + when: format_hostname + + - name: get seed ip + shell: + echo $SSH_CONNECTION | cut -d " " -f 1 + register: ip + + - name: add seed to /etc/hosts + blockinfile: + path: /etc/hosts + block: '{{ ip.stdout }} {{ wise2c_seed_host }}' + marker: '# {mark} WISE2C DEPLOY MANAGED BLOCK {{ wise2c_seed_host }}' + + - name: add to /etc/hosts + blockinfile: + path: /etc/hosts + block: '{{ item.key }} {{ item.value.hostname }}' + marker: "# {mark} WISE2C DEPLOY MANAGED BLOCK {{ item.key }}" + with_dict: "{{ hostvars }}" + + - name: disabled selinux + selinux: + state: disabled + + - name: start firewalld + systemd: + name: firewalld + enabled: true + state: started + + - name: config firewalld + shell: | + firewall-cmd --set-default-zone=trusted + firewall-cmd --complete-reload + + - name: distribute wise2c repo + template: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + with_items: + - { src: 'template/wise2c.repo.j2', dest: '/etc/yum.repos.d/wise2c.repo' } + + - name: install docker + yum: + disablerepo: '*' + enablerepo: wise2c + update_cache: true + state: present + name: '{{ item }}' + with_items: + - rsync + - jq + - docker + - python-docker-py + - docker-compose + + - name: distribute chrony server config + template: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + with_items: + - { src: 'template/chrony-server.conf.j2', dest: '/etc/chrony.conf' } + when: inventory_hostname == ansible_play_batch[0] + + - name: distribute chrony client config + template: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + with_items: + - { src: 'template/chrony-client.conf.j2', dest: '/etc/chrony.conf' } + when: inventory_hostname != ansible_play_batch[0] + + - name: start chrony + systemd: + name: chronyd + daemon_reload: true + enabled: true + state: started + + - name: check docker + script: scripts/check_docker.sh {{ registry }} + register: check_output + + - block: + - name: clear docker config + copy: + content: '' + dest: '{{ item }}' + with_items: + - /etc/sysconfig/docker + - /etc/sysconfig/docker-storage + - /etc/sysconfig/docker-storage-setup + - /etc/sysconfig/docker-network + + - name: distribute docker config + template: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + with_items: + - { src: 'template/daemon.json.j2', dest: '/etc/docker/daemon.json' } + + - name: reload & restart docker + systemd: + name: docker + daemon_reload: true + enabled: true + state: restarted + + - name: set sysctl + sysctl: + name: '{{ item }}' + value: 1 + state: present + reload: true + with_items: + - net.ipv4.ip_forward + - net.bridge.bridge-nf-call-iptables + - net.bridge.bridge-nf-call-ip6tables + when: check_output.stdout != 'true' diff --git a/docker-playbook/1.13.1/properties.json b/docker-playbook/1.13.1/properties.json new file mode 100644 index 0000000..3f17b7f --- /dev/null +++ b/docker-playbook/1.13.1/properties.json @@ -0,0 +1,10 @@ +[ + { + "variable": "format_hostname", + "label": "format host name", + "description": "format host name if you check this", + "type": "bool", + "default": "false", + "required": true + } +] \ No newline at end of file diff --git a/docker-playbook/1.13.1/reset.ansible b/docker-playbook/1.13.1/reset.ansible new file mode 100644 index 0000000..3354053 --- /dev/null +++ b/docker-playbook/1.13.1/reset.ansible @@ -0,0 +1,17 @@ +- name: clean docker + hosts: hosts + user: root + tasks: + # - name: install docker + # yum: + # disablerepo: '*' + # enablerepo: wise2c + # state: absent + # name: '{{ item }}' + # with_items: + # - rsync + # - jq + # - chrony + # - docker + # - python-docker-py + # - docker-compose \ No newline at end of file diff --git a/docker-playbook/1.13.1/scripts/check_docker.sh b/docker-playbook/1.13.1/scripts/check_docker.sh new file mode 100644 index 0000000..c27902e --- /dev/null +++ b/docker-playbook/1.13.1/scripts/check_docker.sh @@ -0,0 +1,8 @@ +#! /bin/bash + +name=`curl -sS --unix-socket /var/run/docker.sock http:/v1.24/info | jq -r '.RegistryConfig.IndexConfigs."'$1'".Name'` +if [ "${name}" == "$1" ]; then +echo -n true +else +echo -n false +fi \ No newline at end of file diff --git a/docker-playbook/1.13.1/template/chrony-client.conf.j2 b/docker-playbook/1.13.1/template/chrony-client.conf.j2 new file mode 100644 index 0000000..a566fa8 --- /dev/null +++ b/docker-playbook/1.13.1/template/chrony-client.conf.j2 @@ -0,0 +1,2 @@ +# Use servers . +server {{ ansible_play_batch[0] }} iburst \ No newline at end of file diff --git a/docker-playbook/1.13.1/template/chrony-server.conf.j2 b/docker-playbook/1.13.1/template/chrony-server.conf.j2 new file mode 100644 index 0000000..19988a1 --- /dev/null +++ b/docker-playbook/1.13.1/template/chrony-server.conf.j2 @@ -0,0 +1,21 @@ +# Use servers . +server {{ ansible_play_batch[0] }} iburst + +# Record the rate at which the system clock gains/losses time. +driftfile /var/lib/chrony/drift + +# Allow the system clock to be stepped in the first three updates +# if its offset is larger than 1 second. +makestep 1.0 3 + +# Enable kernel synchronization of the real-time clock (RTC). +rtcsync + +# Allow NTP client access from local network. +allow + +# Serve time even if not synchronized to a time source. +local stratum 10 + +# Specify directory for log files. +logdir /var/log/chrony \ No newline at end of file diff --git a/docker-playbook/1.13.1/template/daemon.json.j2 b/docker-playbook/1.13.1/template/daemon.json.j2 new file mode 100644 index 0000000..98f7344 --- /dev/null +++ b/docker-playbook/1.13.1/template/daemon.json.j2 @@ -0,0 +1,14 @@ +{ + "exec-opt": [ + "native.cgroupdriver=systemd" + ], + "log-driver": "json-file", + "log-opts": { + "max-size": "100m", + "max-file": "5" + }, + "insecure-registries": [ + "{{ registry }}" + ], + "storage-driver": "overlay2" +} \ No newline at end of file diff --git a/docker-playbook/1.13.1/template/wise2c.repo.j2 b/docker-playbook/1.13.1/template/wise2c.repo.j2 new file mode 100644 index 0000000..98f6adb --- /dev/null +++ b/docker-playbook/1.13.1/template/wise2c.repo.j2 @@ -0,0 +1,5 @@ +[wise2c] +name=wise2c +baseurl=http://{{ wise2c_seed_host }}:2009/rpms +enabled=1 +gpgcheck=0 diff --git a/docker-playbook/1.13.1/yat/hosts.gotmpl b/docker-playbook/1.13.1/yat/hosts.gotmpl new file mode 100644 index 0000000..4c4465a --- /dev/null +++ b/docker-playbook/1.13.1/yat/hosts.gotmpl @@ -0,0 +1,4 @@ +[hosts] +{{ range $v := .AllHosts -}} +{{ $v.IP }} hostname={{ $v.HostName }} +{{ end }} \ No newline at end of file diff --git a/docker-playbook/1.13.1/yat/hosts.yml.gotmpl b/docker-playbook/1.13.1/yat/hosts.yml.gotmpl new file mode 100644 index 0000000..02763da --- /dev/null +++ b/docker-playbook/1.13.1/yat/hosts.yml.gotmpl @@ -0,0 +1,3 @@ +wise2c_seed_host: wise2c-seed +registry: {{ .registry.Inherent.endpoint }} +format_hostname: {{ .docker.Property.format_hostname }} \ No newline at end of file diff --git a/etcd-playbook/3.1.12/ansible.cfg b/etcd-playbook/3.1.12/ansible.cfg new file mode 100644 index 0000000..87f0107 --- /dev/null +++ b/etcd-playbook/3.1.12/ansible.cfg @@ -0,0 +1,5 @@ +[defaults] +inventory=hosts +callback_plugins = ../../callback_plugins +callback_whitelist = log_back +retry_files_enabled = false \ No newline at end of file diff --git a/etcd-playbook/3.1.12/file/README.md b/etcd-playbook/3.1.12/file/README.md new file mode 100644 index 0000000..e69de29 diff --git a/etcd-playbook/3.1.12/group_vars/etcd.yml b/etcd-playbook/3.1.12/group_vars/etcd.yml new file mode 100644 index 0000000..6e4839c --- /dev/null +++ b/etcd-playbook/3.1.12/group_vars/etcd.yml @@ -0,0 +1,16 @@ +command: +- etcd +- | + {% for host in ansible_play_batch -%} + {% if host == inventory_hostname -%} + --name etcd{{ loop.index0 }} + {% endif -%} + {% endfor -%} +- --data-dir /var/lib/etcd +- --advertise-client-urls http://{{ inventory_hostname }}:2379 +- --listen-client-urls http://{{ inventory_hostname }}:2379 +- --listen-peer-urls http://{{ inventory_hostname }}:2380 +- --initial-cluster-token etcd-cluster +- --initial-advertise-peer-urls http://{{ inventory_hostname }}:2380 +- --initial-cluster {% for host in play_hosts %}etcd{{ loop.index0 }}=http://{{ host }}:2380{% if not loop.last %},{% endif %}{% endfor %} +- --initial-cluster-state new \ No newline at end of file diff --git a/etcd-playbook/3.1.12/inherent.yaml b/etcd-playbook/3.1.12/inherent.yaml new file mode 100644 index 0000000..bdc14d8 --- /dev/null +++ b/etcd-playbook/3.1.12/inherent.yaml @@ -0,0 +1,3 @@ +endpoint: {{ range $i, $v := .Hosts.self -}} + http://{{ $v.IP }}:2379{{if notLast $i $.Hosts.self}},{{end}} + {{- end }} \ No newline at end of file diff --git a/etcd-playbook/3.1.12/init.sh b/etcd-playbook/3.1.12/init.sh new file mode 100644 index 0000000..6ae664a --- /dev/null +++ b/etcd-playbook/3.1.12/init.sh @@ -0,0 +1,13 @@ +#! /bin/bash + +set -e + +path=`dirname $0` + +image=gcr.io/google_containers/etcd-amd64:${1} +echo "" >> ${path}/group_vars/etcd.yml +echo "image: ${image}" >> ${path}/group_vars/etcd.yml + +docker pull ${image} +docker save ${image} > ${path}/file/etcd.tar +bzip2 -z --best ${path}/file/etcd.tar \ No newline at end of file diff --git a/etcd-playbook/3.1.12/install.ansible b/etcd-playbook/3.1.12/install.ansible new file mode 100644 index 0000000..cf4db52 --- /dev/null +++ b/etcd-playbook/3.1.12/install.ansible @@ -0,0 +1,36 @@ +- name: install etcd + hosts: etcd + user: root + vars: + path: /var/tmp/wise2c/etcd + tasks: + - name: make etcd dir + file: + path: '{{ item }}' + state: directory + mode: 0755 + with_items: + - '{{ path }}' + + - name: copy etcd image + copy: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + with_items: + - { src: 'file/etcd.tar.bz2', dest: '{{ path }}' } + + - name: load etcd image + docker_image: + load_path: '{{ path }}/etcd.tar.bz2' + name: '{{ image }}' + timeout: 600 + + - name: run etcd + docker_container: + name: etcd + network_mode: host + restart_policy: unless-stopped + image: '{{ image }}' + command: '{{ command }}' + volumes: + - /data/wisecloud/etcd:/var/lib/etcd \ No newline at end of file diff --git a/etcd-playbook/3.1.12/properties.json b/etcd-playbook/3.1.12/properties.json new file mode 100644 index 0000000..25b806f --- /dev/null +++ b/etcd-playbook/3.1.12/properties.json @@ -0,0 +1,10 @@ +[ + { + "variable": "self", + "label": "etcd hosts", + "description": "hosts for setup etcd", + "type": "host", + "default": "", + "required": true + } +] \ No newline at end of file diff --git a/etcd-playbook/3.1.12/reset.ansible b/etcd-playbook/3.1.12/reset.ansible new file mode 100644 index 0000000..50c5c5a --- /dev/null +++ b/etcd-playbook/3.1.12/reset.ansible @@ -0,0 +1,15 @@ +- name: clean etcd + hosts: etcd + user: root + tasks: + - name: stop & rm old etcd container + docker_container: + name: etcd + state: absent + + - name: clean etcd directory + file: + path: '{{ item }}' + state: absent + with_items: + - /data/wisecloud/etcd \ No newline at end of file diff --git a/etcd-playbook/3.1.12/yat/hosts.gotmpl b/etcd-playbook/3.1.12/yat/hosts.gotmpl new file mode 100644 index 0000000..5c34008 --- /dev/null +++ b/etcd-playbook/3.1.12/yat/hosts.gotmpl @@ -0,0 +1,4 @@ +[etcd] +{{ range $v := .etcd.Hosts.self -}} +{{ $v.IP }} +{{ end }} \ No newline at end of file diff --git a/init.sh b/init.sh new file mode 100644 index 0000000..a145af5 --- /dev/null +++ b/init.sh @@ -0,0 +1,18 @@ +#! /bin/bash + +set -e + +path=`dirname $0` + +for dir in `ls ${path}` +do + if [[ ${dir} =~ -playbook$ ]]; then + for version in `ls ${path}/${dir}` + do + echo ${version} + if [ -f ${path}/${dir}/${version}/init.sh ]; then + bash ${path}/${dir}/${version}/init.sh ${version} + fi + done + fi +done \ No newline at end of file diff --git a/kubernetes-playbook/v1.10.3/ansible.cfg b/kubernetes-playbook/v1.10.3/ansible.cfg new file mode 100644 index 0000000..87f0107 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/ansible.cfg @@ -0,0 +1,5 @@ +[defaults] +inventory=hosts +callback_plugins = ../../callback_plugins +callback_whitelist = log_back +retry_files_enabled = false \ No newline at end of file diff --git a/kubernetes-playbook/v1.10.3/file/README.md b/kubernetes-playbook/v1.10.3/file/README.md new file mode 100644 index 0000000..e69de29 diff --git a/kubernetes-playbook/v1.10.3/file/apiserver-kubelet-client.crt b/kubernetes-playbook/v1.10.3/file/apiserver-kubelet-client.crt new file mode 100644 index 0000000..2966bb9 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/file/apiserver-kubelet-client.crt @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIC/zCCAeegAwIBAgIIWMwr1Sadq2EwDQYJKoZIhvcNAQELBQAwFTETMBEGA1UE +AxMKa3ViZXJuZXRlczAeFw0xNzA3MDQwMjMzMzdaFw0xODA3MDQwNDUxNTVaMEEx +FzAVBgNVBAoTDnN5c3RlbTptYXN0ZXJzMSYwJAYDVQQDEx1rdWJlLWFwaXNlcnZl +ci1rdWJlbGV0LWNsaWVudDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB +AM7U/tT1COTNNCvy07aIZm3q1ZPxxIrc2Mi0J+3wpe5sUxQCyQ28hWX/GlVdiAys +7YNcTC8HjkTHKBLJauOkjpmi3VTAkGahVWVE11U14WouJV+UFToZXv2flGJ4yd04 +Z1cJNoZajGjertnkwdbmMQAMiusdfipqCD2uxRKBEGX39Nc4XVM/Yls8MPPST/Xk +kFfEEoh4WPk4HyROQDtUNT9vgyXHScPuOoBXnQ7CcTF35POloSZPwHB0mmiiwbrQ +FxSRePaopQyJITAQmhHZ4xC9EH/M8TYD4UhpbzR0U1FTSJiho83omVHBhkQmzAZF +NKfPWQWUrN8O4eM7AYFX3GcCAwEAAaMnMCUwDgYDVR0PAQH/BAQDAgWgMBMGA1Ud +JQQMMAoGCCsGAQUFBwMCMA0GCSqGSIb3DQEBCwUAA4IBAQARR9Hb0K8sX1ApIj5l +TC0GCu+GkpplVz5Rw9oRmkt2E1nh7nX+XeAgy1SM0XZRjIDXpWYPZ2WASd4QWOlb +aUuR1/lZySeMtaS9FK2+/sbdSutBdnpwE8hejMsOp8vyIt93HXb1D7Vql0HjbBOJ +qpJk2zLNvP8Gjub9dr5iK2vHPUS1c5fGzEqubnlLOeGO0khMfVks6zQp9Ftce1Wf +mprI7cGBd/qXO8Pg0RQ3MTGCC+fIqPXrlVKXn/OYV0I1MLtP+NiKmfJf50xR2s3V +2l1gE555f6rAN1ehAGqzn0v9SrWgxdq7OyVyxzaS8WyWIJDf9VELranUj4FkEOVZ +K/z5 +-----END CERTIFICATE----- diff --git a/kubernetes-playbook/v1.10.3/file/apiserver-kubelet-client.key b/kubernetes-playbook/v1.10.3/file/apiserver-kubelet-client.key new file mode 100644 index 0000000..d5081af --- /dev/null +++ b/kubernetes-playbook/v1.10.3/file/apiserver-kubelet-client.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEAztT+1PUI5M00K/LTtohmberVk/HEitzYyLQn7fCl7mxTFALJ +DbyFZf8aVV2IDKztg1xMLweORMcoEslq46SOmaLdVMCQZqFVZUTXVTXhai4lX5QV +Ohle/Z+UYnjJ3ThnVwk2hlqMaN6u2eTB1uYxAAyK6x1+KmoIPa7FEoEQZff01zhd +Uz9iWzww89JP9eSQV8QSiHhY+TgfJE5AO1Q1P2+DJcdJw+46gFedDsJxMXfk86Wh +Jk/AcHSaaKLButAXFJF49qilDIkhMBCaEdnjEL0Qf8zxNgPhSGlvNHRTUVNImKGj +zeiZUcGGRCbMBkU0p89ZBZSs3w7h4zsBgVfcZwIDAQABAoIBAQC0TzEdG8S2GkJq +MdXpYf3RwxCQWgtad28xgQTyRIGTWbIPVuJJbFjq8zrUwqYxTqv8gYEU2sRnJyvD +PP5HGBUM0NOc6Aa6wdj9YMdMTJ2HgFUqfqEGtkl+Vxj3w49PoLVORgTXmaagYckS +wX9Oxfxfq4+LqnlrpmYqx+qb2BIgoTjeubBGG5YpvQGA5D8OoTgDh9j+Fs70Nskg +RbmnLJ56VYSHOHyLVQ9LUvWA0m/KIxVPUyHoJheqw4IfFUj9bA4cncl3hZ4qEzzz +J1qiknGGOhiBVNbMvP+hnW7nzQgNV3FN9Zr2jZ/6WzAF4WcYhXkpa39Enzzkk5w0 +zdEetKwpAoGBAOy3G3caf4glcivfZ5C0KOfB92HuQg+axE5yXxe3NKJtCxuQ5Ou6 +QMlHMTMQHWS8RDz9ntCaUjnxRaeUIQcnX173vvooYf4p5kesLoRMi8puFn9GBw9q +Xr/8KZMalGQIa6KUsik9EJS5VidyEkAwlSx0kndDMA4evOKMtrvLsZILAoGBAN+u +pfPkt7bOWq42IsuKBACQ9gE1EYaxVZ0AB7/D2iZldKcLP487p0GJgdFvMEXChccX +dKe/hhGcrNBhF/pOqitVKNJQAwwiXCEoD9EW+vENvioLhVlt9kHdp5wXmUqfqM2B +0ZZ/i590mXCj7k2NZGzFheyiNt+kg81biPkU3xSVAoGBANV48/3fGa/QBTxnhmBK ++LC4jb31PgIQkoQkRHmAsKjiKag8bRXgq9hYqZfhKoDT/735AqYg5ZJ3cVeFEJwA +99MPHV0/2c96Pb/ZGUIaPd7alNNGdcuDI9uDLoMI71We+mJuMpVaCn/0/Csqhib5 +KS4kGooPP2Ecez7bo1eMhKCtAoGAUvfgHIBI2KjgH+B6tY7C/0bFyRrbHl/mxq59 +MVc/MqDNTSyx7boNxxRvL7UTbbzCjF+Z6KL04tF/lGd/UlwdaKdU1fXRu41/KNlI +TKE+gW08jTHqy4orHrFN+2sRdAmWvmuZxz4WFxZT1+EmgmOgzWvSyjw9KGVIckKy +otloCaUCgYEA3W6YvOH1eEecZc+wjJ1ejmNUc3Ugc1uioyyQeGxTBp8XL8nz/dxy +QXyLssRIhCYjTsCTa4MtA2HyHXP/1d0ZrA5cgJpifvbhmSuMgn/IRMJqgvwA5Usr +AMQz0JC4UPrjh89C2VkpkYqsAVj/2JJi+xugU5ReM46XLyY8A4XXthE= +-----END RSA PRIVATE KEY----- diff --git a/kubernetes-playbook/v1.10.3/file/ca.crt b/kubernetes-playbook/v1.10.3/file/ca.crt new file mode 100644 index 0000000..dda6a53 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/file/ca.crt @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICyDCCAbCgAwIBAgIBADANBgkqhkiG9w0BAQsFADAVMRMwEQYDVQQDEwprdWJl +cm5ldGVzMB4XDTE3MDcwNDAyMzMzN1oXDTI3MDcwMjAyMzMzN1owFTETMBEGA1UE +AxMKa3ViZXJuZXRlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANDj +I5qX0fFgrlIK9YhBjHuIpTXqZldyveevNhdwlOYDiCKpGwPdaxC9++foh88Xerv/ +QvO5EflPu8IhEmoM+wu7a2hdVPPOcPxE9Fn0N6O0LXtgpjkAgALXQklKx1tk6Fja +M4BhUaJD9zKSP6PVSjPRDTs+4yJnWGJQYaAN3pkIF9mFx2+GWoo07F4yDoRUtsqv ++kBISIyWai+lOjofZS0cIoxgNwUMxg4OGcL3F1Yxkf36o4qtO7H8FPJFAvnKHFgp +IpYdfiporRykw4e0vSSYmpoCzBgzg/po8K7Tw/jSGPUR4m91IYBTJm1ZDBAMbnLE +tPmOOqze2az0YSHcekECAwEAAaMjMCEwDgYDVR0PAQH/BAQDAgKkMA8GA1UdEwEB +/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAGwZth8zU7AAbZxD1lzBvlSFn9yh +W8I6xYLBBAtUT0anvrqXV2XttW7QtaEDIFOQrohjUwkWZyRm9iKTZZCh2Pw1pNkf +YQzsg0weEb++YJSVrpzMDl/P4V/lZsv1rFanma+wu0wdmeJkVP8mfqtbjdKlioMa +azrmkiZm37NAdqbF5/kAGYNb/oHJukx9MR9oIw3aP1zDREGC42soj5xRujiDzMKH +vdY8IjU1SArEd3HxrLbrrEMqs4baiEx9Rp4y3hbrvKGFPS+x5IU3nPKUJTbCNw8S +8ImrvUFpY1VOR0rDjHs+Fh8vDp7LoTxA4x8Ryy0NlsXnBjJSFaecVazDQ8Q= +-----END CERTIFICATE----- diff --git a/kubernetes-playbook/v1.10.3/file/ca.key b/kubernetes-playbook/v1.10.3/file/ca.key new file mode 100644 index 0000000..12daae4 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/file/ca.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEA0OMjmpfR8WCuUgr1iEGMe4ilNepmV3K95682F3CU5gOIIqkb +A91rEL375+iHzxd6u/9C87kR+U+7wiESagz7C7traF1U885w/ET0WfQ3o7Qte2Cm +OQCAAtdCSUrHW2ToWNozgGFRokP3MpI/o9VKM9ENOz7jImdYYlBhoA3emQgX2YXH +b4ZaijTsXjIOhFS2yq/6QEhIjJZqL6U6Oh9lLRwijGA3BQzGDg4ZwvcXVjGR/fqj +iq07sfwU8kUC+cocWCkilh1+KmitHKTDh7S9JJiamgLMGDOD+mjwrtPD+NIY9RHi +b3UhgFMmbVkMEAxucsS0+Y46rN7ZrPRhIdx6QQIDAQABAoIBAD8lq0m8w7bYp1od +/gPm7PUbZfZamf2trkMv8IY9foXaY3k27ffJI+i3xkNhRE0SqAPVMwRC2nAn7nbN +UKfGrM3rJpkyPdBGhFl+7u+SqI9QlL9LhHSO9iPltyA4/vNeGe9iZ1dUFD2dlkkv +dRWuEPSBKiLS7A8mds2hxyF/j99qyvvW5W1pS4cRDkXs1/mn/UwI5DOYCxgT59KQ +4H8M/z8L8wD3c5YDY7idFufc8mVVcxA7ExL+S+Hvoy4pg9DQ99H9wh5t7RbHJs60 +plHM3gWwIjG7jXv69M6UDYMd5imLsnxZxcasNvM5S98YiK9fl90hng4ZszSvv5Wz +GkEHgNECgYEA3egyyoeqIMZnOI9QyYuIf1dEcjhT2kZTGH1WaNjVQUlVzVIuQyIy +lDU8KLkBwE27fZUglaOglp3fU4xMAB1o1Fx4ZBlmCckMlsWCKd0EGt0BdF2YRKXn +F53okCS6Gnia4E76d0xWucTKXApiW/PhyxZRWTXk2ak5d3mSJ3KbD1sCgYEA8Prc +nGd9NwVVaX8+VMFkFUlEjqP9wExf9FHnnQXxAQ2MG7BrrbrB4UTIBiqFuJYiV/D2 +9KczHRcQiw2h8lfLsbG1Is6WH5s+qFQyMjYzWYZPJwnyuz3iJaKgyHBRDYUnTTgZ +xMEzNrCgHNIIAWm+UH/WFsRwqadZPzDQ/RtpS5MCgYBu/FV66kNyxQiXR0a2pu0M +E4+OORHnV8jztKxlIB342z7oxDOTLCVz7vQ5wd5YWghuFQoJDZ+h9S/fT4orfIoT +vHQSTIm2VzHOrtYdLgeBkAvMMYuYuglMzJOmlFfoKW38xkOLK0ks/Hnhcugi6WWC +95SUM9pT6sltMgahaDaZhQKBgQCD2K11gYXX4bouo2jmFH1+y/yPkpgWa3MgiOOR +XRvUeKYMzETN492KNAjAnulU6gfWV8e2afikVOc/PXE61+Bh05oIdkFa/6STkqV4 +JYGI3NxXvrCo0530+3q+z/z4yb6MGEK5DP/JT2/69Mtego2XG6p2AHqnyCEjWsEt +ip7cswKBgCA7ANxZHhIFebHFNm0HUQzGFN9WpfJTNhn/veNqzvegS1Z1BvXwxXxO +urYfu8gONyJXrrOKf2vwBgRxwCbiZ2fFACPx/SQrMliNRuV6MvclfuIXxInvX6R3 +VqKBQnmO8xg/GRIem/8BWBUihp4m6auA8GYOpd6wl+6fz9i7+Su7 +-----END RSA PRIVATE KEY----- diff --git a/kubernetes-playbook/v1.10.3/file/kube-flannel-rbac.yml b/kubernetes-playbook/v1.10.3/file/kube-flannel-rbac.yml new file mode 100644 index 0000000..d66465c --- /dev/null +++ b/kubernetes-playbook/v1.10.3/file/kube-flannel-rbac.yml @@ -0,0 +1,42 @@ +# Create the clusterrole and clusterrolebinding: +# $ kubectl create -f kube-flannel-rbac.yml +# Create the pod using the same namespace used by the flannel serviceaccount: +# $ kubectl create --namespace kube-system -f kube-flannel.yml +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: flannel +rules: + - apiGroups: + - "" + resources: + - pods + verbs: + - get + - apiGroups: + - "" + resources: + - nodes + verbs: + - list + - watch + - apiGroups: + - "" + resources: + - nodes/status + verbs: + - patch +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: flannel +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: flannel +subjects: +- kind: ServiceAccount + name: flannel + namespace: kube-system diff --git a/kubernetes-playbook/v1.10.3/file/sa.key b/kubernetes-playbook/v1.10.3/file/sa.key new file mode 100644 index 0000000..b23fdba --- /dev/null +++ b/kubernetes-playbook/v1.10.3/file/sa.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpgIBAAKCAQEA4+Td6C+8Wp9t99S6sipRcNCgUxm9+c98VFCfoV/3t9AFw3CZ +aFRZpWchH73Tk1laKGG3sbHJD1eaBYR69qe2cfPWJSmiFSvzdlo1tqig9QrRdgKB +Ds6P1njX4p1qMrRRV9ipM09S9jR82KAZXwIMHwXaG/D3fa1SyBR9P6To6Cb2aENk +v9DxlChsUHESWuXlw3cjo3f7vQWfQq72xiJLRGilgljSbAGSd7KZhMtSWFqyypwq +mBq/9Q/7SojmQoNpBKFpDVNcWGyZjWOjQwBDYePJOl6ccoEUrZ1KkBPFQWm6kJIc +do2Hk/vgJtGjdncK04TswbyhKaHeUDiNAQQnGwIDAQABAoIBAQC20+iXGpzQUzEk +7xwsTTjy+dx1bqRzYlrLRbca/uO8Kn5FMfNQuMMGqDrxvRedEcT7upFlVE0KKuxc +2tDPSvNabhVx0PnAZHc4jtyiwpwGmnw6YX3qRBsvI9mGa2VEclcD08TCbjQPY0J5 +g8924iyZQtedLO9Qexl7fLySr5lOjFfnxzidctxNKkP99V8WO2HzPAwhh8jyuJcj +EDwp9lPBawpIXt4cfn7pCmEGiWVw/56uhW8VCAByxfBOF/AkcFY2vZrnuG74WxPy +jW+wP6M4N5r6eLVBuIH1gYP7ha15xmtUdsb+KDINZVFWOi2j5Ms9RwIcllUiX6p+ +d+YoqZMJAoGBAPZMalwWp/bcMAYbqd77Kodzgc1+MgZSiA5gHBQlQx8BpGc+RDMU +kglIrE/f/lJyTfrCneWiz4omb44De1s6EgL5W2rKVgl3gIVxjpZUeHoI/kofa3tS +56lbhNfDVkC/52ofzdyLC5mk5OaIovR8aADBCktUVueQNFWccEqSZ0FtAoGBAOze +3gDSvosNPnvLYETNXbJeXGrYklFP2+oJ/eVoXTMqln6+qHu9/o/t+P/tQAusyNTO +fnusnjIoDLvOL/OWz8bu0JAuPao0vhz93cFU4ZCLrncu1iFylCrFidEm6rASatXM +qN5ppinzq3LDFlWDNUBBLoaDYQNba+dMKYBH572nAoGBAM/shsWjIrzV+XzOkcN6 +Sdb7fhMae+S2e8GXBV1Eb7uXSVEXUb/Fl9tajI0JzcuQT6Bn96BKp+Y6uGYtLlA/ +X8E+/RvUIHnxdoAw82yZdvOe7/1nNPdxb7ybVDRJ5WDYIOaIXuPWRj6447xykQ7Q +j4RDcwtQ8eSe6m9zl6B8o8qpAoGBAKw23PF8R0yRtHwMwVFEfnrQYCDOlJLJnPnr +iczgs+IfdItx0s0ktY+vVPm9ZHMYjGssNol0Vw/gTmG85uATJb1cpAYvmGXHMvGh +ITkOnXCaHZ5JTyXCSDdQp4KI6Nhai5Il2iDabxTRNDWb4QELBAxTV6A0pLPsI+dm +WEYMAVDBAoGBALLQykhe8UAAhETunNZ619g7nSgOi3ByVEnOa2u9NEfbMLsUDzXT +3PpsuXrheT2BvsEWvyOfD01R1Nzr07oZB4W1kocLJ+hEJPZPgvHGBK349RhFqzk4 +4OLuSJQPuWjJAwWNgpyYnjdQ560hDZgjNqWqfohkP2zTc1EtmZhFsN29 +-----END RSA PRIVATE KEY----- diff --git a/kubernetes-playbook/v1.10.3/file/sa.pub b/kubernetes-playbook/v1.10.3/file/sa.pub new file mode 100644 index 0000000..5526f43 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/file/sa.pub @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4+Td6C+8Wp9t99S6sipR +cNCgUxm9+c98VFCfoV/3t9AFw3CZaFRZpWchH73Tk1laKGG3sbHJD1eaBYR69qe2 +cfPWJSmiFSvzdlo1tqig9QrRdgKBDs6P1njX4p1qMrRRV9ipM09S9jR82KAZXwIM +HwXaG/D3fa1SyBR9P6To6Cb2aENkv9DxlChsUHESWuXlw3cjo3f7vQWfQq72xiJL +RGilgljSbAGSd7KZhMtSWFqyypwqmBq/9Q/7SojmQoNpBKFpDVNcWGyZjWOjQwBD +YePJOl6ccoEUrZ1KkBPFQWm6kJIcdo2Hk/vgJtGjdncK04TswbyhKaHeUDiNAQQn +GwIDAQAB +-----END PUBLIC KEY----- diff --git a/kubernetes-playbook/v1.10.3/group_vars/README.md b/kubernetes-playbook/v1.10.3/group_vars/README.md new file mode 100644 index 0000000..e69de29 diff --git a/kubernetes-playbook/v1.10.3/inherent.yaml b/kubernetes-playbook/v1.10.3/inherent.yaml new file mode 100644 index 0000000..72d5458 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/inherent.yaml @@ -0,0 +1,5 @@ +endpoint: {{ if eq (print .Property.endpoint) "" -}} + {{ (index .Hosts.master 0).IP }}:6443 + {{- else -}} + {{ .Property.endpoint }} + {{- end }} diff --git a/kubernetes-playbook/v1.10.3/init.sh b/kubernetes-playbook/v1.10.3/init.sh new file mode 100644 index 0000000..23ca416 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/init.sh @@ -0,0 +1,87 @@ +#! /bin/bash + +set -e + +path=`dirname $0` + +kubernetes_repo="gcr.io/google_containers" +kubernetes_version=`docker run -it --rm \ + -e KUBERNETES_VERSION=${1} \ + -e KUBERNETES_COMPONENT=kube-apiserver \ + ymian/kube-version:1.10` +dns_version=`docker run -it --rm \ + -e KUBERNETES_VERSION=${1} \ + -e KUBERNETES_COMPONENT=kube-dns \ + ymian/kube-version:1.10` +pause_version="3.1" +echo "" >> ${path}/yat/all.yml.gotmpl +echo "kubernetes_repo: ${kubernetes_repo}" >> ${path}/yat/all.yml.gotmpl +echo "kubernetes_version: ${kubernetes_version}" >> ${path}/yat/all.yml.gotmpl +echo "dns_version: ${dns_version}" >> ${path}/yat/all.yml.gotmpl +echo "pause_version: ${pause_version}" >> ${path}/yat/all.yml.gotmpl + +flannel_repo="quay.io/coreos" +flannel_version="v0.10.0" +echo "flannel_repo: ${flannel_repo}" >> ${path}/yat/all.yml.gotmpl +echo "flannel_version: ${flannel_version}-amd64" >> ${path}/yat/all.yml.gotmpl + +curl -sS https://raw.githubusercontent.com/coreos/flannel/${flannel_version}/Documentation/kube-flannel.yml \ + | sed -e "s,quay.io/coreos,{{ registry_endpoint }}/{{ registry_project }},g" > ${path}/template/kube-flannel.yml.j2 + +dashboard_repo="k8s.gcr.io" +dashboard_version="v1.8.3" +echo "dashboard_repo: ${dashboard_repo}" >> ${path}/yat/all.yml.gotmpl +echo "dashboard_version: ${dashboard_version}" >> ${path}/yat/all.yml.gotmpl + +#curl -sS https://raw.githubusercontent.com/kubernetes/dashboard/${dashboard_version}/src/deploy/recommended/kubernetes-dashboard.yaml \ +# | sed -e "s,k8s.gcr.io,{{ registry_endpoint }}/{{ registry_project }},g" > ${path}/template/kubernetes-dashboard.yml.j2 + +curl -sS https://raw.githubusercontent.com/wise2c-devops/playbook/master/kubernetes-playbook/v1.10.3/template/kubernetes-dashboard-wise2c.yaml.j2 \ + | sed -e "s,k8s.gcr.io,{{ registry_endpoint }}/{{ registry_project }},g" > ${path}/template/kubernetes-dashboard.yml.j2 + +#curl -L -o ${path}/file/cni-plugins-amd64-v0.6.0.tgz https://github.com/containernetworking/plugins/releases/download/v0.6.0/cni-plugins-amd64-v0.6.0.tgz + +echo "=== pulling kubernetes images ===" +docker pull ${kubernetes_repo}/kube-apiserver-amd64:${kubernetes_version} +docker pull ${kubernetes_repo}/kube-controller-manager-amd64:${kubernetes_version} +docker pull ${kubernetes_repo}/kube-scheduler-amd64:${kubernetes_version} +docker pull ${kubernetes_repo}/kube-proxy-amd64:${kubernetes_version} +docker pull ${kubernetes_repo}/pause-amd64:${pause_version} +docker pull ${kubernetes_repo}/k8s-dns-sidecar-amd64:${dns_version} +docker pull ${kubernetes_repo}/k8s-dns-kube-dns-amd64:${dns_version} +docker pull ${kubernetes_repo}/k8s-dns-dnsmasq-nanny-amd64:${dns_version} +echo "=== pull kubernetes images success ===" +echo "=== saving kubernetes images ===" +mkdir -p ${path}/file +docker save ${kubernetes_repo}/kube-apiserver-amd64:${kubernetes_version} \ + ${kubernetes_repo}/kube-controller-manager-amd64:${kubernetes_version} \ + ${kubernetes_repo}/kube-scheduler-amd64:${kubernetes_version} \ + ${kubernetes_repo}/kube-proxy-amd64:${kubernetes_version} \ + ${kubernetes_repo}/pause-amd64:${pause_version} \ + ${kubernetes_repo}/k8s-dns-sidecar-amd64:${dns_version} \ + ${kubernetes_repo}/k8s-dns-kube-dns-amd64:${dns_version} \ + ${kubernetes_repo}/k8s-dns-dnsmasq-nanny-amd64:${dns_version} \ + > ${path}/file/k8s.tar +rm ${path}/file/k8s.tar.bz2 -f +bzip2 -z --best ${path}/file/k8s.tar +echo "=== save kubernetes images success ===" + +echo "=== pulling flannel image ===" +docker pull ${flannel_repo}/flannel:${flannel_version}-amd64 +echo "=== pull flannel image success ===" +echo "=== saving flannel image ===" +docker save ${flannel_repo}/flannel:${flannel_version}-amd64 \ + > ${path}/file/flannel.tar +rm ${path}/file/flannel.tar.bz2 -f +bzip2 -z --best ${path}/file/flannel.tar +echo "=== save flannel image success ===" + +echo "=== pulling dashboard image ===" +docker pull ${dashboard_repo}/kubernetes-dashboard-amd64:${dashboard_version} +echo "=== pull dashboard image success ===" +echo "=== saving dashboard image ===" +docker save ${dashboard_repo}/kubernetes-dashboard-amd64:${dashboard_version} \ + > ${path}/file/dashboard.tar +rm ${path}/file/dashboard.tar.bz2 -f +bzip2 -z --best ${path}/file/dashboard.tar +echo "=== save dashboard image success ===" diff --git a/kubernetes-playbook/v1.10.3/install.ansible b/kubernetes-playbook/v1.10.3/install.ansible new file mode 100644 index 0000000..b5f283b --- /dev/null +++ b/kubernetes-playbook/v1.10.3/install.ansible @@ -0,0 +1,79 @@ +- name: install kubernetes package + hosts: all + user: root + vars: + path: /var/tmp/wise2c/kubernetes + tasks: + - name: make k8s master dir + file: + path: '{{ item }}' + state: directory + mode: 0755 + with_items: + - /etc/kubernetes/pki + - '{{ path }}' + - $HOME/.kube + + - name: check kubernetes + script: scripts/check_kubelet.sh + register: check_output + + - name: remove swapfile from /etc/fstab + mount: + name: swap + fstype: swap + state: absent + + - name: disable swap + command: swapoff -a + + - block: + - name: install kubernetes components + yum: + disablerepo: '*' + enablerepo: wise2c + update_cache: true + state: present + name: '{{ item }}' + with_items: + - kubernetes-cni-0.6.0 + - kubectl-{{ kubernetes_version[1:] }} + - kubelet-{{ kubernetes_version[1:] }} + - kubeadm-{{ kubernetes_version[1:] }} + + - name: unarchive cni + unarchive: + src: file/cni-plugins-amd64-v0.6.0.tgz + dest: /opt/cni/bin + + - name: distribute kubelet config + template: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + with_items: + - { src: 'template/kubelet.conf.j2', dest: '/etc/systemd/system/kubelet.service.d/wise2c-kubelet.conf' } + + - name: reload & enable kubelet + systemd: + name: kubelet + daemon_reload: true + enabled: true + + - name: set sysctl + sysctl: + name: '{{ item }}' + value: 1 + state: present + reload: true + with_items: + - net.bridge.bridge-nf-call-iptables + - net.bridge.bridge-nf-call-ip6tables + + - name: setup master + include_tasks: master.ansible + when: role == 'master' + + - name: setup node + include_tasks: node.ansible + when: role == 'node' + when: check_output.stdout != 'true' diff --git a/kubernetes-playbook/v1.10.3/master.ansible b/kubernetes-playbook/v1.10.3/master.ansible new file mode 100644 index 0000000..54ef245 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/master.ansible @@ -0,0 +1,111 @@ +- name: copy k8s images + copy: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + with_items: + - { src: 'file/k8s.tar.bz2', dest: '{{ path }}' } + - { src: 'file/flannel.tar.bz2', dest: '{{ path }}' } + - { src: 'file/dashboard.tar.bz2', dest: '{{ path }}' } + - { src: 'file/kube-flannel-rbac.yml', dest: '{{ path }}' } + run_once: true + +- name: load k8s images + docker_image: + load_path: '{{ path }}/{{ item }}' + name: k8s + timeout: 600 + with_items: + - k8s.tar.bz2 + - flannel.tar.bz2 + - dashboard.tar.bz2 + run_once: true + +- name: docker login + docker_login: + registry: '{{ registry_endpoint }}' + username: '{{ registry_user }}' + password: '{{ registry_password }}' + reauthorize: true + run_once: true + +- name: tag images + docker_image: + name: '{{ item.repo }}/{{ item.name }}' + repository: '{{ registry_endpoint }}/{{ registry_project }}/{{ item.name }}' + tag: '{{ item.tag }}' + with_items: + - { repo: '{{ kubernetes_repo }}', name: 'kube-controller-manager-amd64', tag: '{{ kubernetes_version }}' } + - { repo: '{{ kubernetes_repo }}', name: 'kube-apiserver-amd64', tag: '{{ kubernetes_version }}' } + - { repo: '{{ kubernetes_repo }}', name: 'kube-scheduler-amd64', tag: '{{ kubernetes_version }}' } + - { repo: '{{ kubernetes_repo }}', name: 'kube-proxy-amd64', tag: '{{ kubernetes_version }}' } + - { repo: '{{ kubernetes_repo }}', name: 'k8s-dns-sidecar-amd64', tag: '{{ dns_version }}' } + - { repo: '{{ kubernetes_repo }}', name: 'k8s-dns-kube-dns-amd64', tag: '{{ dns_version }}' } + - { repo: '{{ kubernetes_repo }}', name: 'k8s-dns-dnsmasq-nanny-amd64', tag: '{{ dns_version }}' } + - { repo: '{{ kubernetes_repo }}', name: 'pause-amd64', tag: '{{ pause_version }}' } + - { repo: '{{ flannel_repo }}', name: 'flannel', tag: '{{ flannel_version }}' } + - { repo: '{{ dashboard_repo }}', name: 'kubernetes-dashboard-amd64', tag: '{{ dashboard_version }}' } + run_once: true + +- name: push images + docker_image: + name: '{{ registry_endpoint }}/{{ registry_project }}/{{ item.name }}' + tag: '{{ item.tag }}' + push: true + state: present + with_items: + - { repo: '{{ kubernetes_repo }}', name: 'kube-controller-manager-amd64', tag: '{{ kubernetes_version }}' } + - { repo: '{{ kubernetes_repo }}', name: 'kube-apiserver-amd64', tag: '{{ kubernetes_version }}' } + - { repo: '{{ kubernetes_repo }}', name: 'kube-scheduler-amd64', tag: '{{ kubernetes_version }}' } + - { repo: '{{ kubernetes_repo }}', name: 'kube-proxy-amd64', tag: '{{ kubernetes_version }}' } + - { repo: '{{ kubernetes_repo }}', name: 'k8s-dns-sidecar-amd64', tag: '{{ dns_version }}' } + - { repo: '{{ kubernetes_repo }}', name: 'k8s-dns-kube-dns-amd64', tag: '{{ dns_version }}' } + - { repo: '{{ kubernetes_repo }}', name: 'k8s-dns-dnsmasq-nanny-amd64', tag: '{{ dns_version }}' } + - { repo: '{{ kubernetes_repo }}', name: 'pause-amd64', tag: '{{ pause_version }}' } + - { repo: '{{ flannel_repo }}', name: 'flannel', tag: '{{ flannel_version }}' } + - { repo: '{{ dashboard_repo }}', name: 'kubernetes-dashboard-amd64', tag: '{{ dashboard_version }}' } + run_once: true + +- name: generate kubeadm config + template: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + with_items: + - { src: 'template/kubeadm.conf.j2', dest: '{{ path }}/kubeadm.conf' } + - { src: 'template/kube-flannel.yml.j2', dest: '{{ path }}/kube-flannel.yml' } + - { src: 'template/kubernetes-dashboard.yml.j2', dest: '{{ path }}/kubernetes-dashboard.yml' } + +- name: copy crt & key + copy: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + with_items: + - { src: 'file/ca.key', dest: '/etc/kubernetes/pki' } + - { src: 'file/ca.crt', dest: '/etc/kubernetes/pki' } + - { src: 'file/sa.key', dest: '/etc/kubernetes/pki' } + - { src: 'file/sa.pub', dest: '/etc/kubernetes/pki' } + - { src: 'file/apiserver-kubelet-client.key', dest: '/etc/kubernetes/pki' } + - { src: 'file/apiserver-kubelet-client.crt', dest: '/etc/kubernetes/pki' } + +- name: setup + shell: | + kubeadm init --config {{ path }}/kubeadm.conf + +- name: fetch admin.conf + fetch: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + flat: true + with_items: + - { src: '/etc/kubernetes/admin.conf', dest: 'file/admin.conf' } + run_once: true + +- name: config kubectl + shell: | + cp /etc/kubernetes/admin.conf $HOME/.kube/config + chown $(id -u):$(id -g) $HOME/.kube/config + +- name: apply addons + shell: | + kubectl apply -f {{ path }}/kube-flannel.yml + kubectl apply -f {{ path }}/kubernetes-dashboard.yml + run_once: true diff --git a/kubernetes-playbook/v1.10.3/node.ansible b/kubernetes-playbook/v1.10.3/node.ansible new file mode 100644 index 0000000..2b04ebd --- /dev/null +++ b/kubernetes-playbook/v1.10.3/node.ansible @@ -0,0 +1,18 @@ +- name: copy k8s admin.conf + copy: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + with_items: + - { src: 'file/admin.conf', dest: '{{ ansible_env.HOME }}/.kube/config' } + +- name: setup node + shell: | + kubeadm join --token {{ token }} {{ endpoint }} --discovery-token-unsafe-skip-ca-verification {{ endpoint }} + sed -i "s/.*server:.*/ server: https:\/\/{{ endpoint }}/g" /etc/kubernetes/kubelet.conf + cp {{ path }}/admin.conf $HOME/.kube/config + chown $(id -u):$(id -g) $HOME/.kube/config + +- name: restart kubelet + systemd: + name: kubelet + state: restarted diff --git a/kubernetes-playbook/v1.10.3/properties.json b/kubernetes-playbook/v1.10.3/properties.json new file mode 100644 index 0000000..3d080d8 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/properties.json @@ -0,0 +1,24 @@ +[ + { + "variable": "master", + "label": "kubernetes master hosts", + "description": "hosts to setup kubernetes master", + "type": "host", + "required": false + }, + { + "variable": "node", + "label": "kubenetes node hosts", + "description": "hosts to setup kubernetes node", + "type": "host", + "required": false + }, + { + "variable": "endpoint", + "label": "kubernetes entry point", + "description": "other can access kubernetes by this", + "type": "string", + "default": "", + "required": false + } +] \ No newline at end of file diff --git a/kubernetes-playbook/v1.10.3/reset.ansible b/kubernetes-playbook/v1.10.3/reset.ansible new file mode 100644 index 0000000..bbbddc6 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/reset.ansible @@ -0,0 +1,25 @@ +- name: clean k8s master + hosts: all + user: root + tasks: + - name: kubeadm reset + shell: | + kubeadm reset + + - name: install kubernetes components + yum: + state: absent + disablerepo: '*' + enablerepo: wise2c + name: '{{ item }}' + with_items: + - kubernetes-cni-0.5.1 + - kubectl-{{ kubernetes_version[1:] }} + - kubelet-{{ kubernetes_version[1:] }} + - kubeadm-{{ kubernetes_version[1:] }} + + - name: clean link + shell: | + ip link delete cni0 + ip link delete flannel.1 + ignore_errors: true \ No newline at end of file diff --git a/kubernetes-playbook/v1.10.3/scripts/check_kubelet.sh b/kubernetes-playbook/v1.10.3/scripts/check_kubelet.sh new file mode 100644 index 0000000..267c519 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/scripts/check_kubelet.sh @@ -0,0 +1,15 @@ +#! /bin/bash + +# while read -r line +# do +# if [[ "${line}" =~ "server: https://$1:$2" ]] +# then printf ${line} +# fi +# done < /etc/kubernetes/kubelet.conf + +code=`curl -sL -o /dev/null -w %{response_code} http://127.0.0.1:10255/stats` +if [ "${code}" == "200" ]; then +printf true +else +printf false +fi \ No newline at end of file diff --git a/kubernetes-playbook/v1.10.3/scripts/label.sh b/kubernetes-playbook/v1.10.3/scripts/label.sh new file mode 100644 index 0000000..a1f9aa1 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/scripts/label.sh @@ -0,0 +1,8 @@ +HOSTNAME=`hostname` +while : ; do + kubectl label --overwrite nodes ${HOSTNAME,,} io.wise2c.service=$1 + if [ $? != 0 ]; then + sleep 2 + else break + fi +done \ No newline at end of file diff --git a/kubernetes-playbook/v1.10.3/scripts/taint.sh b/kubernetes-playbook/v1.10.3/scripts/taint.sh new file mode 100644 index 0000000..d76384a --- /dev/null +++ b/kubernetes-playbook/v1.10.3/scripts/taint.sh @@ -0,0 +1,8 @@ +HOSTNAME=`hostname` +while : ; do + kubectl taint --overwrite nodes ${HOSTNAME,,} node-role.kubernetes.io=master:NoSchedule + if [ $? != 0 ]; then + sleep 2 + else break + fi +done \ No newline at end of file diff --git a/kubernetes-playbook/v1.10.3/template/kube-flannel.yml.j2 b/kubernetes-playbook/v1.10.3/template/kube-flannel.yml.j2 new file mode 100644 index 0000000..823b563 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/template/kube-flannel.yml.j2 @@ -0,0 +1,103 @@ +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: flannel + namespace: kube-system +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: kube-flannel-cfg + namespace: kube-system + labels: + tier: node + app: flannel +data: + cni-conf.json: | + { + "name": "-cbr0-", + "cniVersion": "0.3.0", + "plugins": [ + { + "type": "flannel", + "delegate": { + "isDefaultGateway": true + } + }, + { + "type": "portmap", + "capabilities": {"portMappings": true}, + "noSnat": false + } + ] + } + net-conf.json: | + { + "Network": "10.244.0.0/16", + "Backend": { + "Type": "vxlan" + } + } +--- +apiVersion: extensions/v1beta1 +kind: DaemonSet +metadata: + name: kube-flannel-ds + namespace: kube-system + labels: + tier: node + app: flannel +spec: + template: + metadata: + labels: + tier: node + app: flannel + spec: + hostNetwork: true + nodeSelector: + beta.kubernetes.io/arch: amd64 + tolerations: + - key: node-role.kubernetes.io/master + operator: Exists + effect: NoSchedule + serviceAccountName: flannel + containers: + - name: kube-flannel + image: {{ registry_endpoint }}/{{ registry_project }}/flannel:v0.8.0-amd64 + command: [ "/opt/bin/flanneld", "--ip-masq", "--kube-subnet-mgr" ] + securityContext: + privileged: true + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + volumeMounts: + - name: run + mountPath: /run + - name: flannel-cfg + mountPath: /etc/kube-flannel/ + - name: install-cni + image: {{ registry_endpoint }}/{{ registry_project }}/flannel:v0.8.0-amd64 + command: [ "/bin/sh", "-c", "set -e -x; cp -f /etc/kube-flannel/cni-conf.json /etc/cni/net.d/10-flannel.conflist; while true; do sleep 3600; done" ] + volumeMounts: + - name: cni + mountPath: /etc/cni/net.d + - name: flannel-cfg + mountPath: /etc/kube-flannel/ + volumes: + - name: run + hostPath: + path: /run + - name: cni + hostPath: + path: /etc/cni/net.d + - name: flannel-cfg + configMap: + name: kube-flannel-cfg \ No newline at end of file diff --git a/kubernetes-playbook/v1.10.3/template/kubeadm.conf.j2 b/kubernetes-playbook/v1.10.3/template/kubeadm.conf.j2 new file mode 100644 index 0000000..a567795 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/template/kubeadm.conf.j2 @@ -0,0 +1,23 @@ +apiVersion: kubeadm.k8s.io/v1alpha1 +kind: MasterConfiguration +etcd: + endpoints: +{% for host in groups['etcd'] %} + - http://{{ host }}:2379 +{% endfor %} +networking: + podSubnet: 10.244.0.0/16 +kubernetesVersion: {{ kubernetes_version }} +token: 904250.ab14566918c0703b +tokenTTL: 0s +apiServerExtraArgs: + apiserver-count: '3' + runtime-config: batch/v2alpha1=true + feature-gates: LocalStorageCapacityIsolation=true +controllerManagerExtraArgs: + feature-gates: LocalStorageCapacityIsolation=true +schedulerExtraArgs: + feature-gates: LocalStorageCapacityIsolation=true +apiServerCertSANs: + - {{ endpoint.split(':')[0] }} +imageRepository: {{ registry_endpoint }}/{{ registry_project }} diff --git a/kubernetes-playbook/v1.10.3/template/kubelet.conf.j2 b/kubernetes-playbook/v1.10.3/template/kubelet.conf.j2 new file mode 100644 index 0000000..6dac4e6 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/template/kubelet.conf.j2 @@ -0,0 +1,5 @@ +[Service] +Environment="KUBELET_EXTRA_ARGS=--pod-infra-container-image={{ registry_endpoint }}/{{ registry_project }}/pause-amd64:3.1 --feature-gates=LocalStorageCapacityIsolation=true" \ + --kube-reserved-cgroup=/kubepods.slice --kube-reserved=cpu=500m,memory=500Mi,ephemeral-storage=1Gi \ + --system-reserved-cgroup=/system.slice --system-reserved=cpu=500m,memory=500Mi,ephemeral-storage=1Gi \ + --eviction-hard=memory.available<500Mi,nodefs.available<10%" diff --git a/kubernetes-playbook/v1.10.3/template/kubernetes-dashboard-wise2c.yaml.j2 b/kubernetes-playbook/v1.10.3/template/kubernetes-dashboard-wise2c.yaml.j2 new file mode 100644 index 0000000..e3192e3 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/template/kubernetes-dashboard-wise2c.yaml.j2 @@ -0,0 +1,182 @@ +# Copyright 2017 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Configuration to deploy release version of the Dashboard UI compatible with +# Kubernetes 1.8. +# +# Example usage: kubectl create -f + +# ------------------- Dashboard Secret ------------------- # + +apiVersion: v1 +kind: Secret +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard-certs + namespace: kube-system +type: Opaque + +--- +# ------------------- Dashboard Service Account ------------------- # + +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard + namespace: kube-system + +--- +# ------------------- Dashboard Role & Role Binding ------------------- # + +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: kubernetes-dashboard-minimal + namespace: kube-system +rules: + # Allow Dashboard to create 'kubernetes-dashboard-key-holder' secret. +- apiGroups: [""] + resources: ["secrets"] + verbs: ["create"] + # Allow Dashboard to create 'kubernetes-dashboard-settings' config map. +- apiGroups: [""] + resources: ["configmaps"] + verbs: ["create"] + # Allow Dashboard to get, update and delete Dashboard exclusive secrets. +- apiGroups: [""] + resources: ["secrets"] + resourceNames: ["kubernetes-dashboard-key-holder", "kubernetes-dashboard-certs"] + verbs: ["get", "update", "delete"] + # Allow Dashboard to get and update 'kubernetes-dashboard-settings' config map. +- apiGroups: [""] + resources: ["configmaps"] + resourceNames: ["kubernetes-dashboard-settings"] + verbs: ["get", "update"] + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: kubernetes-dashboard-minimal + namespace: kube-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: kubernetes-dashboard-minimal +subjects: +- kind: ServiceAccount + name: kubernetes-dashboard + namespace: kube-system + +--- +# ------------------- Dashboard Deployment ------------------- # + +kind: Deployment +apiVersion: apps/v1beta2 +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard + namespace: kube-system +spec: + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + k8s-app: kubernetes-dashboard + template: + metadata: + labels: + k8s-app: kubernetes-dashboard + spec: + containers: + - name: kubernetes-dashboard + image: {{ registry_endpoint }}/{{ registry_project }}/kubernetes-dashboard-amd64:v1.8.3 + ports: + - containerPort: 8443 + protocol: TCP + args: + - --auto-generate-certificates + # Uncomment the following line to manually specify Kubernetes API server Host + # If not specified, Dashboard will attempt to auto discover the API server and connect + # to it. Uncomment only if the default does not work. + # - --apiserver-host=http://my-address:port + volumeMounts: + - name: kubernetes-dashboard-certs + mountPath: /certs + # Create on-disk volume to store exec logs + - mountPath: /tmp + name: tmp-volume + livenessProbe: + httpGet: + scheme: HTTPS + path: / + port: 8443 + initialDelaySeconds: 30 + timeoutSeconds: 30 + volumes: + - name: kubernetes-dashboard-certs + secret: + secretName: kubernetes-dashboard-certs + - name: tmp-volume + emptyDir: {} + serviceAccountName: kubernetes-dashboard + # Comment the following tolerations if Dashboard must not be deployed on master + tolerations: + - key: node-role.kubernetes.io/master + effect: NoSchedule + +--- +# ------------------- Dashboard Service ------------------- # + +kind: Service +apiVersion: v1 +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard + namespace: kube-system +spec: + type: NodePort + ports: + - port: 8443 + nodePort: 30300 + selector: + k8s-app: kubernetes-dashboard + +--- +# ------------------- Dashboard Service Account------------------- # +apiVersion: v1 +kind: ServiceAccount +metadata: + name: admin-user + namespace: kube-system + +--- +# ------------------- Dashboard Cluster Role Binding------------------- # +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: admin-user +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin +subjects: +- kind: ServiceAccount + name: admin-user + namespace: kube-system diff --git a/kubernetes-playbook/v1.10.3/template/kubernetes-dashboard.yml.j2 b/kubernetes-playbook/v1.10.3/template/kubernetes-dashboard.yml.j2 new file mode 100644 index 0000000..fe19620 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/template/kubernetes-dashboard.yml.j2 @@ -0,0 +1,97 @@ +# Copyright 2015 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Configuration to deploy release version of the Dashboard UI compatible with +# Kubernetes 1.6 (RBAC enabled). +# +# Example usage: kubectl create -f + +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: kubernetes-dashboard + labels: + k8s-app: kubernetes-dashboard +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin +subjects: +- kind: ServiceAccount + name: kubernetes-dashboard + namespace: kube-system +--- +kind: Deployment +apiVersion: extensions/v1beta1 +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard + namespace: kube-system +spec: + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + k8s-app: kubernetes-dashboard + template: + metadata: + labels: + k8s-app: kubernetes-dashboard + spec: + containers: + - name: kubernetes-dashboard + image: {{ registry_endpoint }}/{{ registry_project }}/kubernetes-dashboard-amd64:v1.6.3 + ports: + - containerPort: 9090 + protocol: TCP + args: + # Uncomment the following line to manually specify Kubernetes API server Host + # If not specified, Dashboard will attempt to auto discover the API server and connect + # to it. Uncomment only if the default does not work. + # - --apiserver-host=http://my-address:port + livenessProbe: + httpGet: + path: / + port: 9090 + initialDelaySeconds: 30 + timeoutSeconds: 30 + serviceAccountName: kubernetes-dashboard + # Comment the following tolerations if Dashboard must not be deployed on master + tolerations: + - key: node-role.kubernetes.io/master + effect: NoSchedule +--- +kind: Service +apiVersion: v1 +metadata: + labels: + k8s-app: kubernetes-dashboard + name: kubernetes-dashboard + namespace: kube-system +spec: + type: NodePort + ports: + - port: 9090 + nodePort: 30300 + selector: + k8s-app: kubernetes-dashboard diff --git a/kubernetes-playbook/v1.10.3/template/max-scale.yml.j2 b/kubernetes-playbook/v1.10.3/template/max-scale.yml.j2 new file mode 100644 index 0000000..1ccc05b --- /dev/null +++ b/kubernetes-playbook/v1.10.3/template/max-scale.yml.j2 @@ -0,0 +1,55 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + labels: + app: max-scale + name: max-scale +spec: + replicas: 1 + selector: + matchLabels: + app: max-scale + template: + metadata: + labels: + app: max-scale + name: max-scale + spec: + containers: + - env: + - name: MYSQL_ROOT_PASSWORD + value: password + - name: REPLICATION_USER + value: root + - name: REPLICATION_PASSWORD + value: password + - name: MasterIP + value: {{ master }} + - name: Slave1IP + value: {{ slave1 }} + - name: Slave2IP + value: {{ slave2 }} + - name: MySQLPort + value: "3307" + - name: NeverMasterIP + value: {{ neverMaster }} + image: {{ registry }}/{{ project }}/maxscale1.4.5-1-docker:latest + imagePullPolicy: IfNotPresent + name: max-scale +--- +kind: Service +apiVersion: v1 +metadata: + labels: + app: max-scale + name: max-scale +spec: + type: NodePort + ports: + - name: 3306-3306 + port: 3306 + nodePort: 30308 + targetPort: 3306 + protocol: TCP + selector: + app: max-scale \ No newline at end of file diff --git a/kubernetes-playbook/v1.10.3/yat/all.yml.gotmpl b/kubernetes-playbook/v1.10.3/yat/all.yml.gotmpl new file mode 100644 index 0000000..e6cb423 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/yat/all.yml.gotmpl @@ -0,0 +1,6 @@ +endpoint: {{ .kubernetes.Inherent.endpoint }} +token: 904250.ab14566918c0703b +registry_endpoint: {{ .registry.Inherent.endpoint }} +registry_user: {{ .registry.Inherent.user }} +registry_password: {{ .registry.Inherent.password }} +registry_project: library \ No newline at end of file diff --git a/kubernetes-playbook/v1.10.3/yat/hosts.gotmpl b/kubernetes-playbook/v1.10.3/yat/hosts.gotmpl new file mode 100644 index 0000000..b92dc22 --- /dev/null +++ b/kubernetes-playbook/v1.10.3/yat/hosts.gotmpl @@ -0,0 +1,14 @@ +[etcd] +{{ range $v := .etcd.Hosts.self -}} +{{ $v.IP }} +{{ end }} + +[master] +{{ range $v := .kubernetes.Hosts.master -}} +{{ $v.IP }} role=master +{{ end }} + +[node] +{{ range $v := .kubernetes.Hosts.node -}} +{{ $v.IP }} role=node +{{ end }} \ No newline at end of file diff --git a/manual/KubernetesDeployUI-001.png b/manual/KubernetesDeployUI-001.png new file mode 100644 index 0000000..4826d87 Binary files /dev/null and b/manual/KubernetesDeployUI-001.png differ diff --git a/manual/KubernetesDeployUI-002.png b/manual/KubernetesDeployUI-002.png new file mode 100644 index 0000000..ed86221 Binary files /dev/null and b/manual/KubernetesDeployUI-002.png differ diff --git a/manual/KubernetesDeployUI-003.png b/manual/KubernetesDeployUI-003.png new file mode 100644 index 0000000..a32cd62 Binary files /dev/null and b/manual/KubernetesDeployUI-003.png differ diff --git a/manual/KubernetesDeployUI-004.png b/manual/KubernetesDeployUI-004.png new file mode 100644 index 0000000..fff27f4 Binary files /dev/null and b/manual/KubernetesDeployUI-004.png differ diff --git a/manual/KubernetesDeployUI-005.png b/manual/KubernetesDeployUI-005.png new file mode 100644 index 0000000..12f4a35 Binary files /dev/null and b/manual/KubernetesDeployUI-005.png differ diff --git a/manual/KubernetesDeployUI-006.png b/manual/KubernetesDeployUI-006.png new file mode 100644 index 0000000..0a78a58 Binary files /dev/null and b/manual/KubernetesDeployUI-006.png differ diff --git a/manual/KubernetesDeployUI-007.png b/manual/KubernetesDeployUI-007.png new file mode 100644 index 0000000..f25fd9f Binary files /dev/null and b/manual/KubernetesDeployUI-007.png differ diff --git a/manual/KubernetesDeployUI-008.png b/manual/KubernetesDeployUI-008.png new file mode 100644 index 0000000..49a5c0b Binary files /dev/null and b/manual/KubernetesDeployUI-008.png differ diff --git a/manual/KubernetesDeployUI-009.png b/manual/KubernetesDeployUI-009.png new file mode 100644 index 0000000..f0f6d92 Binary files /dev/null and b/manual/KubernetesDeployUI-009.png differ diff --git a/manual/KubernetesDeployUI-010.png b/manual/KubernetesDeployUI-010.png new file mode 100644 index 0000000..f87f6be Binary files /dev/null and b/manual/KubernetesDeployUI-010.png differ diff --git a/manual/KubernetesDeployUI-011.png b/manual/KubernetesDeployUI-011.png new file mode 100644 index 0000000..25584bb Binary files /dev/null and b/manual/KubernetesDeployUI-011.png differ diff --git a/manual/KubernetesDeployUI-012.png b/manual/KubernetesDeployUI-012.png new file mode 100644 index 0000000..32ad1d7 Binary files /dev/null and b/manual/KubernetesDeployUI-012.png differ diff --git a/manual/KubernetesDeployUI-013.png b/manual/KubernetesDeployUI-013.png new file mode 100644 index 0000000..6884f98 Binary files /dev/null and b/manual/KubernetesDeployUI-013.png differ diff --git a/manual/KubernetesDeployUI-014.png b/manual/KubernetesDeployUI-014.png new file mode 100644 index 0000000..51080ad Binary files /dev/null and b/manual/KubernetesDeployUI-014.png differ diff --git a/manual/KubernetesDeployUI-015.png b/manual/KubernetesDeployUI-015.png new file mode 100644 index 0000000..0b958de Binary files /dev/null and b/manual/KubernetesDeployUI-015.png differ diff --git a/manual/KubernetesDeployUI-016.png b/manual/KubernetesDeployUI-016.png new file mode 100644 index 0000000..2f3de7b Binary files /dev/null and b/manual/KubernetesDeployUI-016.png differ diff --git a/manual/KubernetesDeployUI-017.png b/manual/KubernetesDeployUI-017.png new file mode 100644 index 0000000..4cdc874 Binary files /dev/null and b/manual/KubernetesDeployUI-017.png differ diff --git a/manual/KubernetesDeployUI-018.png b/manual/KubernetesDeployUI-018.png new file mode 100644 index 0000000..b7e5b00 Binary files /dev/null and b/manual/KubernetesDeployUI-018.png differ diff --git a/manual/KubernetesDeployUI-019.png b/manual/KubernetesDeployUI-019.png new file mode 100644 index 0000000..f904d95 Binary files /dev/null and b/manual/KubernetesDeployUI-019.png differ diff --git a/manual/KubernetesDeployUI-020.png b/manual/KubernetesDeployUI-020.png new file mode 100644 index 0000000..fe4b61e Binary files /dev/null and b/manual/KubernetesDeployUI-020.png differ diff --git a/manual/KubernetesDeployUI-021.png b/manual/KubernetesDeployUI-021.png new file mode 100644 index 0000000..3010671 Binary files /dev/null and b/manual/KubernetesDeployUI-021.png differ diff --git a/manual/KubernetesDeployUI-022.png b/manual/KubernetesDeployUI-022.png new file mode 100644 index 0000000..42d7a88 Binary files /dev/null and b/manual/KubernetesDeployUI-022.png differ diff --git a/manual/KubernetesDeployUI-023.png b/manual/KubernetesDeployUI-023.png new file mode 100644 index 0000000..768e376 Binary files /dev/null and b/manual/KubernetesDeployUI-023.png differ diff --git a/manual/KubernetesDeployUI-024.png b/manual/KubernetesDeployUI-024.png new file mode 100644 index 0000000..773f4b9 Binary files /dev/null and b/manual/KubernetesDeployUI-024.png differ diff --git a/manual/KubernetesDeployUI-025.png b/manual/KubernetesDeployUI-025.png new file mode 100644 index 0000000..b5f364a Binary files /dev/null and b/manual/KubernetesDeployUI-025.png differ diff --git a/manual/KubernetesDeployUI-026.png b/manual/KubernetesDeployUI-026.png new file mode 100644 index 0000000..a4603f7 Binary files /dev/null and b/manual/KubernetesDeployUI-026.png differ diff --git a/manual/KubernetesDeployUI-027.png b/manual/KubernetesDeployUI-027.png new file mode 100644 index 0000000..7b7d2c8 Binary files /dev/null and b/manual/KubernetesDeployUI-027.png differ diff --git a/manual/KubernetesDeployUI-028.png b/manual/KubernetesDeployUI-028.png new file mode 100644 index 0000000..a211c59 Binary files /dev/null and b/manual/KubernetesDeployUI-028.png differ diff --git a/manual/KubernetesDeployUI-029.png b/manual/KubernetesDeployUI-029.png new file mode 100644 index 0000000..a444447 Binary files /dev/null and b/manual/KubernetesDeployUI-029.png differ diff --git a/manual/KubernetesDeployUI-030.png b/manual/KubernetesDeployUI-030.png new file mode 100644 index 0000000..78fc1fd Binary files /dev/null and b/manual/KubernetesDeployUI-030.png differ diff --git a/manual/KubernetesDeployUI-031.png b/manual/KubernetesDeployUI-031.png new file mode 100644 index 0000000..8f3be41 Binary files /dev/null and b/manual/KubernetesDeployUI-031.png differ diff --git a/manual/KubernetesDeployUI-032.png b/manual/KubernetesDeployUI-032.png new file mode 100644 index 0000000..1f01784 Binary files /dev/null and b/manual/KubernetesDeployUI-032.png differ diff --git a/manual/KubernetesDeployUI-033.png b/manual/KubernetesDeployUI-033.png new file mode 100644 index 0000000..ae0002b Binary files /dev/null and b/manual/KubernetesDeployUI-033.png differ diff --git a/manual/KubernetesDeployUI-034.png b/manual/KubernetesDeployUI-034.png new file mode 100644 index 0000000..fd6fbf8 Binary files /dev/null and b/manual/KubernetesDeployUI-034.png differ diff --git a/manual/KubernetesDeployUI-035.png b/manual/KubernetesDeployUI-035.png new file mode 100644 index 0000000..1de0e36 Binary files /dev/null and b/manual/KubernetesDeployUI-035.png differ diff --git a/manual/KubernetesDeployUI-036.png b/manual/KubernetesDeployUI-036.png new file mode 100644 index 0000000..1546eb4 Binary files /dev/null and b/manual/KubernetesDeployUI-036.png differ diff --git a/manual/README.md b/manual/README.md new file mode 100644 index 0000000..7b0e808 --- /dev/null +++ b/manual/README.md @@ -0,0 +1 @@ +软件使用界面截图 diff --git a/registry-playbook/v1.2.2/ansible.cfg b/registry-playbook/v1.2.2/ansible.cfg new file mode 100644 index 0000000..87f0107 --- /dev/null +++ b/registry-playbook/v1.2.2/ansible.cfg @@ -0,0 +1,5 @@ +[defaults] +inventory=hosts +callback_plugins = ../../callback_plugins +callback_whitelist = log_back +retry_files_enabled = false \ No newline at end of file diff --git a/registry-playbook/v1.2.2/file/README.md b/registry-playbook/v1.2.2/file/README.md new file mode 100644 index 0000000..e69de29 diff --git a/registry-playbook/v1.2.2/group_vars/README.md b/registry-playbook/v1.2.2/group_vars/README.md new file mode 100644 index 0000000..e69de29 diff --git a/registry-playbook/v1.2.2/inherent.yaml b/registry-playbook/v1.2.2/inherent.yaml new file mode 100644 index 0000000..3c32a23 --- /dev/null +++ b/registry-playbook/v1.2.2/inherent.yaml @@ -0,0 +1,11 @@ +endpoint: {{ if eq (print .Property.endpoint) "" -}} + {{ (index .Hosts.self 0).IP }} + {{- else -}} + {{ .Property.endpoint }} + {{- end }} +user: admin +password: {{ if eq (print .Property.password) "" -}} + Harbor12345 + {{- else -}} + {{ .Property.password }} + {{- end }} \ No newline at end of file diff --git a/registry-playbook/v1.2.2/init.sh b/registry-playbook/v1.2.2/init.sh new file mode 100644 index 0000000..14bfb42 --- /dev/null +++ b/registry-playbook/v1.2.2/init.sh @@ -0,0 +1,17 @@ +#! /bin/bash + +set -e + +path=`dirname $0` +version=$1 +echo "" >> ${path}/yat/registry.yml.gotmpl +echo "version: ${version}" >> ${path}/yat/registry.yml.gotmpl + +curl https://storage.googleapis.com/harbor-releases/harbor-offline-installer-${version}.tgz \ + -o ${path}/file/harbor-offline-installer-${version}.tgz + +curl -sS https://raw.githubusercontent.com/vmware/harbor/${version}/make/harbor.cfg \ + | sed \ + -e "s,hostname = reg\.mydomain\.com,hostname = {{ inventory_hostname }},g" \ + -e "s,harbor_admin_password = Harbor12345,harbor_admin_password = {{ password }},g" \ + > ${path}/template/harbor.cfg.j2 \ No newline at end of file diff --git a/registry-playbook/v1.2.2/install.ansible b/registry-playbook/v1.2.2/install.ansible new file mode 100644 index 0000000..d0b4bb5 --- /dev/null +++ b/registry-playbook/v1.2.2/install.ansible @@ -0,0 +1,31 @@ +- name: setup registry + hosts: registry + user: root + vars: + path: /var/tmp/wise2c/registry + tasks: + - name: make registry dir + file: + path: '{{ item }}' + state: directory + mode: 0755 + with_items: + - '{{ cpath }}' + - '{{ path }}' + + - name: unarchive harbor + unarchive: + src: file/harbor-offline-installer-{{ version }}.tgz + dest: '{{ cpath }}' + + - name: generate registry config + template: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + with_items: + - { src: 'template/harbor.cfg.j2', dest: '{{ cpath }}/harbor/harbor.cfg' } + + - name: launch registry + shell: ./install.sh + args: + chdir: '{{ cpath }}/harbor' \ No newline at end of file diff --git a/registry-playbook/v1.2.2/properties.json b/registry-playbook/v1.2.2/properties.json new file mode 100644 index 0000000..3cc91d4 --- /dev/null +++ b/registry-playbook/v1.2.2/properties.json @@ -0,0 +1,26 @@ +[ + { + "variable": "self", + "label": "registry hosts", + "description": "hosts for setup registry", + "type": "host", + "default": "", + "required": true + }, + { + "variable": "endpoint", + "label": "registry entry point", + "description": "everyone can access registry by this", + "type": "string", + "default": "", + "required": false + }, + { + "variable": "password", + "label": "registry password", + "description": "everyone can 'docker login' use this", + "type": "string", + "default": "Harbor12345", + "required": true + } +] diff --git a/registry-playbook/v1.2.2/reset.ansible b/registry-playbook/v1.2.2/reset.ansible new file mode 100644 index 0000000..c2da3df --- /dev/null +++ b/registry-playbook/v1.2.2/reset.ansible @@ -0,0 +1,22 @@ +- name: clean registry + hosts: registry + user: root + tasks: + - name: stop & rm registry + docker_service: + project_src: '{{ cpath }}/harbor' + state: absent + remove_volumes: true + + - name: clean registry directory + file: + path: '{{ item }}' + state: absent + with_items: + - /data/registry + - /data/database + - /data/ca_download + - /data/config + - /data/job_logs + - /data/psc + - '{{ cpath }}' \ No newline at end of file diff --git a/registry-playbook/v1.2.2/template/README.md b/registry-playbook/v1.2.2/template/README.md new file mode 100644 index 0000000..e69de29 diff --git a/registry-playbook/v1.2.2/yat/hosts.gotmpl b/registry-playbook/v1.2.2/yat/hosts.gotmpl new file mode 100644 index 0000000..cd303b5 --- /dev/null +++ b/registry-playbook/v1.2.2/yat/hosts.gotmpl @@ -0,0 +1,4 @@ +[registry] +{{ range $v := .registry.Hosts.self -}} +{{ $v.IP }} +{{ end }} \ No newline at end of file diff --git a/registry-playbook/v1.2.2/yat/registry.yml.gotmpl b/registry-playbook/v1.2.2/yat/registry.yml.gotmpl new file mode 100644 index 0000000..5fbac3f --- /dev/null +++ b/registry-playbook/v1.2.2/yat/registry.yml.gotmpl @@ -0,0 +1,2 @@ +cpath: /var/lib/wise2c/registry +password: {{ .registry.Inherent.password }} \ No newline at end of file