Skip to content
Merged
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
89 changes: 89 additions & 0 deletions kubernetes/operationcode_python_backend/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: back-end
spec:
replicas: 2
revisionHistoryLimit: 5
template:
spec:
containers:
- name: app
image: operationcode/back-end:latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you currently have a dockerhub repo setup for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://cloud.docker.com/repository/registry-1.docker.io/operationcode/back-end

You do now. Need to get credentials in circle ci to handle it.

imagePullPolicy: Always
ports:
- containerPort: 8000
env:
- name: DB_NAME
valueFrom:
secretKeyRef:
name: python-backend-secrets
key: postgres_name
- name: DB_USER
valueFrom:
secretKeyRef:
name: python-backend-secrets
key: postgres_user
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: python-backend-secrets
key: postgres_password
- name: DB_HOST
valueFrom:
secretKeyRef:
name: python-backend-secrets
key: postgres_host
- name: DB_PORT
valueFrom:
secretKeyRef:
name: python-backend-secrets
key: postgres_port
- name: SECRET_KEY
valueFrom:
secretKeyRef:
name: python-backend-secrets
key: secret_key_base
- name: PYBOT_AUTH_TOKEN
valueFrom:
secretKeyRef:
name: python-backend-secrets
key: pybot_auth_token
- name: PYBOT_URL
valueFrom:
secretKeyRef:
name: python-backend-secrets
key: pybot_url
- name: MAILCHIMP_API_KEY
valueFrom:
secretKeyRef:
name: python-backend-secrets
key: mailchimp_api_key
- name: MAILCHIMP_LIST_ID
valueFrom:
secretKeyRef:
name: python-backend-secrets
key: mailchimp_list_id
- name: SENTRY_DSN
valueFrom:
secretKeyRef:
name: python-backend-secrets
key: sentry_dsn

- name: GOOGLE_OAUTH_CLIENT_ID
valueFrom:
secretKeyRef:
name: python-backend-secrets
key: google_oauth_client_id

- name: GOOGLE_OAUTH_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: python-backend-secrets
key: google_oauth_client_secret


volumes:
- name: python-backend-secrets
secret:
secretName: python-backend-secrets
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

commonLabels:
app: back-end

resources:
- deployment.yaml
- service.yaml
13 changes: 13 additions & 0 deletions kubernetes/operationcode_python_backend/base/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: back-end-service
spec:
selector:
app: back-end
ports:
- protocol: TCP
name: http
port: 80
targetPort: 8000
type: ClusterIP
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: back-end
spec:
template:
spec:
containers:
- name: app
env:
- name: DB_HOST
value: # TODO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to use terraform for provisioning this or do you need help setting it up?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's TODO because we need to wait until the last minute to snapshot the current prod before going live

- name: ENVIRONMENT
value: aws_prod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the significance of this aws_prod vs prod?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a hacky way to tell django to use the aws_s3 bucket to serve static assets, while still allowing me to run the production config locally sans remote static files

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this aws_prod and not just production?

Copy link
Member Author

@AllenAnthes AllenAnthes May 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied from above

It's a hacky way to tell django to use the aws_s3 bucket to serve static assets, while still allowing me to run the production config locally sans remote static files

20 changes: 20 additions & 0 deletions kubernetes/operationcode_python_backend/overlays/prod/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: "true"
name: back-end
spec:
rules:
- host: api.operationcode.org
http:
paths:
- backend:
serviceName: operationcode-backend-service
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be back-end-service if you want to receive traffic. However, we'll likely want to hold off on that or put this up on an alternate URL for testing until it works

servicePort: 80
path: /
tls:
- hosts:
- api.operationcode.org
secretName: operationcode-backend-tls
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: operationcode

bases:
- ../../base

resources:
- ingress.yaml

patchesStrategicMerge:
- deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: back-end
spec:
template:
spec:
containers:
- name: app
env:
- name: DB_HOST
value: django-staging.czwauqf3tjaz.us-east-2.rds.amazonaws.com
- name: ENVIRONMENT
value: aws_staging
- name: RELEASE
value: 0.1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: "true"
name: back-end
spec:
rules:
- host: api.staging.operationcode.org
http:
paths:
- backend:
serviceName: operationcode-backend-service
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this need to match the new service name?

servicePort: 80
path: /
tls:
- hosts:
- api.staging.operationcode.org
secretName: operationcode-backend-tls
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: operationcode-staging

bases:
- ../../base

resources:
- ingress.yaml

patchesStrategicMerge:
- deployment.yaml