上次实践了用minikube安装kubernetes,安装是成功了,但创建容器实例时不行,于是又找了其它自动化安装kubernetes的方法,没有一个顺的,最后狠下心来自己手动安装,
先安装docker环境,
apt-get update,
apt-get install apt-transport-https ca-certificates curl software-properties-common,
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -,
apt-key fingerprint 0EBFCD88,
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable",
apt-get update,
apt-get install docker-ce,
然后安装kubernetes环境,
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -,
vim /etc/apt/sources.list.d/kubernetes.list,
apt-get update,
apt-get install -y kubelet kubeadm kubernetes-cni,
关闭swap,swapoff -a,
初始化,
kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=127.0.0.1,
切换到普通用户,ubuntu/ubuntu,
mkdir -p $HOME/.kube,
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config,
sudo chown $(id -u):$(id -g) $HOME/.kube/config,
让控制节点也能当计算节点,
配置网络,
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml,
kubectl create -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml,
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml,
检查系统状态,
kubectl get all --namespace=kube-system,
创建测试容器,
kubectl create -f https://raw.githubusercontent.com/sverrirab/kube-test-container/master/kubernetes/kube-test-container.yaml,
领取专属 10元无门槛券
私享最新 技术干货