Skip to content

Commit

Permalink
Merge branch 'master' into rails-5---fix-comments-controller-specs
Browse files Browse the repository at this point in the history
  • Loading branch information
yuenmichelle1 authored Jul 1, 2024
2 parents 61e6707 + 2a7b7af commit 484b0cf
Show file tree
Hide file tree
Showing 2 changed files with 202 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/deploy_staging_canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

name: Deploy Staging Canary

on:
push:
branches:
- master
workflow_dispatch:

jobs:
deploy_staging_canary:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: azure/login@v2
with:
creds: '${{ secrets.AZURE_AKS }}'

- uses: azure/aks-set-context@v4
with:
resource-group: kubernetes
cluster-name: microservices

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Create commit_id.txt
run: echo '${{ github.sha }}-next' > commit_id.txt

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.rails-next
push: true
tags: ghcr.io/zooniverse/talk-api:${{ github.sha }}-next
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Modify & apply template
run: |
sed "s/__IMAGE_TAG__/${{ github.sha }}/g" ./kubernetes/deployment-staging-canary.tmpl \
| kubectl apply -f -
150 changes: 150 additions & 0 deletions kubernetes/deployment-staging-canary.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: talk-staging-canary-app
labels:
app: talk-staging-canary-app
spec:
replicas: 1
selector:
matchLabels:
app: talk-staging-canary-app
template:
metadata:
labels:
app: talk-staging-canary-app
spec:
containers:
- name: talk-staging-canary-app
image: ghcr.io/zooniverse/talk-api:__IMAGE_TAG__-next
resources:
requests:
memory: "150Mi"
cpu: "100m"
limits:
memory: "250Mi"
cpu: "500m"
livenessProbe:
httpGet:
path: /
port: 81
httpHeaders:
- name: X-Forwarded-Proto
value: https
readinessProbe:
httpGet:
path: /
port: 81
httpHeaders:
- name: X-Forwarded-Proto
value: https
initialDelaySeconds: 20
envFrom:
- secretRef:
name: talk-common-env-vars
- secretRef:
name: talk-staging-env-vars
- configMapRef:
name: talk-staging-shared
volumeMounts:
- name: static-assets
mountPath: "/static-assets"
lifecycle:
postStart:
exec:
command: ["/bin/bash", "-c", "cp -R /rails_app/public/* /static-assets"]
- name: talk-staging-nginx
image: zooniverse/nginx
resources:
requests:
memory: "30Mi"
cpu: "10m"
limits:
memory: "100Mi"
cpu: "500m"
livenessProbe:
httpGet:
path: /
port: 80
httpHeaders:
- name: X-Forwarded-Proto
value: https
initialDelaySeconds: 10
readinessProbe:
httpGet:
path: /
port: 80
httpHeaders:
- name: X-Forwarded-Proto
value: https
initialDelaySeconds: 20
lifecycle:
preStop:
exec:
# SIGTERM triggers a quick exit; gracefully terminate instead
command: ["/usr/sbin/nginx","-s","quit"]
ports:
- containerPort: 80
volumeMounts:
- name: static-assets
mountPath: "/static-assets"
- name: talk-nginx-config
mountPath: "/etc/nginx-sites"
volumes:
- name: static-assets
hostPath:
# directory location on host node temp disk
path: /mnt/talk-staging-app-static-assets
type: DirectoryOrCreate
- name: talk-nginx-config
configMap:
name: talk-nginx-conf-staging
---
apiVersion: v1
kind: Service
metadata:
name: talk-staging-canary
spec:
selector:
app: talk-staging-canary-app
ports:
- protocol: TCP
port: 80
targetPort: 80
type: NodePort
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: talk-staging-canary-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/canary: "true"
nginx.ingress.kubernetes.io/canary-by-header: "Canary-Testing-Opt-In"
spec:
tls:
- hosts:
- talk-staging.zooniverse.org
- talk-staging.azure.zooniverse.org
secretName: talk-staging-tls
rules:
- host: talk-staging.zooniverse.org
http:
paths:
- pathType: Prefix
path: /
backend:
service:
name: talk-staging-canary
port:
number: 80
- host: talk-staging.azure.zooniverse.org
http:
paths:
- pathType: Prefix
path: /
backend:
service:
name: talk-staging-canary
port:
number: 80

0 comments on commit 484b0cf

Please sign in to comment.