Installer: pihole + root-ca-server + fix bitwarden cert issuer name
diff --git a/charts/certificate-issuer/templates/root-ca-server.yaml b/charts/certificate-issuer/templates/root-ca-server.yaml
new file mode 100644
index 0000000..06f38d8
--- /dev/null
+++ b/charts/certificate-issuer/templates/root-ca-server.yaml
@@ -0,0 +1,85 @@
+# TODO(giolekva): move to ingerss-nginx-private namespace
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: {{ .Values.private.name }}-root-ca
+  namespace: {{ .Release.Namespace }}
+spec:
+  selector:
+    matchLabels:
+      app: {{ .Values.private.name }}-root-ca
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: {{ .Values.private.name }}-root-ca
+    spec:
+      volumes:
+      - name: root-ca-secret
+        secret:
+          secretName: {{ .Values.private.name }}-ca-root
+          items:
+          - key: ca.crt
+            path: private-root-ca.crt
+      containers:
+      - name: file-server
+        image: giolekva/static-file-server:latest
+        imagePullPolicy: Always
+        ports:
+        - name: http
+          containerPort: 80
+        command: ["static-file-server"]
+        args: ["-port=80", "-dir=/etc/static-file-server/data"]
+        volumeMounts:
+        - name: root-ca-secret
+          mountPath: /etc/static-file-server/data/
+          readOnly: true
+        resources:
+          requests:
+            memory: "10Mi"
+            cpu: "10m"
+          limits:
+            memory: "20Mi"
+            cpu: "100m"
+      tolerations:
+      - key: "pcloud"
+        operator: "Equal"
+        value: "role"
+        effect: "NoSchedule"
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ .Values.private.name }}-root-ca
+  namespace: {{ .Release.Namespace }}
+spec:
+  type: ClusterIP
+  selector:
+    app: {{ .Values.private.name }}-root-ca
+  ports:
+    - name: http
+      port: 80
+      targetPort: http
+      protocol: TCP
+---
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  name: {{ .Values.private.name }}-root-ca
+  namespace: {{ .Release.Namespace }}
+  annotations:
+    nginx.ingress.kubernetes.io/ssl-redirect: "false"
+spec:
+  ingressClassName: {{ .Values.private.ingressClassName }}
+  rules:
+  - host: root-ca.{{ .Values.private.domain }}
+    http:
+      paths:
+      - pathType: Prefix
+        path: "/"
+        backend:
+          service:
+            name: {{ .Values.private.name }}-root-ca
+            port:
+              name: http
diff --git a/charts/certificate-issuer/values.yaml b/charts/certificate-issuer/values.yaml
index 4f40083..57a0d43 100644
--- a/charts/certificate-issuer/values.yaml
+++ b/charts/certificate-issuer/values.yaml
@@ -5,4 +5,5 @@
   ingressClass: ingress-nginx
 private:
   name: selfsigned-private
+  domain: pcloud
 
