k8s deployment and application

# What is k8s

- ** Kubernetes ** name comes from the Greek, meaning "helmsman" or "navigator." 8 is K8s letter "ubernete" is replaced with the abbreviation "8".
- K8S creator, is a well-known industry giants - ** Google **.
- However K8S is not a new invention. Its predecessor, is Google's own fiddle ten years ** ** Borg systems.
- K8S is June 2014 officially announced by Google, the company came out and announced that open source.

# Why use k8s

- Kubernetes is Google 2014 founded management is the open source version of Google 10 years of large-scale container management technology Borg.
- K8s is a container cluster management system is an open source platform, automated deployment of cluster container can be achieved, automatic scaling capacity, maintenance and other functions

# when to use

- quickly deploy applications
- rapid expansion of application 
- seamlessly new application functionality
- saving resources, optimize the use of hardware resources

# Where with

- ** Portable **: support for public cloud, private cloud, hybrid cloud, multi-cloud (Multi-Cloud)
- ** ** Scalable: modular, plug-in technology, can be mounted, can be combined
- ** ** automation: automatic deployment, automatic restart, automatic replication, automatic retractable / extension

# how to use

- ** Build, Ship and run (create, send and running) **
- ** Build once, the run Anywhere (build once , can be used everywhere) **
- Docker three core concepts of technology, namely:

1. Mirror (Image)
2. container (Container)
3. Warehouse (the Repository)

## k8s architecture

A K8S system, commonly referred to as a ** K8S cluster (Cluster) **

This cluster consists of two parts:

- a ** Master node (master node) **

- Master node includes API Server, Scheduler, Controller manager, etcd.

<200b> API Server is an external interface of the whole system, and other components for client calls, the equivalent of "operating room."

<200b> Scheduler is responsible for scheduling resources within the cluster, the equivalent of "control room."

<200b> Controller manager responsible for managing the controller, the equivalent of "the great explorer."


- ** group of Node node (compute nodes) **

- Node node includes ** Docker, kubelet, kube-proxy, Fluentd, kube-dns ** (optional), there is ** Pod **.

<200b> ** Pod ** Kubernetes is the basic operation unit.

<200b> a Pod represents a process running in the cluster, which encapsulates one or more internal containers closely related.

<200b> In addition to the Pod, K8S there a ** Service **, a Foreign Service can be seen as a set of access interfaces provide the same services in the Pod

<200b> Docker, needless to say, to create a container.

<200b> Kubelet, is responsible for monitoring the Pod assigned to it in the Node, including create, modify, monitor, delete and so on.

<200b> Kube-proxy, the main agency responsible for providing for the Pod objects.

<200b> Fluentd, is responsible for log collection, storage and query.

Installation configuration

1 set ip and host names
/ etc / hosts

2 Open routing forwarding
net.ipv4.ip_forward = 1

Configuration 3 yum source
RHEL7-extras.iso

4 arranged private warehouse Registry [the repo]
yum the install Docker-Distribution
Management mirroring Docker
yum the install Docker
/ etc / sysconfig / Docker
image uploaded
centos.tar
Kubernetes dashboard.tar-
POD-infrastructure.tar
verification
http://192.168.1.10 curl : 5000 / v2 / _catalog

5 配置 kubernets - master
package:
etcd
kubernetes-master
kubernetes-client
service:
kube-apiserver
kube-controller-manager
kube-scheduler
etcd
conf:
/etc/etcd/etcd.conf
6: ETCD_LISTEN_CLIENT_URLS="http://192.168.1.10:2379"
/etc/kubernetes/config
22: KUBE_MASTER="--master=http://192.168.1.10:8080"
/etc/kubernetes/apiserver
8: KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
17: KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.1.10:2379"
23: 删除 ServiceAccount 参数
/etc/kubernetes/controller-manager
/etc/kubernetes/scheduler
验证
kubectl get cs
kubectl get csr
kubectl get node

6 configuration kubernets - minion ( do node Node )
Package:
Kubernetes-node
Docker
-Service:
kubelet
Kube-Proxy
Docker
the conf:
/ etc / sysconfig / Docker
. 4: Add the parameter --insecure-registry = 192.168.1.10: 5000 --add 192.168.1.10:5000 -registry
/ etc / Kubernetes / config
22 is: KUBE_MASTER = "--master = HTTP: //192.168.1.10: 8080"
/ etc / Kubernetes / kubelet
. 5: KUBELET_ADDRESS = "- address = 0.0.0.0 "
. 11: KUBELET_HOSTNAME =" - the override = hostname-name "
14: Add = --kubeconfig / etc / Kubernetes / kubelet.kubeconfig
--pod-Infra-Container-Image-POD = Infrastructure: Latest
/ etc / Kubernetes /kubelet.kubeconfig (self-defined configuration files)
apiVersion: V1
kind: Config
clusters:
- cluster:
server: http://192.168.1.10:8080 ###Master的IP,即自身IP
name: local
contexts:
- context:
cluster: local
name: local
current-context: local


7 网络
master:
/etc/etcd/etcd.conf
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"

etcdctl mk /atomic.io/network/config '{"Network": "10.254.0.0/16", "Backend": {"Type": "vxlan"}}'

minion :( node three nodes do)
Package:  flannel (Master also installed above the package) package installed configuration change is completed, restart the machine
/ etc / sysconfig / flanneld
FLANNEL_ETCD_ENDPOINTS = "http://192.168.1.10:2379" # dubbed own ip

systemctl restart flanneld docker # turn off the docker on three machines, and then turn starts flanneld, docker

8 Create a container, test

Modify the configuration file

  baseos.yaml real machine to copy from the master to the host

 

  vim base.yaml # modify only replicates: 2 and images: myos: v1

Test
1.kubectl create -f baseos.yaml # Create a container
kubectl get pod -o wide # to see whether the container create 
kubectl exec -it test-os-3826630470 -jc5j4 - / bin / bash # container into the container number from the previous step to obtain

2.vim Kube-dashboard.yaml

replicates: 1 # will sync to all node

image:192.168.1.186:5000/kubernetes-dashboard-amd64:v1.8.3

args:

    ---apiserver-host=http://192.168.1.186:8080

kubectl create -f kube-dashboard.yaml

kubectl -n kube-system get pod # to see whether the container is created

kubectl -n default get pod -o wide # to view details

kubectl describe pods # see details
kubectl exec -it test-os-3826630470 -jc5j4 - / bin / bash # into the container   

Guess you like

Origin www.cnblogs.com/mkmkmk/p/12186335.html