当前位置: 首页 > 工具软件 > chartmuseum > 使用案例 >

ChartMuseum的安装教程和基本配置

闻人哲茂
2023-12-01

一. 安装docker-compose

curl -L https://github.com/docker/compose/releases/download/1.29.0/docker-compose-uname -s-uname -m -o /usr/local/bin/docker-compose

上条命令自动安装版本为1.29.0 的docker-compose

二. 安装chartmuseum 和chartmuseumui

mkdir /opt/chartmuseum
cd /opt/chartmuseum/
vim docker-compose.yaml
version: '3.0'
services:
   ui:
     #build: ./
     image: idobry/chartmuseumui:latest
     environment:
       CHART_MUSESUM_URL: http://chartmuseum:8080
     ports:
       - 1999:8080
     container_name: chartui
   chartmuseum:
     image: chartmuseum/chartmuseum:latest
     volumes:
     - ./charts:/charts
     restart: always
     environment:
       PORT: 8080
       STORAGE: local
       STORAGE_LOCAL_ROOTDIR: /charts
     ports:
       - 8089:8080
     container_name: chartmuseum

三. 可能会出现的问题

     volumes:
     - ./charts:/charts

就上面这docker挂载没有权限,进入docker里看/charts 目录是什么用户和组,然后退出容器就给宿主机./charts 权限。

四.API

curl -X GET "chart=@mychart-0.1.0.tgz" http://localhost:8089/api/org1/repoa/charts 

Helm Chart Repository

GET /index.yaml - retrieved when you run helm repo add chartmuseum http://localhost:8089/
GET /charts/mychart-0.1.0.tgz - retrieved when you run helm install chartmuseum/mychart
GET /charts/mychart-0.1.0.tgz.prov - retrieved when you run helm install with the --verify flag

Chart Manipulation

POST /api/charts - upload a new chart version
POST /api/prov - upload a new provenance file
DELETE /api/charts/<name>/<version> - delete a chart version (and corresponding provenance file)
GET /api/charts - list all charts
GET /api/charts/<name> - list all versions of a chart
GET /api/charts/<name>/<version> - describe a chart version
GET /api/charts/<name>/<version>/templates - get chart template
GET /api/charts/<name>/<version>/values - get chart values
HEAD /api/charts/<name> - check if chart exists (any versions)
HEAD /api/charts/<name>/<version> - check if chart version exists

Server Info

GET / - HTML welcome page
GET /info - returns current ChartMuseum version
GET /health - returns 200 OK

五 安装helm-push插件

https://github.com/chartmuseum/helm-push
下载 linux可执行文件 https://github.com/chartmuseum/helm-push/releases/download/v0.10.2/helm-push_0.10.2_linux_amd64.tar.gz
解压缩

tar -zxvf helm-push_0.10.2_linux_amd64.tar.gz 
[root@node-194 helm-push]# ls
bin  LICENSE  plugin.yaml

### /root/.local/share/helm/plugins/helm-push/bin/helm-cm-push
cp /home/helm-push /root/.local/share/helm/plugins/

[root@node-194 helm-push]# helm env
HELM_BIN="helm"
HELM_CACHE_HOME="/root/.cache/helm"
HELM_CONFIG_HOME="/root/.config/helm"
HELM_DATA_HOME="/root/.local/share/helm"
HELM_DEBUG="false"
HELM_KUBEAPISERVER=""
HELM_KUBEASGROUPS=""
HELM_KUBEASUSER=""
HELM_KUBECAFILE=""
HELM_KUBECONTEXT=""
HELM_KUBETOKEN=""
HELM_MAX_HISTORY="10"
HELM_NAMESPACE="default"
HELM_PLUGINS="/root/.local/share/helm/plugins"
HELM_REGISTRY_CONFIG="/root/.config/helm/registry.json"
HELM_REPOSITORY_CACHE="/root/.cache/helm/repository"
HELM_REPOSITORY_CONFIG="/root/.config/helm/repositories.yaml"

验证

[root@node-194 helm-push]# helm cm-push --help
Helm plugin to push chart package to ChartMuseum

Examples:

  $ helm cm-push mychart-0.1.0.tgz chartmuseum       # push .tgz from "helm package"
  $ helm cm-push . chartmuseum                       # package and push chart directory
  $ helm cm-push . --version="1.2.3" chartmuseum     # override version in Chart.yaml
  $ helm cm-push . https://my.chart.repo.com         # push directly to chart repo URL

Usage:
  helm cm-push [flags]

