背景
上篇文章写了,如何使用nexus 3 添加helm repo,但是最后放出来了一个问题,那就是再用0.0.2的时候如果代理了https://charts.gitlab.io得仓库地址时,在执行以下命令时会报404得错误
helm repo add gitlab http://127.0.0.1:8081/helm-gitlab-charts/
helm fetch gitlab/auto-deploy-app
Error: Failed to fetch http://127.0.0.1:8081/auto-deploy-app-0.2.4.tgz : 404 Not Found
通过错误信息来看,本地下载helm charts得地址是nexus得地址加charts文件,
通过查看https://charts.gitlab.io/index.yaml文件
- created: 2018-06-15T22:48:32.992821306Z
description: GitLab Runner
digest: 034f08a9e6bb733e7e56b3bf2542498da75872d1e373dce70334485829f68d0e
icon: https://gitlab.com/uploads/-/system/project/avatar/250833/runner_logo.png
keywords:
- git
- ci
- deploy
maintainers:
- email: [email protected]
name: GitLab Inc.
- email: [email protected]
name: DJ Mountney
name: gitlab-runner
sources:
- https://hub.docker.com/r/gitlab/gitlab-runner/
- https://docs.gitlab.com/runner/
urls:
- https://gitlab-charts.s3.amazonaws.com/gitlab-runner-0.1.23.tgz
version: 0.1.23
- created: 2018-06-15T22:35:02.572502983Z
description: GitLab Runner
digest: c82d3d98a810322bf87edf47934814e6d3f24f26f614acb1d322f6586a96d593
icon: https://gitlab.com/uploads/-/system/project/avatar/250833/runner_logo.png
keywords:
- git
- ci
- deploy
maintainers:
- email: [email protected]
name: GitLab Inc.
- email: [email protected]
name: DJ Mountney
name: gitlab-runner
sources:
- https://hub.docker.com/r/gitlab/gitlab-runner/
- https://docs.gitlab.com/runner/
urls:
- https://gitlab-charts.s3.amazonaws.com/gitlab-runner-0.1.22.tgz
version: 0.1.22
- created: 2018-06-14T16:30:13.81292576Z
description: GitLab Runner
digest: be75401889b81945faa52305bf734117648513f0e7814286ed1a52e2652758a7
icon: https://gitlab.com/uploads/-/system/project/avatar/250833/runner_logo.png
keywords:
- git
- ci
- deploy
maintainers:
- email: [email protected]
name: GitLab Inc.
- email: [email protected]
name: DJ Mountney
name: gitlab-runner
sources:
- https://hub.docker.com/r/gitlab/gitlab-runner/
- https://docs.gitlab.com/runner/
urls:
- https://gitlab-charts.s3.amazonaws.com/gitlab-runner-0.1.21.tgz
version: 0.1.21
- created: 2018-06-07T15:22:28.486461965Z
description: GitLab Runner
digest: d8258443107d13792875f6ae3fdb90cc4fcaabc5f83f3bbf3317143c44493b1f
icon: https://gitlab.com/uploads/-/system/project/avatar/250833/runner_logo.png
keywords:
- git
- ci
- deploy
maintainers:
- email: [email protected]
name: GitLab Inc.
- email: [email protected]
name: DJ Mountney
name: gitlab-runner
sources:
- https://hub.docker.com/r/gitlab/gitlab-runner/
- https://docs.gitlab.com/runner/
urls:
- https://gitlab-charts.s3.amazonaws.com/gitlab-runner-0.1.20.tgz
version: 0.1.20
- created: 2018-06-06T14:26:15.253296358Z
description: GitLab Runner
digest: 3bf24c26fc9cc64bb6d860fccba99672e90445dab5ce1d745115042615759b6f
icon: https://gitlab.com/uploads/-/system/project/avatar/250833/runner_logo.png
keywords:
- git
- ci
- deploy
maintainers:
- email: [email protected]
name: GitLab Inc.
- email: [email protected]
name: DJ Mountney
name: gitlab-runner
sources:
- https://hub.docker.com/r/gitlab/gitlab-runner/
- https://docs.gitlab.com/runner/
urls:
- https://gitlab-charts.s3.amazonaws.com/gitlab-runner-0.1.19.tgz
version: 0.1.19
- created: 2018-05-30T10:35:21.5443457Z
description: GitLab Runner
digest: 540bf4756d198ae75824e733a3d1740cf37464d9ec33e80f62e0097ad2453e26
icon: https://gitlab.com/uploads/-/system/project/avatar/250833/runner_logo.png
keywords:
- git
- ci
- deploy
maintainers:
- email: [email protected]
name: GitLab Inc.
- email: [email protected]
name: DJ Mountney
name: gitlab-runner
sources:
- https://hub.docker.com/r/gitlab/gitlab-runner/
- https://docs.gitlab.com/runner/
urls:
- https://gitlab-charts.s3.amazonaws.com/gitlab-runner-0.1.18.tgz
version: 0.1.18
- created: 2018-05-25T17:47:52.665684883Z
description: GitLab Runner
digest: 88886a71b1ec6065117bda3341f3c4f0bbe2360fad8a22c6d8a8dbcd3c7db880
icon: https://gitlab.com/uploads/-/system/project/avatar/250833/runner_logo.png
keywords:
- git
- ci
- deploy
maintainers:
- email: [email protected]
name: GitLab Inc.
- email: [email protected]
name: DJ Mountney
name: gitlab-runner
sources:
- https://hub.docker.com/r/gitlab/gitlab-runner/
- https://docs.gitlab.com/runner/
urls:
- https://gitlab-charts.s3.amazonaws.com/gitlab-runner-0.1.17.tgz
version: 0.1.17
- created: 2018-05-21T14:12:40.310853577Z
description: GitLab Runner
digest: 06fd24339ed112b961e79d40f4509efd350c2bb5d3ed66b214ce28f067b07aea
icon: https://gitlab.com/uploads/-/system/project/avatar/250833/runner_logo.png
keywords:
- git
- ci
- deploy
maintainers:
- email: [email protected]
name: GitLab Inc.
- email: [email protected]
name: DJ Mountney
name: gitlab-runner
sources:
- https://hub.docker.com/r/gitlab/gitlab-runner/
- https://docs.gitlab.com/runner/
urls:
- https://gitlab-charts.s3.amazonaws.com/gitlab-runner-0.1.16.tgz
version: 0.1.16
- created: 2018-05-18T13:13:54.657084419Z
description: GitLab Runner
digest: 6ac756566fbbfebd7b49f18e61357747c28424eec9ac1a2aa295f475bd0f4e94
icon: https://gitlab.com/uploads/-/system/project/avatar/250833/runner_logo.png
keywords:
- git
- ci
- deploy
maintainers:
- email: [email protected]
name: GitLab Inc.
- email: [email protected]
name: DJ Mountney
name: gitlab-runner
sources:
- https://hub.docker.com/r/gitlab/gitlab-runner/
- https://docs.gitlab.com/runner/
urls:
- https://gitlab-charts.s3.amazonaws.com/gitlab-runner-0.1.15.tgz
version: 0.1.15
- created: 2018-05-18T12:12:35.192390219Z
description: GitLab Runner
digest: 3eb963ee322434e56bb0b9878476a1a734e9b1dce26901a96c1dff8ee16f4e1b
icon: https://gitlab.com/uploads/-/system/project/avatar/250833/runner_logo.png
keywords:
- git
- ci
- deploy
maintainers:
- email: [email protected]
name: GitLab Inc.
- email: [email protected]
name: DJ Mountney
name: gitlab-runner
sources:
- https://hub.docker.com/r/gitlab/gitlab-runner/
- https://docs.gitlab.com/runner/
urls:
- https://gitlab-charts.s3.amazonaws.com/gitlab-runner-0.1.14.tgz
version: 0.1.14
- created: 2018-05-15T12:09:04.553132449Z
description: GitLab Runner
digest: 82192920f22fd497b5fe08556a2af6ad41b024950c46f69376003adc9dbd1102
icon: https://gitlab.com/uploads/-/system/project/avatar/250833/runner_logo.png
keywords:
- git
- ci
- deploy
maintainers:
- email: [email protected]
name: GitLab Inc.
- email: [email protected]
name: DJ Mountney
name: gitlab-runner
sources:
- https://hub.docker.com/r/gitlab/gitlab-runner/
- https://docs.gitlab.com/runner/
urls:
- https://gitlab-charts.s3.amazonaws.com/gitlab-runner-0.1.13.tgz
version: 0.1.13
kubernetes-gitlab-demo:
- apiVersion: v1
created: 2018-05-10T08:51:48.195111007Z
description: GitLab running on Kubernetes suitable for demos
digest: e41d0aef3616687c4327f9d447d5132bc7325cb1e5f380591a40496462441ab8
home: https://about.gitlab.com
icon: https://gitlab.com/gitlab-com/gitlab-artwork/raw/master/logo/logo-square.png
keywords:
- git
- ci
- cd
- deploy
- issue tracker
- code review
- wiki
maintainers:
- email: [email protected]
name: GitLab Inc.
- name: Mark Pundsack
- name: Jason Plum
- name: DJ Mountney
name: kubernetes-gitlab-demo
sources:
- https://hub.docker.com/r/gitlab/gitlab-ce/
- https://docs.gitlab.com/omnibus/
urls:
- https://gitlab-charts.s3.amazonaws.com/kubernetes-gitlab-demo-0.1.29.tgz
version: 0.1.29
generated: 2018-08-28T22:30:11.426662552Z
发现一个问题,https://charts.gitlab.io 中得下载地址跟charts地址不是同一个地址 前缀是这么个地址,但是由于不清楚,nexus helm支持组件究竟是如何处理这块代码的,那么这里就把nexus helm 源码下载,并且下载了window版本得nexus3,在本地配置了远程调试,配置上nexus3 helm 得插件
配置调试环境
-
安装helm扩展组件,参考我的上一篇博客
-
Java得远程调试,由于我常用得开发工具是idea,这里就用idea得远程调试做示例,eclipse同理,这里主要的就 是 下面的这条命令
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
把上面的配置放在nexus的配置文件中$NEXUS_HOME/bin/nexus.vmoptions文件末尾,如下图所示
-
然后启动配置好的nexus 3 ,第一次启动时,会提醒要网络访问,因为远程调试这里需要打开5005端口,允许即可,然后在idea中开启debug即可
Nexus 3 helm 插件的目录结构
源码分析肯定需要看一下这里的目录结构,这个代码的目录结构还是很清晰的。由于我们用的是proxy的功能,那么直接去看proxy中都有什么,由于这个helm插件没有开发多久,功能也不是很多,proxy中只有两个类一个是java的一个是groovy的
我们这里直接看FacetImpl中的代码,先来看一下这个类图
然后查看一下这个类中都有哪些成员变量和方法
总共有5个成员变量,11个方法,5个变量中有一个成员变量很有意思,从命名上来看,IndexYamlAbsoluteUrlRewriter,通过名称,猜测这是用来把原代理的repo中的绝对路径重写为相对路径,从上面出现的问题来看,很可能是这里有问题,去看一下,这个类里有什么方法
这个类中只有四个成员变量,4个方法,通过名称,我们看maybeSetAbsoluteUrlAsRelative的方法
这里有个处理如果是绝对路径直接获取了绝对路径,那么这里可能就会有问题
猜测是这里代码有问题,那么立马修改,重新打包测试。
添加如下代码测试,重新打包,运行,执行上面加载helm charts的命令,问题解决
然后,由于国内无法直接访问 https://kubernetes-charts.storage.googleapis.com/ 地址,或者说不稳定,需要代理一个其他的地址,经过在谷歌上一番搜索,发现有如下两个地址可以用
https://burdenbear.github.io/kube-charts-mirror
https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
这两个地址由于用的,开心的拿这两个地址测试,新建proxy 仓库
然后,使用以下命令添加仓库
helm repo add stable http://localhost:8081/helm-kubernetes-charts
helm fetch stable/zetcd
Error: Failed to fetch http://127.0.0.1:8081/kube-charts-mirror/zetcd-0.1.9.tgz : 404 Not Found
又一次出现了404 错误,由于有上次的经验,这次觉得还是上个类有问题,之前的逻辑处理的是只要除去第一个/,那么截取最后一个
改为上面的代码,再次打包,为题解决
扩展页面上传helm chart
由于我们需要一个在网页上传的功能,这个组件暂时没有,我们自己扩展页面上传的功能
改好的在这里,可以下载,构建使用。