kubernetes1.4 安装

2017-12-09  本文已影响0人  秋幻旎苏
Master节点:yum install -y kubernetes-master docker
Node节点:yum install -y kubernetes-node docker

centos安装kubernetes,calico,nfs
http://blog.csdn.net/yarntime/article/details/51334556
http://m.blog.csdn.net/article/details?id=51334556

修改etcd配置文件

# [member]
ETCD_NAME=default
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.0.241:2380"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
#[cluster]
ETCD_INITIAL_CLUSTER="default=http://192.168.0.241:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.0.241:2379"

1.下载calico程序

# wget -o /usr/bin/calicoctl https://github.com/projectcalico/calico-containers/releases/download/v0.18.0/calicoctl
# chmod +x /usr/bin/calicoctl

2.创建service文件,设置etcd集群服务地址:

# vi /usr/lib/systemd/system/calico-node.service
[Unit] 
Description=calicoctl node 
After=docker.service 
Requires=docker.service 
[Service] 
User=root
Environment=ETCD_AUTHORITY=docker1:2379
PermissionsStartOnly=true
ExecStart=/usr/bin/calicoctl node --detach=false
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target

3.Node节点启动calico

# systemctl enable calico-node
# systemctl start calico-node

4.节点启动后会运行calico-node容器


5.添加环境变量:

export ETCD_AUTHORITY=docker1:2379

6.检查Node节点的连接状态


7.在所有minion节点上,安装calico-cni扩展

wget -N -P /opt/cni/bin https://github.com/projectcalico/calico-cni/releases/download/v1.1.0/calico chmod +x /opt/cni/bin/calico
wget -N -P /opt/cni/bin https://github.com/projectcalico/calico-cni/releases/download/v1.1.0/calico-ipam
chmod +x /opt/cni/bin/calico-ipam

配置cni网络声明:

$ cat /etc/cni/net.d/10-calico.conf
{
"name" : "calico-k8s-network",
"type" : "calico",
"etcd_authority" : "docker1:2379",
"log_level" : "info",
"ipam" : {
"type" : "calico-ipam"
}
}

8.如果是在阿里云上部署,需要设置calico使用ipip
用下面的命令来查看:calicoctl pool show --ipv4

9.验证网络环境是否满足kubernetes需求:

1) 创建一个rc,副本数量和集群的minion节点一致。
2) 测试主机到pod通信:主机 ping 本机PodIp, 主机ping 其它主机PodIp。Pod内部ping宿主机Ip,Pod内部ping其它主机Ip。
3) 测试cluster ip通信:创建service,后端使用可用的Pod服务。在Pod所在minion,使用serviceIp+port访问服务。在其它minion,使用serviceIp+port访问服务。
4) 测试nodePort通信:使用minion本机IP+nodeport访问服务。使用其它minion ip+nodeport访问服务。
如果以上测试全部通过,则网络配置正确,否则需要排查问题。

10.修改kubernetes配置
设置kube-proxy服务的proxy-mode配置为iptables,修改配置文件/etc/kubernetes/proxy:

# kubernetes proxy config
# default config should be adequate
# Add your own!
KUBE_PROXY_ARGS=" --proxy-mode=iptables"

11.设置kubelet的network-plugin为cni,修改配置文件/usr/lib/systemd/system/kubelet.service:

[Unit]
Description=Kubernetes Kubelet Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=docker.service
Requires=docker.service
[Service]
WorkingDirectory=/var/lib/kubelet
EnvironmentFile=-/etc/kubernetes/config
EnvironmentFile=-/etc/kubernetes/kubelet
ExecStart=/usr/bin/kubelet \
--network-plugin-dir=/etc/cni/net.d \
--network-plugin=cni \
$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
[Install]
WantedBy=multi-user.target
上一篇 下一篇

猜你喜欢

热点阅读