From b7fcc67f42535478735b5d0a920f19ae81d9c77d Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Mon, 1 Apr 2019 18:40:50 +0200 Subject: [PATCH] cluster/kube: start implementing rook --- cluster/kube/cluster.jsonnet | 3 + cluster/kube/lib/rook.libsonnet | 147 ++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 cluster/kube/lib/rook.libsonnet diff --git a/cluster/kube/cluster.jsonnet b/cluster/kube/cluster.jsonnet index 2f6da459..5275f661 100644 --- a/cluster/kube/cluster.jsonnet +++ b/cluster/kube/cluster.jsonnet @@ -6,6 +6,7 @@ local metrics = import "lib/metrics.libsonnet"; local calico = import "lib/calico.libsonnet"; local metallb = import "lib/metallb.libsonnet"; local nginx = import "lib/nginx.libsonnet"; +local rook = import "lib/rook.libsonnet"; local Cluster(fqdn) = { local cluster = self, @@ -60,6 +61,8 @@ local Cluster(fqdn) = { }, // Main nginx Ingress Controller nginx: nginx.Environment {}, + // Rook Ceph storage + rook: rook.Environment {}, }; diff --git a/cluster/kube/lib/rook.libsonnet b/cluster/kube/lib/rook.libsonnet new file mode 100644 index 00000000..7327500f --- /dev/null +++ b/cluster/kube/lib/rook.libsonnet @@ -0,0 +1,147 @@ +# Deploy Rook/Ceph Operator + +local kube = import "../../../kube/kube.libsonnet"; + +{ + Environment: { + local env = self, + local cfg = env.cfg, + cfg:: { + image: "rook/ceph:master", + namespace: "rook-ceph-system", + }, + + metadata:: { + namespace: cfg.namespace, + labels: { + "operator": "rook", + "storage-backend": "ceph", + }, + }, + + namespace: kube.Namespace(cfg.namespace), + + crds: { + cephclusters: kube.CustomResourceDefinition("ceph.rook.io", "v1", "CephCluster") { + spec+: { + additionalPrinterColumns: [ + { name: "DataDirHostPath", type: "string", description: "Directory used on the K8s nodes", JSONPath: ".spec.dataDirHostPath" }, + { name: "MonCount", type: "string", description: "Number of MONs", JSONPath: ".spec.mon.count" }, + { name: "Age", type: "date", JSONPath: ".metadata.creationTimestamp" }, + { name: "State", type: "string", description: "Current State", JSONPath: ".status.state" }, + ], + validation: { + # Converted from official operator YAML + "openAPIV3Schema": { + "properties": { + "spec": { + "properties": { + "cephVersion": { + "properties": { + "allowUnsupported": { + "type": "boolean" + }, + "image": { + "type": "string" + }, + "name": { + "pattern": "^(luminous|mimic|nautilus)$", + "type": "string" + } + } + }, + "dashboard": { + "properties": { + "enabled": { + "type": "boolean" + }, + "urlPrefix": { + "type": "string" + }, + "port": { + "type": "integer" + } + } + }, + "dataDirHostPath": { + "pattern": "^/(\\S+)", + "type": "string" + }, + "mon": { + "properties": { + "allowMultiplePerNode": { + "type": "boolean" + }, + "count": { + "maximum": 9, + "minimum": 1, + "type": "integer" + }, + "preferredCount": { + "maximum": 9, + "minimum": 0, + "type": "integer" + } + }, + "required": [ + "count" + ] + }, + "network": { + "properties": { + "hostNetwork": { + "type": "boolean" + } + } + }, + "storage": { + "properties": { + "nodes": { + "items": {}, + "type": "array" + }, + "useAllDevices": {}, + "useAllNodes": { + "type": "boolean" + } + } + } + }, + "required": [ + "mon" + ] + } + } + } + } + }, + }, + cephfilesystems: kube.CustomResourceDefinition("ceph.rook.io", "v1", "CephFilesystem") { + spec+: { + additionalPrinterColumns: [ + { name: "MdsCount", type: "string", description: "Number of MDs", JSONPath: ".spec.metadataServer.activeCount" }, + { name: "Age", type: "date", JSONPath: ".metadata.creationTimestamp" }, + ], + }, + }, + cephnfses: kube.CustomResourceDefinition("ceph.rook.io", "v1", "CephNFS") { + spec+: { + names+: { + shortNames: ["nfs"], + }, + }, + }, + cephobjectstores: kube.CustomResourceDefinition("ceph.rook.io", "v1", "CephObjectStore"), + cephobjectstoreusers: kube.CustomResourceDefinition("ceph.rook.io", "v1", "CephObjectStoreUser"), + cephblockpools: kube.CustomResourceDefinition("ceph.rook.io", "v1", "CephBlockPool"), + volumes: kube.CustomResourceDefinition("rook.io", "v1alpha2", "Volume") { + spec+: { + names+: { + shortNames: ["rv"], + }, + }, + }, + }, + + }, +}