How to select instance region in aws when creating cluster?

This section will show you how to use Rancher to install an RKE Kubernetes cluster on Amazon EC2.

This section will show you how to use Rancher to install an RKE Kubernetes cluster on Amazon EC2.

First, create EC2 cloud credentials in Rancher. Then, using the cloud credentials, create a node template that Rancher will use to set up additional nodes in EC2.

You will next use Rancher to construct an EC2 cluster and define node pools as you configure it. Each node pool will have a specific Kubernetes role, such as etcd, control plane, or worker. Rancher will install RKE Kubernetes on the new nodes and configure each node with the Kubernetes role assigned to the node pool.

Prerequisites

  • The AWS EC2 access and secret keys are used to launch the instance. Refer to the Amazon documentation: How to Create Access Keys and Secret Keys.
  • The IAM policy was designed to include users of the access key and secret key. See Amazon’s documentation: Create IAM Policies (Console) How to establish an IAM policy. Consider the following three JSON policy examples:
  • Example IAM Policy
  • Example IAM Policy with PassRole (Required if you wish to utilize Kubernetes Cloud Provider or send an IAM profile to an instance)
  • Example IAM Policy to allow encrypted EBS volumes
  • An IAM policy is assigned to a user as permission. Refer to the Amazon documentation: How to Attach Permissions to Users (Console).

Creating an EC2 cluster

The processes for creating a cluster vary depending on the Rancher version.

RKE
1. Create Cloud Credentials.
2. Create a node template containing cloud credentials and EC2 information.
3. Create a cluster with node pools using node templates.

RKE2

  1. Create cloud credentials.
  2. Select => Cluster Management.
  3. Click Cloud Credentials.
  4. Click Create.
  5. Click Amazon.
  6. Enter a name for your cloud credential.
  7. In the Default region field, specify the AWS area where the cluster node is situated.
  8. Enter your AWS EC2 access and secret keys.
  9. Click Create.

Create cloud credentials.

  1. Select => Cluster Management.
  2. Click Cloud Credentials.
  3. Click Create.
  4. Click Amazon.
  5. Enter a name for your cloud credential.
  6. In the Default region field, specify the AWS area where the cluster node is situated.
  7. Enter your AWS EC2 access and secret keys.
  8. Click Create.

You have successfully created cloud credentials for provisioning nodes in a cluster. You can use these credentials in other node templates or clusters.

Create a node template with your cloud credentials and EC2 information.

Creating an EC2 node template enables Rancher to configure new EC2 nodes. Node templates can be reused in several clusters.

  1. Select => Cluster Management.
  2. Click RKE1 Configuration > Node Templates.
  3. Select Add Template.
  4. Fill out the EC2 node template. For assistance filling out the form, see EC2 Node Template Configuration.
  5. Click Create.

Using node templates to create clusters with node pools


Add one or more node pools to the cluster. For more information about node pools, see this section.

1. Click => Cluster Management.

2 . On the Clusters page, click Create.

3. Click Amazon EC2.

4. Create a node pool for each Kubernetes role. Select a node template that you created for each node pool. For more information about node pools, including best practices for assigning Kubernetes roles to node pools, see this section.

5. Click Add Members to add users that can access the cluster. Use the Roles drop-down menu to set permissions for each user.

6. Use the Cluster Options to select the version of Kubernetes you want to install, the network provider you want to use, and whether you want to enable project network isolation. See “Selecting a Cloud Provider” to configure the Kubernetes cloud provider. For help configuring clusters, see the RKE Cluster Configuration Reference.
7. Click Create.

The active cluster has been assigned to two projects:

Default contains the default namespace.

The system contains the namespaces cattle-system, ingress-nginx, kube-public, and kube-system.

Desirable next steps.

After you’ve created a cluster, you can access it using the Rancher UI. As a recommended practice, we recommend configuring these alternative methods of accessing the cluster:

Accessing the cluster with the kubectl CLI: Follow these instructions to connect to the cluster via kubectl on your workstation. In this situation, you will authenticate using the Rancher server’s authentication agent, after which Rancher will connect you to the downstream cluster. This allows you to control the cluster without using the Rancher UI.

To access the cluster using the kubectl CLI, use an authorized cluster endpoint. Follow these steps to access the cluster directly using kubectl without first authenticating with Rancher. We recommend enabling this alternative method of accessing the cluster so that you can continue to use it even if Rancher is unavailable.