/etc/kubernetes/config文件中,存储的是Kubernetes各组件的通用配置信息。
$ sudo vim /etc/kubernetes/config KUBE_LOGTOSTDERR="--logtostderr=true" KUBE_LOG_LEVEL="--v=0" KUBE_ALLOW_PRIV="--allow-privileged=false" KUBE_MASTER="--master=http://192.168.56.160:8080" 配置kube-apiserver服务在Kubernetes的master主机上。
创建kube-apiserver配置文件kube-apiserver的专用配置文件为/etc/kubernetes/apiserver。
$ sudo vim /etc/kubernetes/apiserver ### # kubernetes system config # # The following values are used to configure the kube-apiserver # # The address on the local server to listen to. KUBE_API_ADDRESS="--address=0.0.0.0" #KUBE_API_ADDRESS="--insecure-bind-address=127.0.0.1" # The port on the local server to listen on. KUBE_API_PORT="--port=8080" # Port minions listen on KUBELET_PORT="--kubelet-port=10250" # Comma separated list of nodes in the etcd cluster KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.56.160:2379" # Address range to use for services KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=192.168.4.0/24" # default admission control policies KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,ResourceQuota" # Add your own! KUBE_API_ARGS="" 创建systemd文件 $ sudo vim /lib/systemd/system/kube-apiserver.service [Unit] Description=Kubernetes API Server Documentation=https://github.com/GoogleCloudPlatform/kubernetes After=network.target After=etcd.service Wants=etcd.service [Service] User=root EnvironmentFile=-/etc/kubernetes/config EnvironmentFile=-/etc/kubernetes/apiserver ExecStart=/usr/bin/kube-apiserver \ $KUBE_LOGTOSTDERR \ $KUBE_LOG_LEVEL \ $KUBE_ETCD_SERVERS \ $KUBE_API_ADDRESS \ $KUBE_API_PORT \ $KUBELET_PORT \ $KUBE_ALLOW_PRIV \ $KUBE_SERVICE_ADDRESSES \ $KUBE_ADMISSION_CONTROL \ $KUBE_API_ARGS Restart=on-failure Type=notify LimitNOFILE=65536 [Install] WantedBy=multi-user.target 配置kube-controller-manager服务 创建kube-controller-manager配置文件kube-controller-manager的专用配置文件为/etc/kubernetes/controller-manager
$ sudo vim /etc/kubernetes/controller-manager KUBE_CONTROLLER_MANAGER_ARGS="" 创建systemd文件 $ sudo vim /lib/systemd/system/kube-controller-manager.service [Unit] Description=Kubernetes Controller Manager Documentation=https://github.com/GoogleCloudPlatform/kubernetes After=etcd.service After=kube-apiserver.service Requires=etcd.service Requires=kube-apiserver.service [Service] User=root EnvironmentFile=-/etc/kubernetes/config EnvironmentFile=-/etc/kubernetes/controller-manager ExecStart=/usr/bin/kube-controller-manager \ $KUBE_LOGTOSTDERR \ $KUBE_LOG_LEVEL \ $KUBE_MASTER \ $KUBE_CONTROLLER_MANAGER_ARGS Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target 配置kube-scheduler服务 创建kube-scheduler配置文件kube-scheduler的专用配置文件为/etc/kubernetes/scheduler
$ sudo vim /etc/kubernetes/scheduler KUBE_SCHEDULER_ARGS="" 创建systemd文件 $ sudo vim /lib/systemd/system/kube-scheduler.service [Unit] Description=Kubernetes Scheduler Documentation=https://github.com/kubernetes/kubernetes [Service] User=root EnvironmentFile=-/etc/kubernetes/config EnvironmentFile=-/etc/kubernetes/scheduler ExecStart=/usr/bin/kube-scheduler \ $KUBE_LOGTOSTDERR \ $KUBE_MASTER Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target 启动Kubernetes master节点的服务 $ sudo systemctl daemon-reload $ sudo systemctl enable kube-apiserver kube-controller-manager kube-scheduler $ sudo systemctl start kube-apiserver kube-controller-manager kube-scheduler Kubernetes node配置Kubernetes node节点也需要配置/etc/kubernetes/config文件,内容与Kubernetes mater节点一致。
flannel配置 创建配置目录和文件 $ sudo vim /etc/default/flanneld.conf # Flanneld configuration options # etcd url location. Point this to the server where etcd runs FLANNEL_ETCD_ENDPOINTS="http://192.168.56.160:2379" # etcd config key. This is the configuration key that flannel queries # For address range assignment FLANNEL_ETCD_PREFIX="/coreos.com/network" # Any additional options that you want to pass #FLANNEL_OPTIONS=""其中,FLANNEL_ETCD_PREFIX选项就是刚才配置的etcd网络。
创建systemd文件 $ sudo vim /lib/systemd/system/flanneld.service [Unit] Description=Flanneld Documentation=https://github.com/coreos/flannel After=network.target After=etcd.service Before=docker.service [Service] User=root EnvironmentFile=/etc/default/flanneld.conf ExecStart=/usr/bin/flanneld \ -etcd-endpoints=${FLANNEL_ETCD_ENDPOINTS} \ -etcd-prefix=${FLANNEL_ETCD_PREFIX} \ $FLANNEL_OPTIONS ExecStartPost=/usr/bin/flannel/mk-docker-opts.sh -k DOCKER_OPTS -d /run/flannel/docker Restart=on-failure Type=notify LimitNOFILE=65536 [Install] WantedBy=multi-user.target RequiredBy=docker.service 启动服务 $ sudo systemctl daemon-reload $ sudo systemctl enable flanneld $ sudo systemctl start flanneld 查看服务是否启动 $ sudo systemctl status flanneld ● flanneld.service - Flanneld Loaded: loaded (/lib/systemd/system/flanneld.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2017-03-27 11:59:00 CST; 6min ago ... docker配置 docker安装通过apt来安装docker。
$ sudo apt -y install docker.io 使flannel作用docker网络