#1 上传文件至 ''

Merged
yingying merged 1 commits from yingying-patch-1 into master 1 year ago
  1. +28
    -0
      .gitignore
  2. +208
    -0
      LICENSE
  3. +98
    -2
      README.md
  4. +82
    -0
      hosts
  5. +5
    -0
      setup.yml
  6. +17
    -0
      tmp

+ 28
- 0
.gitignore View File

@@ -0,0 +1,28 @@
# ---> macOS
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


+ 208
- 0
LICENSE View File

@@ -0,0 +1,208 @@
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.

+ 98
- 2
README.md View File

@@ -1,2 +1,98 @@
# proprietary-cloud-deploy

# 说明
*部署脚本于长城专有云平台*
部署脚本中包括了kubernetes底层组件、efk等一系列服务的安装。采用ansbile脚本实现自动安装,运维人员需要对ansible工具有一定简单了解。主要服务基本实现全容器化、k8s化部署,可以通过kubernetes dashboard监控到所有容器服务;部署脚本基于centos 7 或者kylin v10 sp1,要求内核版本为4以上;既提供一键快速安装方式,也提供分步执行安装方式。
# 组件版本
| 名称 | 版本号 | 备注 |
|-------------------------|--------------|----------|
| Kernel | 4以上 | |
| kube-apiserver | 1.21.0 | |
| kube-controller-manager | 1.21.0 | |
| kube-scheduler | 1.21.0 | |
| kube-proxy | 1.21.0 | |
| kubelet | 1.21.0 | |
| etcd | 3.3.15 | |
| calico | 3.3.1 | |
| docker | 18.06.3-ce | |
| coredns | 1.6.2 | |
| kubernets-dashboard | 1.10.1 | |
| traefik | 2.1.1 | |
| pause | 3.1 | |
| elasticsearch | 6.2.4 | |
| keepalived | 2.0.19-r0 | |
| Haproxy | 2.1.2 | |
| gluster | 4.0 | |
| heketi | 6.0 | |
| metrics-server | 0.2.0 | |
| node-problem-detector | 0.4.1 | |
| openvpn | 2.1 | |
| efk | 7.10.2 | |
| mysql | 8.0 | |
| redis | 5.0 | |
| rocketmq | 4.5.0 | |
| gw-proprietary-cloud | 0.1 | |
# 部署示意图
![k8s部署图](https://github.com/toyangdon/k8s_deploy/blob/master/kubernetes%20%E7%BB%84%E7%BB%87%E5%9B%BE.png?raw=true)
# 快速安装
1. 安装ansible
`yum install -y ansible`
2. 下载部署文件到部署节点的/etc/ansible目录下
`git clone –depth=1 https://git.trustie.net/toyangdon/proprietary-cloud-deploy.git`
将部署文件复制到/etc/ansible目录下
`cp -rf k8s_deploy/* /etc/ansible/`
3. 配置集群安装信息
**根据实际情况修改`hosts`文件**
`vi /etc/ansible/hosts`
4. 配置ssh免密码
`sh tools/ssh-key-copy.sh root ${passwd} #请输入实际的root用户密码`
5. 执行一键安装
**centos**
`ansible-playbook setup.yml`
**kylin v10 sp1**
`ansible-playbook -e 'ansible_python_interpreter=/usr/bin/python3.7' setup.yml`
**单机部署**
`ansible-playbook -e 'apiserver_mem_requests=100Mi' -e 'apiserver_cpu_requests=100m' setup.yml`
# 分步安装
`playbooks`目录提供分步安装的相关playbook,主要分为两大块`kubernetes`和`gpaas`
## `kubernetes` 部署
1. `ansible-playbook playbooks/kubernetes/00.check.yml` 检查集群服务器
1. `ansible-playbook playbooks/kubernetes/01.docker.yml` 在所有主机上安装并启动docker服务
2. `ansible-playbook playbooks/kubernetes/02.prepare.yml` 服务器通用配置,生成并分发集群所需相关证书
3. `ansible-playbook playbooks/kubernetes/03.harbor.yml` 部署harbor节点,安装并启动harbor服务(可选)
4. `ansible-playbook playbooks/kubernetes/04.lb.yml` 准备lb节点所需的相关安装文件,包括keepalived和haproxy
5. `ansible-playbook playbooks/kubernetes/05.kube-master.yml` 准备master节点所需的相关安装文件
6. `ansible-playbook playbooks/kubernetes/06.kube-node.yml` 在主机上安装并启动kubelet服务,先启动lb,再启动master,最后启动kube-node
7. `ansible-playbook playbooks/kubernetes/07.calico.yml` 在主机上准备calico服务所需要的相关安装文件(与flannel可选)
8. `ansible-playbook playbooks/kubernetes/07.flannel.yml` 在主机上准备flannel服务所需要的相关安装文件(与calico可选) (暂时不可用)
9. `ansible-playbook playbooks/kubernetes/09.storage-nfs.yml` 安装nfs服务(与gfs可选)(暂时不可用)
10. `ansible-playbook playbooks/kubernetes/10.storage-gluster.yml` 准备安装gfs服务
11. `ansible-playbook playbooks/kubernetes/20.addnode.yml` 新增节点
12. `ansible-playbook playbooks/kubernetes/30.addons.yml` kubernetes所有插件服务的部署,包括kube-proxy、kubedns、calico、glusterfs等等
13. `ansible-playbook playbooks/kubernetes/90.setup.yml` 一键安装kubernetes,即顺序执行以上所有步骤(除了20.addnode)
14. `ansible-playbook playbooks/kubernetes/99.clean.yml` 一键清理kubernetes集群(慎用)
## `gpass` 部署
目前分为`efk`和`monitor`二部分
### `efk` 部署
1. `ansible-playbook playbooks/gpaas/elk/01.es.yml` es部署
3. `ansible-playbook playbooks/gpaas/elk/02.fluentd.yml` fluentd
4. `ansible-playbook playbooks/gpaas/elk/03.kibana.yml` kibana部署
5. `ansible-playbook playbooks/gpaas/elk/90.setup.yml` 一键安装elk,即顺序执行以上所有步骤
### `monitor` 部署
1. `ansible-playbook playbooks/gpaas/monitor/01.prometheus.yml` prometheus部署
2. `ansible-playbook playbooks/gpaas/monitor/90.setup.yml` 一键安装监控平台,即顺序执行以上所有步骤
### 一键部署`gpass`
1. `ansible-playbook playbooks/gpaas/90.setup.yml`
## `专有云组件`部署
1. `ansible-playbook playbooks/proprietary-cloud/90.setup.yml`
# `ansible`容器化
1. 安装docker
`systemctl stop firewalld` #关闭防火墙
`sh tools/docker/install.sh`
2. 运行ansible镜像执行k8s安装
`/opt/k8s/bin/docker run --name ansible -it --privileged -v /root/k8s-install:/etc/ansible toyangdon/ansible:latest` #进入容器内执行ansible脚本

+ 82
- 0
hosts View File

@@ -0,0 +1,82 @@
[deploy]
localhost
#镜像仓库
[registry]
10.2.1.212
#节点配置
#管理节点
[kube-master]
10.2.1.212
10.2.1.170
10.2.1.148
#计算节点
[kube-compute-node]
#存储节点
[kube-storage-node]
10.2.1.212
10.2.1.170
[kube-node:children]
kube-compute-node
kube-storage-node
[kube-cluster:children]
kube-node
kube-master
lb
#代理节点
#多管理节点时必须配置有代理节点
#LB_ROLE:master、backup、lb_only,master\backup表示使用keepalived实现haproxy高可用,lb_only表示不使用keepalived
[lb]
10.2.1.212
10.2.1.170
[elasticsearch]
10.2.1.212
10.2.1.170
[mysql]
10.2.1.148
10.2.1.170
#openvpn服务,请另外创建一台虚拟机(4c8g)作为openvpn服务器,该虚拟机可用于暴露私有云内部网络,openvpnExternalIp表示服务器的外部IP,openvpnRouteCIDR表示需求经过vpn路由的ip范围
[openvpn]
10.2.1.224 openvpnExternalIp=10.2.1.224 openvpnRouteCIDR=10.2.1.0/16 ansible_ssh_user=root ansible_ssh_pass=Greatwall@123
# 预留组,后续添加node节点使用
[new-node]
[kube-cluster:vars]
ansible_python_interpreter=/usr/bin/python3
[all:vars]
#集群 MASTER IP 如果单master部署,则该值为master ip,如果多master部署,则改值为lb的vip
MASTER_IP="10.2.1.164"
#gfs磁盘设备名
gfs_device=/dev/sdb
zstackServerIP=10.1.1.9
zstackServerAdminUser=admin
zstackServerAdminPassword=Greatwall@123
#默认区域
defaultRegionCode=cn-cs-1
defaultRegionName=长沙一区
#专有云访问域名
gwcloudDomain=gwcloud.com
#专有云告警邮箱服务器
monitorEmailEnable=true
monitorEmailHost=mail.greatwall.com.cn
monitorEmailPort=465
monitorEmailUsername=hnck
monitorEmailFrom=hnck@greatwall.com.cn
monitorEmailPassword=Eghucn-91406

+ 5
- 0
setup.yml View File

@@ -0,0 +1,5 @@
- import_playbook: playbooks/kubernetes/90.setup.yml
- import_playbook: playbooks/gpaas/90.setup.yml
- import_playbook: playbooks/proprietary-cloud/90.setup.yml

+ 17
- 0
tmp View File

@@ -0,0 +1,17 @@
openssl genrsa -out ca.key 2048
openssl rsa -in ca.key -pubout -out ca_public.key
openssl req -newkey rsa:2048 -nodes -keyout ca.key -x509 -days 365 -out cacerts.pem -subj "/C=CN/ST=GD/L=SZ/O=example/OU=dev/CN=rancher.com"
openssl genrsa -out tls.key 2048
openssl req -new -key tls.key -passin pass:123456 -out tls.csr -subj "/C=CN/ST=GD/L=SZ/O=example/OU=dev/CN=rancher.com"
openssl x509 -req -days 3650 -in tls.csr -CA cacerts.pem -CAkey ca.key -CAcreateserial -out tls.crt
kubectl -n cattle-system create secret tls tls-rancher-ingress --cert=tls.crt --key=tls.key
kubectl -n cattle-system create secret generic tls-ca --from-file=cacerts.pem
helm install rancher rancher-stable/rancher --namespace cattle-system --set hostname=rancher.com --set ingress.tls.source=secret --set privateCA=true
openssl genrsa -out dashboard.key 2048
openssl req -new -out dashboard.csr -key dashboard.key -subj '/CN=10.10.101.201'
openssl x509 -req -in dashboard.csr -signkey dashboard.key -out dashboard.crt
kubectl -n kube-system create secret tls kubernetes-dashboard-certs --cert=dashboard.crt --key=dashboard.key

Loading…
Cancel
Save