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

How to install Kubernetes1.12.2 using a docker image

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

Share

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

This article introduces the knowledge of "how to use docker image to install Kubernetes1.12.2". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Installation of kubernetes version 1.12.2

At least two machines are allowed: master,node

Ip: master:192.168.1.220

Node1:192.168.1.221

Node2:192.168.1.205

Environment: centos7

Configuration: from 2core 4G onwards

Note:

The maximum support of docker version is 18.06, which is higher than that of this edition.

Kubernetes12.2+docker-ce18.06.1ce

(1) configuration of the environment:

Execute on the master and node side:

1: security policy rule configuration

Systemctl stop firewalld

Systemctl disable firewalld

Setenforce 0

Iptables-F

Iptables-t nat-F

Iptables-I FORWARD-s 0.0.0.0swap 0-d 0.0.0.0swap 0-j ACCEPT

Yum-y install ntp

Ntpdate pool.ntp.org

Systemctl start ntpd

Systemctl enable ntpd

2: kernel settings:

Close selinux

Vim / etc/sysconfig/selinux

SELINUX=disable

Modify kernel parameters

$vim / etc/sysctl.conf

Net.ipv4.ip_forward=1

Net.bridge.bridge-nf-call-ip6tables = 1

Net.bridge.bridge-nf-call-iptables = 1

Net.bridge.bridge-nf-call-arptables = 1

Vm.swappiness=0

Close swap

Swapoff-a

Comment auto-mount

Vim / etc/fstab

Close selinux

Vim / etc/selinux/config

Save and modify kernel parameters

Sysctl-p

Make sure that the following two files show a value of 1:

[root@k8m1 ~] # cat / proc/sys/net/bridge/bridge-nf-call-ip6tables

one

[root@k8m1 ~] # cat / proc/sys/net/bridge/bridge-nf-call-ip6tables

Each node modifies the following values

[root@k8n2 ~] # vim / etc/sysconfig/kubelet

KUBELET_EXTRA_ARGS= "fail-swap-on=false"

3: domain name resolution, secret-free login, time synchronization

A:

[root@k8m1 ~] # vim / etc/hosts

[root@k8m1 ~] # cat / etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.1.220 k8m1

192.168.1.221 k8n1

192.168.1.205 k8n2

B:

[root@k8m1 ~] # vim / etc/hosts

[root@k8m1] # ssh-keygen-t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/ root/.ssh/id_rsa):

Created directory'/ root/.ssh'.

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in / root/.ssh/id_rsa.

Your public key has been saved in / root/.ssh/id_rsa.pub.

The key fingerprint is:

SHA256:ldQKudY4N7CV+VrQV6qCOeEC5KlKIeLk7F8tR/cm8kI root@k8m1

The key's randomart image is:

+-[RSA 2048]-+

|. .. =.. |

| o. +. =. O. | |

| | oo + .Oo +.. | | |

| B.. . . * = o. |

| =. .os +. +. | |

| o. OE..o. | |

|. O.+. O |

|. . O.o o |

|. .. | |

+-[SHA256]-+

[root@k8m1] # ssh-copy-id-I ~ / .ssh/id_rsa k8n1

[root@k8m1] # ssh-copy-id-I ~ / .ssh/id_rsa k8n2

The c:master and node sides execute the

[root@k8m1 ~] # yum-y install ntp

[root@k8m1 ~] # ntpdate pool.ntp.org

10 Nov 11:07:32 ntpdate [50259]: step time server 193.228.143.22 offset 14.725020 sec

[root@k8m1 ~] # systemctl start ntpd

[root@k8m1 ~] # systemctl enable ntpd

Created symlink from / etc/systemd/system/multi-user.target.wants/ntpd.service to / usr/lib/systemd/system/ntpd.service.

[root@k8m1 ~] #

(2) installation of docker: installation is officially required.

Configure docker-CE source: all master node should be configured.

$sudo yum install-y yum-utils\

Device-mapper-persistent-data\

Lvm2

$sudo yum-config-manager\

-- add-repo\

Https://download.docker.com/linux/centos/docker-ce.repo

$yum list docker-ce-- showduplicates | sort-r

$yum install docker-ce-18.06.1.ce

