You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -23,6 +23,69 @@ To interact with the Kubernetes cluster, you should also install [`kubectl`](htt
23
23
Start your LocalStack container using your preferred method.
24
24
We will demonstrate how you can auto-install an embedded Kubernetes cluster, configure ingress, and deploy a sample service with ECR.
25
25
26
+
### Deploy the necessary networking components
27
+
28
+
First we need to create a VPC for the EKS cluster. You can create a new VPC using the [`CreateVpc` API](https://docs.aws.amazon.com/vpc/latest/APIReference/API_CreateVpc.html).
29
+
30
+
Run the following command:
31
+
32
+
```bash title="Create VPC"
33
+
awslocal ec2 create-vpc --cidr-block 10.0.0.0/16
34
+
```
35
+
36
+
```bash title="Output"
37
+
{
38
+
"Vpc": {
39
+
...
40
+
"CidrBlock": "10.0.0.0/16",
41
+
"VpcId": "<vpc-id>",
42
+
...
43
+
}
44
+
}
45
+
```
46
+
47
+
Next, we need to create a subnet in the VPC. You can create a 2 subnets using the [`CreateSubnet` API](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateSubnet.html). Some extra tags might be required for specific Controllers to work properly. Please refer to their specific documentation for more details.
48
+
49
+
Run the following command:
50
+
51
+
```bash title="Create Subnet 1"
52
+
awslocal ec2 create-subnet \
53
+
--vpc-id <vpc-id> \
54
+
--cidr-block 10.0.1.0/24 \
55
+
--availability-zone us-east-1a
56
+
```
57
+
58
+
```bash title="Output"
59
+
{
60
+
"Subnet": {
61
+
...
62
+
"SubnetId": "<subnet-id-1>",
63
+
"VpcId": "<vpc-id>",
64
+
"CidrBlock": "10.0.1.0/24"
65
+
...
66
+
}
67
+
}
68
+
```
69
+
70
+
```bash title="Create Subnet 2"
71
+
awslocal ec2 create-subnet \
72
+
--vpc-id <vpc-id> \
73
+
--cidr-block 10.0.2.0/24 \
74
+
--availability-zone us-east-1b
75
+
```
76
+
77
+
```bash title="Output"
78
+
{
79
+
"Subnet": {
80
+
...
81
+
"SubnetId": "<subnet-id-2>",
82
+
"VpcId": "<vpc-id>",
83
+
"CidrBlock": "10.0.2.0/24"
84
+
...
85
+
}
86
+
}
87
+
```
88
+
26
89
### Create an embedded Kubernetes cluster
27
90
28
91
The default approach for creating Kubernetes clusters using the local EKS API is by setting up an embedded [k3d](https://k3d.io/) kube cluster within Docker.
@@ -38,14 +101,15 @@ EKS_START_K3D_LB_INGRESS=1
38
101
```
39
102
:::
40
103
41
-
You can create a new cluster using the [`CreateCluster`](https://docs.aws.amazon.com/eks/latest/APIReference/API_CreateCluster.html) API.
104
+
You can create a new cluster using the [`CreateCluster` API](https://docs.aws.amazon.com/eks/latest/APIReference/API_CreateCluster.html).
The cluster creation process may take a few moments as LocalStack sets up the necessary components. Avoid attempting to access the cluster until the status changes to `ACTIVE`.
140
+
141
+
Run the following command to wait for the cluster status to become `ACTIVE`:
142
+
143
+
```bash title="Wait for Cluster"
144
+
awslocal eks wait cluster-active --name cluster1
145
+
```
146
+
70
147
:::note
71
148
When setting up a local EKS cluster, if you encounter a `"status": "FAILED"` in the command output and see `Unable to start EKS cluster` in LocalStack logs, remove or rename the `~/.kube/config` file on your machine and retry.
72
149
The CLI mounts this file automatically for CLI versions before `3.7`, leading EKS to assume you intend to use the specified cluster, a feature that has specific requirements.
@@ -86,36 +163,63 @@ f05770ec8523 rancher/k3s:v1.21.5-k3s2 "/bin/k3s server --t…" 1 minut
86
163
...
87
164
```
88
165
89
-
After successfully creating and initializing the cluster, we can easily find the server endpoint, using the [`DescribeCluster`](https://docs.aws.amazon.com/eks/latest/APIReference/API_DescribeCluster.html) API.
166
+
### Creating a managed node group
167
+
168
+
The EKS cluster created in the previous step does not include any worker nodes by default. While you can inspect the server node, it is [tainted](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/), and workloads cannot be scheduled on it. To run workloads on the cluster, you must add at least one worker node. One way to do this is by creating a managed node group. When you create a managed node group, LocalStack automatically provisions a Docker container, joins it to the cluster, and provisions a mocked EC2 instance.
169
+
170
+
You can create a managed node group for your EKS cluster using the [`CreateNodegroup` API](https://docs.aws.amazon.com/eks/latest/APIReference/API_CreateNodegroup.html).
At this point, your EKS cluster is fully operational and ready to deploy workloads.
222
+
119
223
### Utilizing ECR Images within EKS
120
224
121
225
You can now use ECR (Elastic Container Registry) images within your EKS environment.
@@ -141,7 +245,7 @@ Once you have configured this correctly, you can seamlessly use your ECR image w
141
245
To showcase this behavior, let's go through a concise step-by-step guide that will lead us to the successful pulling of an image from local ECR.
142
246
For the purpose of this guide, we will retag the `nginx` image to be pushed to a local ECR repository under a different name, and then utilize it for a pod configuration.
143
247
144
-
You can create a new ECR repository using the [`CreateRepository`](https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_CreateRepository.html) API.
248
+
You can create a new ECR repository using the [`CreateRepository` API](https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_CreateRepository.html).
Now, let us set up the EKS cluster using the image pushed to local ECR.
189
293
190
-
Next, we can configure `kubectl` to use the EKS cluster, using the [`UpdateKubeconfig`](https://docs.aws.amazon.com/eks/latest/APIReference/API_UpdateClusterConfig.html) API.
294
+
Next, we can configure `kubectl` to use the EKS cluster, using the [`UpdateKubeconfig` API](https://docs.aws.amazon.com/eks/latest/APIReference/API_UpdateClusterConfig.html).
0 commit comments