Pod details of the Kubernetes object (with installation deployment method)

Source: Internet
Author: User
Tags docker ps etcd k8s

first introduce what k8s is: (Quote from k8s Chinese community)

Kubernetes is a container cluster management system, it is an open source platform, can realize the automatic deployment of container cluster, auto-scaling capacity, maintenance and other functions.

Kubernetes you can:

    • Quick Deploy app

    • Rapid extension Application

    • Seamless docking of new application features

    • Conserve resources and optimize the use of hardware resources

In fact, k8s can do a lot of things, and simple operation, very convenient, the following first describes how to install, and then for the pod details, if you do not know about Docker, you can first refer to the previous article to learn!

Environment Introduction:

CentOS 7.2

Kubernetes 1.5.2

Docker 1.12.1


I. Installation configuration

1. Installing k8s

Yum-y Install Kubernetes

This command will install Kube-apiserver,kube-controller-manager,kubelet,kube-proxy,kube-scheduler at the same time


2. Changing server-side settings

Vim/etc/kubernetes/apiserver

#### kubernetes system config## the following values are used to  configure the kube-apiserver## the address on the local server  to listen to. #KUBE_API_ADDRESS = "--insecure-bind-address=127.0.0.1" kube_api_address= "--address= 0.0.0.0 "# the port on the local server to listen on. Kube_api_port= "--port=8080" # port minions listen onkubelet_port= "--kubelet-port=10250" #  comma separated list of nodes in the etcd clusterkube_etcd_ servers= "--etcd-servers=http://127.0.0.1:2379" # address range to use for  Services#kube_service_addresses= "--SERVICE-CLUSTER-IP-RANGE=10.254.0.0/16" kube_service_addresses= "--portal_net =10.254.0.0/16 "# default admission control policies#kube_admission_control="-- Admission-control=namespacelifecycle,namespaceexists,Limitranger,securitycontextdeny,serviceaccount,resourcequota "Kube_admission_control="--admission-control= Namespacelifecycle,namespaceexists,limitranger,resourcequota "# add your own! Kube_api_args= ""

Vim/etc/kubernetes/controller-manager #指定客户端主机的ip地址

kubelet_addresses= "--machines= 192.168.6.109"

Vim/etc/kubernetes/kubelet #这个镜像是k8s构建pod必备镜像, if you cannot download the image from the default location, you can download it separately in the private library, where 6.109 is a private library

#KUBELET_POD_INFRA_CONTAINER = "--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure: Latest "kubelet_pod_infra_container="--pod-infra-container-image=192.168.6.109:5000/pod-infrastructure:latest "

3. Start related services

systemctl Start kube-apiserver kube-controller-manager kubelet kube-proxy kube-scheduler


4. If you want Docker to pull mirrors from the private library during pod creation, you also need to remove the relevant certificate validation

Vim/etc/docker/daemon.json

{"Insecure-registries": ["192.168.6.109:5000"]

5. Restart the Docker service

Systemctl Restart Docker


Two. Node installation

1. Installing k8s

Yum-y Install Kubernetes


2. Change node settings

Vim /etc/kubernetes/apiserver

kube_etcd_servers= "--etcd-servers=kube_api_address="--insecure-bind-address=192.168.6.200 "

Vim/etc/kubernetes/config

Kube_master= "--master=http://192.168.6.200:8080"

Vim/etc/kubernetes/kubelet

kubelet_address= "--address=0.0.0.0" kubelet_hostname= "--hostname-override=192.168.6.109" KUBELET_API_SERVER= "-- api-servers=http://192.168.6.200:8080 "


3. Start the related service, the node must open 10250 ports

systemctl start Kubelet Kube-proxy


4. To see if the node is functioning properly, execute it on the server side

Kubectl get node #此时应该存在2个节点, a native, a node


Two. What's a pod?

In K8s, the pod is the smallest/simplest base unit created or deployed, and a pod is a container group of multiple Docker containers

, each pod contains at least one label, the form of the label is Key:value, which can be matched faster to the corresponding Pod,service the main function is to expose the pod corresponding to the port, or do load balancer use! The usage of the service is discussed in more detail in the next section.

1.Pod Application Example

Vim Obj.json

{   "Kind":  "Pod",                               #类型, stand-alone pod    "Apiversion":  "v1",                          #API版本    "metadata":  {                                       " Name ": " Podtest ",                       #pod名称        "Labels": {    "name":  "Nginx-server"                #标签}}, "Spec":  { &Nbsp;   "Containers":[{                             "name":  "Master1",                   # Name of the first container           "image":  "Nginx",                     #使用的镜像            "Ports":[{                                  "Containerport": 80,              #容器内的端口       "Hostport": 8811                  #映射的主机端口  }],      "Volumemounts": [{                         #数据卷       "Mountpath":  "/var/log/nginx",   #容器内的目录       "name":  "nginx-conf"               #数据卷名称  }]     },{           "name":  "Master2",                    #第二个容器的名称   "image":  "Redis",  "Ports":[{       "Containerport": 6379,      "Hostport": 7480          }]     }],    "volumes":  [{   "name":  "nginx-conf", &NBsp;              #对应上面的数据卷名称   "EmptyDir":  {}                       #本地挂载目录, here is the empty directory, path in/$K 8S installation path/pkg/volume/empty_dir   }]  }}

2. Create this pod

Kubectl create-f Obj.json

Pod "Podtest" created


3. View the pods you have created

Kubectl Get pod

If you are prompted to have 2 running then normal, if not, you can view the specific error log


4. View pod run log

Kubectl logs Podtest Master1/master2


5. View the details of creating pods

Kubectl describe pod podtest


6. View container creation on a node

Docker PS

You can see that 3 containers have been created, the third container provides network and port support, and the above two provide nginx and Redis services respectively, then if you access the Curl 192.168.6.109:8811 the pre-set page will appear!


7.pod Delete

If you want to modify the configuration, you need to delete the pod before creating it.

Kubectl delete-f Obj.json

Kubectl Delete pod Podtest


8. Extended Query

Kubectl Get pod-o Wide

You can get the pod's running IP, node usage


Pod details of the Kubernetes object (with installation deployment method)

Related Article

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.