5 (阿坝师范高等专科学校)

历史公告

  • 来自牧羊人 发布于 2019-12-20 18:18
    0000
  • 来自牧羊人 发布于 2019-12-20 18:16
    K8S集群安装部署 sspa 2019.08.26 15:36:34 字数 305 阅读 599 参考地址:https://www.cnblogs.com/xkops/p/6169034.html 1. 确保系统已经安装epel-release源 # yum -y install epel-release 2. 关闭防火墙服务和selinx,避免与docker容器的防火墙规则冲突 # systemctl stop firewalld # systemctl disable firewalld # setenforce 0 3. 安装配置Kubernetes Master 3.1 使用yum安装etcd和kubernetes-master # yum -y install etcd kubernetes-master node:在安装etcd之前确保 /etc/hosts 下的配置正确。 3.2 编辑 /etc/etcd/etcd.conf 文件 ETCD_NAME=default # 默认名称 ETCD_DATA_DIR="/var/lib/etcd/default.etcd" # 默认etcd数据目录 ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379" # 主要0.0.0.0为监听的网卡地址,不要乱改 ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379" # 连接的etc地址,本文是单机版的etcd,不用改变 3.3 编辑 /etc/kubernetes/apiserver 文件 KUBE_API_ADDRESS="--insecure-bind-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="" 3.4 启动 etcd, kube-apiserver, kube-controller-manager, kube-scheduler 等服务,并设置开机启动。 # for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do systemctl restart $SERVICES;systemctl enable $SERVICES;systemctl status $SERVICES ; done 注意:如果服务启动失败请运行 cat /usr/lib/systemd/system/$SERVICES 命令注意如下字段的信息提示: [Service] WorkingDirectory=/var/lib/kubelet EnvironmentFile=-/etc/kubernetes/config EnvironmentFile=-/etc/kubernetes/kubelet ExecStart=/usr/bin/kubelet \ $KUBE_LOGTOSTDERR \ $KUBE_LOG_LEVEL \ $KUBELET_API_SERVER \ $KUBELET_ADDRESS \ $KUBELET_PORT \ $KUBELET_HOSTNAME \ $KUBE_ALLOW_PRIV \ $KUBELET_POD_INFRA_CONTAINER \ $KUBELET_ARGS Restart=on-failure 对比各个参数配置,查找问题。 3.5 在etcd中定义flannel网络 # etcdctl mk /atomic.io/network/config '{"Network":"172.17.0.0/16"}' 4. 安装配置Kubernetes Node 4.1 使用yum安装flannel和kubernetes-node # yum -y install flannel kubernetes-node 4.2 为flannel网络指定etcd服务,修改 /etc/sysconfig/flanneld 文件 FLANNEL_ETCD="http://master:2379" # master地址 FLANNEL_ETCD_KEY="/atomic.io/network" 4.3 修改 /etc/kubernetes/config 文件 KUBE_LOGTOSTDERR="--logtostderr=true" KUBE_LOG_LEVEL="--v=0" KUBE_ALLOW_PRIV="--allow-privileged=false" KUBE_MASTER="--master=http://master:8080"# master地址 4.4 按照如下内容修改对应node的配置文件/etc/kubernetes/kubelet KUBELET_ADDRESS="--address=0.0.0.0" KUBELET_PORT="--port=10250" KUBELET_HOSTNAME="--hostname-override=node" #修改成对应Node的IP KUBELET_API_SERVER="--api-servers=http://master:8080" #指定Master节点的API Server KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest" KUBELET_ARGS="" 4.5 在所有Node节点上启动 kube-proxy,kubelet,docker,flanneld 等服务,并设置开机启动。 # for SERVICES in kube-proxy kubelet docker flanneld;do systemctl restart $SERVICES;systemctl enable $SERVICES;systemctl status $SERVICES; done 5. 验证集群是否安装成功 在master上执行如下命令: # kubectl get node