Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Using Rancher to manage AWS EKS clusters

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The author introduces the James Sun AWS solution architect. James has more than 15 years of experience in the information technology industry. Prior to joining AWS, he held a number of senior technical positions at MapR, Hewlett-Packard, NetApp, Yahoo and EMC. He has a doctorate from Stanford University. This article was originally posted on the official Amazon AWS blog.

Rancher is a popular open source enterprise Kubernetes management platform that is used by many organizations to manage mixed-deployed Kubernetes clusters. Rancher supports Amazon Elastic Container Service for Kubernetes (Amazon EKS), which allows Rancher users to take control of AWS EKS directly through the Rancher platform.

When combined with Rancher, Amazon EKS is easy to use and can have both the usage habits you have developed in Rancher and the functionality, reliability and performance you expect from AWS. EKS, Amazon's managed Kubernetes solution, allows you to quickly create scalable Kubernetes instances in the cloud. While Rancher has simple and easy-to-use UI and more extension features for Kubernetes, the combination of strength will greatly improve the operational experience and performance used by enterprise Kubernetes.

Whether you are a novice user of EKS and Rancher, or have some knowledge of EKS or Rancher and focus on how to use open source software to manage EKS, this article is worth reading.

This article demonstrates how to use Rancher to set up EKS clusters, deploy publicly accessible applications to test clusters, and deploy sample projects to use other open source software such as Grafana and InfluxDB to track real-time geospatial data.

Preparation in advance

If you are going to follow this article for synchronization, you need to have:

Host VM, laptop, or server with a public Internet IP address and unblocked ports 22, 80, and 443.

Docker, installed on the host VM, laptop, or server.

An AWS account with sufficient permissions to access Amazon EKS can be found here for more information:

Https://docs.aws.amazon.com/eks/latest/userguide/EKS_IAM_user_policies.html

Once the above prerequisites have been met, we can start with the first step: installing Rancher.

Start the Rancher Docker container

On the VM host, issue the following command to start the Rancher container (Rancher version should be equal to or higher than 2.0):

Docker run-d-- restart=unless-stopped-- name rancher-- hostname rancher-p 80:80-p 443 rancher/rancher:latest

The above command should create a Rancher container version 2.16 or later

