Skip to content

Testing Atlantis v2 #2

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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions app/config.py

This file was deleted.

5 changes: 0 additions & 5 deletions app/database.ini

This file was deleted.

5 changes: 5 additions & 0 deletions app/deployment/dev.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
env = "dev"
k8s_secret_name = "gcr-json-key"
k8s_secret_password = "key.json"
k8s_secret_server = "gcr.io"
k8s_secret_username = "_json_key"
5 changes: 5 additions & 0 deletions app/deployment/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: flask-api-chart
description: A Helm chart for deploying Flash application to GKE
version: 1.0.0
appVersion: 0.0.1
38 changes: 38 additions & 0 deletions app/deployment/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.app.name }}
namespace: {{ .Values.app.namespace }}
labels:
app: {{ .Values.app.name }}
spec:
replicas: {{ .Values.app.replicas }}
selector:
matchLabels:
app: {{ .Values.app.name }}
template:
metadata:
labels:
app: {{ .Values.app.name }}
spec:
imagePullSecrets:
- name: {{ .Values.imagePullSecrets.name }}
containers:
- name: {{ .Values.app.name }}
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: POSTGRES_USER
value: "{{ .Values.database.user }}"
- name: POSTGRES_PASSWORD
value: "{{ .Values.database.password }}"
- name: POSTGRES_HOST
value: "{{ .Values.database.host }}"
- name: POSTGRES_DB
value: "{{ .Values.database.dbname }}"
- name: POSTGRES_PORT
value: "{{ .Values.database.port }}"
resources:
limits:
cpu: "{{ .Values.app.resources.cpu }}"
memory: "{{ .Values.app.resources.memory }}"
21 changes: 21 additions & 0 deletions app/deployment/helm/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ .Values.hpa.name }}
namespace: {{ .Values.hpa.namespace }}
labels:
app: {{ .Values.app.name }}
spec:
scaleTargetRef:
kind: {{ .Values.hpa.targetKind }}
name: {{ .Values.hpa.targetName }}
apiVersion: {{ .Values.hpa.targetAPIVersion }}
minReplicas: {{ .Values.hpa.minReplicas }}
maxReplicas: {{ .Values.hpa.maxReplicas }}
metrics:
- type: Resource
resource:
name: {{ .Values.hpa.metricName }}
target:
type: {{ .Values.hpa.metricType }}
averageValue: {{ .Values.hpa.metricAverageValue }}
19 changes: 19 additions & 0 deletions app/deployment/helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.service.name }}
namespace: {{ .Values.service.namespace }}
labels:
app: {{ .Values.app.name }}
spec:
selector:
app: {{ .Values.app.name }}
type: {{ .Values.service.type }}
ports:
- name: tcp
protocol: TCP
port: {{ .Values.service.tcpPort }}
targetPort: {{ .Values.service.targetPort }}
- name: http
port: {{ .Values.service.httpPort }}
targetPort: {{ .Values.service.targetPort }}
42 changes: 42 additions & 0 deletions app/deployment/helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
app:
name: flask-api
namespace: default
replicas: 3
resources:
cpu: "0.1"
memory: "64Mi"

image:
repository: gcr.io/developing-stuff/flask-api
tag: v0.0.2
pullPolicy: Always

database:
user: admin
password: admin
host: 10.30.244.110
port: "5432"
dbname: databesos

imagePullSecrets:
name: gcr-json-key

service:
name: flask-api-service
namespace: default
type: LoadBalancer
tcpPort: 25443
httpPort: 80
targetPort: 5000

hpa:
name: flask-api-hpa
namespace: default
targetKind: Deployment
targetName: flask-api
targetAPIVersion: apps/v1
minReplicas: 1
maxReplicas: 5
metricName: cpu
metricType: AverageValue
metricAverageValue: 40m
42 changes: 42 additions & 0 deletions app/deployment/helm/values/dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
app:
name: flask-api
namespace: default
replicas: 3
resources:
cpu: "0.1"
memory: "64Mi"

image:
repository: gcr.io/developing-stuff/flask-api
tag: v0.0.2
pullPolicy: Always

database:
user: admin
password: admin
host: bitnami-postgresql.default.svc.cluster.local
port: "5432"
dbname: databesos

imagePullSecrets:
name: gcr-json-key

service:
name: flask-api-service
namespace: default
type: LoadBalancer
tcpPort: 25443
httpPort: 80
targetPort: 5000

hpa:
name: flask-api-hpa
namespace: default
targetKind: Deployment
targetName: flask-api
targetAPIVersion: apps/v1
minReplicas: 1
maxReplicas: 5
metricName: cpu
metricType: AverageValue
metricAverageValue: 40m
42 changes: 42 additions & 0 deletions app/deployment/helm/values/prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
app:
name: flask-api
namespace: default
replicas: 3
resources:
cpu: "0.1"
memory: "64Mi"

image:
repository: gcr.io/developing-stuff/flask-api
tag: v0.0.2
pullPolicy: Always

database:
user: admin
password: admin
host: bitnami-postgresql.default.svc.cluster.local
port: "5432"
dbname: databesos

imagePullSecrets:
name: gcr-json-key

service:
name: flask-api-service
namespace: default
type: LoadBalancer
tcpPort: 25443
httpPort: 80
targetPort: 5000

hpa:
name: flask-api-hpa
namespace: default
targetKind: Deployment
targetName: flask-api
targetAPIVersion: apps/v1
minReplicas: 1
maxReplicas: 5
metricName: cpu
metricType: AverageValue
metricAverageValue: 40m
12 changes: 12 additions & 0 deletions app/deployment/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module "flask-app" {
source = "../modules/flask-app"
env = var.env
}

module "gke_secret" {
source = "../modules/gke-secret"
k8s_secret_name = var.k8s_secret_name
k8s_secret_password = var.k8s_secret_password
k8s_secret_server = var.k8s_secret_server
k8s_secret_username = var.k8s_secret_username
}
5 changes: 5 additions & 0 deletions app/deployment/prod.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
env = "prod"
k8s_secret_name = "gcr-json-key"
k8s_secret_password = "key.json"
k8s_secret_server = "gcr.io"
k8s_secret_username = "_json_key"
7 changes: 7 additions & 0 deletions app/deployment/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://registry.terraform.io/providers/hashicorp/helm/latest/docs
provider "helm" {
kubernetes {
config_path = var.kubeconfig_path
}
alias = "gke"
}
29 changes: 29 additions & 0 deletions app/deployment/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
variable "env" {
description = "Environment variable"
type = string

validation {
condition = contains(["prod", "dev"], var.env)
error_message = "Error! \"${var.env}\" not in acceptable values: \"prod\", \"env\""
}
}

variable "k8s_secret_name" {
type = string
description = "Kubernetes secret name"
}

variable "k8s_secret_server" {
type = string
description = "Kubernetes server name"
}

variable "k8s_secret_username" {
type = string
description = "Kubernetes username"
}

variable "k8s_secret_password" {
type = string
description = "Kubernetes password"
}
14 changes: 14 additions & 0 deletions app/deployment/version.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# https://www.terraform.io/docs/language/settings/index.html
terraform {
required_version = ">= 1.0.0"
required_providers {
helm = {
source = "hashicorp/helm"
version = "~> 2.3.0"
}
}
backend "gcs" {
bucket = "tf-flask-app-v1"
prefix = "app_state"
}
}
12 changes: 0 additions & 12 deletions app/functions.py

This file was deleted.

Loading