Centos7 install k8s cluster 1.15.0 version

Version description##

Pre-installation instructions##

Using kubeadm to install k8s is much easier than installing the components one by one before. It's just that because of the domestic network problems, Google's things have been walled, so it feels more laborious to install. So the key to installing ks is how to pull the image, there are four ways to solve it:

There is a graphical installation of k8s project on github, which has been officially certified by CNCF. Image interface installation k8s

Machine Planning##

Machine name ip address role components installed by yum
k8s-master 10.1.69.101 master docker、kubelet、kubeadm、kubectl
k8s-node1 10.1.69.102 node docker、kubelet、kubeadm
k8s-node2 10.1.69.103 node docker、kubelet、kubeadm

Friendly reminder: Install under the virtual machine, it is best to fix the IP address. Especially the master node, because the IP address is required for installation, and the domain name cannot be used. If the IP address changes next time, the cluster may become unavailable

Ready to work##

1. Install prerequisite software###

yum install -y wget vim net-tools epel-release

2. Close swap

swapoff -a

# Permanently disable, open/etc/fstab commented out the swap line.
sed -i 's/.*swap.*/#&/'/etc/fstab

3. Close selinux

# Temporarily disable selinux
setenforce 0
# Permanently close modification/etc/sysconfig/selinux file settings
sed -i 's/SELINUX=permissive/SELINUX=disabled/'/etc/sysconfig/selinux
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g"/etc/selinux/config

4. Turn off the firewall###

systemctl disable firewalld
systemctl stop firewalld

Install Docker and configure proxy##

1. Configure yum source###

## Configure default source
## Backup
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

## Download Aliyuan
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

## Refresh
yum makecache fast

