【问题标题】:`kubectl cp` to a pod is failing because of Permission Denied由于权限被拒绝,对 pod 的“kubectl cp”失败
【发布时间】:2020-01-04 04:00:29
【问题描述】:

当我尝试将一个小文件复制到 Kubernetes pod 时,它失败并出现以下错误:

:~ $kubectl cp /tmp/a default/resolver-proxy-69dc786fcf-5rplg:/usr/local/bin/ --no-preserve=true
    tar: a: Cannot open: Permission denied
    tar: Exiting with failure status due to previous errors
    command terminated with exit code 2

有人可以帮我解决这个问题吗?我在 minikube 上运行 Kubernetes。

由于类似的错误,我还看到另一个 Postgres Pod 处于错误状态:

:~ $kubectl logs postgres-7676967946-7lp9g postgres
tar: /var/lib/postgresql/data: Cannot open: Permission denied
tar: Error is not recoverable: exiting now

【问题讨论】:

    标签: kubernetes google-kubernetes-engine copy-paste kubectl minikube


    【解决方案1】:

    对于 kubectl cp 尝试先复制到 /tmp 文件夹,然后将文件 mv 到通过转移到 root 用户所需的路径

    kubectl cp /tmp/a default/resolver-proxy-69dc786fcf-5rplg:/tmp/

    然后 exec 进入 pod 并更改为 root 并复制到所需的路径。

    对于第二个问题,执行进入 pod 并通过运行以下命令修复权限。 Postgres 需要能够读写 Postgres 路径。

    chown -R postgres:postgres /var/lib/postgresql/

    【讨论】:

      猜你喜欢
      • 2013-07-31
      • 1970-01-01
      • 1970-01-01
      • 2016-01-12
      • 1970-01-01
      • 2018-02-10
      • 2019-07-28
      • 2015-03-25
      • 2014-11-04
      相关资源
      最近更新 更多