mirror of
https://github.com/optim-enterprises-bv/homelab.git
synced 2025-11-02 02:48:02 +00:00
feat(helm): Modifying chart template to allow a stand-alone auth deployment
This commit is contained in:
@@ -6,27 +6,13 @@ metadata:
|
||||
finalizers:
|
||||
- resources-finalizer.argocd.argoproj.io
|
||||
spec:
|
||||
project: applications
|
||||
project: app-of-apps
|
||||
source:
|
||||
path: helm/application
|
||||
path: apps/test
|
||||
repoURL: https://github.com/vehagn/homelab
|
||||
targetRevision: HEAD
|
||||
helm:
|
||||
values: |
|
||||
name: test
|
||||
namespace: test
|
||||
image:
|
||||
name: containous/whoami
|
||||
service:
|
||||
containerPort: 80
|
||||
auth:
|
||||
enabled: true
|
||||
host: auth-test
|
||||
whitelist:
|
||||
- veghag@gmail.com
|
||||
- wiredmatrices@gmail.com
|
||||
destination:
|
||||
namespace: test
|
||||
namespace: argocd
|
||||
name: in-cluster
|
||||
syncPolicy:
|
||||
automated:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: test2
|
||||
name: test-app1
|
||||
namespace: argocd
|
||||
finalizers:
|
||||
- resources-finalizer.argocd.argoproj.io
|
||||
@@ -13,7 +13,7 @@ spec:
|
||||
targetRevision: HEAD
|
||||
helm:
|
||||
values: |
|
||||
name: test2
|
||||
name: app1
|
||||
namespace: test
|
||||
image:
|
||||
name: containous/whoami
|
||||
33
apps/test/app2.yaml
Normal file
33
apps/test/app2.yaml
Normal file
@@ -0,0 +1,33 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: test-app2
|
||||
namespace: argocd
|
||||
finalizers:
|
||||
- resources-finalizer.argocd.argoproj.io
|
||||
spec:
|
||||
project: applications
|
||||
source:
|
||||
path: helm/application
|
||||
repoURL: https://github.com/vehagn/homelab
|
||||
targetRevision: HEAD
|
||||
helm:
|
||||
values: |
|
||||
name: app2
|
||||
namespace: test
|
||||
image:
|
||||
name: containous/whoami
|
||||
service:
|
||||
containerPort: 80
|
||||
auth:
|
||||
enabled: true
|
||||
create: false
|
||||
destination:
|
||||
namespace: test
|
||||
name: in-cluster
|
||||
syncPolicy:
|
||||
automated:
|
||||
selfHeal: true
|
||||
prune: true
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
32
apps/test/auth.yaml
Normal file
32
apps/test/auth.yaml
Normal file
@@ -0,0 +1,32 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: test-auth
|
||||
namespace: argocd
|
||||
finalizers:
|
||||
- resources-finalizer.argocd.argoproj.io
|
||||
spec:
|
||||
project: applications
|
||||
source:
|
||||
path: helm/application
|
||||
repoURL: https://github.com/vehagn/homelab
|
||||
targetRevision: HEAD
|
||||
helm:
|
||||
values: |
|
||||
name: test-auth
|
||||
namespace: test
|
||||
authOnly: true
|
||||
auth:
|
||||
host: auth-test
|
||||
whitelist:
|
||||
- veghag@gmail.com
|
||||
- wiredmatrices@gmail.com
|
||||
destination:
|
||||
namespace: test
|
||||
name: in-cluster
|
||||
syncPolicy:
|
||||
automated:
|
||||
selfHeal: true
|
||||
prune: true
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
7
apps/test/kustomization.yaml
Normal file
7
apps/test/kustomization.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- app1.yaml
|
||||
- app2.yaml
|
||||
- auth.yaml
|
||||
35
helm/application/templates/_helpers.tpl
Normal file
35
helm/application/templates/_helpers.tpl
Normal file
@@ -0,0 +1,35 @@
|
||||
{{/*
|
||||
Returns string "true" or empty which will be evaluated to boolean false
|
||||
*/}}
|
||||
{{- define "deployment.create" -}}
|
||||
{{- if not .Values.authOnly }}
|
||||
{{- true }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Returns string "true" or empty which will be evaluated to boolean false
|
||||
*/}}
|
||||
{{- define "service.create" -}}
|
||||
{{- if and .Values.service.create (include "deployment.create" .) }}
|
||||
{{- true }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Returns string "true" or empty which will be evaluated to boolean false
|
||||
*/}}
|
||||
{{- define "ingressRoute.create" -}}
|
||||
{{- if and .Values.ingressRoute.create (or .Values.authOnly (include "service.create" .)) }}
|
||||
{{- true }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Returns string "true" or empty which will be evaluated to boolean false
|
||||
*/}}
|
||||
{{- define "auth.create" -}}
|
||||
{{- if or .Values.authOnly (and .Values.auth.enabled .Values.auth.create (include "ingressRoute.create" .)) }}
|
||||
{{- true }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -1,3 +1,4 @@
|
||||
{{- if include "deployment.create" . }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -23,3 +24,4 @@ spec:
|
||||
protocol: TCP
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
@@ -1,3 +1,4 @@
|
||||
{{- if include "service.create" .}}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@@ -12,3 +13,4 @@ spec:
|
||||
protocol: TCP
|
||||
selector:
|
||||
app: {{ .Values.name }}
|
||||
{{- end }}
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- if .Values.ingressRoute.enabled }}
|
||||
{{- if include "ingressRoute.create" . }}
|
||||
apiVersion: traefik.containo.us/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
@@ -12,6 +12,7 @@ spec:
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
routes:
|
||||
{{- if include "service.create" . }}
|
||||
- match: Host(`{{ .Values.name }}.stonegarden.dev`)
|
||||
kind: Rule
|
||||
services:
|
||||
@@ -20,6 +21,9 @@ spec:
|
||||
{{- if .Values.auth.enabled }}
|
||||
middlewares:
|
||||
- name: traefik-forward-auth
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if include "auth.create" . }}
|
||||
- match: Host(`{{ .Values.auth.host }}.stonegarden.dev`)
|
||||
kind: Rule
|
||||
services:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- if and .Values.auth.create .Values.auth.enabled }}
|
||||
{{- if include "auth.create" . }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- if and .Values.auth.create .Values.auth.enabled }}
|
||||
{{- if include "auth.create" . }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- if and .Values.auth.create .Values.auth.enabled }}
|
||||
{{- if include "auth.create" . }}
|
||||
apiVersion: traefik.containo.us/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- if and .Values.auth.create .Values.auth.enabled }}
|
||||
{{- if include "auth.create" . }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
name: name
|
||||
namespace: namespace
|
||||
|
||||
# Skip deployment and only do auth
|
||||
authOnly: false
|
||||
|
||||
image:
|
||||
name: image
|
||||
tag: latest
|
||||
@@ -9,12 +12,13 @@ image:
|
||||
replicas: 1
|
||||
|
||||
service:
|
||||
create: true
|
||||
type: ClusterIP
|
||||
port: 80
|
||||
containerPort: 8080
|
||||
|
||||
ingressRoute:
|
||||
enabled: true
|
||||
create: true
|
||||
|
||||
resources: { }
|
||||
# limits:
|
||||
|
||||
@@ -3,7 +3,7 @@ kind: Kustomization
|
||||
namespace: kubernetes-dashboard
|
||||
|
||||
resources:
|
||||
- https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.1/aio/deploy/alternative.yaml
|
||||
- https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/alternative.yaml
|
||||
- traefik-forward-auth
|
||||
- ingress.yaml
|
||||
- serviceAccount.yaml
|
||||
|
||||
Reference in New Issue
Block a user