首页 > 代码库 > Kubernetes的安装配置
Kubernetes的安装配置
1.环境准备:
三台服务器:
192.168.42.128 master+node
192.168.42.129 node1
192.168.42.130 node2
2.准备yum源
vi virt7-docker-common-release.repo [virt7-docker-common-release] name=virt7-docker-common-release baseurl=http://cbs.centos.org/repos/virt7-docker-common-release/x86_64/os/ gpgcheck=0
3.安装组件分类
master包含 kube-apiserver kube-scheduler kube-controller-manager etcd四个组件 node包含 kube-proxy kubelet flannel 3个组件
1. kube-apiserver:位于master节点,接受用户请求。
2. kube-scheduler:位于master节点,负责资源调度,即pod建在哪个node节点。
3. kube-controller-manager:位于master节点,包含ReplicationManager,Endpointscontroller,Namespacecontroller,and Nodecontroller等。
4. etcd:分布式键值存储系统,共享整个集群的资源对象信息。
5. kubelet:位于node节点,负责维护在特定主机上运行的pod。
6. kube-proxy:位于node节点,它起的作用是一个服务代理的角色
7. flannel:网络配置
4.关闭并且禁用防火墙
systemctl stop firewalld
systemctl disable firewalld
5.关闭并且禁用Enforcing
setenforce 0 getenforce vi /etc/selinux/config 修改:SELINUX=disabled
6.设置NTP同步
*/5 * * * * /usr/sbin/ntpdate cn.ntp.org.cn
7.安装kubernetes master节点
yum install etcd Dependencies Resolved ================================================================================================= Package Arch Version Repository Size ================================================================================================= Installing: etcd x86_64 2.0.9-1.el7 virt7-docker-common-release 2.9 M Transaction Summary ================================================================================================= Install 1 Package
yum install kubernetes Dependencies Resolved ================================================================================================= Package Arch Version Repository Size ================================================================================================= Installing: kubernetes x86_64 1.1.0-0.4.git2bfa9a1.el7 virt7-docker-common-release 26 k Installing for dependencies: docker x86_64 1.6.2-4.gitc3ca5bb.el7 virt7-docker-common-release 5.0 M kubernetes-client x86_64 1.1.0-0.4.git2bfa9a1.el7 virt7-docker-common-release 3.0 M kubernetes-master x86_64 1.1.0-0.4.git2bfa9a1.el7 virt7-docker-common-release 14 M kubernetes-node x86_64 1.1.0-0.4.git2bfa9a1.el7 virt7-docker-common-release 9.8 M socat x86_64 1.7.2.2-5.el7 base 255 k Transaction Summary ================================================================================================= Install 1 Package (+5 Dependent packages)
vi /etc/etcd/etcd.conf
# [member] ETCD_NAME=default ETCD_DATA_DIR="/var/lib/etcd/default.etcd" #ETCD_SNAPSHOT_COUNTER="10000" #ETCD_HEARTBEAT_INTERVAL="100" #ETCD_ELECTION_TIMEOUT="1000" #ETCD_LISTEN_PEER_URLS="http://localhost:2380,http://localhost:7001" ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379" #ETCD_MAX_SNAPSHOTS="5" #ETCD_MAX_WALS="5" #ETCD_CORS="" # #[cluster] #ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380,http://localhost:7001" # 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://localhost:2380,default=http://localhost:7001" #ETCD_INITIAL_CLUSTER_STATE="new" #ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster" #ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379,http://localhost:4001" ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379" #ETCD_DISCOVERY="" #ETCD_DISCOVERY_SRV="" #ETCD_DISCOVERY_FALLBACK="proxy" #ETCD_DISCOVERY_PROXY="" # #[proxy] #ETCD_PROXY="off" # #[security] #ETCD_CA_FILE="" #ETCD_CERT_FILE="" #ETCD_KEY_FILE="" #ETCD_PEER_CA_FILE="" #ETCD_PEER_CERT_FILE="" #ETCD_PEER_KEY_FILE=""
vi /etc/kubernetes/apiserver
### # kubernetes system config # # The following values are used to configure the kube-apiserver # # The address on the local server to listen to. #KUBE_API_ADDRESS="--insecure-bind-address=127.0.0.1" KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0" # The port on the local server to listen on. # KUBE_API_PORT="--port=8080" # Port minions listen on # KUBELET_PORT="--kubelet-port=10250" # Comma separated list of nodes in the etcd cluster KUBE_ETCD_SERVERS="--etcd-servers=http://127.0.0.1:2379" # Address range to use for services KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16" # default admission control policies KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota" # Add your own! KUBE_API_ARGS=""
vi /etc/kubernetes/controller-manager
### # The following values are used to configure the kubernetes controller-manager # defaults from config and apiserver should be adequate # Add your own! #KUBE_CONTROLLER_MANAGER_ARGS="" KUBE_CONTROLLER_MANAGER_ARGS="--node-monitor-grace-period=10s --pod-eviction-timeout=10s"
vi /etc/kubernetes/config
### # kubernetes system config # # The following values are used to configure various aspects of all # kubernetes services, including # # kube-apiserver.service # kube-controller-manager.service # kube-scheduler.service # kubelet.service # kube-proxy.service # logging to stderr means we get it in the systemd journal KUBE_LOGTOSTDERR="--logtostderr=true" # journal message level, 0 is debug KUBE_LOG_LEVEL="--v=0" # Should this cluster be allowed to run privileged docker containers KUBE_ALLOW_PRIV="--allow-privileged=false" # How the controller-manager, scheduler, and proxy find the apiserver KUBE_MASTER="--master=http://192.168.42.128:8080"
设置服务启动
systemctl status etcd kube-apiserver kube-scheduler kube-controller-manager
systemctl enable etcd kube-apiserver kube-scheduler kube-controller-manager
定义kubernetes的网络
etcdctl mk /coreos.com/network/config ‘{"Network":"172.17.0.0/16"}‘
8.安装kubernetes node节点
yum -y install kubernetes-node Dependencies Resolved ================================================================================================= Package Arch Version Repository Size ================================================================================================= Installing: kubernetes-node x86_64 1.1.0-0.4.git2bfa9a1.el7 virt7-docker-common-release 9.8 M Installing for dependencies: docker x86_64 1.6.2-4.gitc3ca5bb.el7 virt7-docker-common-release 5.0 M kubernetes-client x86_64 1.1.0-0.4.git2bfa9a1.el7 virt7-docker-common-release 3.0 M socat x86_64 1.7.2.2-5.el7 base 255 k Transaction Summary ================================================================================================= Install 1 Package (+3 Dependent packages)
yum -y install flannel Dependencies Resolved ================================================================================================= Package Arch Version Repository Size ================================================================================================= Installing: flannel x86_64 0.2.0-7.el7 virt7-docker-common-release 1.3 M Transaction Summary ================================================================================================= Install 1 Package
修改配置文件/etc/kubernetes
vi /etc/kubernetes/config
[root@node1 kubernetes]# cat /etc/kubernetes/config ### # kubernetes system config # # The following values are used to configure various aspects of all # kubernetes services, including # # kube-apiserver.service # kube-controller-manager.service # kube-scheduler.service # kubelet.service # kube-proxy.service # logging to stderr means we get it in the systemd journal KUBE_LOGTOSTDERR="--logtostderr=true" # journal message level, 0 is debug KUBE_LOG_LEVEL="--v=0" # Should this cluster be allowed to run privileged docker containers KUBE_ALLOW_PRIV="--allow-privileged=false" # How the controller-manager, scheduler, and proxy find the apiserver #KUBE_MASTER="--master=http://127.0.0.1:8080" KUBE_MASTER="--master=http://192.168.42.128:8080"
vi /etc/kubernetes/kubelet
[root@node1 kubernetes]# cat /etc/kubernetes/kubelet ### # kubernetes kubelet (minion) config # The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces) KUBELET_ADDRESS="--address=127.0.0.1" # The port for the info server to serve on # KUBELET_PORT="--port=10250" # You may leave this blank to use the actual hostname #KUBELET_HOSTNAME="--hostname-override=127.0.0.1" KUBELET_HOSTNAME="--hostname-override=192.168.42.129" # location of the api-server #KUBELET_API_SERVER="--api-servers=http://127.0.0.1:8080" KUBELET_API_SERVER="--api-servers=http://192.168.42.128:8080" # Add your own! #KUBELET_ARGS="" KUBELET_ARGS="--pod-infra-container-image=kubernetes/pause"
vi /etc/sysconfig/flanneld
# Flanneld configuration options # etcd url location. Point this to the server where etcd runs #FLANNEL_ETCD="http://127.0.0.1:4001" FLANNEL_ETCD="http://192.168.42.128:2379" # etcd config key. This is the configuration key that flannel queries # For address range assignment FLANNEL_ETCD_KEY="/coreos.com/network" # Any additional options that you want to pass #FLANNEL_OPTIONS="" FLANNEL_OPTIONS="-iface=eno16777728"
启动服务
systemctl status kube-proxy flanneld kubelet docker
systemctl enable kube-proxy flanneld kubelet docker
Kubernetes的安装配置
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。