https://github.com/notharshhaa/eks-cluster-terraform
๐๐๐ซ๐ซ๐๐๐จ๐ซ๐ฆ: ๐๐๐ฉ๐ฅ๐จ๐ฒ ๐๐ง ๐๐๐ ๐๐ฅ๐ฎ๐ฌ๐ญ๐๐ซ โ ๐๐ข๐ค๐ ๐ ๐๐จ๐ฌ๐ฌ!
https://github.com/notharshhaa/eks-cluster-terraform
Last synced: about 1 year ago
JSON representation
๐๐๐ซ๐ซ๐๐๐จ๐ซ๐ฆ: ๐๐๐ฉ๐ฅ๐จ๐ฒ ๐๐ง ๐๐๐ ๐๐ฅ๐ฎ๐ฌ๐ญ๐๐ซ โ ๐๐ข๐ค๐ ๐ ๐๐จ๐ฌ๐ฌ!
- Host: GitHub
- URL: https://github.com/notharshhaa/eks-cluster-terraform
- Owner: NotHarshhaa
- Created: 2023-03-11T15:18:17.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-11T15:26:11.000Z (about 3 years ago)
- Last Synced: 2025-01-25T19:31:22.893Z (over 1 year ago)
- Language: HCL
- Size: 9.77 KB
- Stars: 54
- Watchers: 3
- Forks: 51
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐๐๐ซ๐ซ๐๐๐จ๐ซ๐ฆ: ๐๐๐ฉ๐ฅ๐จ๐ฒ ๐๐ง ๐๐๐ ๐๐ฅ๐ฎ๐ฌ๐ญ๐๐ซ โ ๐๐ข๐ค๐ ๐ ๐๐จ๐ฌ๐ฌ!
------
### :loudspeaker: แดแดสสแดาแดสแด: แดสแดแดแด แดสษชs แดสแดแดแดแดแด แดแดแด
แดสแดs
*Kubernetes, often abbreviated as โK8sโ (because there are 8 letters between the โKโ & โsโ in Kubernetes), orchestrates containerized applications to run on a cluster of hosts. K8s also allocates storage and persistent volumes to running containers, provides automatic scaling, and works continuously to maintain the desired state of applications, providing resiliency.*
*Terraform is an extremely popular infrastructure provisioning tool among DevOps. EKS is managed K8S solution provided by AWS, which is widely used managed K8S platform by AWS consumers.*
*Separately, Kubernetes and Terraform are powerful and popular tools for DevOps operations. However, when you decide to use them together, you will see even more benefits for container cluster management!*
-----
## :loudspeaker: แดแดสสแดาแดสแด: แดกสส แด
แดแดสแดส แดกษชแดส แดแดสสแดาแดสแด?
*While you could use the built-in AWS provisioning (UI, CLI, CloudFormation) for EKS clusters, Terraform provides you with several benefits:*
* *Terraform can be used to manage Kubernetes infrastructure, helping you to orchestrate your applications and run them at scale. This alleviates some of the challenges of running Kubernetes, including detecting configuration drift โ planned & unplanned changes.*
* *Terraform will create resources, it will also update & delete tracked resources without requiring inspection of the API.*
* *Terraform understands dependency relationships between resources. For example, if an AWS Kubernetes cluster needs a specific VPC and subnet configurations, Terraform wonโt attempt to create the cluster if the VPC and subnet failed to create with the proper configuration.*
------
## :loudspeaker: แดแดสสแดาแดสแด: แดสแดสแดวซแดษชsษชแดแดs
*For this tutorial, you will need:*
* **AWS account**
* **Terraform & Kubernetes installed on your IDE (I will be using VSCode)**
* **AWS CLI installed and configured on your IDE**
------
## :loudspeaker: แดแดสสแดาแดสแด: แดแดส แดสแดแดแดแดษชแด แด:
1. *Create an EKS cluster (capacity of 2).*
2. *Create a random string that allows 5 characters to build the cluster name.*
3. *They want to output the cluster name and the ip address of the containers in the cluster.*
*Lastly, all code should be in module blocks, not resource blocks.*
***Letโs get started โ buckle up Chuck!!***
------
### ๐ท| sแดแด แดแด าษชสแด sสsแดแดแด
*First, clone my GitHub repository:*
```
git clone https://github.com/harshhaareddy/eks-cluster-terraform
```
*Change into the directory to the folder shown below:*
```
cd eks-cluster-terraform
```
------
### ๐ธ| แดแดสสแดาแดสแด ษชษดษชแด, แดสแดษด & แดแดแดสส
*After you have created the above files, the first step is to initialize the terraform backend by using the `terraform init` command. Next, you will run the `terraform plan` command to evaluate the Terraform configuration. Finally, you will run the command `terraform apply` to apply the configuration.*
*Also, run the following command to to retrieve the access credentials for your cluster and configure kubectl:*
```
aws eks update-kubeconfig --name --region
```
*Run kubectl commands to manage your cluster and deploy Kubernetes configurations to it.*
------
### ๐น| แดแดสสแดาแดสแด แดสแดแดแด
*Navigate to the Terraform Cloud platform, choose your organization and create a new workspace.*

*Under ***Choose your workflow***, select the version control workflow option. After youโve selected your workflow, youโll be directed to a different page where you will need to connect a version control provider. You will want to connect with your GitHub account and select the repo that you created in the first step.*
*From there, you will create our new Workspace:*
*Then you will set variables for our access keys and region. To get started, click ***Configure Variables*** followed by* ***Add variable.***
*We will be inputting the below variables as ***Keys*** and then ***Value*** will be the password.*
* **IMPORTANT**: *Click ***Sensitive*** for your key variables, as this will ensure your private information is not displayed.*
โฅ **AWS_ACCESS_KEY_ID**
โฅ **AWS_SECRET_ACCESS_KEY**
โฅ **AWS_DEFAULT_REGION**
โฅ **CONFIRM_DESTROY**
------
### ๐บ| สแดษด ษดแดแดก แดแดสสแดาแดสแด แดสแดแดแด
แดสแดษด
*Letโs go things kicked off โ click* ***Start new run*** *under the Actions tab.*
*Once you start your run, the next step will be to ***Plan & Apply***. Your plan should finish pretty quickly and once itโs finished, youโll be prompted to click ***Confirm & Apply****.
*From here, click the Apply finished box, scroll to the bottom and youโll see the Outputs in TF Cloud:*
*Letโs pop to the ***AWS EC2*** console and confirm that you have correctly setup your cluster. As you can see from the image below, everything looks great!*
------
### ๐ป| แดแดสสแดาแดสแด แด
แดsแดสแดส
*Letโs destroy our infrastructure! Yay! Navigate back to the Terraform Cloud platform, and under settings click ***Destruction and Deletion***. Click Queue destroy plan and select ***Confirm & Apply***.*
------
## ***Youโve just deployed an EKS Cluster using Terraform Cloud CI/CD!***
------
## :biohazard: แดสแดแด
ษชแดs & แดแดสแด แดสแดแดแด สษชแดแด แดสษชs แดส าแดสสแดแดก
โธ [Harshhaa Dev Projects](https://github.com/Harshhaa-Dev-Projects.git) - Made with :yellow_heart: from [Harshhaa Vardhan Reddy](https://github.com/NotHarshhaa.git)