-
Notifications
You must be signed in to change notification settings - Fork 0
feat: move app deployment to Helm chart #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
14581e3
69ab182
b9c9166
73fdf15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| apiVersion: v2 | ||
| name: platform-code-test-app | ||
| description: Platform code test application | ||
| type: application | ||
| version: 0.1.0 | ||
| appVersion: "1.0" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| {{- define "platform-code-test-app.name" -}} | ||
| {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
| {{- end }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: {{ include "platform-code-test-app.name" . }} | ||
| labels: | ||
| app: {{ include "platform-code-test-app.name" . }} | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| app: {{ include "platform-code-test-app.name" . }} | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: {{ include "platform-code-test-app.name" . }} | ||
| spec: | ||
| containers: | ||
| - name: app | ||
| image: {{ .Values.image.repository }} | ||
| resources: | ||
| limits: | ||
| cpu: {{ .Values.resources.limits.cpu | quote }} | ||
| memory: {{ .Values.resources.limits.memory }} | ||
| requests: | ||
| cpu: {{ .Values.resources.requests.cpu }} | ||
| memory: {{ .Values.resources.requests.memory }} | ||
| {{- if or .Values.db.host .Values.db.existingSecret }} | ||
| env: | ||
| {{- if .Values.db.host }} | ||
| - name: DB_HOST | ||
| value: {{ .Values.db.host | quote }} | ||
| {{- end }} | ||
| {{- if .Values.db.user }} | ||
| - name: DB_USER | ||
| value: {{ .Values.db.user | quote }} | ||
| {{- end }} | ||
| {{- if .Values.db.existingSecret }} | ||
| - name: DB_PASSWORD | ||
| valueFrom: | ||
| secretKeyRef: | ||
| name: {{ .Values.db.existingSecret }} | ||
| key: DB_PASSWORD | ||
| {{- end }} | ||
| {{- end }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| image: | ||
| repository: "" | ||
|
|
||
| nameOverride: "" | ||
|
|
||
| resources: | ||
| limits: | ||
| cpu: "0.5" | ||
| memory: 512Mi | ||
| requests: | ||
| cpu: 250m | ||
| memory: 512Mi | ||
|
|
||
| db: | ||
| host: "" | ||
| user: "" | ||
| # Name of a Kubernetes Secret containing a DB_PASSWORD key | ||
| existingSecret: "" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,18 @@ | ||
| resource "kubernetes_deployment" "app" { | ||
| resource "helm_release" "app" { | ||
| depends_on = [ | ||
| aws_eks_fargate_profile.apps_default, | ||
| ] | ||
|
|
||
| metadata { | ||
| name = var.app_name | ||
| } | ||
|
|
||
| spec { | ||
| selector { | ||
| match_labels = { | ||
| app = var.app_name | ||
| } | ||
| } | ||
| name = var.app_name | ||
| chart = "${path.module}/../charts/platform-code-test-app" | ||
|
|
||
| template { | ||
| metadata { | ||
| labels = { | ||
| app = var.app_name | ||
| } | ||
| } | ||
|
|
||
| spec { | ||
| container { | ||
| image = data.aws_ecr_image.app_image.image_uri | ||
| name = "app" | ||
| set { | ||
| name = "nameOverride" | ||
| value = var.app_name | ||
| } | ||
|
|
||
| resources { | ||
| limits = { | ||
| cpu = "0.5" | ||
| memory = "512Mi" | ||
| } | ||
| requests = { | ||
| cpu = "250m" | ||
| memory = "512Mi" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| set { | ||
| name = "image.repository" | ||
| value = data.aws_ecr_image.app_image.image_uri | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,3 @@ | ||||||||
| data "aws_iam_role" "kubernetes_cluster_admin" { | ||||||||
| name = "kubernetes-cluster-admin" | ||||||||
| } | ||||||||
|
||||||||
| data "aws_iam_role" "kubernetes_cluster_admin" { | |
| name = "kubernetes-cluster-admin" | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| output "db_host" { | ||
| value = aws_rds_cluster.test_app.endpoint | ||
| } | ||
|
|
||
| output "db_user" { | ||
| value = var.app_rds_master_username | ||
| } | ||
|
|
||
| output "db_password" { | ||
| value = random_id.test_app_rds_master_password.b64_url | ||
| sensitive = true | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,14 +10,11 @@ provider "aws" { | |
| } | ||
|
|
||
| # Kubernetes admin AWS provider, only use this for k8s provider. | ||
| # assume_role is omitted — interviewers always take the @deliveroo.co.uk | ||
| # bootstrap path. Candidates are given credentials with a direct EKS access entry. | ||
| provider "aws" { | ||
| region = var.region | ||
| alias = "kubernetes_admin" | ||
|
||
|
|
||
| assume_role { | ||
| role_arn = aws_eks_access_entry.cluster_admin.principal_arn | ||
| session_name = "Terraform" | ||
| } | ||
| } | ||
|
|
||
| data "aws_eks_cluster" "this" { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
env:block is only rendered whendb.hostordb.existingSecretis set, but not when onlydb.useris set. This makesdb.usera no-op unless another DB value is also provided. Consider gatingenv:on any ofdb.host,db.user, ordb.existingSecret(or always renderingenv:and conditionally including individual vars).