1. 关闭selinux和防火墙
2. 网络配置
* `modprobe br_netfilter`
* `echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables`
* `sysctl -w net.ipv4.ip_forward=1`
3. 配置ssh免登陆`ssh-keygen`.`ssh-copy-id`
4. 修改`Download URLs`和官方 images 地址
5. 上传kubeadm,hyperkube等资源到/root/目录下
6. 生成inventory文件
* `cp -r inventory/sample inventory/my`
* `declare -a IPS=(10.10.2.56)`
* `CONFIG_FILE=inventory/my/hosts.ini python3 contrib/inventory_builder/inventory.py ${IPS[@]}`
7. ansible-playbook -i inventory cluster.yml
## 修改官方镜像
```
#!/bin/bash
all_image_files=(
roles/download/defaults/main.yml
roles/kubernetes-apps/ansible/defaults/main.yml
)
for file in ${all_image_files[@]} ; do
sed -i 's/gcr.io\/google-containers\//ottodeng\/gcr.io_google-containers_/g' $file
sed -i 's/gcr.io\/google_containers\//ottodeng\/gcr.io_google_containers_/g' $file
sed -i 's/quay.io\/coreos\//ottodeng\/quay.io_coreos_/g' $file
sed -i 's/quay.io\/calico\//ottodeng\/quay.io_calico_/g' $file
sed -i 's/quay.io\/external_storage\//ottodeng\/quay.io_external_storage_/g' $file
sed -i 's/quay.io\/kubespray\//ottodeng\/quay.io_kubespray_/g' $file
sed -i 's/quay.io\/kubernetes-ingress-controller\//ottodeng\/quay.io_kubernetes-ingress-controller_/g' $file
done
```
```
chmod +x change_registry.sh
./change_registry.sh
```
## 修改Download URLs
```
# Download URLs
# kubeadm_download_url: "https://storage.googleapis.com/kubernetes-release/release/{{ kubeadm_version }}/bin/linux/{{ image_arch }}/kubeadm"
# vault_download_url: "https://releases.hashicorp.com/vault/{{ vault_version }}/vault_{{ vault_version }}_linux_{{ image_arch }}.zip"
# etcd_download_url: "https://github.com/coreos/etcd/releases/download/{{ etcd_version }}/etcd-{{ etcd_version }}-linux-amd64.tar.gz"
# hyperkube_download_url: "https://storage.googleapis.com/kubernetes-release/release/{{ kube_version }}/bin/linux/amd64/hyperkube"
kubeadm_download_url: "file:///root/kubeadm"
vault_download_url: "file:///root/vault_{{ vault_version }}_linux_{{ image_arch }}.zip"
etcd_download_url: "file:///root/etcd-{{ etcd_version }}-linux-amd64.tar.gz"
hyperkube_download_url: "file:///root/hyperkube"
```