0
0
AWScloud~5 mins

Node groups (managed, self-managed, Fargate) in AWS - Commands & Configuration

Choose your learning style9 modes available
Introduction
When you run applications on Kubernetes in AWS, you need servers called nodes. Node groups are collections of these servers. Managed node groups are handled by AWS for you, self-managed node groups you control yourself, and Fargate lets you run nodes without managing servers at all.
When you want AWS to handle server updates and scaling automatically for your Kubernetes nodes.
When you need full control over the servers running your Kubernetes workloads.
When you want to run Kubernetes pods without managing any servers or infrastructure.
When you want to save time by letting AWS manage the node lifecycle.
When you want to customize the server setup beyond what managed node groups allow.
Config File - eks-nodegroup.yaml
eks-nodegroup.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
  name: example-cluster
  region: us-east-1
nodeGroups:
  - name: managed-ng
    instanceType: t3.medium
    desiredCapacity: 2
    iam:
      withAddonPolicies:
        autoScaler: true
  - name: selfmanaged-ng
    instanceType: t3.medium
    desiredCapacity: 2
    ssh:
      allow: true
    privateNetworking: true
fargateProfiles:
  - name: fp-default
    selectors:
      - namespace: default

This file defines an EKS cluster with three types of node groups:

  • managed-ng: A managed node group where AWS handles updates and scaling.
  • selfmanaged-ng: A self-managed node group where you control the nodes, including SSH access.
  • fp-default: A Fargate profile that runs pods in the default namespace without managing servers.
Commands
This command creates the EKS cluster with the managed node group, self-managed node group, and Fargate profile as defined in the config file.
Terminal
eksctl create cluster -f eks-nodegroup.yaml
Expected OutputExpected
2024-06-01T12:00:00Z [ℹ] eksctl version 0.140.0 2024-06-01T12:00:01Z [ℹ] using region us-east-1 2024-06-01T12:00:02Z [ℹ] nodegroup managed-ng will use Amazon Linux 2 2024-06-01T12:00:10Z [ℹ] nodegroup selfmanaged-ng will use Amazon Linux 2 2024-06-01T12:05:00Z [ℹ] created cluster control plane "example-cluster" 2024-06-01T12:10:00Z [ℹ] created nodegroup "managed-ng" 2024-06-01T12:15:00Z [ℹ] created nodegroup "selfmanaged-ng" 2024-06-01T12:20:00Z [ℹ] created Fargate profile "fp-default" 2024-06-01T12:20:01Z [✔] all cluster resources created successfully
-f - Specifies the config file to create the cluster and node groups
This command lists all the nodes in the Kubernetes cluster, showing nodes from managed and self-managed groups. Fargate nodes do not appear here because they are serverless.
Terminal
kubectl get nodes
Expected OutputExpected
NAME STATUS ROLES AGE VERSION ip-192-168-1-10.us-east-1.compute.internal Ready <none> 10m v1.26.3 ip-192-168-2-11.us-east-1.compute.internal Ready <none> 10m v1.26.3
This command shows pods running in the default namespace. Pods scheduled on Fargate run without visible nodes here.
Terminal
kubectl get pods -n default
Expected OutputExpected
NAME READY STATUS RESTARTS AGE example-pod-1 1/1 Running 0 5m example-pod-2 1/1 Running 0 5m
-n - Specifies the namespace to list pods from
This command deletes the entire EKS cluster along with all node groups and Fargate profiles, cleaning up all resources.
Terminal
eksctl delete cluster -f eks-nodegroup.yaml
Expected OutputExpected
2024-06-01T13:00:00Z [ℹ] deleting cluster "example-cluster" in "us-east-1" 2024-06-01T13:10:00Z [ℹ] deleted nodegroup "managed-ng" 2024-06-01T13:15:00Z [ℹ] deleted nodegroup "selfmanaged-ng" 2024-06-01T13:20:00Z [ℹ] deleted Fargate profile "fp-default" 2024-06-01T13:25:00Z [✔] cluster "example-cluster" deleted
-f - Specifies the config file to delete the cluster and node groups
Key Concept

If you remember nothing else from this pattern, remember: managed node groups let AWS handle servers, self-managed node groups give you control, and Fargate runs pods without servers.

Common Mistakes
Trying to SSH into Fargate nodes
Fargate runs serverless pods without actual nodes you can access.
Use logs and Kubernetes commands to debug Fargate pods instead of SSH.
Not specifying the correct namespace when checking pods on Fargate
Fargate profiles are tied to namespaces; pods outside those namespaces won't run on Fargate.
Always specify the namespace matching your Fargate profile when listing pods.
Modifying self-managed nodes manually without updating cluster state
Manual changes can cause drift and unexpected behavior in the cluster.
Use automation tools or eksctl to manage self-managed node groups consistently.
Summary
Create an EKS cluster with managed, self-managed node groups, and a Fargate profile using a single config file.
Use kubectl to verify nodes and pods; managed and self-managed nodes appear as nodes, Fargate pods run serverless.
Delete the cluster and all node groups cleanly with eksctl to avoid leftover resources.