---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: codeserver
  labels:
    app: codeserver
spec:
  replicas: 1
  selector:
    matchLabels:
      app: codeserver
  template:
    metadata:
      labels:
        app: codeserver
    spec:
      containers:
      - name: codeserver
        image: docker.dezendorf.net/code-server:96bac41
        ports:
        - name: web
          containerPort: 8080
        volumeMounts:
        - name: code-data-volume
          mountPath: "/home/coder"
      volumes:
      - name: code-data-volume
        persistentVolumeClaim:
          claimName: code-data-pvc
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: code-data-pvc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: nfs
  resources:
    requests:
      storage: 100M

---
apiVersion: v1
kind: Service
metadata:
  name: codeserver
spec:
  type: ClusterIP
  ports:
    - name: web
      port: 8080
  selector:
    app: codeserver
---
apiVersion: v1
kind: Service
metadata:
  name: codeserver-devport
spec:
  type: ClusterIP
  ports:
    - name: webdev
      port: 5000
  selector:
    app: codeserver
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: codeserver-ingress-route
  namespace: default
spec:
  entryPoints:
    - web
  routes:
  - match: Host(`codeserver.dezendorf.net`)
    kind: Rule
    middlewares:
    - name: redirecthttps
    services:
    - name: codeserver
      port: 8080
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: codeserver-websecure-route
  namespace: default
spec:
  entryPoints:
    - websecure
  routes:
  - match: (Host(`codeserver.dezendorf.net`)||Host(`codeserverr.dezendorf.net`))
    kind: Rule
    middlewares:
    - name: authelia
    services:
    - name: codeserver
      port: 8080
  tls:
    certResolver: myresolver
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: codeserver-devport-websecure-route
  namespace: default
spec:
  entryPoints:
    - websecure
  routes:
  - match: (Host(`devport.dezendorf.net`)||Host(`devportr.dezendorf.net`))
    kind: Rule
    middlewares:
    - name: authelia
    services:
    - name: codeserver-devport
      port: 5000
  tls:
    certResolver: myresolver
