CentOS installation kubernetes1.3 (ii)

Source: Internet
Author: User
Tags centos docker run k8s

Before you deploy Docker, you need to preview the Docker command Docker basic command

Docke pull nginx# Download Nginx mirrors

Docke Push 192.168.161.117:5000/os/centos #上传本地制作的镜像到本地镜像库

Docker Images #查看下载到本地的镜象

Docker tag 980E0E4C79EC 192.168.161.117:5000/os/centos #将Image ID mirrored to 980E0E4C79EC mirror marked as 192.168.161.117:5000/os/ Centos

Docker run-it Nginx/bin/bash #进入交互模式下的nginx容器, the equivalent of a small Linux system, which only installs Nginx
It is not convenient for Docker to turn on sshd to specify the container ID by Docker or kubectl specify pod to connect to the appropriate Docker container. The sshd service of the Docker container is opened, and the internal port of the sshd service of the Docker container is mapped through the host port, which enables access to the internal Docker under the host's port.

Docker run-d-P 10022:22 centos_sshd/usr/sbin/sshd-d #使用 installed sshd tomcentos_sshd mirroring, starting the SSHD service on startup. 10,022:22 The former is the host port, the latter is the port of the Docker container

SSH host-P 10022 #远程登录docker容器build a local mirror library

Docker Pull registry #下载registry镜像, using Docker to deploy the local mirror library directly

Docker run-d-P 5000:5000 Registry # #以registry Mirroring Boot Docker container, build local mirror library, monitor 5000 ports

Curl-x Get Http://127.0.0.1:5000/v2/_catalog # #查看本地仓库已push镜像


deploy k8s pod and serviceAs an example of Nginx mirroring, Docke pull nginx download mirrors to Local

K8s deployment Support Yaml,json, command, dashboard management platform 4 ways to deploy Pod\service 1. Kubectl run My-nginx--image=nginx the--replicas=2--port=80


2./kubectl create-f Nginx_svc.json or Kubectl expose deployment My-nginx---type=nodeport--name=my-nginx-serv

3. After the command completes, view the pod through kubectl get pod
NAME READY STATUS Restarts age
my-nginx-2494149703-7040i 1/1 Running 0 4d
My-nginx-2494149703-8cwj9 1/1 Running 2 4d

4. After the command is complete, view the service through the Kubectl get service
NAME cluster-ip external-ip PORT (S) Age
My-nginx-serv 10.10.10.112 <nodes> 8080/tcp 5d

5. If the pod fails, the status in the image above is not running. View failure logs through Kubectl describle pod my-nginx-2494149703-7040i name:my-nginx-2494149703-7040i
Namespace:default
node:192.168.161.117/192.168.161.117
Start Time:thu, 2017 14:52:26 +0800
labels:pod-template-hash=2494149703
Run=my-nginx
Status:running
ip:10.1.83.9
controllers:replicaset/my-nginx-2494149703
Containers:
My-nginx:
Container id:docker://aa0540cabb114f6291399b1675f9e84fdb8baffcc8c64f1689f65ec63b5f8a49
Image:nginx
Image id:docker://sha256:01f818af747d88b4ebca7cdabd0c581e406e0e790be72678d257735fad84a15f
Port:80/tcp
State:running
Started:thu, 2017 14:52:29 +0800
Ready:true
Restart count:0
Environment Variables: <none>
Conditions:
Type Status
Initialized True
Ready True
Podscheduled True
No volumes.
QoS Tier:besteffort
No events.

6./kubectl EXEC my-nginx-2494149703-7040i-i-T--Bash-il for Docker container commissioning
root@my-nginx-2494149703-7040i:/# pwd
/
root@my-nginx-2494149703-7040i:/# ls
Bin Dev Home lib64 mnt proc run SRV tmp var
Boot etc Lib media opt root sbin sys usr
root@my-nginx-2494149703-7040i:/# Ps-ef|grep Nginx
Root 1 0 0 Jan05? 00:00:00 nginx:master process nginx-g daemon off;
Nginx 7 1 0 Jan05? 00:00:00 Nginx:worker Process
Root 44 34 0 08:27? 00:00:00 grep nginx
root@my-nginx-2494149703-7040i:/# Find/-name Error.log
/var/log/nginx/error.log

6. View nodes, serive, pod by dashboard
7. Access to Nginx via intranet, 30451 port is service configuration load Balancing type is Nodeport, which can be accessed through host ip+ Port Service.service to achieve load-balanced access to pod. The pod consists of multiple docker, Here Ngnx a pod is made up of a docker. Access http://192.168.161.117:30451/can return Welcome to Nginx Screen



Note the Clusterip and internal endpoints content in the services diagram. Cluster IP is 10.10.10.112, which is a cluster of intranet IP, can be accessed on the host with Kubelproxy installed. The 30451 port in the internal endpoints is accessible to any host in the host LAN. Through internal cluster access, the IP and port are taken from the port in step 4th of the CLUSTER-IP or the cluster IP and internal endpoints content in this figure 8080 curl http://10.10.10.112:8080/



The pod internal Nginx container also allocates internal Ip10.1.83.9 and 10.1.83.7 subnets, if node has multiple units. Each host is a separate subnet segment, CENTOS7 under the installation and deployment of kubernets1.3 (i) are described.
Access to the following address can return the successful interface of Welcome to Nginx Curl http://10.10.83.1:8080/curl http://10.10.83.7:8080/

What is more important is the independent subnet of each host, which is interoperable with each other. Through the Docker run-it Centos/bin/bash to two different host, CentOS operating system command interface, ping each other IP can ping each other. Mutual access to the Nginx pod's access address is also available. Follow-up, and then continue to write test Subnet Interoperability example + system to do tomcat application mirror example.

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.