Kubernetes Learning Series Simple cluster installation and configuration

Source: Internet
Author: User
Tags reserved etcd
Environment Configuration


CentOS Linux release 7.3.1611 (Core)
etcd-v3.2.6

Docker-ce-17.03.2.ce

kubernetes-v1.6.9

192.168.108.128 Nodes 1
192.168.108.129 Nodes 2
192.168.108.130 Nodes 3


kubernetes Download

Https://github.com/kubernetes/kubernetes/releases/download/v1.6.9/kubernetes.tar.gz


Installation Configuration
Prerequisites

1. The Docker,docker installation must be available on node nodes please refer to the official documentation

2. Install ETCD v3, specific installation can refer to "ETCD cluster installation configuration and simple Application"


Start Installation


Here choose Binary file installation, download kubernetes.tar.gz is not an executable file, but a series of scripts.

Unzip the downloaded kubernetes.tar.gz

$ tar zxvf kubernetes.tar.gz-c/opt/
$ cd/opt/kubernetes

Execute get-kube-binaries.sh download server and client executable files

$./cluster/get-kube-binaries.sh kubernetes release:v1.6.9 server:linux/amd64 (to override, set Kubernetes_server_arc H) Client:linux/amd64 (autodetected) would download kubernetes-server-linux-amd64.tar.gz from https:// storage.googleapis.com/kubernetes-release/release/v1.6.9 would download and extract Kubernetes-client-linux-amd64.tar.gz from https://storage.googleapis.com/kubernetes-release/release/v1.6.9 are this Ok? [y]/n Y% total% Received% xferd Average Speed 

Load Upload Total spent left Speed 347M 347M 0 0 6110k 0 0:00:58 0:00:58--:--:--10.6M Md5sum (kubernetes-server-linux-amd64.tar.gz) =decfd705eb0f32205d9016a41f2262b6 sha1sum ( kubernetes-server-linux-amd64.tar.gz) =85f88c723881a092da67230936879909cb7882ac% total% Received% Xferd Average S Peed time Dload Upload Total spent left Speed 100 29.0M 29.0M 0 0 1910k 0 0:00:15 0:00:15--:--:--2919k md5sum (kubernetes-client-linux-amd64.tar.gz) =ff28d0f1f3384d7594f2a71d2daa89f3 sha1sum (kubernetes-client-linux-amd64.tar.gz) = b941a95770d5f4b5c6784d1918a766480f600930 extracting/opt/kubernetes/client/kubernetes-client-linux-amd64.tar.gz Into/opt/kubernetes/platforms/linux/amd64 Add '/opt/kubernetes/client/bin ' to your PATH to use newly-installed binaries .

Executing this shell automatically downloads the Kube server and client executables, where the client files are automatically extracted into the client folder under the Kubernetes directory, just add the bin to the path, and you can do nothing here. The client command-line tool is also included in the server's executable package. Server-side executables are downloaded to the Servers folder without automatic decompression, a new/opt/kube directory is created later, and then extracted to the current directory.

$ cp-au/opt/kubernetes/server/kubernetes-server-linux-amd64.tar.gz/opt/kube
$ cd  /opt/kube
$ tar xzvf/ Kubernetes-server-linux-amd64.tar.gz


[Root@bogon kube]# ll kubernetes/server/bin total dosage 1624384-rwxr-x---1 root root 119891993 August 01:20 Cloud-controller-man Ager-rwxr-x---1 root 191034128 August 01:20 hyperkube-rwxr-x---1 root 69883109 August 01:20 kubeadm-rwxr-x ---1 root 55257883 August 01:20 kube-aggregator-rw-r-----1 root root 33 August 01:20 Kube-aggregator.docke R_tag-rw-r-----1 root 56611328 August 01:20 kube-aggregator.tar-rwxr-x---1 root 149557444 August 01:20 kube  -apiserver-rw-r-----1 Root 33 August 01:20 kube-apiserver.docker_tag-rw-r-----1 root root 150910976 August 24        01:20 kube-apiserver.tar-rwxr-x---1 root 131818104 August 01:20 kube-controller-manager-rw-r-----1 root root 33 August 01:20 kube-controller-manager.docker_tag-rw-r-----1 root 133171712 August 01:20 kube-controller-manag Er.tar-rwxr-x---1 root 70704763 August 01:20 kubectl-rwxr-x---1 root 68136904 August 01:20 kubefed-rwxr-x ---1 root root 138853888 August 01:20 kubelet-rwxr-x---1 root root 64015718 August 01:20 kube-proxy-rw-r-----1 root root 33 August 24 01   : kube-proxy.docker_tag-rw-r-----1 root 110821888 August 01:20 kube-proxy.tar-rwxr-x---1 root root 75646372 August  01:20 kube-scheduler-rw-r-----1 root 33 August 01:20 kube-scheduler.docker_tag-rw-r-----1 root root 76999680 August 01:20 Kube-scheduler.tar

Configuring and starting Services
To build a kubernetes cluster, you first need to start Kube-apiserver, Kube-controller-manager, and Kube-scheduler services on the master node. Then start the Kubelet, Kube-proxy service on each node.
Master Node Service configuration

Kube-apiserver.service

Vi/usr/lib/systemd/system/kube-apiserver.service

[unit]
description=kube-apiserver service
after= Network.target

