在 k8s 集群中创建 chartmuseum 命名空间,编写 yaml 文件在 chartmuseum 命名空间中 使用 chartmuseum:latest 镜像创建本地私有 chart 仓库,设置其仓库存储目录为宿主机的 /data/charts 目录。编写 service.yaml 文件,为 chart 私有仓库创建 Service 访问策略,定义其 为 ClusterIP 访问模式。编写完成后启动 chartmuseum 服务。
[root@k8s-master-node1 ~]# cat chartmuseum.yaml
apiVersion: v1
kind: Pod
metadata:
name: chartmuseum
namespace: chartmuseum
labels:
app: chartmuseum
spec:
containers:
- image: chartmuseum/chartmuseum:latest
name: chartmuseum
ports:
- containerPort: 8080
protocol: TCP
env:
- name: DEBUG
value: "1"
- name: STORAGE
value: local
- name: STORAGE_LOCAL_ROOTDIR
value: /charts
volumeMounts:
- name: chartspath
mountPath: /charts
volumes:
- name: chartspath
hostPath:
path: /data/charts
[root@k8s-master-node1 ~]# cat service.yaml
apiVersion: v1
kind: Service
metadata:
name: chartmuseum
namespace: chartmuseum
labels:
app: chartmuseum
spec:
selector:
app: chartmuseum
type: ClusterIP
ports:
- port: 8080
protocol: TCP
targetPort: 8080
[root@k8s-master-node1 ~]# kubectl apply -f chartmuseum.yaml service.yaml
[root@k8s-master-node1 ~]# kubectl get pod,svc -n chartmuseum
NAME READY STATUS RESTARTS AGE
pod/chartmuseum 1/1 Running 0 4m49s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/chartmuseum ClusterIP 10.96.148.242 <none> 8080/TCP 4m49s