Skip to content

Commit 33df13a

Browse files
committed
EKS Hybrid Nodes Module
This commit is the entirety of the EKS Hybrid Nodes module added under Networking group. Special thanks to Bo Guan, Eric Anderson, and Curtis Rissi for their support. This module includes a change to the eksctl cluster.yaml that adds the remoteNetworkConfig required by EKS Hybrid Nodes. However, these parameters have no effect an an EKS cluster that does not make use of them. Additionally, IAM permissions were added to the IDE role to allow the creation of required resources for the hybrid nodes module. All tests pass.
1 parent 7d2b9f5 commit 33df13a

30 files changed

+1317
-5
lines changed

.spelling

+4-1
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,7 @@ joshi
128128
keda
129129
AIML
130130
DCGM
131-
Mountpoint
131+
Mountpoint
132+
nodeadm
133+
containerd
134+
nodeconfig

cluster/eksctl/cluster.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ vpc:
1919
clusterEndpoints:
2020
privateAccess: true
2121
publicAccess: true
22+
remoteNetworkConfig:
23+
remoteNodeNetworks:
24+
- cidrs: ["10.52.0.0/16"]
25+
remotePodNetworks:
26+
- cidrs: ["10.53.0.0/16"]
2227
addons:
2328
- name: vpc-cni
2429
version: 1.19.2

cluster/terraform/eks.tf

