k8s集群部署
部署节点 pikachu1,192.168.146.151master(node) pikachu2,192.168.146.152node1 pikachu3,192.168.146.153node3 pikachu4,192.168.146.154部署节点#wget download.yunwei.edu/shell/yum-repo.sh#bash yum-re...
部署节点 pikachu1,192.168.146.151
master(node) pikachu2,192.168.146.152
node1 pikachu3,192.168.146.153
node3 pikachu4,192.168.146.154
部署节点
#wget download.yunwei.edu/shell/yum-repo.sh
#bash yum-repo.sh
下载安装docker
#wget http://download2.yunwei.edu/shell/docker.tar.gz
#tar zxvf docker.tar.gz
#cd docker/
#sh docker.sh
#systemctl status docker
#docker images
下载docker版ansible
#docker pull reg.yunwei.edu/learn/ansible:alpine3
#docker run -itd -v /etc/ansible:/etc/ansible -v /etc/kubernetes/:/etc/kubernetes/ -v /root/.kube:/root/.kube -v /usr/local/bin/:/usr/local/bin/ --name ansible 1acb4fd5df5b /bin/sh
配置域名解析和无秘钥登录
下载kubernetes安装包
#wget http://download2.yunwei.edu/shell/kubernetes.tar.gz
#tar zxvf kubernetes.tar.gz
#cd kubernetes/
#tar zxvf kube-yunwei-197.tar.gz
#cd kube-yunwei-197/
#mv * /etc/ansible
#tar zxvf k8s197.tar.gz
#cd bin/
#mv * /etc/ansible/bin
#cd /etc/ansible
#cd example/
#cp hosts.s-master.example ../hosts
#vim hosts
# 部署节点:运行ansible 脚本的节点
[deploy]
192.168.146.151# etcd集群请提供如下NODE_NAME、NODE_IP变量,请注意etcd集群必须是1,3,5,7...奇数个节点
[etcd]
192.168.146.154 NODE_NAME=etcd1 NODE_IP="192.168.146.154"
192.168.146.152 NODE_NAME=etcd2 NODE_IP="192.168.146.152"
192.168.146.153 NODE_NAME=etcd3 NODE_IP="192.168.146.153"[kube-master]
192.168.146.152 NODE_IP="192.168.146.152"[kube-node]
192.168.146.152 NODE_IP="192.168.146.152"
192.168.146.153 NODE_IP="192.168.146.153"
192.168.146.154 NODE_IP="192.168.146.154"[all:vars]
# ---------集群主要参数---------------
#集群部署模式:allinone, single-master, multi-master
DEPLOY_MODE=single-master#集群 MASTER IP
MASTER_IP="192.168.146.152"#集群 APISERVER
KUBE_APISERVER="https://192.168.146.152:6443"#TLS Bootstrapping 使用的 Token,使用 head -c 16 /dev/urandom | od -An -t x | tr -d ' ' 生成
BOOTSTRAP_TOKEN="d18f94b5fa585c7123f56803d925d2e7"# 集群网络插件,目前支持calico和flannel
CLUSTER_NETWORK="calico"# 部分calico相关配置,更全配置可以去roles/calico/templates/calico.yaml.j2自定义
# 设置 CALICO_IPV4POOL_IPIP=“off”,可以提高网络性能,条件限制详见 05.安装calico网络组件.md
CALICO_IPV4POOL_IPIP="always"
# 设置 calico-node使用的host IP,bgp邻居通过该地址建立,可手动指定端口"interface=eth0"或使用如下自动发现
IP_AUTODETECTION_METHOD="can-reach=223.5.5.5"# 部分flannel配置,详见roles/flannel/templates/kube-flannel.yaml.j2
FLANNEL_BACKEND="vxlan"# 服务网段 (Service CIDR),部署前路由不可达,部署后集群内使用 IP:Port 可达
SERVICE_CIDR="10.68.0.0/16"# POD 网段 (Cluster CIDR),部署前路由不可达,**部署后**路由可达
CLUSTER_CIDR="172.20.0.0/16"# 服务端口范围 (NodePort Range)
NODE_PORT_RANGE="20000-40000"# kubernetes 服务 IP (预分配,一般是 SERVICE_CIDR 中第一个IP)
CLUSTER_KUBERNETES_SVC_IP="10.68.0.1"# 集群 DNS 服务 IP (从 SERVICE_CIDR 中预分配)
CLUSTER_DNS_SVC_IP="10.68.0.2"# 集群 DNS 域名
CLUSTER_DNS_DOMAIN="cluster.local."# etcd 集群间通信的IP和端口, **根据实际 etcd 集群成员设置**
ETCD_NODES="etcd1=https://192.168.146.152:2380,etcd2=https://192.168.146.153:2380,etcd3=https://192.168.146.154:2380"# etcd 集群服务地址列表, **根据实际 etcd 集群成员设置**
ETCD_ENDPOINTS="https://192.168.146.152:2379,https://192.168.146.153:2379,https://192.168.146.154:2379"# 集群basic auth 使用的用户名和密码
BASIC_AUTH_USER="admin"
BASIC_AUTH_PASS="admin"# ---------附加参数--------------------
#默认二进制文件目录
bin_dir="/usr/local/bin"#证书目录
ca_dir="/etc/kubernetes/ssl"#部署目录,即 ansible 工作目录
base_dir="/etc/ansible"
#docker exec -it ansible /bin/sh
/ #ansible all -m ping
在容器中添加域名解析、无秘钥登录
/ #ssh-keygen
/ #ssh-copy-id ~
/ #ansible all -m ping
/ #cd /etc/ansible
#ansible-playbook 01.prepare.yml
#ansible-playbook 02.etcd.yml
#ansible-playbook 03.docker.yml
#ansible-playbook 04.kube-master.yml
#ansible-playbook 05.kube-node.yml
在安装网络之前把images.tar.gz拷贝到其他节点,解压
pikachu2,3,4
#cd images
#mv *.tar calico
#mv *.gz calico
#for i in `ls`;do docker load -i $i;done
#ansible-playbook 06.network.yml
容器外
#kubectl get node
#kubectl get namespace
#kubectl get pod -n kube-system
#kubectl get pod -n kube-system -o wide
部署节点ansible容器里
#cd /etc/ansible/manifests/
#cd coredns/
#kubectl create -f .
#cd ..
#cd dashboard/
#kubectl create -f .
生成token
#kubectl -n kube-system describe secret $(kubectl -n kube-system get secret|grep admin-user|awk '{print $1}')
更多推荐
所有评论(0)