Skip to content

Commit

Permalink
Add Chart to deploy guard
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 committed Apr 9, 2024
1 parent cca1d42 commit da2e411
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 50 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ jobs:
run: go mod download
- name: Run Tests
run: go test -cover `go list ./... | grep -v 'pkg/client'`

lint-helm:
name: Lint Helm
runs-on: ubuntu-latest
steps:
- uses: azure/[email protected]
- run: helm lint charts/radix-oauth-guard
22 changes: 22 additions & 0 deletions charts/radix-oauth-guard/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions charts/radix-oauth-guard/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
appVersion: 0.2.3
version: 0.2.3
description: Forward Auth to validate, authenticate and authorize JWT tokens
name: radix-oauth-guard
icon: https://radix.equinor.com/images/logos/logo.svg
58 changes: 58 additions & 0 deletions charts/radix-oauth-guard/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "oauth-guard.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "oauth-guard.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "oauth-guard.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "oauth-guard.labels" -}}
helm.sh/chart: {{ include "oauth-guard.chart" . }}
{{ include "oauth-guard.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "oauth-guard.selectorLabels" -}}
app.kubernetes.io/name: {{ include "oauth-guard.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "oauth-guard.serviceAccountName" -}}
{{- default (include "oauth-guard.fullname" .) .Values.serviceAccount.name }}
{{- end }}
58 changes: 58 additions & 0 deletions charts/radix-oauth-guard/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "oauth-guard.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
labels:
{{- include "oauth-guard.labels" . | nindent 4 }}
{{- with .Values.deploymentAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "oauth-guard.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "oauth-guard.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
supplementalGroups:
- 1000
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 8000
name: http
env:
- name: LOG_PRETTY
value: {{ .Values.logPretty | quote }}
- name: LOG_LEVEL
value: {{ .Values.logLevel | quote }}
- name: ISSUER
value: {{ .Values.issuer | quote }}
- name: AUDIENCE
value: {{ .Values.audience | quote }}
- name: SUBJECTS
value: {{ (join "," .Values.subjects) | quote }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
securityContext:
privileged: false
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
11 changes: 11 additions & 0 deletions charts/radix-oauth-guard/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "oauth-guard.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
spec:
selector:
{{- include "oauth-guard.selectorLabels" . | nindent 6 }}
ports:
- name: http
port: 8000
31 changes: 31 additions & 0 deletions charts/radix-oauth-guard/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Default values for charts.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
nameOverride: ""
fullnameOverride: ""

image:
repository: ghcr.io/equinor/radix-oauth-guard
tag: latest
pullPolicy: Always

# Annotations to add to the Deployment
deploymentAnnotations: {}
# Extra pod labels
podLabels: {}

# Logging
logLevel: info
logPretty: "False"
issuer: ""
audience: ""
subjects: []
# - "system:serviceaccount:monitor:prometheus-operator-prometheus"

resources:
limits:
cpu: 50m
memory: 100Mi
requests:
cpu: 50m
memory: 100Mi
50 changes: 0 additions & 50 deletions deploymet.yaml

This file was deleted.

0 comments on commit da2e411

Please sign in to comment.