Skip to content

Commit 790b193

Browse files
authored
Merge pull request #110 from maddevsio/eks-addons
use EKS add-ons to install/upgrade internal components, such as vpc-cni, kube-proxy, coredns
2 parents c7ea66f + 02ea012 commit 790b193

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ You can find more about this project in Anton Babenko stream:
4949
- [Table of contents](#table-of-contents)
5050
- [Architecture diagram](#architecture-diagram)
5151
- [Current infrastructure cost](#current-infrastructure-cost)
52+
- [EKS Upgrading](#eks-upgrading)
5253
- [Namespace structure in the K8S cluster](#namespace-structure-in-the-k8s-cluster)
5354
- [Useful tools](#useful-tools)
5455
- [Useful VSCode extensions](#useful-vscode-extensions)
@@ -136,6 +137,19 @@ This diagram describes the default infrastructure:
136137

137138
> The cost is indicated without counting the amount of traffic for Nat Gateway Load Balancer and S3
138139
140+
## EKS Upgrading
141+
To upgrade k8s cluster to a new version, please use [official guide](https://docs.aws.amazon.com/eks/latest/userguide/update-cluster.html) and check changelog/breaking changes.
142+
Starting from v1.18 EKS supports K8S add-ons. We use them to update things like vpc-cni, kube-proxy, coredns. To get the latest add-ons versions, run:
143+
```bash
144+
aws eks describe-addon-versions --kubernetes-version 1.21 --query 'addons[].[addonName, addonVersions[0].addonVersion]'
145+
```
146+
where 1.21 - is a k8s version on which we are updating.
147+
DO NOT FORGET!!! to update cluster-autoscaler too. It's version must be the same as the cluster version.
148+
Also ***IT'S VERY RECOMMENDED*** to check that deployed objects have actual apiVersions that won't be deleted after upgrading. There is a tool [*pluto*](https://github.com/FairwindsOps/pluto) that can help to do it.
149+
```bash
150+
Switch to the correct cluster
151+
Run `pluto detect-helm -o markdown --target-versions k8s=v1.22.0`, where `k8s=v1.22.0` is a k8s version we want to update to.
152+
```
139153
## Namespace structure in the K8S cluster
140154

141155
![aws-base-namespaces](docs/aws-base-diagrams-Namespaces-v3.svg)

terraform/layer1-aws/aws-eks.tf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,41 @@ EOT
179179
}
180180
}
181181
}
182+
183+
resource "aws_eks_addon" "vpc_cni" {
184+
count = var.addon_create_vpc_cni ? 1 : 0
185+
186+
cluster_name = module.eks.cluster_id
187+
addon_name = "vpc-cni"
188+
resolve_conflicts = "OVERWRITE"
189+
addon_version = var.addon_vpc_cni_version
190+
191+
tags = {
192+
Environment = local.env
193+
}
194+
}
195+
196+
resource "aws_eks_addon" "kube_proxy" {
197+
count = var.addon_create_kube_proxy ? 1 : 0
198+
199+
cluster_name = module.eks.cluster_id
200+
addon_name = "kube-proxy"
201+
resolve_conflicts = "OVERWRITE"
202+
addon_version = var.addon_kube_proxy_version
203+
204+
tags = {
205+
Environment = local.env
206+
}
207+
}
208+
209+
resource "aws_eks_addon" "coredns" {
210+
count = var.addon_create_coredns ? 1 : 0
211+
212+
cluster_name = module.eks.cluster_id
213+
addon_name = "coredns"
214+
resolve_conflicts = "OVERWRITE"
215+
addon_version = var.addon_coredns_version
216+
tags = {
217+
Environment = local.env
218+
}
219+
}

terraform/layer1-aws/variables.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,31 @@ variable "eks_cluster_version" {
9696
description = "Version of the EKS K8S cluster"
9797
}
9898

99+
variable "addon_create_vpc_cni" {
100+
default = true
101+
description = "Enable vpc-cni add-on or not"
102+
}
103+
variable "addon_vpc_cni_version" {
104+
default = "v1.9.1-eksbuild.1"
105+
description = "The version of vpc-cni add-on"
106+
}
107+
variable "addon_create_kube_proxy" {
108+
default = true
109+
description = "Enable kube-proxy add-on or not"
110+
}
111+
variable "addon_kube_proxy_version" {
112+
default = "v1.20.4-eksbuild.2"
113+
description = "The version of kube-proxy add-on"
114+
}
115+
variable "addon_create_coredns" {
116+
default = true
117+
description = "Enable coredns add-on or not"
118+
}
119+
variable "addon_coredns_version" {
120+
default = "v1.8.3-eksbuild.1"
121+
description = "The version of coredns add-on"
122+
}
123+
99124
variable "eks_workers_additional_policies" {
100125
type = list(any)
101126
default = [

0 commit comments

Comments
 (0)