1. 程式人生 > >使用kubeadm一鍵部署kubernetes叢集

使用kubeadm一鍵部署kubernetes叢集


此連結中有kubeadm v1.10.3安裝 用了flannel網路 我使用calico網路

https://blog.csdn.net/nklinsirui/article/details/80602724
github地址
https://github.com/cookcodeblog/k8s-deploy

kubeadm_init.sh
#!/bin/bash

set -e


# Reset firstly if ran kubeadm init before
kubeadm reset


# kubeadm init with flannel network
export KUBE_REPO_PREFIX="registry.cn-shenzhen.aliyuncs.com/cookcodeblog"
export KUBE_ETCD_IMAGE="registry.cn-shenzhen.aliyuncs.com/cookcodeblog/etcd-amd64:3.1.12"
kubeadm init --kubernetes-version=v1.10.3 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.56.102


mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
cp -p $HOME/.bash_profile $HOME/.bash_profile.bak$(date '+%Y%m%d%H%M%S')
echo "export KUBECONFIG=$HOME/.kube/config" >> $HOME/.bash_profile
source $HOME/.bash_profile

pull_calico_images.sh
#!/bin/bash
set -e
# pull calico images
ETCD_VERSION=v3.1.10
NODE_VERSION=v3.0.8
CNI_VERSION=v2.0.6
KUB-CONTROLLERS_VERSION=v2.0.5

GCR_URL=quay.io/calico
CALICO_URL=calico

images=(etcd:${ETCD_VERSION}
node:${NODE_VERSION}
cni:${CNI_VERSION}
kube-controllers:${KUB-CONTROLLERS_VERSION})

for imageName in ${images[@]} ; do
  docker pull $CALICO_URL/$imageName
  docker tag  $CALICO_URL/$imageName $GCR_URL/$imageName
  docker rmi $CALICO_URL/$imageName
done

install_calico.sh
#!/bin/bash

set -e

wget https://docs.projectcalico.org/v3.0/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml
kubectl apply -f calico.yaml

# Wait a while to let network takes effect
sleep 10
kubectl get pods --all-namespaces


# Check component status
kubectl get cs

# Check pods status incase any pods are not in running status
kubectl get pods --all-namespaces


安裝calico

kubectl apply -f https://docs.projectcalico.org/v3.0/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml