Bootstrap

kubernetes简易安装

一键安装脚本
此脚本针对centos7,需要服务器能够连接网络。国内服务器均可使用。运行后根据提示输入本机ip即可,如果输入错误直接ctrl+c即可

以下是手动安装过程和解释
1.安装docker,需要确保安装的版本为1.12
yum -y install docker
2.配置kubernetes源,采用aliyun

vim /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
       http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

3.配置docker加速器

vim /etc/docker/daemon.json
{
  "registry-mirrors": ["https://dhq9bx4f.mirror.aliyuncs.com"]
}

4.安装并启动相关组件
yum -y install kubelet kubeadm kubectl kubernetes-cni
systemctl enable docker && systemctl start docker
systemctl enable kubelet && systemctl start kubelet

5.从国内预下载镜像,并更名为gcr.io/google_containers/是为了让kubeadm可以识别并直接使用。

docker pull warrior/pause-amd64:3.0
docker tag warrior/pause-amd64:3.0 gcr.io/google_containers/pause-amd64:3.0

docker pull warrior/etcd-amd64:3.0.17
docker tag warrior/etcd-amd64:3.0.17 gcr.io/google_containers/etcd-amd64:3.0.17

docker pull warrior/kube-apiserver-amd64:v1.6.0
docker tag warrior/kube-apiserver-amd64:v1.6.0 gcr.io/google_containers/kube-apiserver-amd64:v1.6.0

docker pull warrior/kube-scheduler-amd64:v1.6.0
docker tag warrior/kube-scheduler-amd64:v1.6.0 gcr.io/google_containers/kube-scheduler-amd64:v1.6.0

docker pull warrior/kube-controller-manager-amd64:v1.6.0
docker tag warrior/kube-controller-manager-amd64:v1.6.0 gcr.io/google_containers/kube-controller-manager-amd64:v1.6.0

docker pull warrior/kube-proxy-amd64:v1.6.0
docker tag warrior/kube-proxy-amd64:v1.6.0 gcr.io/google_containers/kube-proxy-amd64:v1.6.0

docker pull gysan/dnsmasq-metrics-amd64:1.0
docker tag gysan/dnsmasq-metrics-amd64:1.0 gcr.io/google_containers/dnsmasq-metrics-amd64:1.0

docker pull warrior/k8s-dns-kube-dns-amd64:1.14.4
docker tag warrior/k8s-dns-kube-dns-amd64:1.14.4 gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.4

docker pull warrior/k8s-dns-dnsmasq-nanny-amd64:1.14.1
docker tag warrior/k8s-dns-dnsmasq-nanny-amd64:1.14.1 gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.1

docker pull warrior/k8s-dns-sidecar-amd64:1.14.1
docker tag warrior/k8s-dns-sidecar-amd64:1.14.1 gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.1

docker pull awa305/kube-discovery-amd64:1.0
docker tag awa305/kube-discovery-amd64:1.0 gcr.io/google_containers/kube-discovery-amd64:1.0

docker pull gysan/exechealthz-amd64:1.2
docker tag gysan/exechealthz-amd64:1.2 gcr.io/google_containers/exechealthz-amd64:1.2

6.使用kubeadm安装kubernetes
kubeadm init –kubernetes-version=v1.6.0

7.复制admin.conf到家目录,这样才能使用kubectl
cp /etc/kubernetes/admin.conf /root/
echo “export KUBECONFIG=/root/admin.conf” >> /root/.bash_profile
source /root/.bash_profile

8.将主节点加入集群并设置可用于容器分配。默认跳过即可
kubeadm join –token a80cf9.ef28a3838f387ca1 192.168.1.1:6443
kubeadm kubectl taint nodes –all node-role.kubernetes.io/master-

9.安装网络插件
kubectl apply -f https://git.io/weave-kube-1.6

;