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

Поделиться
HTML-код
  • Опубликовано: 22 окт 2024

Комментарии • 120

  • @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]: ruclips.net/p/PLiMWaCMwGJXnKY6XmeifEpjIfkWRo9v2l&si=wc6LIC5V2tD-Tzwl

  • @George-mk7lp
    @George-mk7lp Год назад +7

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

  • @bigvandi
    @bigvandi 2 года назад +4

    I'm impressed by how clearly you expressed your knowledge in a short but saturated video.

  • @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!

  • @bernardoteisceira975
    @bernardoteisceira975 7 месяцев назад

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

  • @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!!

  • @nandashyam
    @nandashyam 2 года назад +1

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

  • @premierde
    @premierde 3 месяца назад

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

    • @AntonPutra
      @AntonPutra  3 месяца назад

      thanks! i have one for azure - ruclips.net/video/8HmReos6dlY/видео.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.ruclips.net/user/videoC_YZXpXwtbg/edit

  • @ShahNawaz-yz9cn
    @ShahNawaz-yz9cn Год назад +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

  • @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/:

  • @habibverse
    @habibverse 2 года назад +1

    thank you Anton, you always bring interessant subjects

  • @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.

  • @2mahender
    @2mahender Год назад +1

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

    • @AntonPutra
      @AntonPutra  Год назад +1

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

    • @2mahender
      @2mahender Год назад

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

  • @ManojKumar-cd6ud
    @ManojKumar-cd6ud 2 года назад +1

    Really helpful!! Thanks a bunch.

  • @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 "*" "*"

  • @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.

  • @AndresKasekamp
    @AndresKasekamp 3 месяца назад

    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  3 месяца назад

      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 - ruclips.net/video/5XpPiORNy1o/видео.html

  • @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

  • @AshwaqHussain
    @AshwaqHussain Год назад +3

    Thanks!

    • @AshwaqHussain
      @AshwaqHussain Год назад +1

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

    • @AntonPutra
      @AntonPutra  Год назад

      Thank you Ashwaq!

    • @AntonPutra
      @AntonPutra  Год назад

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

  • @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?

  • @AMMARSUHAIL-hm5xt
    @AMMARSUHAIL-hm5xt Год назад +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  Год назад

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

    • @rochak6998
      @rochak6998 Год назад

      @@AntonPutra

  • @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 ?

  • @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.

  • @MdAshraf007
    @MdAshraf007 10 месяцев назад

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

    • @AntonPutra
      @AntonPutra  10 месяцев назад

      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 10 месяцев назад

      @@AntonPutra I see, thank you :)

    • @MdAshraf007
      @MdAshraf007 10 месяцев назад

      @@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?

  • @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!

  • @preethi-devops
    @preethi-devops Год назад

    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  Год назад

      try to create custom launch template

    • @preethi-devops
      @preethi-devops Год назад

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

    • @AntonPutra
      @AntonPutra  Год назад

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

    • @preethi-devops
      @preethi-devops Год назад

      @@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  Год назад

      @@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

  • @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 !

  • @renatosouza1k
    @renatosouza1k 5 месяцев назад

    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  5 месяцев назад

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

  • @sujithsurendran7686
    @sujithsurendran7686 2 года назад +1

    Thank you

  • @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

  • @gheywood1
    @gheywood1 Год назад +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 Год назад +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!

  • @rodrigorios6585
    @rodrigorios6585 6 месяцев назад

    Is the LoadBalancer Controller really necessary my friend?

    • @AntonPutra
      @AntonPutra  6 месяцев назад +1

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

    • @rodrigorios6585
      @rodrigorios6585 6 месяцев назад

      How to know if the Cluster Autoscaler actually works?

  • @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

  • @ramathegreat7405
    @ramathegreat7405 Год назад +1

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

    • @AntonPutra
      @AntonPutra  Год назад

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

  • @pratikbin
    @pratikbin 2 года назад +1

    Love it 🔥

  • @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

  • @AntonPutra
    @AntonPutra  Год назад +3

    Monitor EKS & EC2 instances with MANAGED Prometheus - ruclips.net/video/-nUQNFAX5TI/видео.html

  • @AntonPutra
    @AntonPutra  Год назад +1

    Get Full-Length High-Quality DevOps Tutorials for Free - Subscribe Now! - ruclips.net/user/AntonPutra

  • @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

  • @AntonPutra
    @AntonPutra  Год назад +1

    🟢 [New] Terragrunt Tutorial: Create VPC, EKS from Scratch! (Step-by-Step) - ruclips.net/video/yduHaOj3XMg/видео.html

  • @Cherupakstmt
    @Cherupakstmt 2 года назад +2

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

  • @AntonPutra
    @AntonPutra  Год назад +1

    ❤Performance Benchmarks Playlist - ruclips.net/p/PLiMWaCMwGJXl-h2RgOSpdO-pQaSRwlVjd

  • @abhijeetsamanta4246
    @abhijeetsamanta4246 Год назад

    How to add efs in this eks cluster which you explained

    • @AntonPutra
      @AntonPutra  Год назад +1

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

  • @AntonPutra
    @AntonPutra  Год назад +1

    👉 How to Manage Secrets in Terraform - ruclips.net/video/3N0tGKwvBdA/видео.html
    👉 Terraform Tips & Tricks - ruclips.net/video/7S94oUTy2z4/видео.html
    👉 ArgoCD Tutorial - ruclips.net/video/zGndgdGa1Tc/видео.html

  • @aalang
    @aalang 7 месяцев назад

    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  7 месяцев назад +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 7 месяцев назад +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 7 месяцев назад

      @@ZooMweBG Thanks.

  • @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)

  • @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