YUM warehouse online simple installation single node K8S (pure combat)

Posted by Carlo Gambino on Tue, 04 Feb 2020 18:33:54 +0100

Simple online installation of single node K8S using YUM warehouse

Experimental environment:

Using system: CentOS 7.4

Name role IP address
centos7-min2 master 192.168.142.220
centos7-4 node 192.168.142.136

Experimental steps:

1, Configuration step directory

master configuration

node configuration

Test results

2, master configuration

Use yum warehouse to install atcd database, kubernetes component and flannel network component

[root@master ~]# yum install -y etcd kubernetes flannel

Modify etcd configuration file

[root@master ~]# vim /etc/etcd/etcd.conf
//Modify according to the figure below
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"                      //Data file storage path
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379 "/ / address of external service
ETCD_NAME="default"
ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379 "/ / listening address of the client of this node

Modify the apiserver configuration file

[root@master ~]# vim /etc/kubernetes/apiserver
//Modify according to the figure below
KUBE_API_ADDRESS="--address=0.0.0.0"                //Listening interface
KUBE_API_PORT="--port=8080"                           //Listening port of apiserver
KUBELET_PORT="--kubelet-port=10250"                    //Port on which kubelet listens
KUBE_ETCD_SERVERS="--etcd-servers=http://127.0.0.1:2379 "/ / specify the service address and port of ETCD
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"                 //ip address range that kubernetes can assign
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota"
KUBE_API_ARGS=""                     //Additional configuration items are needed to simply enable a cluster without configuration

Configure the flannel network

[root@localhost sysconfig]# vim /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS="http://192.168.142.220:2379 "/ / fill in the local address
FLANNEL_ETCD_PREFIX="/coreos.com/network"

Start all services

[root@localhost sysconfig]# for server in etcd kube-apiserver kube-controller-manager kube-scheduler;do systemctl restart $server;systemctl enable $server;systemctl status $server;done
//I believe you can understand the for loop used here for batch startup

Setting up etcd database

[root@localhost sysconfig]# etcdctl -C //192.168.142.220:2379 set /coreos.com/network/comfig '{"Network":"10.1.0.0/16"}'

3, node configuration

Install the components of flannel and kubernetes

[root@node ~]# yum -y install flannel kubernetes

Modify kubernetes configuration file

[root@node ~]# vim /etc/kubernetes/config
//Modify as follows
KUBE_LOGTOSTDERR="--logtostderr=true"
KUBE_LOG_LEVEL="--v=0"
KUBE_ALLOW_PRIV="--allow-privileged=false"
KUBE_MASTER="--master=http://192.168.142.220:8080 "/ / point to the master address and the port is the apiserver listening port
KUBE_ETCD_SERVERS="--etcd_servers=http://192.168.142.220:2379 "/ / point to etcd server address

Modify kubelet configuration file

[root@node ~]# vim /etc/kubernetes/kubelet
//Modify as follows
KUBELET_ADDRESS="--address=0.0.0.0"                     //Monitor the whole network segment
KUBELET_PORT="--port=10250"               //Port remains unchanged
KUBELET_HOSTNAME="--hostname-override=192.168.142.136"                 //Refer to oneself
KUBELET_API_SERVER="--api-servers=http://192.168.142.220:8080 "/ / point to the master
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
KUBELET_ARGS=""

Modify the flannel network configuration

[root@node ~]# vim /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS="http://192.168.142.220:2379 "/ / point to the primary server
FLANNEL_ETCD_PREFIX="/coreos.com/network"

Turn on all components

[root@node ~]# for SERVICES in flanneld kube-proxy kubelet docker; do systemctl restart $SERVICES; systemctl enable $SERVICES; systemctl status $SERVICES; done

4, Test results

Return to master

[root@master sysconfig]# kubectl get nodes
NAME             STATUS    AGE
192.168.142.136   Ready     34m

Be careful:

Using YUM warehouse to install K8S online is usually only suitable for the experimental environment, and the fault tolerance is too poor.

Topics: Linux Kubernetes network vim yum