{"id":28937535,"url":"https://github.com/heschmat/aws-docker-kubernetes-demo","last_synced_at":"2026-05-03T23:32:17.817Z","repository":{"id":284836218,"uuid":"953337105","full_name":"heschmat/aws-docker-kubernetes-demo","owner":"heschmat","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-04T20:25:11.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-22T21:36:18.871Z","etag":null,"topics":["aws-ecr","aws-eks","docker","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heschmat.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-23T05:42:14.000Z","updated_at":"2025-06-04T20:25:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"f9f9e470-a198-4b96-b404-69c405818823","html_url":"https://github.com/heschmat/aws-docker-kubernetes-demo","commit_stats":null,"previous_names":["heschmat/aws-docker-kubernetes-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/heschmat/aws-docker-kubernetes-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heschmat%2Faws-docker-kubernetes-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heschmat%2Faws-docker-kubernetes-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heschmat%2Faws-docker-kubernetes-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heschmat%2Faws-docker-kubernetes-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heschmat","download_url":"https://codeload.github.com/heschmat/aws-docker-kubernetes-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heschmat%2Faws-docker-kubernetes-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272839630,"owners_count":25001860,"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","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-ecr","aws-eks","docker","kubernetes"],"created_at":"2025-06-22T21:30:32.294Z","updated_at":"2026-05-03T23:32:12.762Z","avatar_url":"https://github.com/heschmat.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EKS Cluster Setup with PostgreSQL Deployment\n\nThis guide walks you through the process of creating an Amazon EKS cluster and deploying a PostgreSQL database using Helm. The instructions aim to be clear and descriptive, providing not only commands but also context, caveats, and example outputs for better understanding.\n\n---\n\n## 1. Create the EKS Cluster\n\nWe use `eksctl` to create our EKS cluster using a predefined configuration file.\n\n```bash\neksctl create cluster -f ./eks/cluster-config.yaml\n```\n\n\u003e 💡 **Tip:** To optimize for cost, we use spot instances.\n\n### Troubleshooting:\n\nIf you encounter errors, navigate to the AWS CloudFormation console to investigate. For example, setting the EBS volume size to 8Gi will fail (the minimum must be 20Gi by default).\n\n📸 *\\[Insert screenshots here]*\n\n```bash\nkubectl config current-context\n```\n\n✅ **Sample Output:**\n\n```\ndevops-master@coworking.us-east-1.eksctl.io\n```\n\n---\n\n## 2. Install Helm\n\nInstall Helm v3 using the official installation script:\n\n```bash\ncurl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash\n```\n\nAdd the Bitnami chart repository:\n\n```bash\nhelm repo add bitnami https://charts.bitnami.com/bitnami\nhelm repo update\n```\n\n---\n\n## 3. Create Namespace for PostgreSQL\n\n```bash\nkubectl create namespace postgres\n```\n\n---\n\n## 4. Configure StorageClass\n\nBy default, the EBS-backed `gp2` storage class has a `Delete` reclaim policy, which deletes volumes even on instance restart. We'll create a new StorageClass with a `Retain` policy.\n\n```bash\nkubectl get storageclass\n```\n\n✅ **Sample Output:**\n\n```\nNAME   PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE\ngp2    kubernetes.io/aws-ebs   Delete          WaitForFirstConsumer   false                  14m\n```\n\n```bash\nkubectl apply -f ./db/gp2-retain.yaml\n```\n\n```bash\nkubectl get storageclass\n```\n\n✅ **Sample Output:**\n\n```\nNAME         PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE\ngp2          kubernetes.io/aws-ebs   Delete          WaitForFirstConsumer   false                  16m\ngp2-retain   kubernetes.io/aws-ebs   Retain          WaitForFirstConsumer   false                  17s\n```\n\n---\n\n## 5. Enable EBS CSI Driver\n\n```bash\nkubectl get csidrivers\n```\n\n✅ **Sample Output (initial):**\n\n```\nNAME              ATTACHREQUIRED   PODINFOONMOUNT   STORAGECAPACITY   TOKENREQUESTS   REQUIRESREPUBLISH   MODES        AGE\nefs.csi.aws.com   false            false            false             \u003cunset\u003e         false               Persistent   14m\n```\n\nIf `ebs.csi.aws.com` is missing, follow these steps:\n\n### Associate IAM OIDC Provider:\n\n```bash\neksctl utils associate-iam-oidc-provider \\\n  --region=us-east-1 \\\n  --cluster=coworking \\\n  --approve\n```\n\n### Create IAM Service Account:\n\n```bash\neksctl create iamserviceaccount \\\n  --name ebs-csi-controller-sa \\\n  --namespace kube-system \\\n  --cluster coworking \\\n  --region us-east-1 \\\n  --attach-policy-arn arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy \\\n  --approve \\\n  --role-only\n```\n\n### Retrieve IAM Role ARN:\n\n```bash\naws cloudformation describe-stacks \\\n  --stack-name eksctl-coworking-addon-iamserviceaccount-kube-system-ebs-csi-controller-sa \\\n  --query \"Stacks[0].Outputs[?OutputKey=='Role1'].OutputValue\" \\\n  --output text\n```\n\n### Create the Addon:\n\n```bash\neksctl create addon \\\n  --name aws-ebs-csi-driver \\\n  --cluster coworking \\\n  --region us-east-1 \\\n  --service-account-role-arn \u003crole-arn-from-above\u003e \\\n  --force\n```\n\n```bash\nkubectl get csidrivers\n```\n\n✅ **Sample Output (after install):**\n\n```\nNAME              ATTACHREQUIRED   PODINFOONMOUNT   STORAGECAPACITY   TOKENREQUESTS   REQUIRESREPUBLISH   MODES        AGE\nebs.csi.aws.com   true             false            false             \u003cunset\u003e         false               Persistent   33s\nefs.csi.aws.com   false            false            false             \u003cunset\u003e         false               Persistent   23m\n```\n\n---\n\n## 6. Deploy PostgreSQL\n\n### Create Secret:\n\n```bash\nkubectl create secret generic postgres-secret \\\n  --from-literal=postgres-password='changeme' \\\n  --from-literal=postgres-user='cw-user' \\\n  --from-literal=postgres-db='coworking-db' \\\n  -n postgres\n```\n\n### Configure Helm Values (`postgres-values.yaml`):\n\n```yaml\nauth:\n  existingSecret: postgres-secret\n  username: cw-user\n  database: coworking-db\n\nprimary:\n  persistence:\n    enabled: true\n    storageClass: gp2-retain\n    size: 8Gi\n```\n\n\u003e 📝 We're using the `gp2-retain` storage class created earlier.\n\n### Install PostgreSQL using Helm:\n\n```bash\nhelm install my-postgres bitnami/postgresql -n postgres -f ./db/postgres-values.yaml\n```\n\n---\n\n## 7. Verify the Deployment\n\n```bash\nkubectl get pods -n postgres -w\n```\n\n✅ **Sample Output:**\n\n```\nNAME                       READY   STATUS              RESTARTS   AGE\nmy-postgres-postgresql-0   0/1     ContainerCreating   0          4s\nmy-postgres-postgresql-0   0/1     Running             0          5s\nmy-postgres-postgresql-0   1/1     Running             0          17s\n```\n\n```bash\nkubectl get pvc -n postgres\n```\n\n```bash\nkubectl get pv\n```\n\nPVC status should be `Bound`.\n\n---\n\n## 8. Connect to PostgreSQL\n\n### Option 1: Local Port Forwarding\n\n```bash\nkubectl port-forward svc/my-postgres-postgresql 5432:5432 -n postgres\n```\n\nIn another terminal (from EC2 instance or your machine):\n\n```bash\nPGPASSWORD=changeme psql -h 127.0.0.1 -U cw-user -d coworking-db\n```\n\n### Option 2: Temporary Pod\n\n```bash\nkubectl run psql-client --rm -it --restart=Never --image=bitnami/postgresql \\\n  --env=\"PGPASSWORD=changeme\" \\\n  --command -- psql -h my-postgres-postgresql.postgres.svc.cluster.local -U cw-user -d coworking-db\n```\n\nOnce inside:\n\n```bash\npsql -h my-postgres-postgresql -U cw-user -d coworking-db\n```\n\n✅ **Prompt:**\n\n```\ncoworking-db=\u003e\n```\n\nYou can run commands like `\\l` to list databases.\n\n---\n\n## ✅ You're all set!\n\nYou now have a fully operational EKS cluster with a PostgreSQL instance running inside it, leveraging spot instances, persistent storage, and Helm deployment best practices.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheschmat%2Faws-docker-kubernetes-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheschmat%2Faws-docker-kubernetes-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheschmat%2Faws-docker-kubernetes-demo/lists"}