How to run Kubernetes on AWS with rancher

Source: Internet
Author: User
Tags docker run etcd k8s

As we all know, Amazon has EC2 container service, which is the solution that Amazon uses to run Docker containers. But I don't think EC2 container service is very good, so now I'm going to test rancher and Kubernetes on AWS.


Kubernetes is an open-source system for automating deployment, scaling, and managing containerized applications. Rancher is a complete container management and runtime platform that can be used within the enterprise, providing enterprise-level access control and container orchestration.


Rancher Environment Deployment


In the first step, I will create a new virtual private cloud in the default wizard, which is prepared for rancher. The next thing to do is create one or more new hosts, and the rancher document says to install Docker manually, I chose the Rancheros AMI here. The AMI is intended for this purpose, and it is very small (even if curl is not installed).


650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/8C/ED/wKioL1h-0uvzrdOGAADvbJec2CQ869.jpg "title=" Figure 1.jpg "alt=" Wkiol1h-0uvzrdogaadvbjec2cq869.jpg "/>


The security group restricts only my IP access to the TCP port k8080. This is important because the default setting is not to start the authorization. It's great to allow each other's access between different hosts, which can be done by saving the security group (and then getting sg-identifier) and adding all the access rights to that security group.


650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/8C/ED/wKioL1h-02DAlvW7AAJA2lK12GQ919.jpg "title=" Figure 2.jpg "alt=" Wkiol1h-02dalvw7aaja2lk12gq919.jpg "/>


When the new instance is ready, just use SSH to connect and start Rancher/server server docker image with sudo docker run-d--restart=always-p 8080:8080 rancher. The rancher application will run itself within the Docker image.


650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/8C/F0/wKiom1h-04_jPPPXAAAaD0ukCs4513.png "title=" Code 1.png "alt=" Wkiom1h-04_jpppxaaaad0ukcs4513.png "/>


You can track logs with the Docker logs-f {containerid} command:


650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/8C/F0/wKiom1h-08Lj_xgOAAAkCf979Pw963.png "title=" Code 2.png "alt=" Wkiom1h-08lj_xgoaaakcf979pw963.png "/>


Everything is perfect! Rancher server starts up. You can browse to the IP of this instance, by default, Rancher server will run on port 8080. All hosts can use a public IP, but if you have a host on a virtual private cloud, this is a bit of a hassle, so you can choose to use a private IP instead of a public IP. This can be changed in administration and settings.


650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/8C/F1/wKiom1h-09qgLn0ZAACqdQyPT1M803.jpg "title=" Figure 3.jpg "alt=" Wkiom1h-09qgln0zaacqdqypt1m803.jpg "/>


When rancher server is up and running, we need to add some Docker hosts. You can start a new host (which is nice because it launches another instance with the same configuration), or you can add hosts like hosts in server (but this is not the best way).


Kubernetes Environment Deployment


Next, add a new host in Rancher server, click Infrastructure, and then click Add Host. After the host has been added, you can add the kubernetes environment. The kubernetes is then automatically deployed to the new host.


650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/8C/F1/wKiom1h-1BSiX-NiAADa0X8eXIM211.jpg "title=" Figure 4.jpg "alt=" Wkiom1h-1bsix-niaada0x8exim211.jpg "/>


This will take a few minutes and you can monitor its current status by selecting the environment:


650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/8C/F1/wKiom1h-1CbjzKZCAABq0_4egvI959.jpg "title=" Figure 5.jpg "alt=" Wkiom1h-1cbjzkzcaabq0_4egvi959.jpg "/>


Kubernetes when the environment is created, you can navigate to the catalog to deploy a container. For example, choose the k8s Example Ghost container--it takes almost no time to start up and run instantly:


650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/8C/ED/wKioL1h-1ESQPHUSAACwHJ1vLfE530.jpg "title=" Figure 6.jpg "alt=" Wkiol1h-1esqphusaacwhj1vlfe530.jpg "/>


During the deployment of Kubernetes, the stack is created along with the following instances:


  • Rancher Ingress Controller 1 (rancher/ingress-controller): The Rancher ingress Controller takes full advantage of Rancher's existing load balancing capabilities and integrates ingress load balancing with Kubernetes Rancher features.

  • Rancher Server (rancher/server): Rancher Management Server, which will run the Web front end and API.

  • Rancher Agent (rancher/agent): Each node obtains a relatively independent agent to administer the node.

  • Rancher Kubernetes Agent 1 (rancher/kubernetes-agent): The agent responsible for handling communication between Rancher and Kubernetes.

  • Rancher Agent Instance (rancher/agent-instance): An image of the proxy instance of the rancher.

  • Kubernetes ETCD 1 (rancher/etc):ETCD is a high-availability key-value storage component for persisted, secure distributed storage for objects and metadata.

  • Kubernetes Proxy 1 (rancher/k8s): Kubernetes Network proxy running on each node.

  • Kubernetes Scheduler 1 (rancher/k8s): Kubernetes controller Manager is a core component of Kubernetes.

  • Kubelet 1 (rancher/k8s):Kubelet is the most important node agent to run on each node.


When you add an additional host, the following are also added synchronously:

    • Kubernetes Proxy2

    • Kubernetes ETCD 2

    • Kubelet 2


Because I didn't want to maintain my own Registry, I created an Amazon Container Registry and used rancher Registry. You can directly copy the address in Amazon Container Registry, user name AWS (note case sensitive) and password (Base64 encoded string).


You can get credentials this way:


650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/8C/ED/wKioL1h-1LjQkH__AAAEZZXq8BI615.png "title=" Code 3.png "alt=" Wkiol1h-1ljqkh__aaaezzxq8bi615.png "/>


Then create the Docker image:


650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/8C/ED/wKioL1h-1Mqxur38AAAEJQ_dAAI657.png "title=" Code 4.png "alt=" Wkiol1h-1mqxur38aaaejq_daai657.png "/>


To label the image:


650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/8C/ED/wKioL1h-1NqQqp9NAAAFK6wFKPw249.png "title=" Code 5.png "alt=" Wkiol1h-1nqqqp9naaafk6wfkpw249.png "/>


Push this image to registry:


650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/8C/F1/wKiom1h-1dHTt-ijAAAEy6Y340A372.png "title=" Code 6.png "alt=" Wkiom1h-1dhtt-ijaaaey6y340a372.png "/>


If you want to learn more about how to run kubernetes on rancher, you can visit here:

Http://rancher.com/kubernetes/, or come here to read the free ebook: Http://info.rancher.com/deploying-scaling-kubernetes-ebook.


Original source: Rancher Labs

This article is from the "12452495" blog, please be sure to keep this source http://12462495.blog.51cto.com/12452495/1892799

How to run Kubernetes on AWS with rancher

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.