Kubernetes stand-alone installation deployment

Source: Internet
Author: User
Tags install go docker run etcd k8s

System environment:

Ubuntu 16.04.2 LTS

Software Environment:

Docker 1.12.6

Go 1.8.3

ETCD 3.1.8

Flannel 0.7.1

Kubernetes Master 1.7.0-alpha

Installation steps:

1 Installing Docker

1) apt-get Update

2) Apt-get Upgrade

3) apt-get Install Docker.io

4) Service Docker restart

5) Docker Run Hello-world

6) Docker run-it Ubuntu bash

2 Install Go1) Download the Go Language Compression packwget https://golang.org/dl/go1.8.3.linux-amd64.tar.gz 2) Unzip the packagetar-c/usr/local-xzf go1.8.3.linux-amd64.tar.gz3) Add the following environment variables to/etc/profile (for a system-wide installation) or $HOME/.profileexport path= $PATH:/usr/local/go/bin4) Write Hello. Go file, fill in the following, put in the $home/go/src/hello folder
" FMT " Func Main () {    fmt. Printf ("Hello, world\n")}
5) test the Go locale, $HOME/go/default to/root/go/Go run ~/go/src/hello/hello.go 3 Installing ETCD1) Download ETCD Compression packwget https://github.com/coreos/etcd/releases/download/v3.1.8/etcd-v3.1.8-linux-amd64.tar.gz

2) Unzip the ETCD compression pack

Tar-xzf etcd-v3.1.8-linux-amd64.tar.gz

3) Copy ETCD executable program

CD ETCD-V3.1.8-LINUX-AMD64

CP Etcd Etcdctl/usr/bin

4 Installing flannel 1) Download flannel Compression Packwget https://github.com/coreos/flannel/releases/download/v0.7.1/flannel-v0.7.1-linux-amd64.tar.gz

2) Unzip the flannel compression pack

Tar-xzf flannel-v0.7.1-linux-amd64.tar.gz

3) Copy Flannel executable program

CD FLANNEL-V0.7.1-LINUX-AMD64

CP Flannelid Mk-docker-opts.sh/usr/bin

5 Installing k8s 1) Get k8s Master version (1.7.0-alpha)git clone https://github.com/kubernetes/kubernetes.git

2) Compiling k8s

CD Kubernetes

Make Quick-release

After the compilation is complete:

k8s Server file : ~/go/src/kubernetes/_output/release-stage/server/linux-amd64/kubernetes/server/bin

k8s Client file : ~/go/src/kubernetes/_output/release-stage/client/linux-amd64/kubernetes/client/bin

3) Copy k8s server and client executable files

CD ~/go/src/kubernetes/_output/release-stage/server/linux-amd64/kubernetes/server/bin

CP */usr/bin

CD ~/go/src/kubernetes/_output/release-stage/client/linux-amd64/kubernetes/client/bin

CP */usr/bin

Note: Replace the 10.229.43.237 in the following operation with the IP address of the host where you installed k8s

6 Starting and testing EtcdK8s uses ETCD to save the information for the Master and node nodes, so you need to start ETCD1 before starting k8s Etcdetcd-initial-advertise-peer-urls http://10.229.43.237:2380 -listen-peer-urls/ http 10.229.43.237:2380 -listen-client-urls http://10.229.43.237:2379,http://127.0.0.1:2379 - Advertise-client-urls http://10.229.43.237:2379 2) Read-write Etcd key and Valueetcdctl set Foo bar

Etcdctl get foo

7 Start Flannel and associate Docker1) Start Flannelflanneld 2) Set ETCD configuration Flanneletcdctl set/coreos.com/network/config ' {"Network": "172.17.0.0/16"} ' Etcdctl Set/coreos.com/network/subnets/172.17.10.0-24 ' {"Publicip": "10.229.43.237"} ' 3) set flannel associated Docker

Mk-docker-opts.sh-i
Source/run/flannel/subnet.env
Rm/var/run/docker.pid
Ifconfig Docker0 ${flannel_subnet}
Service Docker restart

8 Start k8s1) Start Kube-apiserverkube-apiserver--address=0.0.0.0--insecure-port=8080--service-cluster-ip-range= ' 10.10.10.1/24 '--log_dir=/ Usr/local/kubernete_test/logs/kube--kubelet_port=10250--v=0--logtostderr=false--etcd_servers=/http 10.229.43.237:2379 --allow_privileged=false 2) Start Kube-controller-managerkube-controller-manager--v=0--logtostderr=false--log_dir=/usr/local/kubernete_test/ Logs/kube--master=10.229.43.237:8080 3) Start Kube-scheduler kube-controller-manager--v=0--logtostderr=false-- Kube-scheduler--master= ' 10.229.43.237:8080 '--v=0--log_dir=/usr/local/kubernete_test/logs/kube 4) Test if the master node starts normally kubectl get componentstatuses5) Start Kube-proxykube-proxy--logtostderr=false--v=0--master=http://10.229.43.237:8080 6) Start Kubeletkubelet--logtostderr=false--v=0--allow-privileged=false--log_dir=/usr/local/kubernete_test/logs/kube-- address=0.0.0.0--port=10250--hostname_override=10.229.43.237--api_servers=http://10.229.43.237:8080 7) Set the cluster context on nodekubectl config set-cluster test-cluster--server=http://10.229.43.237:8080 kubectl config set-context test-cluster--cluster=test-clusterkubectl config use-context test-cluster8) Prepare Kubernetes/pause imagebecause the k8s pod requires pause mirroring to start the pause container, you need to prepare the Kubernetes/pause imageDocker Pull Docker.io/kubernetes/pauseDocker tag f9d5de079539 gcr.io/google_containers/pause:2.0 this is equivalent to renaming the Docker.io to gcr.io,f9d5de079539 as the image ID (Docker images) that was pulled down.9) Confirm that the k8s is starting successfullyKubectl Get Nodes 9 Deployment of Nginx cluster1) Create Nginx podskubectl run Nginx--image=nginx--port=80--replicas=5kubectl get pods 2) Create Nginx-service.yaml
apiVersion:v1kind:Servicemetadata:  name:nginx  Labels:    app:nginxspec:  ports:    9090 selector  :    name:nginx     
3) Create service according to Podskubectl create-f Nginx-service.yamlKubectl Get Services to this k8s the cluster deployment is complete.

Kubernetes stand-alone installation deployment

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.