kubernetes-部署

 

环境
master 192.168.0.76
node 192.168.0.36


master 部署
yum -y install kubernetes-master

master 组件相关的配置文件

1 kube-apiserver 配置文件/etc/kubernetes/apiserver

#apiserver 监听地址
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
# apiserver 监听端口默认配置8080,配置其他端口时可以在这里配置
KUBE_API_PORT="--port=8080"
监听etcd 的地址, 根据实际情况 填写。 如果部署在一台机器行,就用下面的地址
KUBE_ETCD_SERVERS="--etcd-servers=http://127.0.0.1:2379"

2 kube-controller-manager.service 配置文件 /etc/kubernetes/controller-manager
3 kube-scheduler.service 配置文件 /etc/kubernetes/scheduler
4 kubernetes 的系统配置文件 /etc/kubernetes/config
该配置对下面的 kubernetes 服务都有效
kube-apiserver.service
kube-controller-manager.service
kube-scheduler.service
kubelet.service
kube-proxy.service


systemctl start kube-apiserver.service
systemctl enable kube-apiserver.service

systemctl start kube-controller-manager.service
systemctl enable kube-controller-manager.service

systemctl start kube-scheduler.service
systemctl enable kube-scheduler.service

 

yum -y install etcd
systemctl status etcd.service
systemctl enable etcd.service

配置文件/etc/etcd/etcd.conf
修改对应的监听地址
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"

etcd 运行查查看其健康状态
etcdctl -C http://127.0.0.1:2379 cluster-health


node部署
yum -y install kubernetes-node
systemctl start kube-proxy.service
systemctl enable kube-proxy.service

systemctl start kubelet.service
systemctl enable kubelet.service


通过kubectl 查询master 各组件的健康状态
kubectl -s http://192.168.0.76:8080 get componentstatus

NAME STATUS MESSAGE ERROR
scheduler Healthy ok
controller-manager Healthy ok
etcd-0 Healthy {"health":"true"}


查询 kubernetes node 的健康状态
kubectl -s http://192.168.0.76:8080 get node

NAME STATUS AGE
127.0.0.1 NotReady 27m
jinkang-centostest2 Ready 3s
node1 Ready 24m


网络配置
使用flannel 为 node节点配置网络
会为不同node的docker网桥配置不同的IP网段以保证docker容器的IP
在集群内唯一。


yum -y install flannel
配置文件 /etc/sysconfig/flanneld
中有配置etcd 的配置,根据实际情况修改


运行应用 deployment

kubectl -s http://192.168.0.76:8080 run nginx --image=2622e6cca7eb

kubectl -s http://192.168.0.76:8080 get deployment

kubectl -s http://192.168.0.76:8080 describe deployment
kubectl -s http://192.168.0.76:8080 get replicaset
kubectl describe replicaset

kubernetes-部署

上一篇:10行代码判断上传文件的格式


下一篇:js调用函数加括号和不加括号的区别