diff --git a/charts/pihole/.helmignore b/charts/pihole/.helmignore
new file mode 100644
index 0000000..0e8a0eb
--- /dev/null
+++ b/charts/pihole/.helmignore
@@ -0,0 +1,23 @@
+# 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
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/charts/pihole/Chart.lock b/charts/pihole/Chart.lock
new file mode 100644
index 0000000..ace2816
--- /dev/null
+++ b/charts/pihole/Chart.lock
@@ -0,0 +1,6 @@
+dependencies:
+- name: pihole
+  repository: https://mojo2600.github.io/pihole-kubernetes/
+  version: 2.4.2
+digest: sha256:c34c7b7a16ef0994b1b6d51061347e85ffac7ec557b13b7b5580cb5ed0aa8fff
+generated: "2021-11-08T23:15:18.130485+04:00"
diff --git a/charts/pihole/Chart.yaml b/charts/pihole/Chart.yaml
new file mode 100644
index 0000000..04c1030
--- /dev/null
+++ b/charts/pihole/Chart.yaml
@@ -0,0 +1,10 @@
+apiVersion: v2
+name: pihole
+description: A Helm chart for PCloud Pihole service
+type: application
+version: 0.0.1
+appVersion: "0.0.1"
+dependencies:
+- name: pihole
+  version: 2.4.2
+  repository: https://mojo2600.github.io/pihole-kubernetes/
diff --git a/charts/pihole/charts/pihole-2.4.2.tgz b/charts/pihole/charts/pihole-2.4.2.tgz
new file mode 100644
index 0000000..aa7db75
--- /dev/null
+++ b/charts/pihole/charts/pihole-2.4.2.tgz
Binary files differ
diff --git a/charts/pihole/templates/_helpers.tpl b/charts/pihole/templates/_helpers.tpl
new file mode 100644
index 0000000..063b2b4
--- /dev/null
+++ b/charts/pihole/templates/_helpers.tpl
@@ -0,0 +1,7 @@
+{{- define "clientSecret" -}}
+{{- if .Values.oauth2.clientSecret -}}
+{{- .Values.oauth2.clientSecret -}}
+{{- else -}}
+{{- randAlphaNum 32 -}}
+{{- end -}}
+{{- end -}}
diff --git a/charts/pihole/templates/oauth2-client.yaml b/charts/pihole/templates/oauth2-client.yaml
new file mode 100644
index 0000000..da80ddf
--- /dev/null
+++ b/charts/pihole/templates/oauth2-client.yaml
@@ -0,0 +1,19 @@
+apiVersion: hydra.ory.sh/v1alpha1
+kind: OAuth2Client
+metadata:
+  name: {{ .Values.oauth2.clientId }}
+  namespace: {{ .Release.Namespace }}
+spec:
+  grantTypes:
+  - authorization_code
+  responseTypes:
+  - code
+  scope: "openid email profile"
+  secretName: {{ .Values.oauth2.secretName }}
+  redirectUris:
+  - https://pihole.{{ .Values.domain }}/oauth2/callback
+  hydraAdmin:
+    url: {{ .Values.oauth2.hydraAdmin }}
+    port: 80
+    endpoint: /clients
+    forwardedProto: https
diff --git a/charts/pihole/templates/oauth2-proxy-config.yaml b/charts/pihole/templates/oauth2-proxy-config.yaml
new file mode 100644
index 0000000..1365162
--- /dev/null
+++ b/charts/pihole/templates/oauth2-proxy-config.yaml
@@ -0,0 +1,62 @@
+{{- $secret := include "clientSecret" . -}}
+---
+apiVersion: v1
+kind: Secret
+type: Opaque
+metadata:
+  name: {{ .Values.oauth2.secretName }}
+  namespace: {{ .Release.Namespace }}
+data:
+  client_id: {{ .Values.oauth2.clientId | b64enc  }}
+  client_secret: {{ $secret | b64enc }}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ .Values.oauth2.configName }}
+  namespace: {{ .Release.Namespace }}
+data:
+  oauth2-proxy.cfg: |
+    http_address = "0.0.0.0:8080"
+
+    reverse_proxy = true
+
+    ## the OAuth Redirect URL.
+    # defaults to the "https://" + requested host header + "/oauth2/callback"
+    # redirect_url = "http://pihole.pcloud/oauth2/callback"
+
+    upstreams = [
+        "http://pihole-web.{{ .Release.Namespace}}.svc"
+    ]
+
+    email_domains = [
+        "*"
+    ]
+
+    standard_logging = false
+    request_logging = false
+    auth_logging = false
+
+    pass_basic_auth = true
+    pass_user_headers = true
+    pass_host_header = true
+
+    ## The OAuth Client ID, Secret
+    client_id = "{{ .Values.oauth2.clientId }}"
+    client_secret = "{{ $secret }}"
+
+    ## Pass OAuth Access token to upstream via "X-Forwarded-Access-Token"
+    pass_access_token = false
+
+    cookie_name = "_oauth2_proxy_pihole"
+    cookie_secret = "123456789012345678901234567890--"
+    cookie_domains = "pihole.{{ .Values.domain }}"
+    cookie_expire = "168h"
+    cookie_refresh = "100h"
+    cookie_secure = true
+    cookie_httponly = true
+
+    provider = "oidc"
+    oidc_issuer_url = "{{ .Values.hydraPublic }}"
+    provider_display_name = "PCloud"
+    profile_url = "{{ .Values.profileUrl }}"
diff --git a/charts/pihole/templates/oauth2-proxy.yaml b/charts/pihole/templates/oauth2-proxy.yaml
new file mode 100644
index 0000000..8f4541b
--- /dev/null
+++ b/charts/pihole/templates/oauth2-proxy.yaml
@@ -0,0 +1,88 @@
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: pihole-oauth2-proxy
+  namespace: {{ .Release.Namespace }}
+spec:
+  type: ClusterIP
+  selector:
+    app: pihole-oauth2-proxy
+  ports:
+  - name: http
+    port: 80
+    targetPort: http
+    protocol: TCP
+---
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  name: ingress
+  namespace: {{ .Release.Namespace }}
+  annotations:
+    cert-manager.io/cluster-issuer: "{{ .Values.certificateIssuer }}"
+    acme.cert-manager.io/http01-edit-in-place: "true"
+spec:
+  ingressClassName: {{ .Values.ingressClassName }}
+  tls:
+  - hosts:
+    - pihole.{{ .Values.domain }}
+    secretName: cert-pihole.{{ .Values.domain }}
+  rules:
+  - host: pihole.{{ .Values.domain }}
+    http:
+      paths:
+      - path: /
+        pathType: Prefix
+        backend:
+          service:
+            name: pihole-oauth2-proxy
+            port:
+              name: http
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: pihole-oauth2-proxy
+  namespace: {{ .Release.Namespace }}
+spec:
+  selector:
+    matchLabels:
+      app: pihole-oauth2-proxy
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: pihole-oauth2-proxy
+    spec:
+      volumes:
+      - name: config
+        configMap:
+          name: {{ .Values.oauth2.configName }}
+      containers:
+      - name: pihole-oauth2-proxy
+        image: quay.io/oauth2-proxy/oauth2-proxy:v7.2.0-arm64
+        imagePullPolicy: Always
+        ports:
+        - name: http
+          containerPort: 8080
+          protocol: TCP
+        command:
+        - oauth2-proxy
+        - --config=/etc/oauth2-proxy/oauth2-proxy.cfg
+        volumeMounts:
+        - name: config
+          mountPath: /etc/oauth2-proxy
+          readOnly: true
+        resources:
+          requests:
+            memory: "10Mi"
+            cpu: "10m"
+          limits:
+            memory: "20Mi"
+            cpu: "100m"
+      tolerations:
+      - key: "pcloud"
+        operator: "Equal"
+        value: "role"
+        effect: "NoSchedule"
diff --git a/charts/pihole/values.yaml b/charts/pihole/values.yaml
new file mode 100644
index 0000000..9c038d6
--- /dev/null
+++ b/charts/pihole/values.yaml
@@ -0,0 +1,12 @@
+pihole: {}
+oauth2:
+  clientId: app-pihole
+  secretName: oauth2-secret
+  configName: oauth2-proxy
+domain: example.com
+hydraPublic: https://hydra.example.com
+profileUrl: https://profile.example.com
+certificateIssuer: public
+ingressClassName: public
+
+
diff --git a/charts/vaultwarden/templates/install.yaml b/charts/vaultwarden/templates/install.yaml
index a47c3b5..d3a21fb 100644
--- a/charts/vaultwarden/templates/install.yaml
+++ b/charts/vaultwarden/templates/install.yaml
@@ -69,7 +69,7 @@
   name: ingress
   namespace: {{ .Release.Namespace }}
   annotations:
-    cert-manager.io/cluster-issuer: "{{ .Values.certificateIssuier }}"
+    cert-manager.io/cluster-issuer: "{{ .Values.certificateIssuer }}"
     acme.cert-manager.io/http01-edit-in-place: "true"
 spec:
   ingressClassName: {{ .Values.ingressClassName }}