kubernetes集群搭建(3):master节点安装

1.master节点上执行:

yum -y install kubernetes flannel etcd

2.修改etcd配置为:

[root@k8s-master ~]# vi /etc/etcd/etcd.conf 

ETCD_NAME=default
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"

3.修改apiserver配置为:

[root@k8s-master ~]# vi /etc/kubernetes/apiserver 

KUBE_API_ADDRESS="--address=0.0.0.0"
KUBE_API_PORT="--port=8080"
KUBELET_PORT="--kubelet_port=10250"
KUBE_ETCD_SERVERS="--etcd_servers=http://127.0.0.1:2379"
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"
KUBE_ADMISSION_CONTROL="--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"
KUBE_API_ARGS=""

注意:红色部分为后续创建service时,虚拟ip的地址范围

 

4.修改kubelet配置

[root@k8s-master ~]# vi /etc/kubernetes/kubelet 

###
# kubernetes kubelet (minion) config

# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)
KUBELET_ADDRESS="--address=0.0.0.0"

# The port for the info server to serve on
# KUBELET_PORT="--port=10250"

# You may leave this blank to use the actual hostname
KUBELET_HOSTNAME="--hostname-override=k8s-master"

# location of the api-server
KUBELET_API_SERVER="--api-servers=http://127.0.0.1:8080"

# pod infrastructure container
#KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=192.168.100.6:5000/rhel7/pod-infrastructure:1.0"

# Add your own!
KUBELET_ARGS="--cluster-dns=10.254.0.2 --cluster-domain=cluster.local"

注意:

1.  192.168.100.6:5000/rhel7/pod-infrastructure:1.0 为私库中的地址,默认配置文件中地址被和谐了,所以可以获取其他镜像源到本地私库

[root@localhost ~]# docker images |grep pod-infrastructure
127.0.0.1:5000/rhel7/pod-infrastructure                                  1.0                 adf142596532        8 months ago        206 MB
docker.io/jqka/pod-infrastructure                                        latest              adf142596532        8 months ago        206 MB

2. --cluster-dns=10.254.0.2 --cluster-domain=cluster.local

  # 10.254.0.2 为dns解析地址   和 第3步中的ip要在同一范围

  # cluster.local 集群的域名字,用在服务发现dns解析中

 

5. 修改kuberlet 配置信息

[root@k8s-master ~]# vi /etc/kubernetes/config 

KUBE_LOGTOSTDERR="--logtostderr=true"

# journal message level, 0 is debug
KUBE_LOG_LEVEL="--v=0"

# Should this cluster be allowed to run privileged docker containers
KUBE_ALLOW_PRIV="--allow-privileged=false"

# How the controller-manager, scheduler, and proxy find the apiserver
KUBE_MASTER="--master=http://k8s-master:8080"

6.启动服务并设置为开机启动

for SERVICES  in flanneld etcd docker kube-apiserver kube-controller-manager kube-scheduler;  do
    systemctl restart $SERVICES
    systemctl enable $SERVICES
    systemctl status $SERVICES -l
done

7.设置etcd网络信息,用于后续节点启动的容器ip分配

etcdctl mk /atomic.io/network/config '{"Network":"172.16.0.0/16"}'

8.测试是否成功(由于还没配置node节点,只要命令不报错就行,下面为我配置好节点后的输出

[root@k8s-master ~]# kubectl get nodes
NAME        STATUS    AGE
k8s-node1   Ready     11d
k8s-node2   Ready     11d

 

posted @ 2018-04-23 10:29  肖哥哥  阅读(1570)  评论(0编辑  收藏  举报
生命不息  奋斗不止  每天进步一点点