## Configure k8s source
cat </etc/yum.repos.d/kubernetes.repo
[ kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
EOF

## Rebuild yum cache
yum clean all
yum makecache fast
yum -y update

Copy code

2. Install docker

yum -y install yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum -y install docker-ce
systemctl enable docker
systemctl start docker

3. Ensure that the cgroup driver used by kubelet is consistent with that of Docker###

cat >/etc/docker/daemon.json <Copy code

4. Set up docker proxy (core step-if there is a proxy)

No agent performs step 5

mkdir /etc/systemd/system/docker.service.d
touch /etc/systemd/system/docker.service.d/http-proxy.conf

[ Service]
Environment="HTTP_PROXY=http://xxx"
Environment="HTTPS_PROXY=http://xxx"
Environment="NO_PROXY=localhost,127.0.0.1,localaddress,.localdomain.com"

systemctl daemon-reload && systemctl restart docker

5. Pull the mirror image from the domestic warehouse (core step-if there is no agent)

## View the images required for cluster initialization and the corresponding dependent version numbers, the ones listed are the images that need to be downloaded
kubeadm config images list
Copy code
#! /bin/bash

## Use the following script to download the domestic mirror and modify the tag to google&#39;s tag
set-e

KUBE_VERSION=v1.15.0
KUBE_PAUSE_VERSION=3.1
ETCD_VERSION=3.3.10
CORE_DNS_VERSION=1.3.1

GCR_URL=k8s.gcr.io
ALIYUN_URL=registry.cn-hangzhou.aliyuncs.com/google_containers

images=(kube-proxy:${KUBE_VERSION}
kube-scheduler:${KUBE_VERSION}
kube-controller-manager:${KUBE_VERSION}
kube-apiserver:${KUBE_VERSION}
pause:${KUBE_PAUSE_VERSION}
etcd:${ETCD_VERSION}
coredns:${CORE_DNS_VERSION})for imageName in ${images[@]};do
 docker pull $ALIYUN_URL/$imageName
 docker tag  $ALIYUN_URL/$imageName $GCR_URL/$imageName
 docker rmi $ALIYUN_URL/$imageName
done

6. Configure network proxy (optional)

 ## Configuration/etc/profile file, especially https, replace xxx with the proxy address of yourself or your company
 http_proxy=xxx
 https_proxy=xxx
 HTTP_PROXY=xxx
 HTTPS_PROXY=xxx
Copy code

Start installing k8s

1. Install kubeadm, kubelet, etc.###

yum -y install kubelet kubeadm kubectl kubernetes-cni
systemctl enable kubelet && systemctl start kubelet

2. Cluster initialization###

## The master node executes:
sudo kubeadm init \
 - - apiserver-advertise-address 10.1.69.101 \
 - - kubernetes-version=v1.15.0 \
 - - pod-network-cidr=10.244.0.0/16
Copy code

Friendly reminder: If the image is not pulled in advance, this step will be slower. If the proxy is configured, execute: kubeadm config images pull, pull the image separately

If kubeadm reset is uninstalled and then installed, an error may be reported. Add this parameter: --ignore-preflight-errors=all

Get a reply:

(... Omit)
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

## Save the command, if it is lost, it is difficult to retrieve it. Needed when a node joins
kubeadm join 10.1.69.101:6443--token ou5pvo.qseafc4s8licblzy \
 - - discovery-token-ca-cert-hash sha256:de9c10f11c50c074f212698b9d514fc12a9c1c4ffe70961aff89ac5e585f0663
Copy code

3. Copy configuration, use ### for kubectl

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

4. Install flannel network###

sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

## Check if the flannal is installed successfully

sudo kubectl -n kube-system get po -l app=flannel -o wide
Copy code

5. Node node joins the cluster##

Other nodes execute:

kubeadm join 10.1.69.101:6443--token ou5pvo.qseafc4s8licblzy \
 - - discovery-token-ca-cert-hash sha256:de9c10f11c50c074f212698b9d514fc12a9c1c4ffe70961aff89ac5e585f0663

Clean installation##

sudo kubeadm reset

Dashboard plugin installation##

1. Download the plugin and configure

apiVersion: v1 kind: ServiceAccount metadata: name: dashboard namespace: kube-system --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1beta1 metadata: name: dashboard subjects: - kind: ServiceAccount name: dashboard namespace: kube-system roleRef: kind: ClusterRole name: cluster-admin apiGroup: rbac.authorization.k8s.io

2. Perform installation

It takes a certain amount of time to download the image. If the pod is running, the installation is successful. kubectl get pod -n kube-system |grep kubernetes-dashboard

3. Login interface view###

Get the login interface token kubectl -n kube-system describe $(kubectl -n kube-system \ get secret -n kube-system -o name | grep namespace) | grep token

Problems encountered##

The image tag is not specified when exporting save

When kubeadm init, the address of apiserver is wrong

echo "1">/proc/sys/net/bridge/bridge-nf-call-iptables

kubeadm reset, reset node, rejoin

Recommended Posts

Centos7 install k8s cluster 1.15.0 version
CentOS7.3.1611 deploys k8s1.5.2 cluster
CentOS6 install couchdb2 cluster
CentOS7 deploys k8s cluster
Centos7.2/7.3 cluster install Kubernetes 1.8.4 + Dashboard
Centos install high version GCC
CentOS 8.0.1905 install ZABBIX4.4 version (verified)
Centos7.6 install MySQL+Redis (latest version)
1.5 Install Centos7
CentOS6 mininal install CouchDB2 detailed version
k8s practice (1): Centos 7.6 deployment k8s (v1.14.2) cluster
Detailed steps to install and configure k8s cluster in centos 7
Centos6 install Python2.7.13
Centos7.3 install nginx
CentOS7.2 install Mysql5.7.13
Centos7 install Python 3.6.
CentOS7 install MySQL
Centos7 install protobuf
CentOS 7 install Docker
CentOS7 install GlusterFS
CentOS7 install Docker
Centos6.5 install Tomcat
CentOS install Python 3.6
Vmware install CentOS6
centos7 install docker-ce 18.01.0
CentOS 7.2 install MariaDB
CentOS 7 install Hadoop 3.0.0
Centos7 install Python2.7
Centos 7.6 install seleniu
Install mysql8.0.13 version under Linux CentOS7 system
Centos install the latest version of cmake
CentOS 7.3 install Zabbix3
Centos7 install LAMP+PHPmyadmin
CentOS install mysql
CentOS install openjdk 1.8
CENTOS6.5 install CDH5.12.1 (1)
CentOS install PHP
Centos7 install Docker
CentOS7 install mysql
centOs install rabbitMQ
CentOS 7 install MySQL 5.6
Centos7 install Nginx
CentOS6.5 install CDH5.13
Centos7 install docker18
Centos install Python3
centos7 install nginx-rtmp
CentOS8 install MySQL8.0
CentOS install PostgreSQL 9.1
CentOS7 install mysql8
CentOS 7 install Java 1.8
CentOS8 install fastdfs6.06
CentOS 7 install Gitlab
Centos 7 install PostgreSQL
CentOS7 install MySQL8
CentOS 7 install Java 1.8
CentOS 6 install Docker
centos 6.5 install zabbix 4.4
Centos8 install Docker
CentOS6.8 install python2.7
CentOS install nodejs 8
CentOS6.5 install GNS3