[Service]
type=notify
execstart=/opt/kube/kubernetes/server/bin/kube-apiserver \
            --admission-control=namespaceautoprovision,limitranger,securitycontextdeny \
            --apiserver-count=1 \
            --cors-allowed-origins=.* \
            --enable-garbage-collector=false \
            --etcd-servers=http:// 192.168.108.128:2379 \
            --insecure-bind-address=0.0.0.0 \
            --insecure-port=8080 \
            --log-dir=/opt/ Kube/log/kube-apiserver \
            --logtostderr=false \
            --service-cluster-ip-range=192.168.108.0/24 \
            --v= 5 \

restart=always
limitnofile=65536

[Install]
Wantedby=default.target

Kube-controller-manager.service
$ vi/usr/lib/systemd/system/kube-controller-manager.service

[unit]
Description=kube-controller-manager Service
after=network.target

[service]
type=simple
execstart=/opt/kube/kubernetes/server/bin/ Kube-controller-manager \
          --enable-garbage-collector=false \
          --logtostderr=false \
          --log-dir=/opt/ Kube/log/kube-controller-manager \
          --pod-eviction-timeout=5m0s \
          --master=http://0.0.0.0:8080 \--
          node-monitor-grace-period=40s \
          --terminated-pod-gc-threshold=12500 \
          --leader-elect=true \
          --v=5 \

restart=always
limitnofile=65536

[Install]
Wantedby=default.target

Kube-scheduler.service

$ vi/usr/lib/systemd/system/kube-scheduler.service

[unit]
Description=kube-scheduler service
after= Network.target

[Service]
type=simple
execstart=/opt/kube/kubernetes/server/bin/kube-scheduler \
            --log-dir=/opt/kube/log/kube-scheduler \
            --logtostderr=false \
            --master=http://0.0.0.0:8080 \--
            leader-elect=true \
            --v=5 \

restart=always
limitnofile=65536

[Install]
wantedby= Default.target

After the configuration is complete, execute the systemctl start command to start the 3 services sequentially. Systemctl--system Daemon-reload
Systemctl Start Kube-apiserver.service
Systemctl Start Kube-controller-manager.service
Systemctl Start Kube-scheduler.service

To view service startup information:
Systemctl Status Kube-apiserver.service-l
Systemctl Status Kube-controller-manager.service-l
Systemctl Status Kube-scheduler.service-l
Node Service configuration
192.168.108.129
Kubelet.service

[Unit]
Description=kubelet service
after=network.target

[service]
type=simple
execstart=/opt/kube/ Kubernetes/server/bin/kubelet \
            --api-servers=http://192.168.108.128:8080 \
            --hostname-override=node-2 \
            --image-gc-high-threshold=80 \
            --image-gc-low-threshold=50 \
            --log-dir=/opt/kube/log/kubelet \
            --logtostderr=false \
            --pod-infra-container-image=docker.cloudin.com/google_containers/pause-amd64 : 3.0 \
            --system-reserved cpu=2000m,memory=1g \
            --v=5 \

restart=always
limitnofile=65536

[ Install]
Wantedby=default.target

Kube-proxy.service

$ vi/usr/lib/systemd/system/kube-proxy.service

[unit]
description=kube-proxy service
after= Network.target

[Service]
type=simple
execstart=/opt/kube/kubernetes/server/bin/kube-proxy  \
            --log-dir=/opt/kube/log/kube-proxy \
            --logtostderr=false \
            --master=http://192.168.108.128:8080 \
            --v=5 \

Restart=always
limitnofile=65536

[Install]
Wantedby=default.target

192.168.108.130

Kubelet.service

$ vi/usr/lib/systemd/system/kubelet.service

[unit]
description=kubelet service
After=network.target

[Service]
Type=simple
execstart=/opt/kube/kubernetes/server/bin/kubelet \
            --api-servers=http:// 192.168.108.128:8080 \
            --hostname-override=node-3 \
            --image-gc-high-threshold=80 \--
            image-gc-low-threshold=50 \
            --log-dir=/opt/kube/log/kubelet \
            --logtostderr=false \--
            pod-infra-container-image=docker.cloudin.com/google_containers/pause-amd64:3.0 \
            --system-reserved cpu= 2000m,memory=1g \
            --v=5 \

restart=always
limitnofile=65536

[Install]
wantedby= Default.target

Kube-proxy.service

$ vi/usr/lib/systemd/system/kube-proxy.service

[unit]
description=kube-proxy service
after= Network.target

[Service]
type=simple
execstart=/opt/kube/kubernetes/server/bin/kube-proxy  \
            --log-dir=/opt/kube/log/kube-proxy \
            --logtostderr=false \
            --master=http://192.168.108.128:8080 \
            --v=5 \

Restart=always
limitnofile=65536

[Install]
Wantedby=default.target

After the configuration is complete, execute the systemctl start command to start the 2 services.
Systemctl--system Daemon-reload
Systemctl start Kubelet.service systemctl start Kube-proxy.service

To view service startup information:
Systemctl Status Kubelet.service-l
Systemctl Status Kube-proxy.service-l

Client Commands

$ cd/opt/kube/kubernetes/server

To view cluster nodes:

$ bin/kubectl Get nodes

To delete a service:

$ bin/kubectl Delete node $NODENAME

To view kubernets related interfaces:

http://192.168.108.128:8080/


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.