安装Kube

安装Docker

yum install -y docker

加速Docker

DOCKER_MIRRORS="https://5md0553g.mirror.aliyuncs.com"
mkdir -p /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": ["${DOCKER_MIRRORS}"]
}
EOF

启动Docker

systemctl enable docker && systemctl start docker
如果在虚拟机中可能启动失败,需要修改
vi /etc/sysconfig/docker 修改 OPTIONS='--selinux-enabled=false ...

 

下载依赖镜像

GCR_HUB="gcr.io/google_containers"
QUAY_HUB="quay.io/coreos"
IMAGE_HUB=kingsylin

KUBE_VERSION=1.7.2
KUBE_PAUSE_VERSION=3.0
KUBE_CNI_VERSION=0.5.1
ETCD_VERSION=3.0.17
DNS_VERSION=1.14.4
FLANNEL_VERSION=v0.8.0

images=(kube-proxy-amd64:v${KUBE_VERSION}
kube-scheduler-amd64:v${KUBE_VERSION}
kube-controller-manager-amd64:v${KUBE_VERSION}
kube-apiserver-amd64:v${KUBE_VERSION}
pause-amd64:${KUBE_PAUSE_VERSION}
etcd-amd64:${ETCD_VERSION}
k8s-dns-sidecar-amd64:${DNS_VERSION}
k8s-dns-kube-dns-amd64:${DNS_VERSION}
k8s-dns-dnsmasq-nanny-amd64:${DNS_VERSION})
for imageName in ${images[@]} ; do
    docker pull $IMAGE_HUB/$imageName
    docker tag $IMAGE_HUB/$imageName $GCR_HUB/$imageName
    docker rmi $IMAGE_HUB/$imageName
done

images=(flannel:${FLANNEL_VERSION}-amd64)
for imageName in ${images[@]} ; do
    docker pull $IMAGE_HUB/$imageName
    docker tag $IMAGE_HUB/$imageName  $QUAY_HUB/$imageName
    docker rmi $IMAGE_HUB/$imageName
done

 

 设置安装源

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

安装kubeadm,kubelet和kubectl

KUBE_VERSION=1.7.2
KUBE_CNI_VERSION=0.5.1
setenforce 0
yum install --enablerepo=kubernetes -y kubernetes-cni-${KUBE_CNI_VERSION} kubelet-${KUBE_VERSION} kubectl-${KUBE_VERSION} kubeadm-${KUBE_VERSION}

RHEL / CentOS 7上的某些用户报告了由于iptables被绕过而导致流量被错误路由的问题。您应该确保net.bridge.bridge-nf-call-iptables在您的sysctl配置中设置为1 ,例如

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

配置Kubeadm

sed -i "s/cgroup-driver=systemd/cgroup-driver=cgroupfs/g" /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

重新启动kubelet

systemctl enable kubelet && systemctl start kubelet

 参考资料

https://kubernetes.io/docs/setup/independent/install-kubeadm/#master-nodes

posted @ 2018-04-12 21:50  kingsy.lin  阅读(162)  评论(0编辑  收藏  举报