解决K8s报错:Error: error installing: the server could not find the requested resource

K8s在helm初始化的报错,我的k8s为1.16.1,用的helm是2.13.1

[root@k8s-master ~]# helm init --service-account tiller --skip-refresh
Creating /root/.helm
Creating /root/.helm/repository
Creating /root/.helm/repository/cache
Creating /root/.helm/repository/local
Creating /root/.helm/plugins
Creating /root/.helm/starters
Creating /root/.helm/cache/archive
Creating /root/.helm/repository/repositories.yaml
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
Adding local repo with URL: http://127.0.0.1:8879/charts
$HELM_HOME has been configured at /root/.helm.
Error: error installing: the server could not find the requested resource

百度了一下,可能是因为版本冲突的原因,于是去github上下了3.0的

 其实3.0做了很大的改动,根本不要初始化,还出了一些新特性。

Helm 3.0 已经发布,该版本是 CLI 工具的最新主要版本,主要关注简单性、安全性和可用性,内容如下:新特性

  • 移除 Tiller(Helm 2 是一种 Client-Server 结构,客户端称为 Helm,服务器称为 Tiller)。Helm 3 只有客户端结构,客户端仍称为 Helm。如下图所示,它的操作类似于 Helm 2 客户端,但客户端直接与 Kubernetes API 服务器交互。

  • 支持 Helm 图表新版本

  • 支持库图表

  • Release 以新格式存储

  • 支持在 OCI 注册表中存储 Helm 图表(实验性)

  • 现在可以根据 JSON 模式验证图表提供的值

  • 支持 XDG 基目录规范

  • 不需要初始化 Helm

  • 改进版本升级策略

  • 简化 CRD 支持

  • Helm 测试框架更新

  • 仍支持 Helm 2 接口

更改存储库 

Helm 3 改进了存储库的体验。在 Helm 2 中,默认情况下包含图表存储库。在 Helm 3 中,默认情况下不包含任何存储库。因此,你首先需要做的事情之一就是添加一个存储库。

与 Helm 2 兼容

Helm 3 引入一个新的 Chart 版本 (v2)。在大多数情况下,在 Helm 2  的图表在 Helm 3  同样可用。

于是重新下了一个2.15的,然后就可以了

[root@k8s-master helm]# ll
总用量 58188
-rw-r--r-- 1 root root 22949819 1月   5 20:58 helm-v2.13.1-linux-amd64.tar.gz
-rw-r--r-- 1 root root 24525846 1月   5 22:46 helm-v2.15.2-linux-amd64.tar.gz
-rw-r--r-- 1 root root 12101232 1月   5 22:10 helm-v3.0.2-linux-amd64.tar.gz
-rw-r--r-- 1 root root      354 1月   5 22:39 rbac.yaml
[root@k8s-master helm]# tar -zvxf helm-v2.15.2-linux-amd64.tar.gz
linux-amd64/
linux-amd64/tiller
linux-amd64/helm
linux-amd64/README.md
linux-amd64/LICENSE
[root@k8s-master helm]# cp -a linux-amd64/helm /usr/local/bin
[root@k8s-master helm]# cd /usr/local/bin/
[root@k8s-master bin]#  chmod a+x helm
[root@k8s-master bin]# helm init --service-account tiller --skip-refresh
Creating /root/.helm
Creating /root/.helm/repository
Creating /root/.helm/repository/cache
Creating /root/.helm/repository/local
Creating /root/.helm/plugins
Creating /root/.helm/starters
Creating /root/.helm/cache/archive
Creating /root/.helm/repository/repositories.yaml
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
Adding local repo with URL: http://127.0.0.1:8879/charts
$HELM_HOME has been configured at /root/.helm.

Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.

Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy.
To prevent this, run `helm init` with the --tiller-tls-verify flag.
For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation
[root@k8s-master bin]#
原文地址:https://www.cnblogs.com/dalianpai/p/12154061.html