首页 > Web开发 > 详细

kubeadmin安装最新版本的kubenets

时间:2020-03-23 20:37:00      阅读:126      评论:0      收藏:0      [点我收藏+]

系统设置

CentOS Linux release 7.6.1810 (Core)

修改主机名

vim /etc/hostname k8s-master hostname -F /etc/hostname

设置本地解析

vim /etc/hosts 172.16.227.40 k8s-master

关闭及禁用防火墙

systemctl disable firewalld

systemctl stop firewalld

关闭selinux

sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config

设置启动参数

cat <<EOF > /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 EOF

sysctl --system

安装docker,kubeadm, kubelet and kubectl

安装docker

yum install -y yum-utils device-mapper-persistent-data lvm2

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

yum list docker-ce --showduplicates | sort -r

yum install docker

systemctl start docker systemctl enable docker

kubeadm, kubelet and kubectl

cat <<EOF > /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF

yum install -y kubelet kubeadm kubectl

systemctl enable kubelet && systemctl start kubelet

# 添加--image-repository参数,默认镜像下载会失败,

kubernetes-version与上面安装的kubelet版本对应一样

kubeadm init --kubernetes-version=???. --pod-network-cidr=10.244.0.0/16 --image-repository registry.aliyuncs.com/google_containers

设置kubectl命令

mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

sudo chown $(id -u):$(id -g) $HOME/.kube/config

安装pod network

wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

kubectl apply -f  kube-flannel.yml

执行上面命令出错时提示如下:

解决办法:

配置kubenetes的flannel网络的时候,出现以下报错

The connection to the server localhost:8080 was refused - did you specify the right host or port?

 

 

原因:kubenetes master没有与本机绑定,集群初始化的时候没有设置

解决办法:执行以下命令   export KUBECONFIG=/etc/kubernetes/admin.conf

/etc/kubernetes/admin.conf这个文件主要是集群初始化的时候用来传递参数的


这样默认安装好只有一个master节点
要想在主节点运行pods,还需要
 
5.0/1 nodes are available: 1 node(s) had taints that the pod didn‘t tolerate.

解决方法是安装flannel

有时候一个pod创建之后一直是pending,没有日志,也没有pull镜像,describe的时候发现里面有一句话: 1 node(s) had taints that the pod didn‘t tolerate.

直译意思是节点有了污点无法容忍,执行 kubectl get no -o yaml | grep taint -A 5 之后发现该节点是不可调度的。这是因为kubernetes出于安全考虑默认情况下无法在master节点上部署pod,于是用下面方法解决:

kubectl taint nodes --all node-role.kubernetes.io/master-
 

kubeadmin安装最新版本的kubenets

原文:https://www.cnblogs.com/allmdzz/p/12554811.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!