Skip to content
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
46 changes: 46 additions & 0 deletions .github/workflows/portal-dev-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Deploy to Production

on:
workflow_dispatch:
inputs:
tag:
type: string
description: The tag to deploy
required: true

env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
DOCKER_REGISTRY: your-registry
DOCKER_IMAGE: your-app

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up kubectl
uses: azure/k8s-set-context@v1
with:
kubeconfig: ${{ secrets.DEV_KUBE_CONFIG }}

- name: Install Helm
uses: azure/setup-helm@v3
with:
version: 'v3.12.0'

- name: Update image tag in values file
run: |
sed -i "s/tag: .*/tag: ${{ github.event.inputs.tag }}/" charts/portal/environments/dev.yaml

- name: Commit changes
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
git add charts/portal/environments/dev.yaml
git commit -m "Update image tag to ${{ github.event.inputs.tag }}"
git push

- name: Deploy to dev
run: |
helm upgrade portal portal -n portal -f portal/values.yaml -f portal/environments/dev.yaml
46 changes: 46 additions & 0 deletions .github/workflows/portal-production-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Deploy to Production

on:
workflow_dispatch:
inputs:
tag:
type: string
description: The tag to deploy
required: true

env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
DOCKER_REGISTRY: your-registry
DOCKER_IMAGE: your-app

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up kubectl
uses: azure/k8s-set-context@v1
with:
kubeconfig: ${{ secrets.PRODUCTION_KUBE_CONFIG }}

- name: Install Helm
uses: azure/setup-helm@v3
with:
version: 'v3.12.0'

- name: Update image tag in values file
run: |
sed -i "s/tag: .*/tag: ${{ github.event.inputs.tag }}/" charts/portal/environments/production.yaml

- name: Commit changes
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
git add charts/portal/environments/production.yaml
git commit -m "Update image tag to ${{ github.event.inputs.tag }}"
git push

- name: Deploy to production
run: |
helm upgrade portal portal -n portal -f portal/values.yaml -f portal/environments/production.yaml
4 changes: 4 additions & 0 deletions charts/portal/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: portal
description: A Helm chart for deploying the portal
version: 0.1.0
20 changes: 20 additions & 0 deletions charts/portal/environments/dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
image:
tag: c819a2996f8d96cfcadc73cba625d01d70f8df2b

environment: dev
replicaCount: 1

ingress:
hosts:
- host: portal.dev.codetogether.com
paths:
- path: /
pathType: Prefix

resources:
limits:
cpu: 300m
memory: 384Mi
requests:
cpu: 100m
memory: 128Mi
20 changes: 20 additions & 0 deletions charts/portal/environments/production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
environment: production
replicaCount: 2
image:
tag: prod-1c73b5aa304002a7412eadd86f063350ec78db8d

ingress:
enabled: false
hosts:
- host: app.codetogether.com
paths:
- path: /
pathType: Prefix

resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 200m
memory: 256Mi
65 changes: 65 additions & 0 deletions charts/portal/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}
labels:
app: {{ .Release.Name }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ .Release.Name }}
spec:
imagePullSecrets:
{{- toYaml .Values.imagePullSecrets | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: [ "yarn", "run", "start:backend" ]
args: [ "--hostname=0.0.0.0", "--port=3000" ]
ports:
- containerPort: 3000
resources:
{{- toYaml .Values.resources | nindent 12 }}
envFrom:
- secretRef:
name: portal-secrets
readinessProbe:
httpGet:
path: /saas-admin
port: 3000
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 5
successThreshold: 1
livenessProbe:
httpGet:
path: /saas-admin
port: 3000
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 5
successThreshold: 1
startupProbe:
httpGet:
path: /saas-admin
port: 3000
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 20
successThreshold: 1
volumeMounts:
- name: kubeconfig
mountPath: /root/.kube/config
subPath: kube-config
volumes:
- name: kubeconfig
configMap:
name: portal-kubeconfig
defaultMode: 0600

23 changes: 23 additions & 0 deletions charts/portal/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Release.Name }}
spec:
ingressClassName: {{ .Values.ingress.className }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ $.Release.Name }}
port:
number: {{ $.Values.service.port }}
{{- end }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/portal/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}
labels:
app: {{ .Release.Name }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: 3000
protocol: TCP
selector:
app: {{ .Release.Name }}
24 changes: 24 additions & 0 deletions charts/portal/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Default values for the application
replicaCount: 2

image:
repository: registry.digitalocean.com/codetogether-registry/portal
tag: latest
pullPolicy: Always

imagePullSecrets:
- name: digitalocean-registry

service:
type: ClusterIP
port: 3000

resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 200m
memory: 256Mi