diff --git a/k8s/argo-apps/vaultwarden.yaml b/k8s/argo-apps/vaultwarden.yaml new file mode 100644 index 0000000..93f12e0 --- /dev/null +++ b/k8s/argo-apps/vaultwarden.yaml @@ -0,0 +1,64 @@ +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: vaultwarden + namespace: argocd +spec: + destination: + name: '' + namespace: apps-roboces + server: https://kubernetes.default.svc + sources: + - path: k8s/charts/vaultwarden + repoURL: https://git.roboces.dev/catalin/fukuops.git + targetRevision: main + helm: + valuesObject: + conf: + db: + enable_db_wal: true + connection_retries: 15 + timeout: 30 + web_vault: + enabled: true + folder: "web-vault/" + + replicaCount: 1 + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: false + runAsUser: 10000 + runAsGroup: 10000 + capabilities: + drop: + - all + service: + type: LoadBalancer + ingress: + enabled: true + className: "traefik" + hosts: + - host: vault.roboces.dev + paths: + - path: / + pathType: Prefix + resources: + requests: + cpu: 250m + memory: 256Mi + limits: + cpu: 500m + memory: 512Mi + persistence: + enabled: true + storageClass: "truenas-nfs-csi" + accessMode: ReadWriteMany + size: 5Gi + secret: + existingSecretName: vaultwarden-secrets + project: roboces + syncPolicy: + automated: + prune: true + selfHeal: true diff --git a/k8s/charts/vaultwarden/Chart.yaml b/k8s/charts/vaultwarden/Chart.yaml new file mode 100644 index 0000000..66593fd --- /dev/null +++ b/k8s/charts/vaultwarden/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: vaultwarden +description: A Helm chart for Vaultwarden password manager +type: application +version: 0.1.0 +appVersion: "1.37.0" diff --git a/k8s/charts/vaultwarden/templates/_helpers.tpl b/k8s/charts/vaultwarden/templates/_helpers.tpl new file mode 100644 index 0000000..9aa0345 --- /dev/null +++ b/k8s/charts/vaultwarden/templates/_helpers.tpl @@ -0,0 +1,60 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "vaultwarden.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +*/}} +{{- define "vaultwarden.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 "vaultwarden.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "vaultwarden.labels" -}} +helm.sh/chart: {{ include "vaultwarden.chart" . }} +{{ include "vaultwarden.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "vaultwarden.selectorLabels" -}} +app.kubernetes.io/name: {{ include "vaultwarden.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Service account name +*/}} +{{- define "vaultwarden.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "vaultwarden.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/k8s/charts/vaultwarden/templates/deployment.yaml b/k8s/charts/vaultwarden/templates/deployment.yaml new file mode 100644 index 0000000..d9e7446 --- /dev/null +++ b/k8s/charts/vaultwarden/templates/deployment.yaml @@ -0,0 +1,94 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "vaultwarden.fullname" . }} + labels: + {{- include "vaultwarden.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "vaultwarden.selectorLabels" . | nindent 6 }} + strategy: + type: Recreate + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "vaultwarden.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + envFrom: + - secretRef: + name: {{ .Values.secret.existingSecretName | default (include "vaultwarden.fullname" .) }} + env: + {{- range $key, $value := .Values.env }} + - name: {{ $key }} + value: {{ $value | quote }} + {{- end }} + {{- if .Values.conf.db.database_url }} + - name: DATABASE_URL + value: {{ .Values.conf.db.database_url | quote }} + {{- end }} + {{- range $key, $value := .Values.conf.db }} + {{- if and (ne $key "database_url") $value }} + - name: {{ upper (print "DB_" $key) }} + value: {{ $value | quote }} + {{- end }} + {{- end }} + {{- range $key, $value := .Values.conf.web_vault }} + - name: {{ upper (print "WEB_VAULT_" $key) }} + value: {{ $value | quote }} + {{- end }} + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: data + mountPath: /data + volumes: + - name: data + {{- if .Values.persistence.existingClaim }} + persistentVolumeClaim: + claimName: {{ .Values.persistence.existingClaim }} + {{- else }} + persistentVolumeClaim: + claimName: {{ include "vaultwarden.fullname" . }}-data + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + restartPolicy: Always + automountServiceAccountToken: false diff --git a/k8s/charts/vaultwarden/templates/ingress.yaml b/k8s/charts/vaultwarden/templates/ingress.yaml new file mode 100644 index 0000000..0c3cf36 --- /dev/null +++ b/k8s/charts/vaultwarden/templates/ingress.yaml @@ -0,0 +1,45 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "vaultwarden.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "vaultwarden.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.className }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if .pathType }} + pathType: {{ .pathType }} + {{- end }} + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/k8s/charts/vaultwarden/templates/pvc.yaml b/k8s/charts/vaultwarden/templates/pvc.yaml new file mode 100644 index 0000000..74c2c7c --- /dev/null +++ b/k8s/charts/vaultwarden/templates/pvc.yaml @@ -0,0 +1,21 @@ +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "vaultwarden.fullname" . }}-data + labels: + {{- include "vaultwarden.labels" . | nindent 4 }} +spec: + accessModes: + - {{ .Values.persistence.accessMode }} + {{- if .Values.persistence.storageClass }} + {{- if eq "-" .Values.persistence.storageClass }} + storageClassName: "" + {{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" + {{- end }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size }} +{{- end }} diff --git a/k8s/charts/vaultwarden/templates/service.yaml b/k8s/charts/vaultwarden/templates/service.yaml new file mode 100644 index 0000000..b73fcea --- /dev/null +++ b/k8s/charts/vaultwarden/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "vaultwarden.fullname" . }} + labels: + {{- include "vaultwarden.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} + protocol: TCP + name: http + selector: + {{- include "vaultwarden.selectorLabels" . | nindent 4 }} diff --git a/k8s/charts/vaultwarden/values.yaml b/k8s/charts/vaultwarden/values.yaml new file mode 100644 index 0000000..279fa18 --- /dev/null +++ b/k8s/charts/vaultwarden/values.yaml @@ -0,0 +1,75 @@ +# Configuration is managed in k8s/argo-apps/vaultwarden.yaml +replicaCount: 1 + +image: + repository: vaultwarden/server + pullpolicy: Always + tag: "1.37.0-alpine" + +imagePullSecrets: [] +podAnnotations: {} +podSecurityContext: {} +securityContext: {} + +service: + type: ClusterIP + port: 80 + targetPort: 80 + +ingress: + enabled: false + +conf: + db: + database_url: "" + enable_db_wal: true + connection_retries: 15 + timeout: 30 + idle_timeout: 600 + min_conns: 2 + max_conns: 10 + conn_init: "" + web_vault: + enabled: true + folder: "web-vault/" + +persistence: + enabled: true + storageClass: "truenas-nfs-csi" + accessMode: ReadWriteMany + size: 5Gi + existingClaim: "" + +autoscaling: + enabled: false + +resources: {} + +livenessProbe: + tcpSocket: + port: 80 + initialDelaySeconds: 30 + timeoutSeconds: 15 + successThreshold: 1 + failureThreshold: 3 + periodSeconds: 10 + +readinessProbe: + tcpSocket: + port: 80 + initialDelaySeconds: 15 + timeoutSeconds: 2 + successThreshold: 1 + failureThreshold: 3 + periodSeconds: 10 + +nodeSelector: {} +tolerations: [] +affinity: {} + +env: {} + +secret: + enabled: true + existingSecretName: "vaultwarden-kubernetes-secrets" + data: {} diff --git a/tofu/adguard/main.tf b/tofu/adguard/main.tf index 0896ef7..cae540d 100644 --- a/tofu/adguard/main.tf +++ b/tofu/adguard/main.tf @@ -74,3 +74,17 @@ resource "adguard_rewrite" "k3m3" { domain = "k3m3.fuku" answer = "192.168.1.43" } + +resource "adguard_rewrite" "zeruel" { + domain = "zeruel.fuku" + answer = "192.168.1.3" +} + +resource "adguard_rewrite" "nginx" { + domain = "nginx.fuku" + answer = "192.168.1.12" +} +resource "adguard_rewrite" "pgadmin" { + domain = "pgadmin.fuku" + answer = "192.168.1.12" +}