I want to install some extensions in PosgreSQL, this is the issue what I am trying to archive:https://github.com/bitnami/bitnami-docker-postgresql/issues/346. Now I success enable the initial folder and the next step I want to add some initial shell script to install some extension before container start. I tried to run the command in kubernetes pod before put it into initial script. when I using this command in kubernetes postgresql pod to install wget:
apt-get install wget -y
shows error like this:
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
then I tried to switch to the root of the pod container:
su -
it need password, I am using helm to install the postgresql:
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install my-release bitnami/postgresql
what should I do to install wget in the pod? I have tried this: https://docs.bitnami.com/virtual-machine/faq/administration/use-sudo/
CodePudding user response:
You can use initContainers in order to download a script and use it in the postgres container. The initContainer would contain wget
and download your script and put it in a volume. You can then mount the volume in your postgres container and execute it from there
The values.yaml for that chart would look something like
primary:
initContainers:
- name: do-something
image: image-with-wget
command: ['wget', 'https://myscript']
volumeMounts:
- name: postgres-scripts
mountPath: /postgres/path/for/scripts
Instead /postgres/path/for/scripts
add the actual path where postgres can read from, or configure postgres to read from such a path