kubeadmin安装k8s

master和node主机上安装相关软件

1、修改hostname(可选)

hostnamectl set-hostname master01
hostnamectl set-hostname node01

修改hosts,指定master01、node01

vi /etc/hosts

2、科学上网并提供代理(可选)

看我上一篇文章

3、安装

apt-get update && apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF


apt-get update
apt-get install -y kubelet kubeadm kubectl

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update

apt-get -y install docker-ce

4、额外配置(可选)

设置系统参数 - 允许路由转发,不对bridge的数据进行处理
#写入配置文件
cat <<EOF > /etc/sysctl.d/k8s.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

#生效配置文件
sysctl -p /etc/sysctl.d/k8s.conf
vi /lib/systemd/system/docker.service

  待docker安装完成,配置docker.service(每个节点)

  vi /lib/systemd/system/docker.service

#找到ExecStart=xxx,在这行上面加入一行,内容如下:(k8s的网络需要)
ExecStartPost=/sbin/iptables -I FORWARD -s 0.0.0.0/0 -j ACCEPT

 5、查看安装结果

docker version
systemctl status docker
docker run hello-world
kubeadm version
kubectl version
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
systemctl status kubelet

 master和node主机上部署

0、添加docker代理(可选)

 vim /lib/systemd/system/docker.service
[Service]
 
Environment="HTTP_PROXY=http://[proxy-addr]:[proxy-port]/" "HTTPS_PROXY=https://[proxy-addr]:[proxy-port]/"

systemctl daemon-reload
systemctl restart docker

1、inti msater

kubeadm init 

2、安装weave cni插件

kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"

3、join node

  kubeadm join <master-ip>:<master-port> --token <token> --discovery-token-ca-cert-hash sha256:<hash>

4、使用kubectl

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

5、安装dashboard 和heapster

#1、安装dashboard
https://github.com/kubernetes/dashboard
#2、获取token
https://github.com/kubernetes/dashboard/wiki/Creating-sample-user
#3、安装heapster
https://github.com/kubernetes-retired/heapster/blob/master/docs/influxdb.md

猜你喜欢

转载自www.cnblogs.com/renjunblog/p/10584476.html

相关文章