Install Postgres

If you want to have the latest info on how to install Coder on Kubernetes the check this link.

Now lets install the latest Postgresql via Application Collection from SUSE.

helm pull oci://dp.apps.rancher.io/charts/postgresql

Lets also grab our token from apps.rancher.io and set it as a environment variable.

TOKEN="XXYYZZ"

Create the postgresql namespace, add application collection secret, and install the application with a custom vlaues file.

vi postgres.yaml
auth:
  database: coder
  username: coder
  password: coder
persistence:
  resources:
    requests:
      storage: 16Gi
podTemplates:
  initContainers:
    volume-permissions:
      enabled: true
            
kubectl create namespace postgresql
kubectl create secret docker-registry application-collection --docker-server=dp.apps.rancher.io --docker-username=elajoie@suse.com --docker-password="$TOKEN" -n postgresql
helm install postgresql oci://dp.apps.rancher.io/charts/postgresql --set global.imagePullSecrets={application-collection} -n postgresql -f postgres.yaml

Install Coder

Now let's install Coder and have it use the Postgres instance we have.

kubectl create namespace coder
kubectl create secret generic coder-db-url -n coder --from-literal=url="postgres://coder:coder@postgresql-headless.postgresql.svc.cluster.local:5432/coder?sslmode=disable"
helm repo add coder-v2 https://helm.coder.com/v2
vi coder.yaml
coder:
   env:
    - name: CODER_PG_CONNECTION_URL
      valueFrom:
        secretKeyRef:
          name: coder-db-url
          key: url
       - name: CODER_OAUTH2_GITHUB_DEFAULT_PROVIDER_ENABLE
      value: "false"
    - name: CODER_ACCESS_URL
      value: "https://coder.apps.suse-demo.ai"
            
helm install coder coder-v2/coder --namespace coder --values coder.yaml

Lastly lets create an ingress for TLS access.

vi ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
    external-dns.alpha.kubernetes.io/hostname: coder.apps.suse-demo.ai
  name: coder
  namespace: coder
spec:
  rules:
    - host: coder.apps.suse-demo.ai
      http:
        paths:
          - backend:
              service:
                name: coder
                port:
                  number: 80
            path: /
            pathType: Prefix
  tls:
    - hosts:
        - coder.apps.suse-demo.ai
      secretName: tls-coder-ingress
            
kubectl create ingress -f ingress.yaml