+55
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
locals {
2+
remote_node_cidr = var.remote_network_cidr
3+
remote_pod_cidr = var.remote_pod_cidr
4+
}
5+
16
module "eks" {
27
source = "terraform-aws-modules/eks/aws"
38
version = "~> 20.0"
@@ -30,6 +35,56 @@ module "eks" {
3035

3136
create_cluster_security_group = false
3237
create_node_security_group = false
38+
cluster_security_group_additional_rules = {
39+
hybrid-node = {
40+
cidr_blocks = [local.remote_node_cidr]
41+
description = "Allow all traffic from remote node/pod network"
42+
from_port = 0
43+
to_port = 0
44+
protocol = "all"
45+
type = "ingress"
46+
}
47+
48+
hybrid-pod = {
49+
cidr_blocks = [local.remote_pod_cidr]
50+
description = "Allow all traffic from remote node/pod network"
51+
from_port = 0
52+
to_port = 0
53+
protocol = "all"
54+
type = "ingress"
55+
}
56+
}
57+
58+
node_security_group_additional_rules = {
59+
hybrid_node_rule = {
60+
cidr_blocks = [local.remote_node_cidr]
61+
description = "Allow all traffic from remote node/pod network"
62+
from_port = 0
63+
to_port = 0
64+
protocol = "all"
65+
type = "ingress"
66+
}
67+
68+
hybrid_pod_rule = {
69+
cidr_blocks = [local.remote_pod_cidr]
70+
description = "Allow all traffic from remote node/pod network"
71+
from_port = 0
72+
to_port = 0
73+
protocol = "all"
74+
type = "ingress"
75+
}
76+
}
77+
78+
79+
cluster_remote_network_config = {
80+
remote_node_networks = {
81+
cidrs = [local.remote_node_cidr]
82+
}
83+
# Required if running webhooks on Hybrid nodes
84+
remote_pod_networks = {
85+
cidrs = [local.remote_pod_cidr]
86+
}
87+
}
3388

3489
eks_managed_node_groups = {
3590
default = {

cluster/terraform/variables.tf

+12
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,16 @@ variable "vpc_cidr" {
2020
description = "Defines the CIDR block used on Amazon VPC created for Amazon EKS."
2121
type = string
2222
default = "10.42.0.0/16"
23+
}
24+
25+
variable "remote_network_cidr" {
26+
description = "Defines the remote CIDR blocks used on Amazon VPC created for Amazon EKS Hybrid Nodes."
27+
type = string
28+
default = "10.52.0.0/16"
29+
}
30+
31+
variable "remote_pod_cidr" {
32+
description = "Defines the remote CIDR blocks used on Amazon VPC created for Amazon EKS Hybrid Nodes."
33+
type = string
34+
default = "10.53.0.0/16"
2335
}

lab/iam/iam-role-cfn.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ Resources:
4141
PolicyDocument:
4242
file: ./iam/policies/ec2.yaml
4343

44+
EksWorkshopSsmPolicy:
45+
Type: AWS::IAM::ManagedPolicy
46+
Properties:
47+
Roles:
48+
- !Ref EksWorkshopIdeRole
49+
ManagedPolicyName: ${Env}-ide-ssm
50+
PolicyDocument:
51+
file: ./iam/policies/ssm.yaml
52+
4453
EksWorkshopLabsPolicy1:
4554
Type: AWS::IAM::ManagedPolicy
4655
DependsOn:

lab/iam/policies/base.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,7 @@ Statement:
8686
- kms:Get*
8787
- kms:Describe*
8888
Resource: ["*"]
89+
- Effect: Allow
90+
Action:
91+
- ssm:GetParameter
92+
Resource: !Sub arn:aws:ssm:${AWS::Region}::parameter/aws/service/*

lab/iam/policies/ec2.yaml

+18-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ Statement:
66
- ec2:Describe*
77
- ec2:List*
88
- ec2:RunInstances
9+
- ec2:ImportKeyPair
10+
- ec2:DeleteKeyPair
911
Resource: ["*"]
1012
- Effect: Allow
1113
Action:
1214
- ec2:StopInstances
1315
- ec2:TerminateInstances
16+
- ec2:ModifyInstanceAttribute
1417
Resource: ["*"]
1518
Condition:
1619
StringLike:
@@ -46,6 +49,21 @@ Statement:
4649
- ec2:DeleteNatGateway
4750
- ec2:CreateNetworkInterface
4851
- ec2:DeleteNetworkInterface
52+
- ec2:DescribeNetworkInterfaces
53+
- ec2:CreateTransitGateway
54+
- ec2:DeleteTransitGateway
55+
- ec2:CreateTransitGatewayVpcAttachment
56+
- ec2:DeleteTransitGatewayVpcAttachment
57+
- ec2:CreateTransitGatewayRoute
58+
- ec2:SearchTransitGatewayRoutes
59+
- ec2:DeleteTransitGatewayRoute
60+
- ec2:ModifyNetworkInterfaceAttribute
61+
- ec2:CreateNetworkInterfacePermission
62+
- ec2:AssignIpv6Addresses
63+
- ec2:UnAssignIpv6Addresses
64+
- ec2:ImportKeyPair
65+
- ec2:CreateKeyPair
66+
- ec2:DeleteKeyPair
4967
Resource: ["*"]
5068
- Effect: Allow
5169
Action:
@@ -74,10 +92,6 @@ Statement:
7492
- ec2:AuthorizeSecurityGroup*
7593
- ec2:RevokeSecurityGroup*
7694
Resource: ["*"]
77-
Condition:
78-
StringLike:
79-
aws:ResourceTag/aws:eks:cluster-name:
80-
- ${Env}*
8195
- Effect: Allow
8296
Action:
8397
- ec2:CreateTags

lab/iam/policies/iam.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,4 @@ Statement:
8282
- guardduty.amazonaws.com
8383
- spot.amazonaws.com
8484
- fis.amazonaws.com
85+
- transitgateway.amazonaws.com

lab/iam/policies/ssm.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Version: "2012-10-17"
2+
Statement:
3+
- Effect: Allow
4+
Action:
5+
ssm:CreateActivation
6+
Resource:
7+
- !Sub arn:aws:iam::${AWS::AccountId}:role/${Env}-hybrid-node-role-*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
logmessage "Cleaning up EKS Hybrid Nodes Module"
6+
7+
kubectl delete -k ~/environment/eks-workshop/modules/networking/eks-hybrid-nodes/kustomize --ignore-not-found=true
8+
9+
kubectl delete deployment nginx-deployment --ignore-not-found=true
10+
11+
kubectl delete clusterpolicies.kyverno.io set-pod-deletion-cost --ignore-not-found
12+
13+
uninstall-helm-chart cilium cilium
14+
uninstall-helm-chart kyverno kyverno
15+
16+
kubectl delete namespace cilium --ignore-not-found
17+
kubectl delete namespace kyverno --ignore-not-found
18+
19+
kubectl delete nodes -l eks.amazonaws.com/compute-type=hybrid --ignore-not-found=true

0 commit comments

Comments
 (0)