...
This instruction is valid for running both in a local kubernetes and in a kubernetes ccluster
If running in a local kubernetes, set the env KUBE_HOST to localhost
Code Block | ||||
---|---|---|---|---|
| ||||
$ KUBE_HOST="localhost" |
If running in a kubernetes cluster, set the env KUBE_HOST to the ip of the cluster. NotCheck if the nonrtric names space exists. If not, create the namespace
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$ kubectl get ns nonrtric
$ kubectl create ns nonrtric |
...
cluster-info
Kubernetes master is running at https://10.2.0.103:6443
$ KUBE_HOST=10.2.0.103 |
Check if the nonrtric names space exists. If not, create the namespace
Code Block | ||||
---|---|---|---|---|
| ||||
$ kubectl applyget ns nonrtric $ kubectl create ns nonrtric |
Start the chartmuseum service and pod
Code Block | ||||
---|---|---|---|---|
| ||||
$ kubectl apply -f kube--f kube-cm.yaml |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
apiVersion: v1 kind: Service metadata: name: chartrepo namespace: nonrtric labels: run: chartrepo spec: type: NodePort ports: - port: 8080 targetPort: 8080 protocol: TCP name: http selector: run: chartrepo --- apiVersion: v1 kind: Pod metadata: name: chartrepo namespace: nonrtric labels: run: chartrepo spec: securityContext: runAsUser: 0 containers: - name: chartrepo image: ghcr.io/helm/chartmuseum:v0.13.1 imagePullPolicy: Always ports: - name: http containerPort: 8080 env: - name: DEBUG value: "1" - name: STORAGE value: "local" - name: STORAGE_LOCAL_ROOTDIR value: "/var/chartrepo/charts" - name: DISABLE_API value: "false" volumeMounts: - mountPath: /var/chartrepo/charts name: chartrepo-pv volumes: - name: chartrepo-pv persistentVolumeClaim: claimName: chartrepo-pvc --- apiVersion: v1 kind: PersistentVolume metadata: name: chartrepo-pv annotations: pv.beta.kubernetes.io/gid: "999" labels: run: chartrepo spec: storageClassName: chartrepo-standard capacity: storage: 10Mi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Delete hostPath: path: "/tmp/chartrepo" --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: chartrepo-pvc namespace: nonrtric labels: run: chartrepo spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Mi storageClassName: chartrepo-standard volumeMode: Filesystem |
kubectl apply f cm/svc app.yaml
Find the nodeport of the service
...
Add the chart, created in the section 'Create helm for test', to the chartmuseum repo. The node port of the chartmuseum service is obtained and env var CM_PORT is assigned that port number.
Code Block | ||||
---|---|---|---|---|
| ||||
$ CM_PORT=$(kubectl get svc chartrepo -n nonrtric -o jsonpath='{...ports[?(@.name=="'http'")].nodePort}' |
...
Add the chart to the repo
...
) $ curl --data-binary |
...
@simple-app-0.1.0.tgz |
...
-X POST http:// |
...
$KUBE_HOST:$CM_PORT/api/charts |
...
{"saved":true} |
Create a
If running in kubernetes cluster
Add the service account for the helm manager. Note that this uses the 'This example service account bind to the "cluster-admin' " role which has wide permission. This should only be used for test.kubectrl apply f normally has full permissions to the add/change/read/delete any kubernetes object. It is advisable to bind the service account to a ClusterRole with less permissions if desired.
Code Block | ||||
---|---|---|---|---|
| ||||
$ kubectl apply -f helm-manager-sa. |
...
yaml
serviceaccount/helm-manager-sa created
clusterrolebinding.rbac.authorization.k8s.io/helm-manager-sa-clusterrolebinding created |
Edit the svc-app.yaml, set 'service-acccount-name' to helm-manager-sa
...