Kubernetes 集群安装之ETCD,DOCKER,FLANNEL问题

1安装etcd

yum install -y etcd 

 

修改配置文件/etc/etcd/etcd.conf

# [member]

ETCD_NAME=default

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://192.168.137.150:2380"    单台不需要配

ETCD_LISTEN_CLIENT_URLS="http://192.168.137.154:2379,http://127.0.0.1:2379"      

#ETCD_MAX_SNAPSHOTS="5"

#ETCD_MAX_WALS="5"

#ETCD_CORS=""

#

#[cluster]

#ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.137.150: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://192.168.137.150:2380"

#ETCD_INITIAL_CLUSTER_STATE="new"

#ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"

ETCD_ADVERTISE_CLIENT_URLS="http://192.168.137.154:2379"

#ETCD_DISCOVERY=""

#ETCD_DISCOVERY_SRV=""

#ETCD_DISCOVERY_FALLBACK="proxy"

#ETCD_DISCOVERY_PROXY=""

#

#[proxy]

#ETCD_PROXY="off"

#ETCD_PROXY_FAILURE_WAIT="5000"

#ETCD_PROXY_REFRESH_INTERVAL="30000"

#ETCD_PROXY_DIAL_TIMEOUT="1000"

#ETCD_PROXY_WRITE_TIMEOUT="5000"

#ETCD_PROXY_READ_TIMEOUT="0"

#

#[security]

#ETCD_CERT_FILE=""

#ETCD_KEY_FILE=""

#ETCD_CLIENT_CERT_AUTH="false"

#ETCD_TRUSTED_CA_FILE=""

#ETCD_PEER_CERT_FILE=""

#ETCD_PEER_KEY_FILE=""

#ETCD_PEER_CLIENT_CERT_AUTH="false"

#ETCD_PEER_TRUSTED_CA_FILE=""

#

#[logging]

#ETCD_DEBUG="false"

# examples for -log-package-levels etcdserver=WARNING,security=DEBUG

#ETCD_LOG_PACKAGE_LEVELS=""

 

启动etcd

systemctl start etcd.service

 

在启动flannel之前,在etcd中添加一条网络配置记录,这个配置记录用于flannel分配给每个docker的虚拟ip地址段

etcdctl set /coreos.com/network/config '{ "Network": "10.1.0.0/16" }'

 

2docker 安装

yum install -y docker

 

3 flannel 安装

yum install -y flannel

 

配置文件修改: /etc/sysconfig/falneld

# Flanneld configuration options

 

# etcd url location.  Point this to the server where etcd runs

FLANNEL_ETCD_ENDPOINTS="http://192.168.137.154:2379"        注:etcd_ip

 

# 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=""

 

服务配置文件修改:/usr/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/sysconfig/flanneld

EnvironmentFile=-/etc/sysconfig/docker-network

ExecStart=/usr/bin/flanneld -etcd-endpoints=${FLANNEL_ETCD_ENDPOINTS} -etcd-prefix=${FLANNEL_ETCD_PREFIX}

ExecStartPost=/usr/libexec/flannel/mk-docker-opts.sh -k DOCKER_NETWORK_OPTIONS -d /run/flannel/docker

Restart=on-failure

 

[Install]

WantedBy=multi-user.target

RequiredBy=docker.service

 

启动flanneld服务  (由于flannel将覆盖docker0网段,因此要停止docker服务)

systemctl resatrt flanneld

 

在每个node节点执行以下命令完成对docker0网桥的设置

source /run/flannel/subnet.env

ifconfig docker0 ${FLANNEL_SUBNET}

 

重启docker服务

 

systemctl restart docker

 

以下命令可以用来查看配置:

etcdctl ls /coreos.com/network/subnets

你可能感兴趣的:(Kubernetes 集群安装之ETCD,DOCKER,FLANNEL问题)