0%

使用ChartMuseum搭建一个Helm Server

一、前置条件

  1. 配置好NFS Server
  2. 配置好NFS StorageClass

二、配置

配置PVC

1
2
3
4
5
6
7
8
9
10
11
12
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: helm-server-claim
namespace: infra
spec:
storageClassName: nfs
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi

配置Deployment

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
kind: Deployment
apiVersion: apps/v1
metadata:
name: helm-server
namespace: infra
spec:
replicas: 1
selector:
matchLabels:
app: helm-server
template:
metadata:
labels:
app: helm-server
spec:
containers:
- name: chartmuseum
image: chartmuseum/chartmuseum:latest
args:
- "--storage=local"
- "--storage-local-rootdir=/data"
- "--port=8080"
volumeMounts:
- name: nfs-pvc
mountPath: /data
volumes:
- name: nfs-pvc
persistentVolumeClaim:
claimName: helm-server-claim

Chartmuseum启动相关参数说明:

1
2
3
--storage=local  # 设置为本地存储,这里使用NFS挂载目录的方式,所以,对于Chartmuseum来说是无感知的
--storage-local-rootdir=/data # 设置/data目录为Chartmuseum的数据目录
--port=8080 # 指定端口为8080

配置Service

1
2
3
4
5
6
7
8
9
10
11
12
13
kind: Service
apiVersion: v1
metadata:
name: helm-server
namespace: infra
spec:
selector:
app: helm-server
type: ClusterIP
ports:
- name: default
port: 80
targetPort: 8080

三、测试

直接通过域名访问:

1
http://helm-server.infra.svc.cluster.local

配置helm

1
2
3
$ helm repo add development http://helm-server.infra.svc.cluster.local
$ helm update
$ helm search repo demo

上传helm

1
curl --data-binary '@demo-0.1.0.tgz' http://helm-server.infra.svc.cluster.local/api/charts

安装

1
helm install -f demo.yaml demo development/demo

四、参考资料

1
https://chartmuseum.com/docs/