|
| 1 | +import { Plugin, } from './plugin'; |
| 2 | +import { IPlugin, IPluginFormFields } from './plugin.interface'; |
| 3 | + |
| 4 | + |
| 5 | +// Classname must be same as the CRD's Name |
| 6 | +export class Elasticsearch extends Plugin implements IPlugin { |
| 7 | + public id: string = 'Elasticsearch'; //same as operator name |
| 8 | + public displayName = 'Elasticsearch'; |
| 9 | + public description: string = |
| 10 | + 'Elasticsearch is a distributed, RESTful search and analytics engine capable of addressing a growing number of use cases.'; |
| 11 | + public icon = '/img/addons/elasticsearch.svg'; |
| 12 | + public install: string = 'kubectl create -f https://download.elastic.co/downloads/eck/3.1.0/crds.yaml && kubectl apply -f https://download.elastic.co/downloads/eck/3.1.0/operator.yaml'; |
| 13 | + public url = |
| 14 | + 'https://artifacthub.io/packages/olm/community-operators/elastic-cloud-eck'; |
| 15 | + public docs = [ |
| 16 | + { |
| 17 | + title: 'Kubero Docs', |
| 18 | + url: '', |
| 19 | + }, |
| 20 | + ]; |
| 21 | + public artifact_url = |
| 22 | + 'https://artifacthub.io/api/v1/packages/olm/kubero/kubero-operator'; |
| 23 | + public beta: boolean = false; |
| 24 | + public deprecated: boolean = false; |
| 25 | + |
| 26 | + public formfields: { [key: string]: IPluginFormFields } = { |
| 27 | + 'Elasticsearch.metadata.name': { |
| 28 | + type: 'text', |
| 29 | + label: 'Elasticsearch Instance Name', |
| 30 | + name: 'metadata.name', |
| 31 | + required: true, |
| 32 | + default: 'elasticsearch', |
| 33 | + description: 'The name of the Elasticsearch instance', |
| 34 | + }, |
| 35 | + 'Elasticsearch.spec.version': { |
| 36 | + type: 'combobox', |
| 37 | + label: 'Version/Tag', |
| 38 | + options: ['9.1.0'], // TODO - load this dynamically |
| 39 | + name: 'spec.version', |
| 40 | + required: true, |
| 41 | + default: '9.1.0', |
| 42 | + description: 'Version of the Elasticsearch version to use', |
| 43 | + }, |
| 44 | + 'Elasticsearch.spec.nodeSets[0].count': { |
| 45 | + type: 'number', |
| 46 | + label: 'Master Instances', |
| 47 | + name: 'spec.nodeSets[0].count', |
| 48 | + default: 3, |
| 49 | + required: true, |
| 50 | + description: 'Number of Elasticsearch instances to create', |
| 51 | + }, |
| 52 | + 'Elasticsearch.spec.nodeSets[0].volumeClaimTemplates[0].spec.storageClassName': { |
| 53 | + type: 'select-storageclass', |
| 54 | + label: 'Master Storage Class', |
| 55 | + // options: ['default', 'local-path', 'nfs-client', 'rook-ceph-block'], |
| 56 | + name: 'spec.nodeSets[0].volumeClaimTemplates[0].spec.storageClassName', |
| 57 | + default: 'default', |
| 58 | + required: true, |
| 59 | + }, |
| 60 | + 'Elasticsearch.spec.nodeSets[0].volumeClaimTemplates[0].spec.resources.requests.storage': { |
| 61 | + type: 'text', |
| 62 | + label: 'Master Storage Size*', |
| 63 | + name: 'spec.nodeSets[0].volumeClaimTemplates[0].spec.resources.requests.storage', |
| 64 | + default: '10Gi', |
| 65 | + required: true, |
| 66 | + description: 'Size of the storage', |
| 67 | + }, |
| 68 | + 'Elasticsearch.spec.nodeSets[1].count': { |
| 69 | + type: 'number', |
| 70 | + label: 'Data Node Instances', |
| 71 | + name: 'spec.nodeSets[1].count', |
| 72 | + default: 3, |
| 73 | + required: true, |
| 74 | + description: 'Number of Elasticsearch instances to create', |
| 75 | + }, |
| 76 | + 'Elasticsearch.spec.nodeSets[1].volumeClaimTemplates[0].spec.storageClassName': { |
| 77 | + type: 'select-storageclass', |
| 78 | + label: 'Data Node Storage Class', |
| 79 | + // options: ['default', 'local-path', 'nfs-client', 'rook-ceph-block'], |
| 80 | + name: 'spec.nodeSets[1].volumeClaimTemplates[0].spec.storageClassName', |
| 81 | + default: 'default', |
| 82 | + required: true, |
| 83 | + }, |
| 84 | + 'Elasticsearch.spec.nodeSets[1].volumeClaimTemplates[0].spec.resources.requests.storage': { |
| 85 | + type: 'text', |
| 86 | + label: 'Data Node Storage Size*', |
| 87 | + name: 'spec.nodeSets[1].volumeClaimTemplates[0].spec.resources.requests.storage', |
| 88 | + default: '10Gi', |
| 89 | + required: true, |
| 90 | + description: 'Size of the storage', |
| 91 | + }, |
| 92 | + }; |
| 93 | + |
| 94 | + public env: any[] = []; |
| 95 | + |
| 96 | + // https://www.elastic.co/docs/deploy-manage/deploy/cloud-on-k8s/nodes-orchestration |
| 97 | + public resourceDefinitions: object = { |
| 98 | + Elasticsearch: { |
| 99 | + apiVersion: "elasticsearch.k8s.elastic.co/v1", |
| 100 | + kind: "Elasticsearch", |
| 101 | + metadata: { |
| 102 | + name: "elasticsearch-sample" |
| 103 | + }, |
| 104 | + spec: { |
| 105 | + version: "9.1.0", |
| 106 | + nodeSets: [ |
| 107 | + { |
| 108 | + name: "master-nodes", |
| 109 | + count: 3, |
| 110 | + config: { |
| 111 | + node: { |
| 112 | + roles: [ |
| 113 | + "master" |
| 114 | + ], |
| 115 | + attr: { |
| 116 | + attr_name: "attr_value" |
| 117 | + }, |
| 118 | + store: { |
| 119 | + allow_mmap: false |
| 120 | + } |
| 121 | + } |
| 122 | + }, |
| 123 | + podTemplate: { |
| 124 | + spec: { |
| 125 | + containers: [ |
| 126 | + { |
| 127 | + name: "elasticsearch", |
| 128 | + resources: { |
| 129 | + requests: { |
| 130 | + memory: "4Gi", |
| 131 | + cpu: 1 |
| 132 | + }, |
| 133 | + limits: { |
| 134 | + memory: "4Gi", |
| 135 | + cpu: 2 |
| 136 | + } |
| 137 | + } |
| 138 | + } |
| 139 | + ] |
| 140 | + } |
| 141 | + }, |
| 142 | + volumeClaimTemplates: [ |
| 143 | + { |
| 144 | + metadata: { |
| 145 | + name: "elasticsearch-data" |
| 146 | + }, |
| 147 | + spec: { |
| 148 | + accessModes: [ |
| 149 | + "ReadWriteOnce" |
| 150 | + ], |
| 151 | + resources: { |
| 152 | + requests: { |
| 153 | + storage: "8Gi" |
| 154 | + } |
| 155 | + }, |
| 156 | + storageClassName: "default" |
| 157 | + } |
| 158 | + } |
| 159 | + ] |
| 160 | + }, |
| 161 | + { |
| 162 | + name: "data-nodes", |
| 163 | + count: 3, |
| 164 | + config: { |
| 165 | + node: { |
| 166 | + roles: [ |
| 167 | + "data", |
| 168 | + "ingest", |
| 169 | + "ml" |
| 170 | + ], |
| 171 | + attr: { |
| 172 | + attr_name: "attr_value" |
| 173 | + }, |
| 174 | + store: { |
| 175 | + allow_mmap: false |
| 176 | + } |
| 177 | + } |
| 178 | + }, |
| 179 | + podTemplate: { |
| 180 | + spec: { |
| 181 | + containers: [ |
| 182 | + { |
| 183 | + name: "elasticsearch", |
| 184 | + resources: { |
| 185 | + requests: { |
| 186 | + memory: "4Gi", |
| 187 | + cpu: 1 |
| 188 | + }, |
| 189 | + limits: { |
| 190 | + memory: "4Gi", |
| 191 | + cpu: 2 |
| 192 | + } |
| 193 | + } |
| 194 | + } |
| 195 | + ] |
| 196 | + } |
| 197 | + }, |
| 198 | + volumeClaimTemplates: [ |
| 199 | + { |
| 200 | + metadata: { |
| 201 | + name: "elasticsearch-data" |
| 202 | + }, |
| 203 | + spec: { |
| 204 | + accessModes: [ |
| 205 | + "ReadWriteOnce" |
| 206 | + ], |
| 207 | + resources: { |
| 208 | + requests: { |
| 209 | + storage: "8Gi" |
| 210 | + } |
| 211 | + }, |
| 212 | + storageClassName: "default" |
| 213 | + } |
| 214 | + } |
| 215 | + ] |
| 216 | + } |
| 217 | + ] |
| 218 | + } |
| 219 | + } |
| 220 | + } |
| 221 | + |
| 222 | + protected additionalResourceDefinitions: object = {}; |
| 223 | + |
| 224 | + constructor(availableOperators: any) { |
| 225 | + super(); |
| 226 | + super.init(availableOperators); |
| 227 | + } |
| 228 | +} |
0 commit comments