CENTOS7 Deploying Kubernetes Clusters

Source: Internet
Author: User
Tags etcd

Resource link: Https://pan.baidu.com/s/1-PT_QQAf7cTu_znX-S-r9Q Password: 33SR

Forward: http://blog.51cto.com/lizhenliang/1983392

a , Environmental Planning

Operating system: centos7.3_x64

Kubernetes installation directory:/opt/kubernetes

Release Notes:

kubernetes:v1.9

Docker:18.06.0-ce

ETCD:3.2

Role

Ip

Component

Master

192.168.1.195

Etcd

Kube-apiserver

Kube-controller-manager

Kube-scheduler

Node01

192.168.1.196

Kube-proxy

Kubelet

Docker

Flannel

Node02

192.168.1.197

Kube-proxy

Kubelet

Docker

Flannel

two , Install D Ocker

in the all node execution:

Setenforce 0

Iptables-f

Iptables-t nat-f

Iptables-i forward-s 0.0.0.0/0-D 0.0.0.0/0-j ACCEPT

Iptables-i input-s 192.168.0.0/24-j ACCEPT

Turn on route forwarding

Echo 1 >/proc/sys/net/bridge/bridge-nf-call-iptables
Echo 1 >/proc/sys/net/bridge/bridge-nf-call-ip6tables

in the Install Dockeron N ode:

# Install dependent packages

Yum install-y yum-utils Device-mapper-persistent-data lvm2

# Add a docker package source

Yum-config-manager \

--add-repo \

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

# Update Yum Package index

Yum Makecache Fast

# Install Docker CE

Yum Install Docker-ce

Set the default pull from the Chinese mirror warehouse:

# Vi/etc/docker/daemon.json

{

"Registry-mirrors": ["https://registry.docker-cn.com"]

}

# Systemctl Start Docker

# Systemctl Enable Docker

Test:

# Docker Info

three , installation E TCD

2.1 Download Binary Package

#yum Install Etcd–y

# vi/etc/etcd/etcd.conf

# Systemctl Start Etcd

# Systemctl Enable ETCD

Iv. deployment of F Lannel Network

1) write the allocated subnet segment to ETCD for Flanneld use

# etcdctl-endpoint= "http://192.168.1.195:2379" Set/coreos.com/network/config ' {"Network": "172.17.0.0/16", "backend ": {" Type ":" Vxlan "}} '

2) Download binary package

# wget https://github.com/coreos/flannel/releases/download/v0.9.1/flannel-v0.9.1-linux-amd64.tar.gz

# tar ZXVF flannel-v0.9.1-linux-amd64.tar.gz

# MV Flanneld Mk-docker-opts.sh/usr/bin

3) Configuration Flannel

Vi/etc/sysconfig/flanneld

flannel_options= "--etcd-endpoints=http://192.168.1.195:2379--ip-masq=true"

4) SYSTEMD Management flannel

# Vi/usr/lib/systemd/system/flanneld.service

[Unit]

Description=flanneld Overlay Address ETCD Agent

After=network.target

After=network-online.target

Wants=network-online.target

Before=docker.service

[Service]

Type=notify

Environmentfile=/etc/sysconfig/flanneld

Execstart=/usr/bin/flanneld $FLANNEL _options

Execstartpost=/usr/bin/mk-docker-opts.sh-k docker_network_options-d/run/flannel/subnet.env

Restart=on-failure

[Install]

Wantedby=multi-user.target

Requiredby=docker.service

5) Configure Docker to start the specified subnet segment (difference)

Modified into

6) Start

# Systemctl Daemon-reload

# Systemctl Start Flanneld

# Systemctl Enable Flanneld

# Systemctl Restart Docker

v. Get kubernetes binary package

Https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.9.md

This binary package contains the components of master and node.

Vi. running the master component

Unzip the prepared package :unzip Master.zip

# Mkdir-p/opt/kubernetes/{bin,cfg}

# mv Kube-apiserver Kube-controller-manager Kube-scheduler Kubectl/opt/kubernetes/bin

# chmod +x/opt/kubernetes/bin/* && chmod +x *.sh

#./apiserver.sh 192.168.1.195 http://127.0.0.1:2379

#./scheduler.sh 127.0.0.1

#./controller-manager.sh 127.0.0.1

# echo "Export path= $PATH:/opt/kubernetes/bin" >>/etc/profile

# Source/etc/profile

seven. Run node component

Unzip the prepared package: Unzip Node.zip

# Mkdir-p/opt/kubernetes/{bin,cfg}

# MV Kubelet Kube-proxy/opt/kubernetes/bin

# chmod +x/opt/kubernetes/bin/* && chmod +x *.sh

# MV *.kubeconfig/opt/kubernetes/cfg/

#./kubelet.sh 192.168.1.196 10.10.10.2

#./proxy.sh 192.168.1.196

This node IP is the native eth0 network card IP address.

Viii. Querying the status of a cluster

in the Master performs a view of the cluster nodes:

# Kubectl Get node

To view Component Status:

# Kubectl Get CS

Ix. Starting a test example

Start a Examples of Nginx replicas:

# kubectl Run Nginx--image=nginx--replicas=3

After the pod is working, create the service:

# Kubectl Expose deployment Nginx--port=88--target-port=80--type=nodeport

# Kubectl Get Svc Nginx

in the Node nodes access:

Curl <CLUSTER-IP>:P Ort

Ten Deployment W EB UI

Uploading Yaml files

[Email protected] ~]# Kubectl create-f Kubernetes-dashboard.yaml

CENTOS7 Deploying Kubernetes Clusters

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.