'Superset configurations are lost upon Kubernetes pod start/stop

I'm having a problem with Superset on Kubernetes. After installing Superset when the pod comes down and goes up, the configurations are not saved and I lost the admin user I have created with the command:

docker exec -it superset superset fab create-admin \
           --username admin \
           --firstname Superset \
           --lastname Admin \
           --email [email protected] \
           --password admin

After that command, the only commands I used were:

$ docker exec -it superset superset db upgrade
$ docker exec -it superset superset db upgrade
$ docker exec -it superset superset init

I'm using Rancher to deploy the Superset pod. How can I persist the configurations?



Solution 1:[1]

For me I think you have two options:

  1. Create a volume for your pod. Your pod definition will looks something like this (PS I didn't test this code)
apiVersion: v1
kind: Pod
metadata:
  name: pv-recycler
  namespace: default
spec:
  restartPolicy: Never
  volumes:
  - name: vol
    hostPath:
      path: /any/path/it/will/be/replaced
  containers:
  - name: pv-recycler
    image: "superset"
    command: ["/bin/sh", "superset fab", "create-admin --username admin --firstname Superset --lastname Admin --email [email protected] --password admin"]
    volumeMounts:
    - name: vol
      mountPath: /scrub
  1. Make a dockerfile, add your configuration and build a new image with your configuration

Solution 2:[2]

Migrating solution from the question to an answer

After changing the volumes and the environment variables, and after learning how PYTHONPATH works in general, I figured it out and added my configuration file in a specific location and added that location to the PYTHONPATH environment variable. It works!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TylerH
Solution 2