Skip to content

Commit

Permalink
Created helm charts and dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidOkulski committed Jan 13, 2025
1 parent 8c128c8 commit edab7e6
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## What changes did you make?

_Describe the changes you made in this pull request._

## Why did you make these changes?

_Explain why these changes are necessary and what problems they solve._

## What alternatives did you consider?

_Describe any alternative solutions you considered and why._

### Checklist

- [ ] **I have assigned at least one reviewer**
- [ ] **My code meets the style guide**
- [ ] **My code has adequate test coverage (if applicable)**
75 changes: 75 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Build and Deploy

on:
push:
branches:
- main
- dev
- test

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:

build_and_push:
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v4

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

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

outputs:
image_tag: ${{ steps.meta.outputs.tags }}

deploy:
needs: build_and_push
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Install oc CLI
uses: redhat-actions/oc-installer@v1

- name: Authenticate with OpenShift
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
namespace: ${{ github.ref == 'refs/heads/main' && secrets.OPENSHIFT_PROD_NAMESPACE || (github.ref == 'refs/heads/dev' && secrets.OPENSHIFT_DEV_NAMESPACE) || secrets.OPENSHIFT_TEST_NAMESPACE }}
openshift_token: ${{ github.ref == 'refs/heads/main' && secrets.OPENSHIFT_PROD_TOKEN || (github.ref == 'refs/heads/dev' && secrets.OPENSHIFT_DEV_TOKEN) || secrets.OPENSHIFT_TEST_TOKEN }}
insecure_skip_tls_verify: true

- name: Deploy with Helm
run: |
helm upgrade --install communication-layer ./helm --set image.tag=${{ needs.build_and_push.outputs.image_tag }}
- name: Trigger OpenShift Rollout
run: |
oc rollout restart deployment/communication-layer
13 changes: 13 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:20

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 3030

CMD ["npm", "run", "start"]
4 changes: 4 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: communication-layer
description: A Helm chart for deploying communication layer
version: 0.1.0
28 changes: 28 additions & 0 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: communication-layer
labels:
app.kubernetes.io/name: communication-layer
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: communication-layer
template:
metadata:
labels:
app.kubernetes.io/name: communication-layer
spec:
containers:
- name: communication-layer
image: "{{ .Values.image.tag }}"
envFrom:
- configMapRef:
name: {{ .Values.secretName }}
ports:
- containerPort: 3030
resources: {{- toYaml .Values.resources | nindent 12 }}
restartPolicy: Always
strategy:
type: Recreate
13 changes: 13 additions & 0 deletions helm/templates/network-policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-from-openshift-ingress
spec:
ingress:
- from:
- namespaceSelector:
matchLabels:
network.openshift.io/policy-group: ingress
podSelector: {}
policyTypes:
- Ingress
14 changes: 14 additions & 0 deletions helm/templates/route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: kiln
labels:
app.kubernetes.io/name: kiln
spec:
to:
kind: Service
name: communication-layer
port:
targetPort: 3030
tls:
termination: edge
13 changes: 13 additions & 0 deletions helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: kiln
labels:
app.kubernetes.io/name: communication-layer
spec:
selector:
app.kubernetes.io/name: communication-layer
ports:
- protocol: TCP
port: {{ .Values.service.port }}
targetPort: 3030
20 changes: 20 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
replicaCount: 1

image:
repository: ghcr.io/bcgov/communication-layer
tag: latest
pullPolicy: Always

service:
type: ClusterIP
port: 3030

configMapName: commlayer

resources: {}

nodeSelector: {}

tolerations: []

affinity: {}

0 comments on commit edab7e6

Please sign in to comment.