### 安装git并clone官方安装脚本 yum install git -y kube_version=v1.15.1 if [ ! -d kubespray ]; then git clone https://github.com/kubernetes-sigs/kubespray cd kubespray git checkout release-2.11 cd - fi
cd kubespray if [ ! -d inventory/mycluster ]; then cp -r inventory/sample inventory/mycluster fi
### 更新pip及安装依赖 if [ "$1" = "-U" ]; then easy_install pip pip install pip==8.0.3 pip uninstall requests pip install -U pip pip install -U setuptools pip install -r requirements.txt fi
################### 若不事先准备改好的文件,可使用以下命令修改: ### 改版本号 sed -i "s/^kube_version:.*$/kube_version: $kube_version/" roles/kubespray-defaults/defaults/main.yaml sed -i "s/^kube_version:.*$/kube_version: $kube_version/" roles/download/defaults/main.yml sed -i "s/^kube_version:.*$/kube_version: $kube_version/" inventory/mycluster/group_vars/k8s-cluster/k8s-cluster.yml
### 改镜像源 kube_image_repo=mirrorgooglecontainers sed -i "s/^kube_image_repo:.*$/kube_image_repo: $kube_image_repo/" inventory/mycluster/group_vars/k8s-cluster/k8s-cluster.yml
sed -i "s/^kube_image_repo:.*$/kube_image_repo: $kube_image_repo/" roles/download/defaults/main.yml sed -i "s/k8s.gcr.io/$kube_image_repo/g" roles/download/defaults/main.yml sed -i "s#gcr.io/google_containers#$kube_image_repo#g" roles/download/defaults/main.yml sed -i "s/gcr.io/$kube_image_repo/g" roles/download/defaults/main.yml sed -i "s#(k8s.)?gcr.io(/google_containers)?#$kube_image_repo#g" roles/download/defaults/main.yml
#nodelocaldns_version: 1.15.1 nodelocaldns_image_repo=lzzeng/k8s-dns-node-cache sed -i 's#^nodelocaldns_image_repo:.*$'"#nodelocaldns_image_repo: $nodelocaldns_image_repo#" roles/download/defaults/main.yml
### 改二进制文件下载地址 download_url=http://192.168.100.150/k8s/$kube_version sed -i 's#^kubeadm_download_url:.*$#kubeadm_download_url: '\""$download_url"'/kubeadm\"#' roles/download/defaults/main.yml sed -i 's#^hyperkube_download_url:.*$#hyperkube_download_url: '\""$download_url"'/hyperkube\"#' roles/download/defaults/main.yml sed -i 's#^calicoctl_download_url:.*$#calicoctl_download_url: '\""$download_url"'/calicoctl-linux-amd64\"#' roles/download/defaults/main.yml #1.15.1 使用 3.7.3 sed -i 's#^etcd_download_url:.*$#etcd_download_url: '\""$download_url"'/etcd-v3.3.10-linux-amd64.tar.gz\"#' roles/download/defaults/main.yml #1.15.1 使用 v3.3.10 sed -i 's#^cni_download_url:.*$#cni_download_url: '\""$download_url"'/cni-plugins-linux-amd64-v0.8.1.tgz\"#' roles/download/defaults/main.yml #1.15.1 使用 v0.8.1 sed -i 's#^crictl_download_url:.*$#crictl_download_url: '\""$download_url"'/critest-v1.15.0-linux-amd64.tar.gz\"#' roles/download/defaults/main.yml #1.15.1 使用 v1.15.0