Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #142 from digitalrebar/helm-rook
Browse files Browse the repository at this point in the history
Update Helm Stage with features that enable Rook install
  • Loading branch information
galthaus authored Sep 13, 2018
2 parents e3baaaf + 4f6b983 commit 6f373db
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 19 deletions.
6 changes: 6 additions & 0 deletions krib/params/helm-charts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -65,6 +67,8 @@ Schema:
type: "string"
namespace:
type: "string"
repo:
type: "string"
params:
type: "object"
default: {}
Expand All @@ -81,6 +85,8 @@ Schema:
wait:
type: "boolean"
default: false
templates:
type: object
kubectlbefore:
type: "array"
default: []
Expand Down
17 changes: 17 additions & 0 deletions krib/params/rook-data-dir-host-path.yaml
Original file line number Diff line number Diff line change
@@ -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"
30 changes: 30 additions & 0 deletions krib/profiles/helm-reference.yaml
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 0 additions & 19 deletions krib/profiles/krib-istio-reference.yaml

This file was deleted.

72 changes: 72 additions & 0 deletions krib/templates/helm-rook.cfg.tmpl
Original file line number Diff line number Diff line change
@@ -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"
17 changes: 17 additions & 0 deletions krib/templates/krib-helm.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -91,6 +107,7 @@ if [[ $MASTER_INDEX != notme ]] ; then
{{end}}

{{range $index, $after := $chart.kubectlafter}}
echo "running kubectl {{$after}} ({{$index}})"
kubectl {{$after}}
{{end}}

Expand Down

0 comments on commit 6f373db

Please sign in to comment.