diff --git a/krib/params/helm-charts.yaml b/krib/params/helm-charts.yaml index 411bab29..2c89b28a 100644 --- a/krib/params/helm-charts.yaml +++ b/krib/params/helm-charts.yaml @@ -24,6 +24,8 @@ Documentation: | * prekubectl (optional) array of kubectl [request] commands to run before the helm install * postkubectl (optional) array of kubectl [request] commands to run after the helm install * targz (optional) provides a location for a tar.gz file containing charts to install. Path is relative. + * templates (optional) map of DRP templates keyed to the desired names (must be uploaded!) to render before doing other work. + * repo (optional) adds the requested repo to the helm using `helm repo add` before installing helm. syntax is `[repo name] [repo path]`. example: @@ -65,6 +67,8 @@ Schema: type: "string" namespace: type: "string" + repo: + type: "string" params: type: "object" default: {} @@ -81,6 +85,8 @@ Schema: wait: type: "boolean" default: false + templates: + type: object kubectlbefore: type: "array" default: [] diff --git a/krib/params/rook-data-dir-host-path.yaml b/krib/params/rook-data-dir-host-path.yaml new file mode 100644 index 00000000..4d7578d4 --- /dev/null +++ b/krib/params/rook-data-dir-host-path.yaml @@ -0,0 +1,17 @@ +--- +Name: "rook/data-dir-host-path" +Description: "Location of Ceph Storage" +Documentation: | + This should be set to match the desired location + for Ceph storage. + + Default: /docker + + In future versions, this should be calculated or inferred based on the system inventory +Schema: + type: "string" + default: "/docker" +Meta: + color: "blue" + icon: "chess rock" + title: "Community Content" diff --git a/krib/profiles/helm-reference.yaml b/krib/profiles/helm-reference.yaml new file mode 100644 index 00000000..d8c10d88 --- /dev/null +++ b/krib/profiles/helm-reference.yaml @@ -0,0 +1,30 @@ +--- +Name: helm-reference +Description: Reference Helm Profiles (Istio, Rook, etc) +Documentation: | + DO NOT USE THIS PROFILE! + Copy the contents of the helm/charts param into the Cluster! +Meta: + color: blue + icon: grid layout + title: Community Content +Params: + helm/charts: + - chart: "stable/mysql" + name: "mysql" + - chart: "istio-1.0.1/install/kubernetes/helm/istio" + name: "istio" + targz: https://github.com/istio/istio/releases/download/1.0.1/istio-1.0.1-linux.tar.gz + namespace: "istio-system" + wait: true + params: + set: "sidecarInjectorWebhook.enabled=true" + - chart: "rook-ceph" + name: "rook-ceph" + namespace: "rook-ceph-system" + wait: true + targz: "https://charts.rook.io/beta/rook-ceph-v0.8.1.tgz" + templates: + cluster: helm-rook.cfg.tmpl + kubectlafter: + - "create -f cluster.yaml" diff --git a/krib/profiles/krib-istio-reference.yaml b/krib/profiles/krib-istio-reference.yaml deleted file mode 100644 index e620249f..00000000 --- a/krib/profiles/krib-istio-reference.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -Name: krib-istio-reference -Description: Reference Istio Helm Profiles -Documentation: | - DO NOT USE THIS PROFILE! - Copy the contents of the helm/charts param into the Cluster! -Meta: - color: blue - icon: grid layout - title: Community Content -Params: - helm/charts: - - chart: istio-1.0.1/install/kubernetes/helm/istio - name: "istio" - targz: https://github.com/istio/istio/releases/download/1.0.1/istio-1.0.1-linux.tar.gz - namespace: "istio-system" - wait: true - params: - set: "sidecarInjectorWebhook.enabled=true" diff --git a/krib/templates/helm-rook.cfg.tmpl b/krib/templates/helm-rook.cfg.tmpl new file mode 100644 index 00000000..be1258c8 --- /dev/null +++ b/krib/templates/helm-rook.cfg.tmpl @@ -0,0 +1,72 @@ +# Rook Yaml - See https://rook.io/docs/rook/master/ceph-quickstart.html +# This example first defines some necessary namespace and RBAC security objects. +# The actual Ceph Cluster CRD example can be found at the bottom of this example. +apiVersion: v1 +kind: Namespace +metadata: + name: rook-ceph +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: rook-ceph-cluster + namespace: rook-ceph +--- +kind: Role +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: rook-ceph-cluster + namespace: rook-ceph +rules: +- apiGroups: [""] + resources: ["configmaps"] + verbs: [ "get", "list", "watch", "create", "update", "delete" ] +--- +# Allow the operator to create resources in this cluster's namespace +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: rook-ceph-cluster-mgmt + namespace: rook-ceph +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: rook-ceph-cluster-mgmt +subjects: +- kind: ServiceAccount + name: rook-ceph-system + namespace: rook-ceph-system +--- +# Allow the pods in this namespace to work with configmaps +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: rook-ceph-cluster + namespace: rook-ceph +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: rook-ceph-cluster +subjects: +- kind: ServiceAccount + name: rook-ceph-cluster + namespace: rook-ceph +--- +################################################################################# +# The Ceph Cluster CRD example +################################################################################# +apiVersion: ceph.rook.io/v1beta1 +kind: Cluster +metadata: + name: rook-ceph + namespace: rook-ceph +spec: + dataDirHostPath: {{.Param "rook/data-dir-host-path"}} + dashboard: + enabled: true + storage: + useAllNodes: true + useAllDevices: false + config: + databaseSizeMB: "1024" + journalSizeMB: "1024" \ No newline at end of file diff --git a/krib/templates/krib-helm.sh.tmpl b/krib/templates/krib-helm.sh.tmpl index b7d0dc83..fcfb44f9 100644 --- a/krib/templates/krib-helm.sh.tmpl +++ b/krib/templates/krib-helm.sh.tmpl @@ -34,19 +34,35 @@ if [[ $MASTER_INDEX != notme ]] ; then fi echo "Running Helm Install for all helm/charts" + {{$render := .}} {{range $index, $chart := .Param "helm/charts"}} echo "Installing {{$chart.name}} (from {{$chart.chart}})..." if [[ -z $(helm list {{$chart.name}}) ]] ; then + {{ range $name, $template := $chart.templates }} + echo "expanding template {{$template}} as {{$name}}.yaml" + cat > {{$name}}.yaml << EOF +{{ $render.CallTemplate $template $render }} +EOF + {{end}} + {{range $index, $before := $chart.kubectlbefore}} + echo "running kubectl {{$before}} ({{$index}})" kubectl {{$before}} {{end}} {{if $chart.targz}} + echo "retrieving chart from {{$chart.targz}}" curl -L "{{$chart.targz}}" | tar xz {{end}} + {{if $chart.repo}} + echo "adding chart repo {{$chart.repo}}" + helm repo add {{$chart.repo}} + helm init + {{end}} + helm install {{$chart.chart}} --name {{$chart.name}} \ {{if $chart.namespace}} --namespace {{$chart.namespace}}{{end}} \ {{range $param, $value := $chart.params}} --{{$param}} {{$value}}{{end}} @@ -91,6 +107,7 @@ if [[ $MASTER_INDEX != notme ]] ; then {{end}} {{range $index, $after := $chart.kubectlafter}} + echo "running kubectl {{$after}} ({{$index}})" kubectl {{$after}} {{end}}