helm 3 github

因此,您要发布已创建的Helm图表并将源推送到Github,并且由于某种原因,您是否希望将其发布到已策划的Helm图表列表中?

按照此快速指南将Helm图表自动发布到托管的Helm存储库的Github页面上; 我们将以当前正在开发的Terracotta(企业)Helm图表为例( 已经可以从Helm Hub获得OSS Helm图表 )

首先,准备好您的Helm图表以供发布

您不必一定要这样做,但强烈建议您遵循Helm图表最佳做法 。

一旦完成,就可以成功运行helm lint :

$ helm lint terracotta/ ==> Linting terracotta/ Lint OK 1 chart(s) linted, no failures

而且您还可以从源代码安装头盔图表:

$ helm install terracotta/

然后,您就可以与世界分享您的Helm图表,并使用Helm存储库进行分发

在Github Pages上托管Helm存储库

好吧,如果您不希望或无法将Helm图表纳入策划的Helm图表中 ,您是否可以使用专用软件托管Helm图表?

当然可以,实际上您几乎没有什么选择: ChartMuseum是一个开放源代码的Helm存储库,但也许您已经在组织Artifactory及其Helm存储库功能中运行 ,或者Nexus 3及其Helm插件运行,或者您已经有Quay的订阅.io 。

其实只要你能

  • 运行helm package . (将图表打包到tarball中),然后
  • 运行helm repo index . (顺便说一下,生成index.yaml,不需要安装Tiller甚至不需要运行Kubernetes集群,cli可以在本地执行这些命令)
  • 将这些文件放在静态网页服务器(例如Apache 2或Ngninx)上,

你很厉害 !

就是说,如果您的头盔图表已经存在于Github上 ,并且您已经有一个持续集成提供程序(您自己的Jenkins实例或免费的Microsoft Azure Pipelines),那么您只需要一个脚本就可以自动化面向公众的头盔存储发布Github页面!

使用Azure管道

一旦将Azure管道配置为“监视”您的Github存储库以应用azure-pipelines.yaml中描述的任务,那么您只需要正确地拥有这个azure-pipelines.yaml文件即可!

helm搭建elk helm github_docker

使用正确的azure-pipelines.yaml作业定义文件在Azure Pipelines中设置新的构建管道

这是此文件的一些说明(我将让读者适应Jenkins或任何其他可以运行Docker容器的CI); 特别感谢我的同事Alexander帮助我引导了该集成:

YAML

pool:
  vmImage: 'ubuntu-latest'

我们将使用基于Ubuntu的«worker»; 到目前为止,一切都很好。

YAML

steps:
- task: YodLabs.VariableTasks.SetVariablesWithCredentials.SetVariablesWithCredentials@0
  displayName: 'Github auth'
  inputs:
    ConnectionName: gh-push-tc-org
    userNameVarName: U
    passwordVarName: P

第一步是对Github进行身份验证:这将允许CI机器人提交并推送到Github页面分支; 需要在您的Git存储库“设置”中配置Azure管道才能具有写访问权限。 提供的用户名和密码只是填充。

helm搭建elk helm github_helm搭建elk_02

将Azure Pipelines或任何其他CI的访问权限授予您的Github存储库

YAML

- task: Docker@0
  displayName: 'Generate helm package'
  inputs:
    containerRegistryType: 'Container Registry'
    action: 'Run an image'
    imageName: 'alpine/helm'
    volumes: |
      $(build.sourcesDirectory)/kubernetes/helm/terracotta:/apps
    containerCommand: 'package .'
    detached: false

在此步骤中,我们在Docker容器中运行以下命令: helm package . 在我们的图表目录中(通过卷安装),以生成将包含我们的Helm图表的tarball。

我们可以下载helm cli并直接将其作为bash命令运行; 但是使用装有头盔cli的容器更容易。 (感谢亚历山大的主意)

YAML

- task: Docker@0<br />  displayName: 'Download existing index.yaml'<br />  inputs:<br />    containerRegistryType: 'Container Registry'<br />    action: 'Run an image'<br />    imageName: 'alpine:latest'<br />    volumes: |<br />      $(build.sourcesDirectory)/kubernetes/helm/terracotta:/apps<br />    containerCommand: 'wget -P /apps/ https://softwareag.github.io/terracotta-cloud/index.yaml'<br />detached: false

在此步骤中,我们在Docker容器中运行以下命令: wget -P /apps/ https://softwareag.github.io/terracotta-cloud/index.yaml (通过卷安装),以获取最新版本的存储库索引

有了这个索引,我们就可以在下一步中将新图表添加到该索引中(例如:如果图表版本已更改,我们希望我们的仓库可以引用新版本以及旧版本;如果我们不执行此步骤,则回购将仅包含最新图表…如此之多以确保连续性)

YAML

- task: Docker@0
  displayName: 'Generate helm index.yaml'
  inputs:
    containerRegistryType: 'Container Registry'
    action: 'Run an image'
    imageName: 'alpine/helm'
    volumes: |
      $(build.sourcesDirectory)/kubernetes/helm/terracotta:/apps
    containerCommand: 'repo index <span class="pl-s">--merge index.yaml </span> .'
detached: false

在此步骤中,我们在Docker容器中运行以下命令: helm repo index . 在我们的图表目录中(通过卷安装),以生成index.yaml,该链接将链接到tarball的Helm图表(并且我们使用–merge来确保我们保留对先前版本的引用,以防图表版本已更改)

YAML

- bash: |
    # setup Github Pages branch and repo to push to
    gh_url="https://$U:$P@github.com/SoftwareAG/terracotta-cloud.git"
    gh_branch=gh-pages
    gh_source="#${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}"
    
    # setup git username and email; auth was done in a previous task 
    git config --local user.name "autogen"
    git config --local user.email "autogen-noreply@no-reply.softwareag.com"
    # only keep files that were generated previously : index.yaml and a .tgz archive
    mv $(build.sourcesDirectory)/kubernetes/helm/terracotta/*.* ./
    git status
    git checkout -f gh-pages
    git add index.yaml *.tgz
    git status
    git commit -m "Update repository with latest helm chart from ${gh_source} ${COMMIT}"
    git push $gh_url $gh_branch
displayName: 'Commit Helm Charts'

最后,是时候提交更改并将其推送到Github页面了。

这些页面已配置为在url下提供分支gh_pages : https : gh_pages ; 但您可以使用自己的DNS域。

确保使用README.md调整Helm存储库的外观

在撰写本文时,提供了一个成功构建的示例。

非常感谢我的同事Akom

翻译自: https://www.javacodegeeks.com/2019/07/github-pages-helm-charts-repository.html

helm 3 github