我是靠谱客的博主 乐观歌曲,最近开发中收集的这篇文章主要介绍kubeadm安装一个master多个node的集群使用kubeadm安装master节点将Node节点加入集群最后注意,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

使用kubeadm安装master节点

1.基本配置准备

# swapoff-关闭swap
swapoff -a
sed -ri "/swap/s@(.*)@#/&@g" /etc/fstab
# Firewall limit-开放默认iptables规则
echo -e
"net.bridge.bridge-nf-call-ip6tables = 1nnet.bridge.bridge-nf-call-iptables = 1nnet.ipv4.ip_forward = 1"
>> /etc/sysctl.conf
sysctl -p
#disabled selinux-关闭selinux
echo "SELINUX=disabled" > /etc/selinux/config

2.安装dokcer

#install-docker
apt update && apt-get -y
install apt-transport-https
ca-certificates
curl
gnupg2 software-properties-common && curl -fsSL https://download.docker.com/linux/debian/gpg |
apt-key add - && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian
$(lsb_release -cs)
stable" && apt-get update &&
apt update && apt-get -y install docker-ce=17.06.0~ce-0~debian

3.安装 kube工具

#install kubectl kubelet kubeadm 版本为 1.12.2
apt-get update && apt-get install -y apt-transport-https curl && curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg |apt-key add -
&& echo "deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main"
>>/etc/apt/sources.list.d/kubernetes.list
&& apt update && apt-get install -y kubelet=1.12.2-00
kubeadm kubectl=1.12.2-00

4.下载需要的镜像

# image pull&tag
images=(
kube-apiserver:v1.12.2
kube-controller-manager:v1.12.2
kube-scheduler:v1.12.2
kube-proxy:v1.12.2
pause:3.1
etcd:3.2.24
coredns:1.2.2
pause-amd64:3.1
kubernetes-dashboard-amd64:v1.10.0
heapster-amd64:v1.5.4
heapster-grafana-amd64:v5.0.4
heapster-influxdb-amd64:v1.5.2
)
for imageName in ${images[@]} ; do
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/$imageName
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/$imageName k8s.gcr.io/$imageName
done

5.配置kebelet的 cgroups和image-repo-mirror

# set image-repo-mirror&cgroups
docker info | grep -i cgroup
echo 'KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs --pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0"' >/etc/default/kubelet

6.初始化 kubeadm init

kubeadm init --kubernetes-version=v1.12.2 --apiserver-advertise-address=10.17.40.80
--pod-network-cidr=192.168.0.0/16

7.赋予当前用户 使用kubectl的权限

	mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

8.安装calico(calico-官网)

kubectl apply -f
https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml
kubectl apply -f
https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/kubernetes-datastore/calico-networking/1.7/calico.yaml

将Node节点加入集群

1.基本配置准备

#forward
echo -e
"net.bridge.bridge-nf-call-ip6tables = 1nnet.bridge.bridge-nf-call-iptables = 1nnet.ipv4.ip_forward = 1"
>> /etc/sysctl.conf
sysctl -p
# disabled swap
swapoff -a
sed -ri "/swap/s@(.*)@#/&@g" /etc/fstab
#disabled selinux
echo "SELINUX=disabled" > /etc/selinux/config

2.安装docker

#install docker
apt update && apt-get -y
install
apt-transport-https
ca-certificates
curl
gnupg2
software-properties-common && curl -fsSL https://download.docker.com/linux/debian/gpg |
apt-key add - && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian
$(lsb_release -cs)
stable" && apt-get update && apt-cache madison docker-ce && apt update && apt-get -y install docker-ce=17.06.0~ce-0~debian

3.安装kebelet,kubeadm ,kubectl

# install kubectl kubelet kubeadm 版本为 1.12.2
apt-get update && apt-get install -y apt-transport-https curl
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg |apt-key add -
echo "deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main"
>>/etc/apt/sources.list.d/kubernetes.list
apt update
apt-get install -y kubelet=1.12.2-00
kubeadm kubectl=1.12.2-00

4.下载 kube-proxy image到本地,并重新tag

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.12.2
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.12.2
k8s.gcr.io/kube-proxy:v1.12.2

5.配置kebelet的 cgroups和image-repo-mirror

# set image-repo-mirror&cgroups
docker info | grep -i cgroup
echo 'KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs --pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0"' >/etc/default/kubelet

6.将node节点加入集群

kubeadm join 10.17.40.80:6443 --token qirpum.xiuhtnvipabkqx0q --discovery-token-ca-cert-hash sha256:e2d82dfe71516cbcd64764737e3f20ecf149d2bece14d2befd84b3b16f61bd27

最后注意

1.一定要注意 关闭selinux,打开forward转发

2.若希望建立 多个kube-master构成的集群

	在第一个master进行初始化时,就要指定所有的master-etcd-endpoint
并安装使用反向代理 负载 master集群;加入node节点时,指定的master-IP为反向代理IP

3.若要使用 kubectl命令,需要对此用户执行以下操作

	mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

最后

以上就是乐观歌曲为你收集整理的kubeadm安装一个master多个node的集群使用kubeadm安装master节点将Node节点加入集群最后注意的全部内容,希望文章能够帮你解决kubeadm安装一个master多个node的集群使用kubeadm安装master节点将Node节点加入集群最后注意所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部