How to create EKS Cluster using Terraform MODULES (AWS Load Balancer Controller + Autoscaler + IRSA)

Поділитися
Вставка
  • Опубліковано 3 лют 2025

КОМЕНТАРІ • 123

  • @AntonPutra
    @AntonPutra  Рік тому +4

    🔴 - To support my channel, I’d like to offer Mentorship/On-the-Job Support/Consulting - me@antonputra.com
    👉 [UPDATED] AWS EKS Kubernetes Tutorial [NEW]: ua-cam.com/play/PLiMWaCMwGJXnKY6XmeifEpjIfkWRo9v2l.html&si=wc6LIC5V2tD-Tzwl

  • @George-mk7lp
    @George-mk7lp 2 роки тому +8

    this is the best k8s setup tutorial in the whole youtube i swear

  • @AntonPutra
    @AntonPutra  2 роки тому +3

    Monitor EKS & EC2 instances with MANAGED Prometheus - ua-cam.com/video/-nUQNFAX5TI/v-deo.html

  • @AntonPutra
    @AntonPutra  Рік тому +1

    🟢 [New] Terragrunt Tutorial: Create VPC, EKS from Scratch! (Step-by-Step) - ua-cam.com/video/yduHaOj3XMg/v-deo.html

  • @AntonPutra
    @AntonPutra  Рік тому +1

    Get Full-Length High-Quality DevOps Tutorials for Free - Subscribe Now! - ua-cam.com/users/AntonPutra

  • @AntonPutra
    @AntonPutra  2 роки тому +1

    ❤Performance Benchmarks Playlist - ua-cam.com/play/PLiMWaCMwGJXl-h2RgOSpdO-pQaSRwlVjd.html

  • @unmatal
    @unmatal 2 місяці тому +1

    Thank you very much for this Detailed and Functional Tutorial. I have learned much from you. Best wishes for you

  • @AntonPutra
    @AntonPutra  Рік тому +1

    👉 How to Manage Secrets in Terraform - ua-cam.com/video/3N0tGKwvBdA/v-deo.html
    👉 Terraform Tips & Tricks - ua-cam.com/video/7S94oUTy2z4/v-deo.html
    👉 ArgoCD Tutorial - ua-cam.com/video/zGndgdGa1Tc/v-deo.html

  • @bernardoteisceira975
    @bernardoteisceira975 11 місяців тому

    Incredible tutoria, you rock Anton!! Greetings from Argentina!

  • @roberto_camp
    @roberto_camp 2 роки тому

    Another Master Class Anton! My friend and I worked thru this yesterday and had two EKS clusters up and running. Thank you for all that you do!

  • @nandashyam
    @nandashyam 2 роки тому +1

    Just what I was looking for. Perfect timing. Thanks for uploading.

  • @Ashwaqz
    @Ashwaqz 2 роки тому +3

    Thanks!

    • @Ashwaqz
      @Ashwaqz 2 роки тому +1

      Kudos for the Tutorial,
      Also, could you show how to use karpenter module to the same setup without clusterautoscaler.

    • @AntonPutra
      @AntonPutra  2 роки тому

      Thank you Ashwaq!

    • @AntonPutra
      @AntonPutra  2 роки тому

      Well i have a tutorial (Karpenter) - github.com/antonputra/tutorials/tree/main/lessons/114

  • @habibverse
    @habibverse 2 роки тому +1

    thank you Anton, you always bring interessant subjects

  • @tandapnoelbansikah6280
    @tandapnoelbansikah6280 25 днів тому

    Great tutorial, and the only best as of now on youtube, but am having some issues with the eks modules we used, somethings are deprecated like the nat_gate, and when i excute am having some errors🥺

  • @Ariyonzor
    @Ariyonzor Рік тому +1

    This is a great tutorial, you are helping me alot for acquiring my first devops position, i have an home assignment to provision a vpc and eks cluster that integrates with ecr and this is great and very relevant.
    Altough im having issues with "allow_assume_eks_admins_iam_policy" module which says i have some syntax error in the hidden directory .terraform within the project, weird but i'll troubleshoot it. Thanks alot!!

  • @ManojKumar-cd6ud
    @ManojKumar-cd6ud 2 роки тому +1

    Really helpful!! Thanks a bunch.

  • @premierde
    @premierde 6 місяців тому

    Indeed, quite handy and Insight. Any chance on Azure AKS

    • @AntonPutra
      @AntonPutra  6 місяців тому

      thanks! i have one for azure - ua-cam.com/video/8HmReos6dlY/v-deo.html

  • @ОлександрНіколайчук-ы5с

    Thank you for your work and your great videos.
    could you please show me how to add karpenter for scaling to eks module.

    • @AntonPutra
      @AntonPutra  Рік тому +1

      Thanks, I have a lesson - studio.ua-cam.com/users/videoC_YZXpXwtbg/edit

  • @milkokawaiidjiev5000
    @milkokawaiidjiev5000 Рік тому +2

    I found your channel and I am absolutely in love with your content dude! Huge thanks.
    By any chance - on 12:15min do you know how we can specify a private repo image from ECR in the deployment? For example deploy wordpress.

    • @AntonPutra
      @AntonPutra  Рік тому

      Thanks! It's going to be in the following format (just copy from the ecr)
      .dkr.ecr..amazonaws.com/:

  • @pratikbin
    @pratikbin 2 роки тому +1

    Love it 🔥

  • @gheywood1
    @gheywood1 2 роки тому +1

    At around the 09:17 mark, my "data" resources do not work.
    I have
    data "aws_eks_cluster" "default" {
    name = module.eks.cluster_id
    }
    I get:
    │ Error: Missing required argument

    │ with data.aws_eks_cluster.default,
    │ on eks.tf line 47, in data "aws_eks_cluster" "default":
    │ 47: name = module.eks.cluster_id

    │ The argument "name" is required, but no definition was found. I tried created an output based on module.eks.cluster_id, and I don't get one (although I can get one for module.eks.cluster_name.

    • @gheywood1
      @gheywood1 2 роки тому +1

      Actually, just noticed in the module documentation:
      Description: The ID of the EKS cluster. Note: currently a value is returned only for local EKS clusters created on Outposts
      If you change the definition of those data fields from cluster_id to cluster_name, it works!

  • @ShahNawaz-yz9cn
    @ShahNawaz-yz9cn 2 роки тому +1

    awsome tutorial i created the EKS Cluster but having issue with load balancer it througing an error Kuberntess cluster unreachable :the server has asked for the client to provide credentials . can you assist please thank you

  • @2mahender
    @2mahender 2 роки тому +1

    nice article, can we pass kubernetes/helm provider to child modules from root module, if both are in saperate folders?

    • @AntonPutra
      @AntonPutra  2 роки тому +1

      Thanks, you can use terraform_remote_state
      developer.hashicorp.com/terraform/language/state/remote-state-data

    • @2mahender
      @2mahender 2 роки тому

      @@AntonPutra i thought provider "kubernetes { }..how can i apss to child modules?

  • @2mahender
    @2mahender 2 роки тому +2

    can u a do video on eks fargate core dns patching using terraform and python lambda function, as described in aws documentation

  • @milkokawaiidjiev5000
    @milkokawaiidjiev5000 Рік тому +1

    Do you plan on creating a wordpress guide anytime soon that's deployed through terraform to EKS and uses RDS ? I have difficulties creating my yaml deployments and services and not quite sure if you are able to help on that.

    • @AntonPutra
      @AntonPutra  Рік тому +1

      I think I can do it in the future. You need to use EFS with readwritemany to mount the same volume to database and wordpress itself.

  • @twizzoe
    @twizzoe Рік тому

    Great tutorial, I replicated all this and I moved a step ahead with setting up rbac but I got stuck with error authorizing namespace setup and other resources related for the rbac

    • @AntonPutra
      @AntonPutra  Рік тому

      Thanks, generally only user or role that created EKS cluster would have admin access (for example update config map in kube-system ns). Check with kubectl auth can-i "*" "*"

  • @AndresKasekamp
    @AndresKasekamp 6 місяців тому

    I encountered an issue when deploying microservices with this solution. When my own API gateway was hosted in the SPOT instance and the other node API servers and databases were in the general instance, then the communication between the pods did not work. I fixed the issue by making the general instance larger so all the pods were hosted there from the start. Is cross-node communication blocked by default, do I have to change security group rules or is there something else I am missing?

    • @AntonPutra
      @AntonPutra  6 місяців тому

      No, it's not blocked. Maybe it was in the termination phase, it's hard to say. But it's totally common to create spot and on-demand instances in the same cluster, and networking should work.
      I have updated video with update source, pls take a look - ua-cam.com/video/5XpPiORNy1o/v-deo.html

  • @renatosouza1k
    @renatosouza1k Місяць тому

    To use this same alb for all applications, would it be possible?

    • @AntonPutra
      @AntonPutra  Місяць тому

      yes, you can share application load balancer when you use ingress and aws load balancer controller, but it's not recommended... take a look at official docs

  • @preethi-devops
    @preethi-devops 2 роки тому

    Hi, thanks for the video. I implemented the code. It is working except disk_size . Even though this parameter is set to 128 default disk size of 20 is applied to eks nodes.Any suggestions on how to implement it.with launch templates into the current code is not working

    • @AntonPutra
      @AntonPutra  2 роки тому

      try to create custom launch template

    • @preethi-devops
      @preethi-devops 2 роки тому

      @@AntonPutra can we use custom launch template with the current eks module used in the demo. Appreciate any references. Thanks much

    • @AntonPutra
      @AntonPutra  2 роки тому

      @@preethi-devops Here is an example - github.com/antonputra/tutorials/blob/482596538abd03dd823cd0fe42e5ae2ea77a0765/lessons/102/terraform/7-nodes.tf#L76-L89

    • @preethi-devops
      @preethi-devops 2 роки тому

      @@AntonPutra can’t we use it with eks module rather than creating from resource types. I need to use launch template with existing code with eks module just to change disk size

    • @AntonPutra
      @AntonPutra  2 роки тому

      @@preethi-devops Yes you can "Support for custom AMI, custom launch template, and custom user data including custom user data template"
      Try to use that launch template in `self_managed_node_groups` block in the module

  • @alexnguyen385
    @alexnguyen385 Рік тому

    Hi, I followed all these steps but there's one more thing is when I delete the nginx deployment then all the nodes is not going to scale down. Is there any thing that we can improve this ?

    • @AntonPutra
      @AntonPutra  Рік тому

      Check the logs, make sure that autoscaler actually schedules the node for termination

  • @MdAshraf007
    @MdAshraf007 Рік тому

    hi sir, is this a production grade setup or do we need some changes?

    • @AntonPutra
      @AntonPutra  Рік тому

      Yes, but If you want to further harden it, you would change one parameter to make it a private cluster. This means the control plane endpoint becomes private, and you would need a VPN or a bastion host.

    • @MdAshraf007
      @MdAshraf007 Рік тому

      @@AntonPutra I see, thank you :)

    • @MdAshraf007
      @MdAshraf007 Рік тому

      @@AntonPutra also what type of VPN is normally used by companies? I know of OpenVpn from AWS marketplace but are there any cheaper alternatives? Or methods to setup VPN?

  • @patelakshay2715
    @patelakshay2715 2 роки тому

    Really helpful !! Can you make an video for how to do authorization and authentication in ingress controller instead at pod level for microservices running under kubernetes EKS

    • @AntonPutra
      @AntonPutra  2 роки тому

      Welcome, do you mean something like network policies, istio or something else? mTLS?

    • @patelakshay2715
      @patelakshay2715 2 роки тому +2

      @@AntonPutra Yes istio and can you also make video for how to use stickiness session for AWS ALB and NGINX load balancer ?

  • @mantikoragio6555
    @mantikoragio6555 Рік тому

    Thanks a lot for the lesson, much better than the one with just AWS resources as here the cluster autoscaler is also part of terraform;
    One question though: when scaling up, e.g. from 1 to 2 pods, clearly you get more nodes because of the auto-scaler (also 2), but then when decreasing pods to 1 in the deployment, num. of pods gets reduced to 1 but not amount of nodes (so still 2).
    What happens is that when I create an auto-scaler, I get 2 nodes and my desired num. of nodes is changed to 2 instead of initial 1.
    Is this intended? and if yes, how do I also destroy the nodes to scale down (keep desired at 1)?
    Cheers!

    • @AntonPutra
      @AntonPutra  Рік тому +1

      Thanks! It should scale down to 1 in about 5-10 minutes. You can also configure desired profile on the autoscaler using cli flags or helm variables.

  • @anand.shivam
    @anand.shivam Рік тому

    I followed the tutorial exactly step by step however I got stuck at 9:29 The configmap "aws-auth" does not exist

    • @AntonPutra
      @AntonPutra  Рік тому

      add namespace "kubectl get cm aws-auth -n kube-system -o yaml"

    • @renzcarillo7277
      @renzcarillo7277 Рік тому

      @@AntonPutra error: You must be logged in to the server (Unauthorized)

  • @renatosouza1k
    @renatosouza1k 9 місяців тому

    Whats this lesson? I am appling this code with terragrunt and not work, this error: permissions_boundary must be 20 characters or higher (aws_iam_role_invalid_permissions_boundary)

    • @AntonPutra
      @AntonPutra  9 місяців тому +1

      did you misconfigur iam role? based on the error this one seems similar to yours - github.com/hashicorp/terraform-provider-aws/issues/5546

  • @tomasferrari92
    @tomasferrari92 Рік тому

    Great tutorial man thank you so much! One question.
    When I run tf destroy the load balancer is not deleted, which leads to issues with deleting other resources like VPC. How would you fix this?

    • @AntonPutra
      @AntonPutra  Рік тому +1

      Thanks! You need to first delete all resources from k8s like ingresses (and services of type LoadBalancer) that creates load balancers

    • @tomasferrari92
      @tomasferrari92 Рік тому

      @@AntonPutra you mean manually?

    • @AntonPutra
      @AntonPutra  Рік тому +1

      @@tomasferrari92 kubectl delete -f file.yaml

    • @tomasferrari92
      @tomasferrari92 Рік тому

      @@AntonPutra got it. Thanks!

  • @AMMARSUHAIL-hm5xt
    @AMMARSUHAIL-hm5xt 2 роки тому +1

    Hi , awesome video, I have been following you since long, really like all the stuff you share. I am just stuck on creating service account through terraform for eks? as I have to manually do kubectl apply -f serviceaccount.yaml for load balancer (EKS), how can I automate this part, will appreciate it, if you can provide some knowledge

    • @AntonPutra
      @AntonPutra  2 роки тому

      Thanks AMMAR, you can use kubectl terraform provider or kubernetes provider.
      registry.terraform.io/providers/gavinbunney/kubectl/latest/docs

    • @rochak6998
      @rochak6998 Рік тому

      @@AntonPutra

  • @rohitnarula7038
    @rohitnarula7038 Рік тому

    Can you showcase how to upgrade the cluster, not via AWS UI . Is there any other way to do it

    • @AntonPutra
      @AntonPutra  Рік тому

      It's very easy, update the control plane version and run terraform apply, then node pools one by one

    • @rohitnarula7038
      @rohitnarula7038 Рік тому

      @@AntonPutra but that would result in down time . As mater plane will go down . Nodes will be fine as they will go down one by one

    • @AntonPutra
      @AntonPutra  Рік тому

      @@rohitnarula7038 EKS has HA control plane setup and even if the control plane go down for a little bit, it only means that Kubernetes API server is down. You won't be able to deploy new applications to Kubernetes and some other features such as scheduler won't be available, but it will not affect your application (no downtime for the app). When upgrading the nodes, K8s first drain the node than reschedule the pod, so I would highly recommend to define Pod Disruption Budget (PDB) to minimize the damage to your app. With PDB you can say for example that only 1 pod at a time can be down if you have 5 or 10 of them.

    • @rohitnarula7038
      @rohitnarula7038 Рік тому +1

      @@AntonPutra Thanks alot will try that

    • @AntonPutra
      @AntonPutra  Рік тому

      @@rohitnarula7038 no problem

  • @sujithsurendran7686
    @sujithsurendran7686 2 роки тому +1

    Thank you

  • @evgenyshabarchin
    @evgenyshabarchin Рік тому

    Hey. Thanks for the awesome tutorial. You are the first one who was capable to make terraform tutorial which actually works). If you don’t mind I have a small question. I followed you tutorial and all works find but if I try to add something (another helm chart for example) terraform recreates aws_config map every time I do terraform apply. Any ideas why it’s happening?

    • @AntonPutra
      @AntonPutra  Рік тому

      recreates or updates? you could add ignore block on the terraform resource but i don't think that's the issue

    • @evgenyshabarchin
      @evgenyshabarchin Рік тому

      @@AntonPutra it do in-place upgrade every time even if terraform code has been unchanged. And every time it replace group arn.

  • @abhayprayag3982
    @abhayprayag3982 2 роки тому

    Its spot on. gr8 quick question why can we use aws_auth_roles = [ { rolearn = "arn:aws:iam::66666666666:role/role1" username = "role1" groups = ["system:masters"] }, input of terraform-aws-eks module for adding role to EKS?

  • @ramathegreat7405
    @ramathegreat7405 2 роки тому +1

    Hi guys, I am looking for eks managed groups , is this the same?

    • @AntonPutra
      @AntonPutra  2 роки тому

      Yes =)
      github.com/antonputra/tutorials/blob/main/lessons/125/terraform/2-eks.tf#L20

  • @roeerakovsky7688
    @roeerakovsky7688 2 роки тому

    Thanks for the great video. I follow the steps and had a problem in 2 cases. 1. during a failure at the first deployment I tried to rerun TF and got resources that already exist on the cloud watch IAM group and role. Then I tried to destroy the entire stack and got another error. The only way to redeploy is to delete all zombies manually because they are not fully deleted. how do you suggest dealing with it?

    • @AntonPutra
      @AntonPutra  2 роки тому +1

      I had similar issue with netscope client, disable it before running terraform (or similar monitoring tool on your latop). After terraform fails in the middle, you can either import resources (manually) or delete them (manually)...

    • @roeera1
      @roeera1 2 роки тому

      @@AntonPutra Thanks for your answer. Import actually doesn't work. I deleted them manually. Wanted also to ask you regarding "AWS Load Balancer Controller" is there a way to run 2 different controllers (one for internal and second for ext). I'm asking because they should run with a different annotations. also what is the exact different between was load balancer controller to ingress-nginx (in ingress nginx I managed to run 2 different ingresses)Thank you !

  • @mantikoragio6555
    @mantikoragio6555 Рік тому

    One more question if you don't mind :)
    When I run locally everything is provisioned, when I use GitLab CI (with oidc), everything is provisioned until this step:
    "module.eks.kubernetes_config_map_v1_data.aws_auth[0]: Creating...
    Error: kube-system/cluster-autoscaler failed to create kubernetes rest client for update of resource: Unauthorized
    What resources should be created in addition so that the pipeline is successful, might you have hints? :)
    Cheers!

    • @AntonPutra
      @AntonPutra  Рік тому +1

      Only user/iam role that initially created EKS cluster has access to aws auth config map. First check if you use the same entity to modify aws config map also check how kubernetes provider is setup in your live env. github.com/antonputra/tutorials/blob/main/lessons/160/git-infrastructure-live/dev/kubernetes-addons/terragrunt.hcl#L38-L52

    • @mantikoragio6555
      @mantikoragio6555 Рік тому

      @@AntonPutra only got around to fixing it now; the problem was that the gitlab runner on the TF apply stage didn't have aws cli installed; really hope you'll make longer tutorials for deploying EKS via GitLab CI or Github actions with a sample app, e.g. a DB and a public facing app, so together with ArgoCD.. maybe encorporating hashicorp vault..?
      Thanks so much, your channel + That DevOps Guy are godsends.

    • @AntonPutra
      @AntonPutra  Рік тому

      @@mantikoragio6555 got it thanks. Yes i think to have a sample app definitely can help

  • @ArtemKovalchukl
    @ArtemKovalchukl Рік тому

    in eks module version 19.10.0 i think alrd exist "ingress_allow_access_from_control_plane" ports build in, so if we use "node_security_group_additional_rules" we take arror that we have duplicate security group. I am right?

    • @AntonPutra
      @AntonPutra  Рік тому

      Perhaps, I haven't tried it

    • @ArtemKovalchukl
      @ArtemKovalchukl Рік тому

      @@AntonPutra can you help, how we can add custom headers in this setup?

    • @AntonPutra
      @AntonPutra  Рік тому

      @@ArtemKovalchukl I don't think that you can add custom headers at the ALB level. You can do it on nginx ingress controller with configmap.

    • @ArtemKovalchukl
      @ArtemKovalchukl Рік тому

      @@AntonPutra do you have some examples how to use nginx ingress instead alb with setup like in this tutorial?

    • @AntonPutra
      @AntonPutra  Рік тому

      @@ArtemKovalchukl github.com/antonputra/tutorials/tree/main/lessons/082

  • @rodrigorios6585
    @rodrigorios6585 10 місяців тому

    Is the LoadBalancer Controller really necessary my friend?

    • @AntonPutra
      @AntonPutra  10 місяців тому

      soon, original cloud controller that responsible for create lbs in aws will be removed, same happened with ebs storage class

    • @rodrigorios6585
      @rodrigorios6585 10 місяців тому

      How to know if the Cluster Autoscaler actually works?

  • @Cherupakstmt
    @Cherupakstmt 2 роки тому +2

    Hi, thanks for the video. Can you also show for GKE

  • @aalang
    @aalang 10 місяців тому

    I'm having with the section involving IAM. This block:
    manage_aws_auth_configmap = true
    aws_auth_roles = [
    {
    rolearn = module.eks_admins_iam_role.iam_role_arn
    username = module.eks_admins_iam_role.iam_role_name
    groups = ["system:masters"]
    },
    ]
    I have it in my eks module after eks_managed_node_groups. The terraform syntax profiler doesn't like it and when I do a terraform plan, it errors out:
    │ An argument named "manage_aws_auth_configmap" is not expected here.
    │ An argument named "aws_auth_roles" is not expected here.

    • @AntonPutra
      @AntonPutra  10 місяців тому +1

      Try to use exactly the same Terraform and Terraform module version. After you successfully provision your infrastructure, you can start upgrading one by one.

    • @ZooMweBG
      @ZooMweBG 10 місяців тому +1

      The latest versions of the module are using access_entries to setup access instead of configmap.
      Example:
      access_entries = {
      # One access entry with a policy associated
      admin-role-entry = {
      kubernetes_groups = []
      principal_arn = "arn:aws:iam::example_account_id:role/example_role"
      policy_associations = {
      admin-policy = {
      policy_arn = "arn:aws:eks::aws:cluster-access-policy/AmazonEKSAdminPolicy"
      access_scope = {
      type = "cluster"
      }
      }
      }
      }
      }

    • @aalang
      @aalang 10 місяців тому

      @@ZooMweBG Thanks.

  • @abhijeetsamanta4246
    @abhijeetsamanta4246 2 роки тому

    How to add efs in this eks cluster which you explained

    • @AntonPutra
      @AntonPutra  2 роки тому +1

      here is an example from my another video - github.com/antonputra/tutorials/blob/main/lessons/113/terraform/13-efs.tf

  • @senthilkumar5129
    @senthilkumar5129 2 роки тому +1

    supper

  • @justillia
    @justillia Рік тому

    it would be awesome to share the source of code to us.😀

    • @AntonPutra
      @AntonPutra  Рік тому

      It's in the video description - github.com/antonputra/tutorials/tree/main/lessons/125