1. flannel配置
- 下载二进制文件 https://github.com/coreos/flannel/releases 版本:flannel-v0.7.0-linux-amd64.tar.gz
- flanneld, mk-docker-opts.sh拷贝到/usr/bin目录下(确保两个文件具有可执行的模式chmod 777 flanneld)
- 创建配置文件/lib/systemd/system/flanneld.service
[Unit]
Description=Flanneld overlay address etcd agent
After=network.target
After=network-online.target
Wants=network-online.target
After=etcd.service
Before=docker.service [Service]
Type=notify
EnvironmentFile=-/etc/flannel/flannel.conf
EnvironmentFile=-/etc/sysconfig/docker-network
ExecStart=/usr/bin/flanneld -etcd-endpoints=${FLANNEL_ETCD} -etcd-prefix=${FLANNEL_ETCD_KEY} $FLANNEL_OPTIONS
ExecStartPost=/usr/bin/mk-docker-opts.sh -k DOCKER_NETWORK_OPTIONS -d /run/flannel/docker
Restart=on-failure [Install]
WantedBy=multi-user.target
RequiredBy=docker.service - 创建配置文件/etc/flannel/flannel.conf
#flanneld configuration options # etcd url location. Point this to the server where etcd runs
FLANNEL_ETCD="http://109.105.46.94:2379" # etcd config key. This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_KEY="/flannel/network" # Any additional options that you want to pass
FLANNEL_OPTIONS=""
- 启动服务systemctl start flannel
- 查看是否成功 ip a
2.为了使docker使用flannel创建的子网,需要修改docker的启动文件
- flannel成功启动后,会自动在/run/flannel下创建docker和 subnet.env两个文件,将这两个文件加入到docker启动文件中
- 修改/lib/systemd/system/docker.service
- 重启docker
systemctl daemon-reload
systemctl restart docker
3.将kubelet,kube-proxy拷贝到/user/bin目录下
- 创建kubelet配置文件 /lib/systemd/system/kubelet.service
[Unit]
Description=kubelet
Documentation=http://kubernetes.io/docs/ [Service]
ExecStart=/usr/bin/kubelet \
--address=0.0.0.0 \
--hostname-override=109.105.46.95 \
--api-servers=http://109.105.46.94:8080 \
--log-dir=/home/nwlab/kubernets/logs/kubelet \
--v=0 \
--allow-privileged=false KillMode=process
Restart=on-failure
RestartSec=42s [Install]
WantedBy=multi-user.target
- 创建kube-proxy配置文件 /lib/systemd/system/kube-proxy.service
[Unit]
Description=kube-proxy
Documentation=http://kubernetes.io/docs/ [Service]
ExecStart=/usr/bin/kube-proxy \
--v= \
--logtostderr=true \
--hostname-override=109.105.46.95 \
--log-dir=/home/nwlab/kubernets/logs/kubelet \
--bind-address=0.0.0.0 \
--master=http://109.105.46.94:8080 KillMode=process
Restart=on-failure
RestartSec=42s [Install]
WantedBy=multi-user.target
- 启动kubelet,kube-proxy 服务
systemctl daemon-reload
systemctl restart kubelet.service
systemctl restart kube-proxy.service
- 查看是否成功 在master上执行 kubectl get nodes