(https://hub.docker.com/r/rancher/rancher).

Now point the browser to the public IP; of the host and you should see a Rancher welcome page. Note that because https uses a self-signed certificate, you may receive a cert-authority-invalid warning. Please ignore the warning at this time and continue. If you want to completely eliminate this warning, you can obtain a valid certificate by following the link below before continuing:

Https://aws.amazon.com/premiumsupport/knowledge-center/acm-certificate-error-https/

In the following window, type the public IP of the host so that EKS can inform Rancher of the progress of the installation:

Create an EKS cluster

You first need to create a key certificate for your account. Do this by going to IAM > user > (your user name) > security credentials.

Then click create access key; a pop-up window like this should appear:

Record the access key ID and secret access key; these are what you need to create an EKS cluster in Rancher.

Next, go to the Rancher instance, click the add Cluster button, and then select the Amazon EKS option. Now name the cluster, such as "rancherEKSDemo", and enter the access key ID and secret access key that you recorded in the previous step.

In the region drop-down menu, there are only two areas to choose from: us-east-1 and us-west-2. (note that EKS itself is available in many parts of the world, see this link for more information: https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/.) Select the region where you want to deploy the EKS cluster, set all projects to default, and then click next: select a service role. Rancher will verify that the key ID and the key you submitted are authorized.

On the next screen, examine the "standard" service role generated by Rancher, and then click next: select VPC and subnet. You will be prompted to select IP for the worker node, VPC, and subnet. Simply select the default value and click next: select the instance option. For demonstration purposes, select the default instance type "m4.large" and leave the minimum and maximum ASG (auto scaling group) values as default values. When the verification is complete, click the create button.

It takes 10 to 15 minutes to create an EKS cluster; in the meantime, you will see the cluster status as preset on the console.

Rancher uses the Cloudformation template on the AWS backend to start the installation. You can monitor these detailed events by going to the Cloudformation console, as shown in the following screenshot:

You can also access the EKS console and verify that the cluster is being created, as shown in the following screenshot:

After the cluster is provisioned, you should see that the status in the Rancher console changes to "active":

Test your EKS cluster by deploying nginx Pod

Now you can deploy the Pod/ container on the cluster. To get started, try deploying nginx pod. Click the drop-down menu located in the upper-left corner and select the default project.

Next, you will see the workload screen and click the deploy button located in the upper right corner of the screen:

Now name your workload and specify the "nginx" Docker image. Click add Port, publish container port "80" and specify listening port "80", and then specify a layer 4 load balancer. This will allow you to access your nginx instance over the public Internet.

Click start and wait for the workload and load balancer to complete the provisioning by checking the status of the workload and load balancer tabs until they show activity.

When the load balancer is provisioned, a clickable link appears below the workload. Note that AWS will create a DNS entry for this EKS cluster, which may take several minutes to publish. If a 404 error occurs after clicking the link, wait a few more minutes to update the Elastic Load Balancer DNS record, and then try again.

Clicking the link "80/tcp" should go to the default nginx page:

Expand your nginx deployment

You can easily expand the number of containers to accommodate workload peaks. Simply select the workload in the default project and click the + /-flag to expand and shrink the deployment to dynamically adjust the workload:

Deploy the sample project

Next, let's make this demonstration more interesting by deploying the Rancher project to track the number of passengers in New York City's Citi Bike in real time. You will preset three Pod:

Data extraction Pod: this Pod contains a script that periodically queries real-time data published by Citi Bike in json format and saves it to the InfluxDB database through API.

Time series database Pod using InfluxDB: this Pod has InfluxDB installed to process real-time data from Citi Bike sites. InfluxDB is a popular open source database optimized for query and search time series. In addition, this Pod has a local mount point, where the AWS EBS gp2 storage class is used to provide persistent volumes needed to archive historical data.

Grafana pod: this Pod uses Grafana to display the collected data.

The next step is to create the Kubernetes namespace for the project. Select the default namespace from the drop-down menu in the upper-left corner, and then click Namespace. Click add Namespace and type ns-citibike, and then click create.

Return to the cluster console by selecting the drop-down menu in the upper left corner. The screenshot is shown below. Then choose to start kubectl.

In the shell window, type "kubectl get nodes-o wide" to see the status of the worker nodes; they should all be "ready".

Now issue the following command to start the project:

Curl 'https://raw.githubusercontent.com/aws-samples/managing-eks-clusters-with-rancher/master/run' | bash

Feel free to download the script to see the steps involved. I have added comments to the script for you to review.

Wait a few minutes for the script to complete execution.

In the default project, you should see that three Pod have been provisioned. Wait a few more minutes to update the load balancer's DNS record, and then click 80/tcp to go to Grafana:

On the Grafana login page, enter "admin" as the user name and "admin" as the password, and then log in.

You can now configure the dashboard to display the data.

Configure the data source

Select the gear icon in the left pane, click the data source, and then click + to add the data source on the right side of the window:

Fill in the name of the data source (for example, citibike), select InfluxDB as the type, and enter "coordinates" as the database name:

Then, in the URL field, find the private IP address of InfluxDB pod and fill in http://:8086.

You can find the private IP address of Influxdb by going to the default namespace page in Rancher, and then click deploy-Influxdb pod:

Click Save and Test to add the data source.

Import Control Panel Templat

Download this dashboard template and save it to your desktop:

Https://raw.githubusercontent.com/aws-samples/managing-eks-clusters-with-rancher/master/CitiBike.json

In Grafana, click + in the left pane and select Import. Click the upload json file on the right side of the window, and then select the template you just downloaded to your desktop:

Now you can start tracking the real-time status of every Citi Bike site throughout New York City. You can select the bicycle site ID and view its historical demand trends, as shown in the line chart. You can also specify a time window to track the long-term demand trend of a site. The current bicycle capacity of all sites is also shown on the color-coded map; green indicates that more than 30 bikes are available, while red indicates an insufficient number of bicycles:

City planners can use this information to increase / reduce the capacity of bicycle stations in order to better serve New York residents who rely on bicycles to meet their daily transportation needs.

Integrate with AWS EBS to meet larger storage capacity requirements

When you start the project command above, you also create two persistent volumes (50 GB each) using both the EBS for InfluxDB and the gp2 storage type in the extract Pod, because the container does not have enough local storage space to accommodate the continuous inflow of data. To view these persistent volumes and their persistent volume declarations, go to the default namespace and select the volumes tab at the top.

Now, view the extracted Pod by clicking the workload tab, then click the drop-down menu of the "deploy-citibike" container on the far right of the window, and select execute Shell.

You are now at the shell prompt of the container. Type "mount / grep citibike" and you will see a volume device / dev/xvdxx mounted on / citibike with the ext4 file system.

Make a "ls / citibike"-you will see all the original json files archived there.

Conclusion

In this article, we demonstrated how to use Rancher to create and manage EKS clusters, and as a hands-on example, we successfully deployed a sample project that successfully tracked real-time geospatial data from New York City Citi Bike using popular open source tools (containerized Grafana and InfluxDB).

Original link: https://aws.amazon.com/blogs/opensource/managing-eks-clusters-rancher/?from=groupmessage&isappinstalled=0

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report