Kubernetes 1.10.0 Offline installation

Source: Internet
Author: User
Tags k8s

Describes how to install kubernetes offline, mainly for the study of Kubernetes, not recommended in production environment , install package get address:

Link: Https://pan.baidu.com/s/1nX5_memy8TKrnw1auOsB8Q Password: ZSW7

Operating Environment
Name Operating system Configuration Ip
Master CentOS 7 4 Core 2G Memory 192.168.132.130
Node CentOS 7 4 Core 8G Memory 192.168.132.136

The configuration of the server is recommended to a higher point, which avoids most problems.

master installation

1.1 Setting up partitions

If you have data disks that need to be mounted, you can set the partition first, and you cannot skip this step.

Mkdir-p/var/lib/docker--Create a directory to store Docker

Fdisk-l--View the hard drive information to determine the drive information that needs to be mounted

MKFS.EXT4/DEV/XVDE--Format the hard drive

Mount/dev/xvde/var/lib/docker Mounting Disk

Blkid--View hard drive information

Vim/etc/fstab--Writes the blkid of the new partition to/etc/fstab, the content reference:

UUID={UUID}/var/lib/docker ext4 defaults 0 0

Save the exit and restart the machine.

1.2 Modifying host Names

The hostname of the kubernetes cannot contain uppercase letters , such as if the hostname contains uppercase letters, please modify it first.

Hostnamectl set-hostname xxxxx

1.3 Shutting down the firewall

Systemctl Stop Firewalld.service

Systemctl Disable Firewalld.service

1.4 Forbidden Selinnux

Setenforce 0

Sed-i ' s/selinux=enforcing/selinux=disabled/g '/etc/selinux/config

1.5 No Swap

Swapoff-a

Edit/etc/fstab, and write off swap

Vi/etc/fstab

1.6 Setting up a network bridge

Cat <<eof >/etc/sysctl.d/k8s.conf
Net.bridge.bridge-nf-call-ip6tables = 1
Net.bridge.bridge-nf-call-iptables = 1
Net.ipv4.ip_forward=1
Eof
Sysctl--system

1.7 Installing Docker

Copy the kubernetes-1.10.tar.gz to the/root directory.

Unpack the installation package:

Cd/root

TAR-ZVXF kubernetes-1.10.tar.gz-c/root

Tar-zvxf/root/k8s-1.10/docker-17.03.0-ce.tgz-c/root/k8s-1.10

Copy Docker:

chmod +x/root/k8s-1.10/docker/*

cp/root/k8s-1.10/docker/*/usr/bin/

cp/root/k8s-1.10/docker.service/etc/systemd/system/

Run Docker:

Systemctl Daemon-reload

Systemctl Enable Docker.service

Systemctl Restart Docker.service

Iptables-f

Iptables-p FORWARD ACCEPT

Iptables-f

1.8 Loading Kubernetes related mirrors

Docker Load-i/root/k8s-1.10/kubernetes-1.10.tar

1.9 Installing KUBEADM,KUBECTL,KUBELET,CNI

cd/root/k8s-1.10

chmod +x/root/k8s-1.10/kube/*

cp/root/k8s-1.10/kube/*/usr/bin/

cp/root/k8s-1.10/kubelet.service/etc/systemd/system/

Mkdir-p/ETC/SYSTEMD/SYSTEM/KUBELET.SERVICE.D

Cp/root/k8s-1.10/10-kubeadm.conf/etc/systemd/system/kubelet.service.d

Systemctl Daemon-reload

Systemctl Enable Kubelet.service

Mkdir-p/opt/cni/bin

cd/root/k8s-1.10

TAR-ZVXF cni-plugins-amd64-v0.6.0.tgz-c/opt/cni/bin

1.10 Installing Socat and Ebtables

rpm-ivh/root/k8s-1.10/rpm/socat-1.7.3.2-2.el7.x86_64.rpm

rpm-ivh/root/k8s-1.10/rpm/ebtables-2.0.10-16.el7.x86_64.rpm

Note: If you have already installed you can skip this step, if you have installed Ebtables, you will be prompted for the conflict, but will not affect, can be ignored.

1.11 Initializing Master

Kubeadm Init--kubernetes-version=1.10.0--pod-network-cidr=192.168.0.0/16--apiserver-advertise-address= 192.168.132.130

Note: 192.168.132.130 is the master physical IP.

Save this command, the next node to join the cluster needs to be used.

1.12 Setting the Kubelet config environment variable

Mkdir-p $HOME/.kube
Cp-i/etc/kubernetes/admin.conf $HOME/.kube/config
Chown $ (id-u): $ (id-g) $HOME/.kube/config
Export kubeconfig=/etc/kubernetes/admin.conf

1.13 Creating a network model

cd/root/k8s-1.10

Kubectl create-f Calico.yaml

1.14 Check that all components are started

Kubectl Get Po-n Kube-system

Node installation

Repeat steps 1.1 through 1.0

Execute the command generated in 1.11: Kubeadm join XXX ...

Note: If you fail, you can execute iptables-f on master and try to join again.

Perform kubectl get nodes in master to see the node join situation:

Tag node and execute the following command at Master:

Kubectl label node XXX kubernetes.io/role=node

Test your deployment

To prepare Nginx deployment Yaml,nginx.yaml:

Apiversion:extensions/v1beta1kind:deploymentmetadata:  name:nginx  Labels:    app:nginx  namespace: Defaultspec:  replicas:1  Template:    metadata:      Labels:        app:nginx    Spec:      nodeselector:        kubernetes.io/role:node      containers:      -Name:nginx        image:nginx:1.13        ports:        - CONTAINERPORT:80---kind:ServiceapiVersion:v1metadata:  name:nginx  Labels:    app:nginx  Namespace:defaultspec:  selector:    app:nginx  type:nodeport  ports:  -Name:nginx    nodeport:30000    port:80    protocol:tcp    targetport:80

Perform Kubectl create-f Nginx.yaml in master

Access using node's address http://192.168.132.136:30000/:

Additional Information

There is no need to install all of the components on the master node, but this requires Master,node to do a single installation package. For convenience, the same components as master are installed on node.

Kubernetes 1.10.0 Offline installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.