Note: at present, kubernetes1.12.2 supports a maximum of 18.06 docker versions and has been updated to 18.9.

So you can't mean that only yum installs the latest version, specify the version model.

$systemctl start docker

$systemctl enable docker

$systemctl status docker

Execute the following command to configure the accelerator:

Curl-sSL https://get.daocloud.io/daotools/set_mirror.sh | sh-s http://f1361db2.m.daocloud.io

Then restart docker

$systemctl restart docker

Configure Aliyun:

[root@k8n2 yum.repos.d] # wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

# yum repolist

(3) configure kubernetes source:

Vim / etc/yum.repos.d/kubernetes.repo

[kubernetes]

Name=Kubernetes Rope

Baseurl= https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/

Gpgcheck=1

Gpgkey= https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

Enabled=1

[root@k8n2 yum.repos.d] # yum repolist

Loaded plug-in: fastestmirror

Kubernetes | 1.4 kB 00:00:00

Kubernetes/primary | 37 kB 00:00:00

Loading mirror speeds from cached hostfile

Base: mirrors.163.com

Epel: mirrors.aliyun.com

Extras: mirrors.aliyun.com

Updates: mirrors.aliyun.com

Kubernetes 272/272

Source identity Source name status

Base/7/x86_64 CentOS-7-Base 9911

Docker-ce-stable/x86_64 Docker CE Stable-x86mm 64 25

Epel/x86_64 Extra Packages for Enterprise Linux 7-x86 million 64 12696

Extras/7/x86_64 CentOS-7-Extras 434

Kubernetes Kubernetes Rope 272

Updates/7/x86_64 CentOS-7-Updates 1614

Repolist: 24952

Install on the masterside:

# yum install-y kubelet kubeadm kubectl

Kubeadm init-- help # View initialization command help

Kubeadm config images list

Use the following command: check to see that all the required installation components have the following:

Kubeadm config images list

Service components:

K8s.gcr.io/kube-apiserver:v1.12.2

K8s.gcr.io/kube-controller-manager:v1.12.2

K8s.gcr.io/kube-scheduler:v1.12.2

K8s.gcr.io/kube-proxy:v1.12.2

K8s.gcr.io/pause:3.1

K8s.gcr.io/etcd:3.2.24

K8s.gcr.io/coredns:1.2.2

How to install the components now? DockerHub, of course.

Use the following command to docker pull down:

Docker pull mirrorgooglecontainers/kube-apiserver-amd64:v1.12.2

Docker pull mirrorgooglecontainers/kube-controller-manager-amd64:v1.12.2

Docker pull mirrorgooglecontainers/kube-scheduler-amd64:v1.12.2

Docker pull mirrorgooglecontainers/kube-proxy-amd64:v1.12.2

Docker pull mirrorgooglecontainers/pause-amd64:3.1

Docker pull mirrorgooglecontainers/etcd-amd64:3.2.24

Docker pull kuberneter/coredns:1.2.2

Both the tag and the service component are tagged as downloaded:

Docker tag mirrorgooglecontainers/kube-apiserver-amd64:v1.12.2 k8s.gcr.io/kube-apiserver:v1.12.2

Docker tag mirrorgooglecontainers/kube-controller-manager-amd64:v1.12.2 k8s.gcr.io/kube-controller-manager:v1.12.2

Docker tag mirrorgooglecontainers/kube-scheduler-amd64:v1.12.2 k8s.gcr.io/kube-scheduler:v1.12.2

Docker tag mirrorgooglecontainers/kube-proxy-amd64:v1.12.2 k8s.gcr.io/kube-proxy:v1.12.2

Docker tag mirrorgooglecontainers/pause-amd64:3.1 k8s.gcr.io/pause:3.1

Docker tag mirrorgooglecontainers/etcd-amd64:3.2.24 k8s.gcr.io/etcd:3.2.24

Docker tag kuberneter/coredns:1.2.2 k8s.gcr.io/coredns:1.2.2

Initialize the cluster and execute it only on the masterside: () change it to master address)

Kubeadm init\

-- kubernetes-version=v1.12.2\

-- pod-network-cidr=10.244.0.0/16\

-- apiserver-advertise-address=192.168.1.220

The following token will appear after master initialization. To copy it and save it, add node to use:

Kubeadm join 192.168.1.220 6443-token o4bmhn.12ppkvve2cecgk6m-discovery-token-ca-cert-hash sha256:03b9e1d1979288194bcf694c12a85217236319cfdf1b89aae803e430796c611b

If you forget all of the above token, you can get it with the following command:

Kubeadmin token list

At this time, root users cannot use kubelet to control the cluster needs. Configure the environment variables.

For non-root users

Mkdir-p $HOME/.kube

Sudo cp-I / etc/kubernetes/admin.conf $HOME/.kube/config

Sudo chown $(id-u): $(id-g) $HOME/.kube/config

Start faannel

Kubectl apply-f https://raw.githubusercontent.com/coreos/flannel/bc79dd1505b0c8681ece4de4c0d86c5cd2643275/Documentation/kube-flannel.yml

Root users execute the following configuration environment variables

Export KUBECONFIG=/etc/kubernetes/admin.conf

You can also put it directly into ~ / .bash_profile

Echo "export KUBECONFIG=/etc/kubernetes/admin.conf" > > ~ / .bash_profile

Kubectl get pods-all-namespaces

The node node needs to install the du software:

# yum install-y kubelet kubeadm kubectl

[root@k8n2 ~] # vim / etc/sysconfig/kubelet

KUBELET_EXTRA_ARGS= "--fail-swap-on=false"

The docker image to be installed by the node node:

Docker pull mirrorgooglecontainers/kube-proxy-amd64:v1.12.2

Docker pull mirrorgooglecontainers/pause-amd64:3.1

Docker pull kuberneter/coredns:1.2.2

The ETCD of docker pull mirrorgooglecontainers/etcd-amd64:3.2.24 # node customers can be installed

Or you don't need to install the ETCD cluster. The installation is

Label

Docker tag mirrorgooglecontainers/kube-proxy-amd64:v1.12.2 k8s.gcr.io/kube-proxy:v1.12.2

Docker tag mirrorgooglecontainers/pause-amd64:3.1 k8s.gcr.io/pause:3.1

Docker tag kuberneter/coredns:1.2.2 k8s.gcr.io/coredns:1.2.2

Token: you will join the cluster on your own before execution.

Kubeadm join 192.168.1.220 6443-token o4bmhn.12ppkvve2cecgk6m-discovery-token-ca-cert-hash sha256:03b9e1d1979288194bcf694c12a85217236319cfdf1b89aae803e430796c611b

[root@k8m1 ~] # kubectl get nodes

NAME STATUS ROLES AGE VERSION

K8m1 Ready master 22h v1.12.2

K8n1 Ready 22h v1.12.2

K8n2 Ready 37m v1.12.2

[root@k8m1] # kubectl get pods-- all-namespaces

NAMESPACE NAME READY STATUS RESTARTS AGE

Kube-system coredns-576cbf47c7-jqcn8 1/1 Running 0 22h

Kube-system coredns-576cbf47c7-rqqvk 1/1 Running 0 22h

Kube-system etcd-k8m1 1/1 Running 0 22h

Kube-system kube-apiserver-k8m1 1/1 Running 0 22h

Kube-system kube-controller-manager-k8m1 1/1 Running 0 22h

Kube-system kube-flannel-ds-amd64-ck799 1/1 Running 1 22h

Kube-system kube-flannel-ds-amd64-nkdzg 1/1 Running 0 38m

Kube-system kube-flannel-ds-amd64-tjp27 1/1 Running 0 22h

Kube-system kube-proxy-8b7ds 1/1 Running 0 38m

Kube-system kube-proxy-dmswb 1/1 Running 0 22h

Kube-system kube-proxy-pm7wt 1/1 Running 0 22h

Kube-system kube-scheduler-k8m1 1/1 Running 0 22h

OK, the view node may start slowly, so you have to wait. If you can't add it, you need to troubleshoot the problem.

(if there is a problem with initializing the cluster, you can use the following command to clean up and reinitialize: kubeadm reset)

This is the end of "how to install Kubernetes1.12.2 using docker Image". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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: 0

*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