- 关闭centos 自带的防火墙服务:
systemctl stop firewalld
systemctl disable firewalld
- 配置kubenetes 源
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[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
EOF
- 安装etcd kubenetes
以下操作会自动安装docker,如果已经安装docker,会报错,卸载重装即可
yum -y install etcd kubernetes-master
- 修改配置
安装好软件后,修改两个配置文件
(1)docker配置文件为 etc/sysconfig/docker,其中农OPTIONS的内容设置为:
OPTIONS ='--selinux-enabled=false --insecure-registry gcr.io'
(2)kubernetes apiserver 配置文件为/etc/kubernetes/apiserver,把--admission_control参数中的ServiceAccount删除。
- 按照顺序启动
systemctl start etcd
systemctl start docker
systemctl start kube-apiserver
systemctl start kube-controller-manager
systemctl start kube-scheduler
systemctl start kubelet
systemctl start kube-proxy
#设置开机启动
systemctl enable etcd
systemctl enable docker
systemctl enable kube-apiserver
systemctl enable kube-controller-manager
systemctl enable kube-scheduler
systemctl enable kubelet
systemctl enable kube-proxy
- 验证 kubectl version 显示如下信息说明安装成功
[root@hw k8s]# kubectl version
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"269f928217957e7126dc87e6adfa82242bfe5b1e", GitTreeState:"clean", BuildDate:"2017-07-03T15:31:10Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"269f928217957e7126dc87e6adfa82242bfe5b1e", GitTreeState:"clean", BuildDate:"2017-07-03T15:31:10Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
[root@hw k8s]# etcdctl cluster-health
member 8e9e05c52164694d is healthy: got healthy result from http://localhost:2379
cluster is healthy