Flags:
      --access-token string             Send token in Authorization header [$HELM_REPO_ACCESS_TOKEN]
  -a, --app-version string              Override app version pre-push
      --auth-header string              Alternative header to use for token auth [$HELM_REPO_AUTH_HEADER]
      --ca-file string                  Verify certificates of HTTPS-enabled servers using this CA bundle [$HELM_REPO_CA_FILE]
      --cert-file string                Identify HTTPS client using this SSL certificate file [$HELM_REPO_CERT_FILE]
      --check-helm-version              outputs either "2" or "3" indicating the current Helm major version
      --context-path string             ChartMuseum context path [$HELM_REPO_CONTEXT_PATH]
      --debug                           Enable verbose output
  -d, --dependency-update               update dependencies from "requirements.yaml" to dir "charts/" before packaging
  -f, --force                           Force upload even if chart version exists
  -h, --help                            help for helm
      --home string                     Location of your Helm config. Overrides $HELM_HOME (default "/root/.helm")
      --host string                     Address of Tiller. Overrides $HELM_HOST
      --insecure                        Connect to server with an insecure way by skipping certificate verification [$HELM_REPO_INSECURE]
      --key-file string                 Identify HTTPS client using this SSL key file [$HELM_REPO_KEY_FILE]
      --keyring string                  location of a public keyring (default "/root/.gnupg/pubring.gpg")
      --kube-context string             Name of the kubeconfig context to use
      --kubeconfig string               Absolute path of the kubeconfig file to be used
  -p, --password string                 Override HTTP basic auth password [$HELM_REPO_PASSWORD]
      --tiller-connection-timeout int   The duration (in seconds) Helm will wait to establish a connection to Tiller (default 300)
      --tiller-namespace string         Namespace of Tiller (default "kube-system")
  -t, --timeout int                     The duration (in seconds) Helm will wait to get response from chartmuseum (default 30)
  -u, --username string                 Override HTTP basic auth username [$HELM_REPO_USERNAME]
  -v, --version string                  Override chart version pre-push

上传chart

[root@node-194 chart]# helm repo add chartmuseum http://localhost:8089
"chartmuseum" has been added to your repositories
[root@node-194 chart]# helm repo list
NAME            URL                  
chartmuseum     http://localhost:8089
[root@node-194 chart]# helm cm-push mysql
mysql/           mysql-1.6.9.tgz  
[root@node-194 chart]# helm cm-push mysql-1.6.9.tgz chartmuseum
Pushing mysql-1.6.9.tgz to chartmuseum...
Error: 500: open /charts/mysql-1.6.9.tgz: permission denied
Usage:
  helm cm-push [flags]

Flags:
      --access-token string             Send token in Authorization header [$HELM_REPO_ACCESS_TOKEN]
  -a, --app-version string              Override app version pre-push
      --auth-header string              Alternative header to use for token auth [$HELM_REPO_AUTH_HEADER]
      --ca-file string                  Verify certificates of HTTPS-enabled servers using this CA bundle [$HELM_REPO_CA_FILE]
      --cert-file string                Identify HTTPS client using this SSL certificate file [$HELM_REPO_CERT_FILE]
      --check-helm-version              outputs either "2" or "3" indicating the current Helm major version
      --context-path string             ChartMuseum context path [$HELM_REPO_CONTEXT_PATH]
      --debug                           Enable verbose output
  -d, --dependency-update               update dependencies from "requirements.yaml" to dir "charts/" before packaging
  -f, --force                           Force upload even if chart version exists
  -h, --help                            help for helm
      --home string                     Location of your Helm config. Overrides $HELM_HOME (default "/root/.helm")
      --host string                     Address of Tiller. Overrides $HELM_HOST
      --insecure                        Connect to server with an insecure way by skipping certificate verification [$HELM_REPO_INSECURE]
      --key-file string                 Identify HTTPS client using this SSL key file [$HELM_REPO_KEY_FILE]
      --keyring string                  location of a public keyring (default "/root/.gnupg/pubring.gpg")
      --kube-context string             Name of the kubeconfig context to use
      --kubeconfig string               Absolute path of the kubeconfig file to be used
  -p, --password string                 Override HTTP basic auth password [$HELM_REPO_PASSWORD]
      --tiller-connection-timeout int   The duration (in seconds) Helm will wait to establish a connection to Tiller (default 300)
      --tiller-namespace string         Namespace of Tiller (default "kube-system")
  -t, --timeout int                     The duration (in seconds) Helm will wait to get response from chartmuseum (default 30)
  -u, --username string                 Override HTTP basic auth username [$HELM_REPO_USERNAME]
  -v, --version string                  Override chart version pre-push

原因为安装chartmuseum时指定的存储目录权限不够,需要给charts目录授权

chmod 777 -R charts 
[root@node-194 chart]# helm cm-push -f mysql-1.6.9.tgz chartmuseum
Pushing mysql-1.6.9.tgz to chartmuseum...
Done.
 类似资料: