{"id":13906850,"url":"https://github.com/dockup/infrahub","last_synced_at":"2026-01-29T10:11:43.418Z","repository":{"id":102421269,"uuid":"233768111","full_name":"dockup/infrahub","owner":"dockup","description":"An example starter template that contains terraform scripts and kubernetes configuration files to deploy a simple web application to AWS EKS Cluster","archived":false,"fork":false,"pushed_at":"2020-02-06T06:11:06.000Z","size":23,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-07T23:49:11.411Z","etag":null,"topics":["aws","eks","kubernetes","template","terraform"],"latest_commit_sha":null,"homepage":null,"language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dockup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-01-14T06:01:30.000Z","updated_at":"2023-05-17T15:20:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"6e3f84a1-948a-4291-9ccd-e72b22b34006","html_url":"https://github.com/dockup/infrahub","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dockup%2Finfrahub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dockup%2Finfrahub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dockup%2Finfrahub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dockup%2Finfrahub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dockup","download_url":"https://codeload.github.com/dockup/infrahub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226353483,"owners_count":17611712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","eks","kubernetes","template","terraform"],"created_at":"2024-08-06T23:01:43.618Z","updated_at":"2026-01-29T10:11:43.375Z","avatar_url":"https://github.com/dockup.png","language":"HCL","funding_links":[],"categories":["HarmonyOS"],"sub_categories":["Windows Manager"],"readme":"# InfraHub\nTerraform scripts and Kubernetes scripts.\n\n#### Prerequisites:\n1. AWS cli\n2. Install [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)\n3. Install [helm](https://helm.sh/docs/intro/install/)\n4. Install [terraform cli](https://learn.hashicorp.com/terraform/getting-started/install.html)\n5. Install [aws-iam-authenticator](https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html)\n\n#### Input variables for terraform script:\nCopy `app.auto.tfvars.example` to `app.auto.tfvars` and edit it with the actual values for the following variables:\n\n`aws_region` : The AWS Region where you wish to have all the resources created, eg: \"us-west-2\"\n\n`project_name` : A project name that will be used on many AWS resources for easier naming conventions and better classification of resources in AWS Console.\n\n`cluster_admins_arns` : A list of AWS User ARNs who need admin access to the EKS cluster eg:\n```\n[\n  {\n    userarn = \"arn:aws:iam::1263631783679131273129:root\",\n    username = \"root\",\n    groups = [\"system:masters\"]\n  }\n]\n```\n`database_name` : Name of the RDS database which is used by the application\n\n`database_username` : RDS Postgres username\n\n`database_password` : RDS Postgres password\n\n`project_env` : Deployment environment used for tagging resources in AWS. eg: \"production\", \"staging\"\n\n`codebuild_github_repo` : The GitHub repo url for building images\n\n`github_personal_access_token` : The GitHub personal access token for CodeBuild to pull source code. This token needs the following scopes: `repo` and `admin:repo_hook`. More info [here](https://developer.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/)\n\n`dockerfile_path` : Path to Dockerfile relative to the root directory of source, eg: \"./\"\n\n`AWS_ACCESS_KEY_ID` : AWS ACCESS KEY ID of the user running terraform.\n\n`AWS_SECRET_ACCESS_KEY` : AWS SECRET ACCESS KEY of the user running terraform.\n\n#### Usage:\n\n```\n# For the first time\n$ terraform init\n\n# This credentials will be used by terraform while performing the commands below\n$ export AWS_ACCESS_KEY_ID=\"you key id\"\n$ export AWS_SECRET_ACCESS_KEY=\"you secret key\"\n```\n1. Planning the infra - This will list all the resources that will be created by Terraform\n```\n$ terraform plan -out plan.txt\n```\n\n2. Create or Apply changes to infra - This will actually create the resources in AWS\n```\n$ terraform apply \"plan.txt\"\n```\nMake note of the output. It will be containing Endpoints for RDS, Redis, ElasticSearch.\n\n3. Destroy infra - WARNING: This will destroy all the resources in AWS. Use this only when testing.\n```\n$ terraform destroy \"plan.txt\"\n```\n\n#### Verifying that Kubernetes is running\n1. Update the kubeconfig using `aws` cli.  \n```bash\n$ aws eks --region us-west-2 update-kubeconfig --name my-app-cluster\n```\n2. Verify ec2 nodes are registered under Kubernetes\n```bash\n$ kubectl get nodes -A\n```\nAs per the script, we should have 3 nodes\n\n#### Setup Traefik (Load Balancer for Kubernetes) and Metrics Server (used for Horizontal Pod Autoscaling)\nHelm is like Homebrew for Kubernetes\n\n1. Setup the helm `stable` repo\n```bash\n$ helm repo add stable https://kubernetes-charts.storage.googleapis.com/\n```\n2. Install [Traefik Helm Chart](https://hub.helm.sh/charts/stable/traefik)\n```bash\n$ helm install traefik stable/traefik --set rbac.enabled=true --namespace kube-system\n```\n3. Install [Metrics Server](https://hub.helm.sh/charts/stable/metrics-server)\n```bash\n$ helm install metrics-server stable/metrics-server --namespace kube-system\n```\n\n#### Deploying the App to Kubernetes\nKubernetes deployment configurations can be found inside `kubernetes` folder. Instructions given below will be referencing files from this folder.\n\n##### Deploying the app:\n1. Create a namespace in Kubernetes for the app:\n```bash\n# The namespace \"my-app\" is used in the Kubernetes scripts present in this repo.\n# If you prefer a different name, please change it accordingly in the scripts as well.\n$ kubectl create namespace my-app\n```\n2. Get Traefik external IP. The app once deployed, will be exposed through the External IP provided by the command below\n```bash\n$ kubectl get svc traefik -n kube-system\n```\nReplace `\u003ctraeifk-elb-endpoint-similar-to...\u003e` in `ingress.yaml` with External IP from above command's result.\n\n3. Manually update `app-secrets.yaml` with appropriate values for the Environment Variables. Make sure to add RDS, Redis and ElasticSearch hosts (You would have seen these after running terraform apply)\nNow, apply it to Kubernetes. \n```bash\n$ kubectl apply -f app-secrets.yaml\n```\n\n4. Head over to AWS CodeBuild Console, run a build - This builds the docker image and pushes it to ECR.\n\n5. Once the build is finished, head over to ECR Console and get the latest build image URL.\n\n6. Replace `\u003cimage-pull-url-from-ecr-here\u003e` in `deployment.yaml` with the image URL.\n\n7. Deploy:\n```bash\n$ kubectl apply -f deployment.yaml\n$ kubectl apply -f service.yaml\n$ kubectl apply -f ingress.yaml\n```\n8. Check logs and deployment status\n```bash\n# You should see a pod with name like: my-app-deployment-67fd46d678-rzdg2\n$ kubectl -n my-app get pod\n\n# Check logs\n$ kubectl -n my-app logs -f my-app-deployment-67fd46d678-rzdg2\n\n# Statuses\n$ kubectl -n my-app get deploy\n```\n9. Additionlly, you can also add Horizontal Pod Autoscaling based on CPU and Memory usages.\n```bash\n$ kubectl apply -f autoscale.yaml\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdockup%2Finfrahub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdockup%2Finfrahub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdockup%2Finfrahub/lists"}