You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行gcloud container clusters get-credentials后Linux用户权限异常求助

问题解决步骤

1. 修复主目录权限问题

用户自身无法访问主目录且ls输出权限显示为?????????,核心原因是用户对主目录本身缺乏必要权限,或文件归属、SELinux上下文异常。

  • 切换至root用户,执行以下命令恢复文件归属与基础权限:
    chown -R wls:wls /home/wls
    chmod 755 /home/wls
    
  • 若执行后仍无法访问,检查SELinux状态:
    sestatus
    
    若SELinux处于Enforcing模式,恢复目录上下文:
    restorecon -Rv /home/wls
    

2. 解决gcloud container clusters get-credentials报错

报错Unable to write file [/home/wls]: Is a directory是因为KUBECONFIG环境变量被错误设置为目录路径,而非kubeconfig文件路径。

  • 检查当前KUBECONFIG设置:
    echo $KUBECONFIG
    
  • 若输出为/home/wls,重新设置为正确的配置文件路径:
    export KUBECONFIG="$HOME/.kube/config"
    
    可将上述命令添加至~/.bashrc或~/.profile,实现永久生效。
  • 重新执行集群凭证获取命令:
    gcloud container clusters get-credentials $mycluster
    

内容的提问来源于stack exchange,提问作者Viktor Vlasov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 19:05:35