码迷,mamicode.com
首页 > 其他好文 > 详细

k8s部署

时间:2019-04-04 20:23:53      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:oca   from   domain   esc   ice   ref   cloc   部署   linu   

节点    IP地址
master   192.168.1.202
node1   192.168.1.205
node2   192.168.1.206

注:所有机器的配置都一样

[root@node1 ~]# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
[root@node1 ~]# uname -r
3.10.0-693.el7.x86_64

 

CPU: 2C
Mem: 4G
disk: 100G


[root@node1 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.202 master
192.168.1.205 node1
192.168.1.206 node2

scp /etc/hosts root@192.168.1.205:/etc/
scp /etc/hosts root@192.168.1.206:/etc/

配置ssh:
ssh-copy-id 192.168.1.205
ssh-copy-id 192.168.1.206
注:例如第一次使用 ssh node2 时会需要手动输入一次密码

 

安装
系统初始化安装(所有主机)--【最小化安装】
[root@master ~]# yum -y install epel-release
[root@master ~]# yum -y update
[root@master ~]# yum -y install etcd kubernetes-master ntp flannel

[root@node1 ~]# yum -y install kubernetes-node ntp flannel docker
[root@node2 ~]# yum -y install kubernetes-node ntp flannel docker

时间校对(所有主机上执行)
systemctl start ntpd;systemctl enable ntpd
ntpdate ntp1.aliyun.com
hwclock -w


配置etcd服务器
[root@master ~]# grep -v ‘^#‘ /etc/etcd/etcd.conf
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_CLIENT_URLS="http://localhost:2379,http://192.168.1.202:2379"
ETCD_NAME="default"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.1.202:2379"

启动服务
systemctl start etcd;systemctl enable etcd

检查etcd cluster状态
[root@master ~]# etcdctl cluster-health
member 8e9e05c52164694d is healthy: got healthy result from http://192.168.1.202:2379
cluster is healthy

检查etcd集群成员列表,这里只有一台
[root@master ~]# etcdctl member list
8e9e05c52164694d: name=default peerURLs=http://localhost:2380 clientURLs=http://192.168.1.202:2379 isLeader=true

配置kube-apiserver配置文件
[root@master ~]# cat /etc/kubernetes/config|grep -v ^#|grep -v ^$
KUBE_LOGTOSTDERR="--logtostderr=true"
KUBE_LOG_LEVEL="--v=0"
KUBE_ALLOW_PRIV="--allow-privileged=false"
KUBE_MASTER="--master=http://192.168.1.202:8080"

[root@master ~]# cat /etc/kubernetes/apiserver|grep -v ^#|grep -v ^$
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.1.202:2379"
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"
KUBE_ADMISSION_CONTROL="--admission-control=AlwaysAdmit"
KUBE_API_ARGS=""

配置kube-controller-manager配置文件
[root@master ~]# cat /etc/kubernetes/controller-manager|grep -v ^#|grep -v ^$
KUBE_CONTROLLER_MANAGER_ARGS=""

配置kube-scheduler配置文件
[root@master ~]# cat /etc/kubernetes/scheduler|grep -v ^#|grep -v ^$
KUBE_SCHEDULER_ARGS="--address=0.0.0.0"

启动服务
[root@master ~]# for i in kube-apiserver kube-controller-manager kube-scheduler;do systemctl restart $i; systemctl enable $i;done

==================================================================================================

配置node1节点服务器
配置etcd
[root@master ~]# etcdctl set /atomic.io/network/config ‘{"Network": "172.16.0.0/16"}‘
{"Network": "172.16.0.0/16"}

配置node1网络(flannel方式来配置)
[root@node1 ~]# cat /etc/sysconfig/flanneld|grep -v ^#|grep -v ^$
FLANNEL_ETCD_ENDPOINTS="http://192.168.1.202:2379"
FLANNEL_ETCD_PREFIX="/atomic.io/network"
FLANNEL_OPTIONS=""

配置node1 kube-proxy
[root@node1 ~]# cat /etc/kubernetes/config|grep -v ^#|grep -v ^$
KUBE_LOGTOSTDERR="--logtostderr=true"
KUBE_LOG_LEVEL="--v=0"
KUBE_ALLOW_PRIV="--allow-privileged=false"
KUBE_MASTER="--master=http://192.168.1.202:8080"

[root@node1 ~]# cat /etc/kubernetes/proxy|grep -v ^#|grep -v ^$
KUBE_PROXY_ARGS="--bind=address=0.0.0.0"

配置node1 kubelet
[root@node1 ~]# cat /etc/kubernetes/kubelet|grep -v ^#|grep -v ^$
KUBELET_ADDRESS="--address=127.0.0.1"
KUBELET_HOSTNAME="--hostname-override=192.168.1.205"
KUBELET_API_SERVER="--api-servers=http://192.168.1.202:8080"
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
KUBELET_ARGS=""

启动node1服务
[root@node1 ~]# for i in flanneld kube-proxy kubelet docker;do systemctl restart $i;systemctl enable $i;systemctl status $i ;done

==================================================================================================

配置node2节点服务器
[root@node2 ~]# cat /etc/sysconfig/flanneld |grep -v ^#|grep -v ^$
FLANNEL_ETCD_ENDPOINTS="http://192.168.1.202:2379"
FLANNEL_ETCD_PREFIX="/atomic.io/network"
FLANNEL_OPTIONS=""

[root@node2 ~]# cat /etc/kubernetes/config|grep -v ^#|grep -v ^$
KUBE_LOGTOSTDERR="--logtostderr=true"
KUBE_LOG_LEVEL="--v=0"
KUBE_ALLOW_PRIV="--allow-privileged=false"
KUBE_MASTER="--master=http://192.168.1.202:8080"

[root@node2 ~]# cat /etc/kubernetes/proxy |grep -v ^#|grep -v ^$
KUBE_PROXY_ARGS="0.0.0.0"

[root@node2 ~]# cat /etc/kubernetes/kubelet|grep -v ^#|grep -v ^$
KUBELET_ADDRESS="--address=127.0.0.1"
KUBELET_HOSTNAME="--hostname-override=192.168.1.206"
KUBELET_API_SERVER="--api-servers=http://192.168.1.202:8080"
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
KUBELET_ARGS=""

启动node2服务:
for i in flanneld kube-proxy kubelet docker;do systemctl restart $i;systemctl enable $i;systemctl status $i ;done

查看节点
[root@master ~]# kubectl get nodes
NAME STATUS AGE
192.168.1.205 Ready 42m
192.168.1.206 Ready 22s

 


建立pod
[root@master ~]# kubectl run nginx --image=nginx --port=80 --replicas=2

[root@master ~]# kubectl describe pods nginx

报错:

技术图片

 

k8s部署

标签:oca   from   domain   esc   ice   ref   cloc   部署   linu   

原文地址:https://www.cnblogs.com/smlile-you-me/p/10656653.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!