helm 部署服务到 k8s

helm upgrade -f values.yaml --install dev-auth harbor/helm-chart -n dev

报错

 Error: Kubernetes cluster unreachable: <html><head><meta http-equiv='refresh' content='1;url=/login?from=%2Fversion'/>
 <script>window.location.replace('/login?from=%2Fversion');</script></head><body style='background-color:white; color:white;'>

原因:jenkins 用户当前没有连接 k8s 的权限

解决方案: 添加 config 文件

vim kubeconfig

内容是 k8s 的 config 文件
在这里插入图片描述

export KUBECONFIG=/var/lib/jenkins/kubeconfig

 

报错

WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /var/lib/jenkins/kubeconfig 
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /var/lib/jenkins/kubeconfig

原因:kubeconfig 的权限问题

解决方案

chmod g-r /var/lib/jenkins/kubeconfig
chmod o-r /var/lib/jenkins/kubeconfig

 
报错

Error: failed to download "harbor/helm-chart"

原因:没有 harbor 仓库

解决方案:添加 harbor 仓库,更新仓库

helm repo add  --username admin --password Harbor12345  harbor http://192.168.140.xx/chartrepo/xiangmuming
helm repo update 

 
报错

chmod: changing permissions of ‘/var/lib/jenkins/kubeconfig’: Operation not permitted

原因:kubeconfig 是 root 用户创建的,Jenkins 用户访问会没有权限

解决方案:给 kubeconfig 赋予 jenkins 用户

chown -R jenkins:jenkins kubeconfig
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