kubernetes install for centos

官方的文档写的很清楚

https://kubernetes.io/docs/getting-started-guides/centos/centos_manual_config/

如果已经安装过docker需要卸载

yum remove docker-engine

安装还是有冲突

[root@here ~]# rpm -aq | grep docker
docker-common-1.10.3-59.el7.centos.x86_64
[root@here ~]# yum remove docker…………

[root@here ~]# rpm -qa | grep container-selinux
container-selinux-1.10.3-59.el7.centos.x86_64


增加yum repo
修改/etc/yum.repos.d/virt7-docker-common-release.repo
[virt7-docker-common-release]
name=virt7-docker-common-release baseurl=http://cbs.centos.org/repos/virt7-docker-common-release/x86_64/os/ gpgcheck=0

安装组件
yum -y install --enablerepo=virt7-docker-common-release kubernetes etcd flannel

假设机器地址为
echo "192.168.121.9    centos-master
192.168.121.65    centos-minion-1
192.168.121.66  centos-minion-2
192.168.121.67  centos-minion-3" >> /etc/hosts


配置  /etc/kubernetes/config 同步到所有服务器
# logging to stderr means we get it in the systemd journal
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 replication controller and scheduler find the kube-apiserver KUBE_MASTER="--master=http://centos-master:8080"

关闭防火墙
setenforce 0
systemctl disable iptables-services firewalld
systemctl stop iptables-services firewalld

配置主节点etcd
/etc/etcd/etcd.conf
# [member]
ETCD_NAME=default
ETCD_DATA_DIR="/var/lib/etcd/default.etcd" ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379" #[cluster] ETCD_ADVERTISE_CLIENT_URLS="http://0.0.0.0:2379"

配置主节点 /etc/kubernetes/apiserver 
# The address on the local server to listen to.
KUBE_API_ADDRESS="--address=0.0.0.0"

# The port on the local server to listen on. KUBE_API_PORT="--port=8080" # Port kubelets listen on KUBELET_PORT="--kubelet-port=10250" # Comma separated list of nodes in the etcd cluster KUBE_ETCD_SERVERS="--etcd-servers=http://centos-master:2379" # Address range to use for services KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16" # Add your own! KUBE_API_ARGS=""

启动etcd
systemctl start etcd
etcdctl mkdir /kube-centos/network
etcdctl mk /kube-centos/network/config "{ \"Network\": \"172.30.0.0/16\", \"SubnetLen\": 24, \"Backend\": { \"Type\": \"vxlan\" } }"

配置所有机器的 /etc/sysconfig/flanneld

# Flanneld configuration options

# etcd url location.  Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="http://centos-master:2379" # etcd config key. This is the configuration key that flannel queries # For address range assignment FLANNEL_ETCD_PREFIX="/kube-centos/network" # Any additional options that you want to pass #FLANNEL_OPTIONS=""

主节点启动服务
for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler flanneld; do
    systemctl restart $SERVICES
    systemctl enable $SERVICES systemctl status $SERVICES done

启动api-server的时候报错
unable to load server certificate: open /var/run/kubernetes/apiserver.key: permission denied
修改了文件的全险为755可以通过

查看浏览器 https://master-ip:6443/swagger-ui

在胚胎机器上配置  /etc/kubernetes/kubelet
# The address for the info server to serve on
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 # Check the node number! KUBELET_HOSTNAME="--hostname-override=centos-minion-n" # Location of the api-server KUBELET_API_SERVER="--api-servers=http://centos-master:8080" # Add your own! KUBELET_ARGS=""

在节点上启动服务
for SERVICES in kube-proxy kubelet flanneld docker; do
    systemctl restart $SERVICES
    systemctl enable $SERVICES systemctl status $SERVICES done

配置 kubectl (配置一次即可 其他机器共享)
kubectl config set-cluster default-cluster --server=http://centos-master:8080
kubectl config set-context default-context --cluster=default-cluster --user=default-admin kubectl config use-context default-context

运行检查
$ kubectl get nodes
NAME                   LABELS            STATUS
centos-minion-1        <none>            Ready
centos-minion-2        <none>            Ready
centos-minion-3        <none>            Ready



 

转载于:https://www.cnblogs.com/xuchenCN/p/6755870.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值