• 在CentOS7上部署 Kubernetes集群


    yum -y install  etcd docker  flannel kubenetes

    一般会遇到没有k8s源的问题,先 yum update -y 看是否有效,如果还是没用就创建yum 源,再安装 kubenetes

    如下操作:

    创建yum源

    vi  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

    安装服务

    执行以下命令,安装kubernetes

    yum -y install --enablerepo=virt7-docker-common-release kubernetes 

    接下来开始部署:

    设置三台机器的主机名:

      Master上执行:

    [root@localhost ~]#  hostnamectl --static set-hostname  k8s-master

      Node1上执行:

    [root@localhost ~]# hostnamectl --static set-hostname  k8s-node-1

      Node2上执行:

    [root@localhost ~]# hostnamectl --static set-hostname  k8s-node-2

    禁用防火墙(所有机器)

    systemctl disable  firewalld.services
    systemctl stop  firewalld.services


    启动 etcd docker  flannel 服务:
    1、先启动etcd:
    systemctl enable etcd.service
    systemctl start etcd.service

    2 配置Flannel

      master、node上均编辑/etc/sysconfig/flanneld,修改红色部分

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

    3 配置etcd中关于flannel的key

      Flannel使用Etcd进行配置,来保证多个Flannel实例之间的配置一致性,所以需要在etcd上进行如下配置:(‘/atomic.io/network/config’这个key与上文/etc/sysconfig/flannel中的配置项FLANNEL_ETCD_PREFIX是相对应的,错误的话启动就会出错)

    [root@k8s-master ~]# etcdctl mk /atomic.io/network/config '{ "Network": "10.0.0.0/16" }'
    { "Network": "10.0.0.0/16" }

    4 启动

      启动Flannel之后,需要依次重启docker

      在master执行:

    systemctl enable flanneld.service 
    systemctl start flanneld.service 
    service docker restart

      在node上执行:

    systemctl enable flanneld.service 
    systemctl start flanneld.service 
    service docker restart

    在master节点配置etcd

    yum安装的etcd默认配置文件在/etc/etcd/etcd.conf。编辑配置文件,更改以下带颜色部分信息:

    
    # [member]
    ETCD_NAME=master
    ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
    #ETCD_WAL_DIR=""
    #ETCD_SNAPSHOT_COUNT="10000"
    #ETCD_HEARTBEAT_INTERVAL="100"
    #ETCD_ELECTION_TIMEOUT="1000"
    #ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380"
    ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379,http://0.0.0.0:4001"
    #ETCD_MAX_SNAPSHOTS="5"
    #ETCD_MAX_WALS="5"
    #ETCD_CORS=""
    #
    #[cluster]
    #ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380"
    # if you use different ETCD_NAME (e.g. test), set ETCD_INITIAL_CLUSTER value for this name, i.e. "test=http://..."
    #ETCD_INITIAL_CLUSTER="default=http://localhost:2380"
    #ETCD_INITIAL_CLUSTER_STATE="new"
    #ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
    ETCD_ADVERTISE_CLIENT_URLS="http://etcd:2379,http://etcd:4001"
    #ETCD_DISCOVERY=""
    #ETCD_DISCOVERY_SRV=""
    #ETCD_DISCOVERY_FALLBACK="proxy"
    #ETCD_DISCOVERY_PROXY=""

    在master节点配置kubernetes服务

    1.修改文件/etc/kubernetes/config(所有节点)

    注意,master和slave主机都要修改 
    指定master主机的ip,文件内容如下:

    $ cat /etc/kubernetes/config
    
    
    KUBE_LOGTOSTDERR="--logtostderr=true"
    
    KUBE_LOG_LEVEL="--v=0"
    
    KUBE_ALLOW_PRIV="--allow-privileged=false"
    
    KUBE_MASTER="--master=http://master:8080"

    1.修改配置文件/etc/etcd/etcd.conf,确保etcd监听所有地址。内容如下:

    $ cat /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"

    2.修改配置文件/etc/kubernetes/apiserver

    cat /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,ResourceQuota"
    
    KUBE_API_ARGS=""

    3.修改配置文件/etc/kubernetes/controller-manager,定义slave主机ip地址

    KUBELET_ADDRESSES="--machines=master地址"
     

    在master主机上,启动服务

    执行如下命令,批量启动服务

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

    slave节点配置

    注意:slave节点主机,同样要安装docker,flannel ,k8s

    yum 安装kubernetes

    yum -y install flannel docker

    yum -y install --enablerepo=virt7-docker-common-release kubernetes

    1.修改kubernetes配置文件,指定master。

    $ cat /etc/kubernetes/config
    
    KUBE_MASTER="--master=http://master:8080"

    2.配置kubelet服务。

    $ cat /etc/kubernetes/kubelet
    
    
    KUBELET_ADDRESS="--address=0.0.0.0"
    
    KUBELET_PORT="--port=10250"
    
    KUBELET_HOSTNAME="--hostname-override=node自身"
    
    KUBELET_API_SERVER="--api-servers=http://master:8080"

    在slave主机上,启动服务

    for SERVICES in kube-proxy kubelet docker flanneld; do
        systemctl restart $SERVICES
        systemctl enable $SERVICES
        systemctl status $SERVICES
    done

    验证

    现在登陆master,确认slave的状态

    $ kubectl get nodes
    
    NAME           LABELS                                STATUS    AGE
    10.16.93.182   kubernetes.io/hostname=node1   Ready     1h

    这样就配置完成了
  • 相关阅读:
    51uwb 开源TDOA 科研pro版本配置说明
    51uwb 定位框架-高频率高容量测试代码
    UWB 上位机显示距离异常解决方法
    UWB测距+ kalman滤波
    51UWB 数据网络传输方法--WIFI版
    UWB误区快速扫盲视频-针对初学小白
    UWB DWM1000 开源项目框架 之 TWR测距实现
    一种快速UWB 测距方法(单周期法) -- 代码实现
    一种快速UWB 测距方法(单周期法) -- 原理说明
    北京联通光猫+老毛子固件路由器+Win7 IPV6设置
  • 原文地址:https://www.cnblogs.com/DaBing0806/p/7793847.html
Copyright © 2020-2023  润新知