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
6 changes: 5 additions & 1 deletion .circleci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ $ aws eks list-clusters --query "clusters"

- AWS_ACCESS_KEY_ID # AWS access key for the circleci user - this should be in AWS secret manager
- AWS_SECRET_ACCESS_KEY # AWS secret for the circleci user - this should be in AWS secret manager
- AWS_DEFAULT_REGION # Region of your cluster
- AWS_REGION # Region of your EKS cluster
- AWS_ECR_ACCOUNT_URL # {awsAccountNum}.dkr.ecr.{region}.amazonaws.com
- AWS_ECR_REPO_NAME # The ECR repository name to write images to
- PRODUCTION_EKS_CLUSTER_NAME # The name of the production EKS cluster to deploy into
- STAGING_EKS_CLUSTER_NAME # The name of the staging EKS cluster to deploy into
- AWS_CLUSTER_AUTH_ROLE_ARN_STAGING # The ARN of the role to assume that allows access to the EK cluster. Most likely ends with `kubernetes-admin-staging`
- AWS_CLUSTER_AUTH_ROLE_ARN_PRODUCTION # The ARN of the role to assume that allows access to the EKS cluster. Same as above but for production
- SLACK_WEBHOOK # Webhook for slack notifications. Must be specified, but doesn't need to be set to a real value
- CIRCLECI_API_KEY # Needed for the queueing orb. You can generate this in the project settings in CircleCI. It needs the `status` scope.


## Deployment Process
Expand Down
12 changes: 7 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ jobs:
- version-tag/get
- run: *install-binaries
- aws-cli/install
- aws-cli/setup
- aws-cli/setup:
aws-region: AWS_REGION
- aws-eks/update-kubeconfig-with-authenticator:
cluster-name: << parameters.cluster-name >>
cluster-authentication-role-arn: << parameters.cluster-authentication-role-arn >>
Expand All @@ -204,6 +205,7 @@ jobs:
- run:
name: Deploy
command: |
kubectl create namespace << parameters.namespace >> || echo "Namespace already exists"
cd kubernetes/overlays/<< parameters.config-environment >>
IMAGE=${AWS_ECR_ACCOUNT_URL}/<< parameters.repo >>
kustomize edit set image fake-image=${IMAGE}:${VERSION_TAG}
Expand Down Expand Up @@ -233,8 +235,8 @@ workflows:
cluster-name: "${STAGING_EKS_CLUSTER_NAME}"
config-environment: "staging"
cluster-authentication-role-arn: "${AWS_CLUSTER_AUTH_ROLE_ARN_STAGING}"
region: "${AWS_DEFAULT_REGION}"
namespace: "${CIRCLE_BRANCH}"
region: "${AWS_REGION}"
namespace: "${AWS_ECR_REPO_NAME}"
tag: "${VERSION_TAG}"
requires:
- build_and_push
Expand All @@ -255,8 +257,8 @@ workflows:
cluster-name: "${PRODUCTION_EKS_CLUSTER_NAME}"
config-environment: "production"
cluster-authentication-role-arn: "${AWS_CLUSTER_AUTH_ROLE_ARN_PRODUCTION}"
region: "${AWS_DEFAULT_REGION}"
namespace: "${CIRCLE_BRANCH}"
region: "${AWS_REGION}"
namespace: "${AWS_ECR_REPO_NAME}"
tag: "${VERSION_TAG}"
requires:
- queue/block_workflow
13 changes: 9 additions & 4 deletions kubernetes/base/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@ spec:
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 2
ports:
- containerPort: 80
name: http
envFrom:
- configMapRef:
name: <% .Name %>-config
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: SERVER_PORT
value: "80"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just curious why do we put backend on 80? would it make it more confusing what is being mapped to what? (eg hides the ingress mapping and stuff)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because it's serving HTTP traffic, and that is the default port. Since you don't need to deal with ports conflicting in Kubernetes this isn't a problem.
What do you mean about hiding the ingress mapping?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

as in boilerplate backend port: 80 may lead people to think the port in the deployment is the port for the end url (which in this case it is)
Kinda hides the fact that ingress will expose it at 80 regardless

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If someone fundamentally doesn't understand the difference between deployment, service, and ingress, we should try to solve that with documentation, not hoping that they get confused by all the different ports and look it up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also we are giving them a nice name to refer to, though I realize I put it in the wrong spot above. Will fix that.

- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: DATABASE_USERNAME
valueFrom:
secretKeyRef:
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/base/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ spec:
- name: http
protocol: TCP
port: 80
targetPort: 80
targetPort: http
selector:
app: <% .Name %>
4 changes: 1 addition & 3 deletions kubernetes/overlays/production/kustomization.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
- ../../base

patchesStrategicMerge:
- deployment.yml

resources:
- ../../base
- ingress.yaml
- pdb.yaml

Expand Down
2 changes: 1 addition & 1 deletion kubernetes/overlays/staging/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
resources:
requests:
memory: 128Mi
cpu: 0.5
cpu: 0.1
limits:
memory: 512Mi
cpu: 1.0
4 changes: 1 addition & 3 deletions kubernetes/overlays/staging/kustomization.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
- ../../base

patchesStrategicMerge:
- deployment.yml

resources:
- ../../base
- ingress.yml

configMapGenerator:
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/secrets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Application secrets are stored in the kubernetes secrets management system, wher

## Adding a new secret to staging / production kuberenetes
(Similar to the dev process)
1. Download the `secrets.env` and `settings.ini` for the correct environment from lastpass
1. Download the `secrets.env` for the correct environment from where it is stored
2. Make sure your `kubectl` context is set to the proper environment
3. Run `kubectl apply -k .` (Change the namespace if necessary using `-n <namespace>`)

Expand Down