k8s/helm/apps/chartmuseum/install.sh

40 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
CHART_VERSION=3.9.2
NAMESPACE=chartmuseum
VAULT_AUTH_NAMESPACE="k8s-teapot"
helm repo add chartmuseum https://chartmuseum.github.io/charts
helm repo update
cat << EOH > chartmuseum.hcl
path "kv/data/chartmuseum" {
capabilities = ["read"]
}
EOH
vault policy write chartmuseum chartmuseum.hcl
rm chartmuseum.hcl
kubectl create ns chartmuseum
kubectl create serviceaccount -n ${NAMESPACE} chartmuseum
HOST_IP=$(ip addr show eth0 | grep -Po 'inet \K[\d.]+')
TOKEN="$(kubectl get secret serviceaccounttoken -n chartmuseum -o go-template='{{ .data.token }}' | base64 -d)"
vault write auth/${VAULT_AUTH_NAMESPACE}/role/chartmuseum \
bound_service_account_names=chartmuseum \
bound_service_account_namespaces=chartmuseum \
policies=chartmuseum \
ttl=24h
vault write auth/${VAULT_AUTH_NAMESPACE}/login role=chartmuseum jwt=${TOKEN} iss=https://${HOST_IP}:6443
kubectl apply -n ${NAMESPACE} -f external-secrets.yaml
kubectl apply -n ${NAMESPACE} -f pvc.yaml
helm upgrade --install \
chartmuseum \
chartmuseum/chartmuseum \
-f values.yaml \
-n ${NAMESPACE} \
--version ${CHART_VERSION} \
--cleanup-on-fail