简体   繁体   English

如何在 kubernetes postgresql pod 中安装 wget

[英]how to install wget in kubernetes postgresql pod

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 .我想在 PosgreSQL 中安装一些扩展,这是我要归档的问题: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.现在我成功启用了初始文件夹,下一步我想添加一些初始 shell 脚本来在容器启动之前安装一些扩展。 I tried to run the command in kubernetes pod before put it into initial script.在将其放入初始脚本之前,我尝试在 kubernetes pod 中运行该命令。 when I using this command in kubernetes postgresql pod to install wget:当我在 kubernetes postgresql pod 中使用此命令安装 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:然后我尝试切换到 pod 容器的根目录:

su -

it need password, I am using helm to install the postgresql:它需要密码,我正在使用 helm 安装 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?我应该怎么做才能在 pod 中安装 wget? I have tried this: https://docs.bitnami.com/virtual-machine/faq/administration/use-sudo/我试过这个: https ://docs.bitnami.com/virtual-machine/faq/administration/use-sudo/

You can use initContainers in order to download a script and use it in the postgres container.您可以使用 initContainers 来下载脚本并在 postgres 容器中使用它。 The initContainer would contain wget and download your script and put it in a volume. initContainer 将包含wget并下载您的脚本并将其放入一个卷中。 You can then mount the volume in your postgres container and execute it from there然后,您可以将卷安装在您的 postgres 容器中并从那里执行它

The values.yaml for that chart would look something like该图表的 values.yaml 看起来像

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而是/postgres/path/for/scripts添加 postgres 可以读取的实际路径,或配置 postgres 从这样的路径读取

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM