Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Kubernetes 1.5 installation

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Kubernetes has introduced kubeadm since 1. 3 in an attempt to simplify its complex installation. But kubeadm is still unstable, and I personally think kubeadm is troublesome, so it's better to install it directly with scripts or other automated tools. There are also alternatives for kubeadm to configure ha for master, such as using highly available clustering software such as keepalived or corosync. So in this document, I will still use the traditional way to install the kubernetes cluster

Kubernetes relies on the network of docker and etcd,docker, where flannel is used directly. In this document, we will not elaborate too much on the high availability of master, let's simply set up a basic availability minimization cluster. The three CentOS 7.2servers I use here are described in the following roles:

192.168.1.20 server-20 master node, node node, etcd node 192.168.1.21 server-21 node node, etcd section 192.168.1.22 server-22 node node, etcd node

It is important to note that you need to set your own basic environment, such as shutting down selinux, configuring time synchronization, emptying existing iptables policies, and configuring epel sources.

1. Install and start docker

The installation of docker is relatively simple. You can install it directly using yum:

Yum install-y dockersystemctl start dockersystemctl enable docker

2. Install etcd

Perform the following installation on all nodes:

Yum-y install etcd# create etcd data directory mkdir-p / opt/etcd/datachown-R etcd:etcd / opt/etcd/# modify configuration file / etc/etcd/etcd.conf needs to modify the following parameters: ETCD_NAME=server-20ETCD_DATA_DIR= "/ opt/etcd/data/server-20.etcd" ETCD_LISTEN_PEER_URLS= "ETCD_LISTEN_CLIENT_URLS=" ETCD_INITIAL_ADVERTISE_PEER_URLS= "ETCD_INITIAL_CLUSTER=" server-20=ETCD_ADVERTISE_CLIENT_URLS= "http://192.168.1.20:2379"

# modify etcd startup file sed-I's /\\ "${ETCD_LISTEN_CLIENT_URLS}\\" /\\ "${ETCD_LISTEN_CLIENT_URLS}\"-listen-client-urls=\\ "${ETCD_LISTEN_CLIENT_URLS}\"-advertise-client-urls=\\ "${ETCD_ADVERTISE_CLIENT_URLS}\"-initial-cluster-token=\\ "${ETCD_ INITIAL_CLUSTER_TOKEN}\ "- initial-cluster=\\" ${ETCD_INITIAL_CLUSTER}\ "- initial-cluster-state=\\" ${ETCD_INITIAL_CLUSTER_STATE}\ "/ g' / usr/lib/systemd/system/etcd.service

# start etcdsystemctl enable etcdsystemctl start etcdsystemctl status etcd# to view cluster status etcdctl cluster-health

# start etcdsystemctl enable etcdsystemctl start etcdsystemctl status etcd# to view cluster status etcdctl cluster-health

3. Configure flannel

First register the flannel subnet in etcd:

Etcdctl set / coreos.com/network/config'{"network": "172.16.0.0 Universe 16"}'

Install flannel on all nodes:

Yum install-y flannel

Modify the flannel configuration file / etc/sysconfig/flanneld as follows:

FLANNEL_ETCD= "http://192.168.1.20:2379,http://192.168.1.21:2379,http://192.168.1.22:2379"FLANNEL_ETCD_KEY="/coreos.com/network"

Start flannel:

Systemctl start flanneldsystemctl enable flanneld

It is important to note that if you want docker to use flannel's network, docker must be started after flannel, so you need to restart docker:

Systemctl restart docker

4. Install the kubernetes server

What I use here is a private yum source of kubernetes provided by others on the Internet, as follows:

Vim / etc/yum.repos.d/ Kube. Repos [Kube] name=Mritd Repositorybaseurl= https://yum.mritd.me/centos/7/x86_64enabled=1gpgcheck=1gpgkey=https://mritd.b0.upaiyun.com/keys/rpm.public.key

Download all kubernetes-related packages through yumdownloader before installing them through local yum:

Yumdownloader kubernetes-master kubernetes-client kubernetes-nodeyum localinstall-y kubernetes-master kubernetes-client

Modify the configuration file on kubernetes master as follows:

Vim / etc/kubernetes/configKUBE_LOGTOSTDERR= "--logtostderr=true" KUBE_LOG_LEVEL= "--master= 0" KUBE_ALLOW_PRIV= "--allow-privileged=false" KUBE_MASTER= "--master= http://10.5.10.116:8080"vim / etc/kubernetes/apiserverKUBE_API_ADDRESS="-- address=0.0.0.0 "KUBE_API_PORT="-- port=8080-- secure-port=443 "KUBE_MASTER="-- master= http://10.5.10.116:8080"KUBELET_PORT="--kubelet -port=10250 "KUBE_ETCD_SERVERS="-- etcd-servers= http://10.5.10.116:2379, Http://10.5.10.117:2379,http://10.5.10.131:2379"KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"

Start kubernetes master:

Systemctl start kube-apiserver kube-controller-manager kube-schedulersystemctl enable kube-apiserver kube-controller-manager kube-scheduler

5. Install kubernetes node

Yum install-y kubernetes-node

Modify the configuration file for node:

Vim / etc/kubernetes/configKUBE_LOGTOSTDERR= "--logtostderr=true" KUBE_LOG_LEVEL= "--master= 0" KUBE_ALLOW_PRIV= "--allow-privileged=false" KUBE_MASTER= "--master= http://10.5.10.116:8080"vim / etc/kubernetes/kubeletKUBELET_ADDRESS="-- address=0.0.0.0 "KUBELET_HOSTNAME="-- hostname-override=server-116 "KUBELET_API_SERVER="-- api-servers= http://10.5.10.116:8080"KUBELET_POD_INFRA_CONTAINER=" -- pod-infra-container-p_w_picpath=myhub.fdccloud.com/library/pod-infrastructure:latest "

Start the node side:

Systemctl start kubelet kube-proxysystemctl enable kubelet kube-proxy

Finally, check whether each node is normal through kubectl on kubernetes master:

[root@server-116 ~] # kubectl get nodesNAME STATUS AGEserver-20 Ready 1dserver-21 Ready 1dserver-22 Ready 1d

At this point, complete the basic installation of kubernetes 1.5

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 253

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report