Install frappe app in k8s (microk8s) on postgresql

Maybe it will be helpful for someone

  1. sudo microk8s kubectl create namespace frappe-pg

  2. sudo microk8s helm repo add frappe https://helm.erpnext.com

  3. Configure custom-values.yaml

sudo nano custom-values.yaml

--------------
persistence:
  worker:
    enabled: true
    # existingClaim: ""
    size: 8Gi
    storageClass: "microk8s-hostpath"
--------------
mariadb:
  enabled: false
--------------
postgresql:
  enabled: true
  # host: ""
  image:
    tag: 14.11.0-debian-11-r13
  auth:
    username: "postgres"
    postgresPassword: "changeit"
  primary:
    service:
      ports:
        postgresql: 5432
-----------------
  1. sudo microk8s helm upgrade --install frappe-bench -n frappe-pg -f custom-values.yaml frappe/erpnext

  2. Wait some time for install 5-10 minutes

  3. Delete failed job “frappe-bench-erpnext-conf-bench…” if needed

  4. sudo microk8s helm template frappe-bench -n frappe-pg frappe/erpnext -f custom-values.yaml -s templates/job-configure-bench.yaml > configure-bench-job.yaml

  5. configure bench job:

sudo nano configure-bench-job.yaml

------------------
        env:
          - name: DB_HOST
            value: frappe-bench-postgresql
          - name: DB_PORT
            value: "5432"
-------------------
  1. Install bench. Create Job
    sudo microk8s kubectl apply -n frappe-pg -f configure-bench-job.yaml

  2. Enable site for installation:

sudo nano custom-values.yaml

------------------
  createSite:
    enabled: true
    forceCreate: true
    siteName: "192.168.1.76" #ip of microk8s host
    adminPassword: "changeit"
    installApps:
    - "frappe"
    dbType: "postgres"
    backoffLimit: 0
    resources: {}
    nodeSelector: {}
    tolerations: []
    affinity: {}
------------------
  1. sudo microk8s helm template frappe-bench -n frappe-pg frappe/erpnext -f custom-values.yaml -s templates/job-create-site.yaml > create-new-site-job.yaml

  2. Configure new-site job:
    sudo nano create-new-site-job.yaml

------------------
        args:
          - >
            bench new-site $(SITE_NAME)
            --db-type=$(DB_TYPE)
            --db-host=$(DB_HOST)
            --db-port=$(DB_PORT)
            --admin-password=$(ADMIN_PASSWORD)
            --db-root-username=$(DB_ROOT_USER)
            --db-root-password=$(DB_ROOT_PASSWORD)
            --install-app=frappe
            --force
            ;rm -f currentsite.txt
        env:
          - name: "SITE_NAME"
            value: "192.168.1.76"
          - name: "DB_TYPE"
            value: postgres
          - name: "DB_HOST"
            value: frappe-bench-postgresql
          - name: "DB_PORT"
            value: "5432"
          - name: "DB_ROOT_USER"
            value: "postgres"
          - name: "DB_ROOT_PASSWORD"
            value: "changeit"
          - name: "ADMIN_PASSWORD"
            value: "changeit"
----------------------
  1. Create Job
    sudo microk8s kubectl apply -n frappe-pg -f create-new-site-job.yaml

  2. Port forwarding on host machine:
    sudo microk8s kubectl port-forward -n frappe-pg service/frappe-bench-erpnext 18080:8080 --address 0.0.0.0

  3. Login in frappe:
    http://192.168.1.76:18080

3 Likes