Skip to content

Commit d805fc3

Browse files
Add support to elasticsearch addon
Signed-off-by: Florentin Dubois <florentin.dubois@clever-cloud.com>
1 parent 764188c commit d805fc3

File tree

7 files changed

+727
-9
lines changed

7 files changed

+727
-9
lines changed

deployments/kubernetes/v1.21.0/10-custom-resource-definition.yaml

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
name: v1
1919
schema:
2020
openAPIV3Schema:
21-
description: "Auto-generated derived type for PostgreSqlSpec via `CustomResource`"
21+
description: "Auto-generated derived type for Spec via `CustomResource`"
2222
properties:
2323
spec:
2424
properties:
@@ -90,7 +90,7 @@ spec:
9090
name: v1
9191
schema:
9292
openAPIV3Schema:
93-
description: "Auto-generated derived type for RedisSpec via `CustomResource`"
93+
description: "Auto-generated derived type for Spec via `CustomResource`"
9494
properties:
9595
spec:
9696
properties:
@@ -158,7 +158,7 @@ spec:
158158
name: v1
159159
schema:
160160
openAPIV3Schema:
161-
description: "Auto-generated derived type for MySqlSpec via `CustomResource`"
161+
description: "Auto-generated derived type for Spec via `CustomResource`"
162162
properties:
163163
spec:
164164
properties:
@@ -227,7 +227,7 @@ spec:
227227
name: v1
228228
schema:
229229
openAPIV3Schema:
230-
description: "Auto-generated derived type for MongoDbSpec via `CustomResource`"
230+
description: "Auto-generated derived type for Spec via `CustomResource`"
231231
properties:
232232
spec:
233233
properties:
@@ -296,7 +296,7 @@ spec:
296296
name: v1beta1
297297
schema:
298298
openAPIV3Schema:
299-
description: "Auto-generated derived type for PulsarSpec via `CustomResource`"
299+
description: "Auto-generated derived type for Spec via `CustomResource`"
300300
properties:
301301
spec:
302302
properties:
@@ -377,3 +377,78 @@ spec:
377377
storage: true
378378
subresources:
379379
status: {}
380+
---
381+
apiVersion: apiextensions.k8s.io/v1
382+
kind: CustomResourceDefinition
383+
metadata:
384+
name: elasticsearches.api.clever-cloud.com
385+
spec:
386+
group: api.clever-cloud.com
387+
names:
388+
categories: []
389+
kind: ElasticSearch
390+
plural: elasticsearches
391+
shortNames:
392+
- es
393+
singular: elasticsearch
394+
scope: Namespaced
395+
versions:
396+
- additionalPrinterColumns: []
397+
name: v1
398+
schema:
399+
openAPIV3Schema:
400+
description: "Auto-generated derived type for Spec via `CustomResource`"
401+
properties:
402+
spec:
403+
properties:
404+
instance:
405+
properties:
406+
plan:
407+
type: string
408+
region:
409+
type: string
410+
required:
411+
- plan
412+
- region
413+
type: object
414+
options:
415+
properties:
416+
apm:
417+
type: boolean
418+
encryption:
419+
type: boolean
420+
kibana:
421+
type: boolean
422+
version:
423+
enum:
424+
- 6
425+
- 7
426+
type: integer
427+
required:
428+
- apm
429+
- encryption
430+
- kibana
431+
- version
432+
type: object
433+
organisation:
434+
type: string
435+
required:
436+
- instance
437+
- options
438+
- organisation
439+
type: object
440+
status:
441+
nullable: true
442+
properties:
443+
addon:
444+
nullable: true
445+
type: string
446+
type: object
447+
required:
448+
- spec
449+
title: ElasticSearch
450+
type: object
451+
served: true
452+
storage: true
453+
subresources:
454+
status: {}

docs/40-custom-resources.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,73 @@ spec:
346346
REGION: par
347347
...
348348
```
349+
350+
## ElasticSearch
351+
352+
Below, you will find the custom resource in yaml format that you can use to
353+
deploy a managed services.
354+
355+
```yaml
356+
---
357+
apiVersion: api.clever-cloud.com/v1
358+
kind: ElasticSearch
359+
metadata:
360+
namespace: default
361+
name: elasticsearch
362+
spec:
363+
organisation: orga_xxxx
364+
options:
365+
version: 13
366+
encryption: true
367+
kibana: true
368+
apm: true
369+
instance:
370+
region: par
371+
plan: s
372+
...
373+
```
374+
375+
### Supported version
376+
377+
| Version | Code |
378+
| ------- | ---- |
379+
| `6` | 6 |
380+
| `7` | 7 |
381+
382+
### Supported region
383+
384+
For region, the code could be used to select the desired region.
385+
386+
| Name | Code |
387+
| -------------------------------- | -------- |
388+
| Jeddah | `jed` |
389+
| Paris | `par` |
390+
| Singapore | `sgp` |
391+
| Montreal | `mtl` |
392+
| Roubaix | `rbx` |
393+
| Warsaw | `wsw` |
394+
| Roubaix (with hds certification) | `rbxhds` |
395+
| Sydney | `syd` |
396+
| New Yord | `nyc` |
397+
398+
### Supported plan
399+
400+
For plan, both name and code could be used to select the desired plan.
401+
402+
| Name | Code |
403+
| ------ | -------- |
404+
| `XS` | `xs` |
405+
| `S` | `s` |
406+
| `M` | `m` |
407+
| `L` | `l` |
408+
| `XL` | `xl` |
409+
| `XXL` | `xxl` |
410+
| `XXXL` | `xxxl` |
411+
| `4XL` | `xxxxl` |
412+
| `5XL` | `xxxxxl` |
413+
414+
### Note
415+
416+
When you create an elasticsearch addon, we create for you a cellar addon to save your backups. This
417+
operator will not manage backups of the addon. It is up to you to delete backup, if you do not want
418+
to keep them.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
apiVersion: api.clever-cloud.com/v1
3+
kind: ElasticSearch
4+
metadata:
5+
namespace: default
6+
name: elasticsearch
7+
spec:
8+
organisation: orga_xxxx
9+
options:
10+
version: 7
11+
encryption: true
12+
kibana: true
13+
apm: true
14+
instance:
15+
region: par
16+
plan: xs
17+
---
18+
apiVersion: v1
19+
kind: ServiceAccount
20+
metadata:
21+
labels:
22+
app: debian-elasticsearch
23+
name: debian-elasticsearch
24+
namespace: default
25+
---
26+
apiVersion: policy/v1
27+
kind: PodDisruptionBudget
28+
metadata:
29+
name: debian-elasticsearch
30+
namespace: default
31+
spec:
32+
minAvailable: 0
33+
selector:
34+
matchLabels:
35+
app: debian-elasticsearch
36+
---
37+
apiVersion: networking.k8s.io/v1
38+
kind: NetworkPolicy
39+
metadata:
40+
name: debian-elasticsearch
41+
namespace: default
42+
spec:
43+
podSelector:
44+
matchLabels:
45+
app: debian-elasticsearch
46+
policyTypes:
47+
- Ingress
48+
- Egress
49+
ingress:
50+
- {}
51+
egress:
52+
- {}
53+
---
54+
apiVersion: apps/v1
55+
kind: Deployment
56+
metadata:
57+
namespace: default
58+
name: debian-elasticsearch
59+
labels:
60+
app: debian-elasticsearch
61+
spec:
62+
replicas: 1
63+
selector:
64+
matchLabels:
65+
app: debian-elasticsearch
66+
template:
67+
metadata:
68+
labels:
69+
app: debian-elasticsearch
70+
spec:
71+
serviceAccountName: debian-elasticsearch
72+
automountServiceAccountToken: true
73+
containers:
74+
- image: debian:bullseye-slim
75+
imagePullPolicy: Always
76+
name: debian-elasticsearch
77+
command:
78+
- "sleep"
79+
- "3600"
80+
env:
81+
- name: ES_ADDON_APM_AUTH_TOKEN
82+
valueFrom:
83+
secretKeyRef:
84+
name: elasticsearch-secrets # build using the name of the addon following by -secrets
85+
key: ES_ADDON_APM_AUTH_TOKEN
86+
- name: ES_ADDON_APM_HOST
87+
valueFrom:
88+
secretKeyRef:
89+
name: elasticsearch-secrets
90+
key: ES_ADDON_APM_HOST
91+
- name: ES_ADDON_APM_PASSWORD
92+
valueFrom:
93+
secretKeyRef:
94+
name: elasticsearch-secrets
95+
key: ES_ADDON_APM_PASSWORD
96+
- name: ES_ADDON_APM_USER
97+
valueFrom:
98+
secretKeyRef:
99+
name: elasticsearch-secrets
100+
key: ES_ADDON_APM_USER
101+
- name: ES_ADDON_HOST
102+
valueFrom:
103+
secretKeyRef:
104+
name: elasticsearch-secrets
105+
key: ES_ADDON_HOST
106+
- name: ES_ADDON_KIBANA_HOST
107+
valueFrom:
108+
secretKeyRef:
109+
name: elasticsearch-secrets
110+
key: ES_ADDON_KIBANA_HOST
111+
- name: ES_ADDON_KIBANA_USER
112+
valueFrom:
113+
secretKeyRef:
114+
name: elasticsearch-secrets
115+
key: ES_ADDON_KIBANA_USER
116+
- name: ES_ADDON_PASSWORD
117+
valueFrom:
118+
secretKeyRef:
119+
name: elasticsearch-secrets
120+
key: ES_ADDON_PASSWORD
121+
- name: ES_ADDON_URI
122+
valueFrom:
123+
secretKeyRef:
124+
name: elasticsearch-secrets
125+
key: ES_ADDON_URI
126+
- name: ES_ADDON_USER
127+
valueFrom:
128+
secretKeyRef:
129+
name: elasticsearch-secrets
130+
key: ES_ADDON_USER
131+
- name: ES_ADDON_VERSION
132+
valueFrom:
133+
secretKeyRef:
134+
name: elasticsearch-secrets
135+
key: ES_ADDON_VERSION
136+
resources:
137+
requests:
138+
memory: 64M
139+
cpu: 100m
140+
limits:
141+
memory: 64M
142+
cpu: 100m

src/cmd/crd.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use crate::{
1414
svc::{
1515
cfg::Configuration,
1616
crd::{
17-
config_provider::ConfigProvider, mongodb::MongoDb, mysql::MySql,
18-
postgresql::PostgreSql, pulsar::Pulsar, redis::Redis,
17+
config_provider::ConfigProvider, elasticsearch::ElasticSearch, mongodb::MongoDb,
18+
mysql::MySql, postgresql::PostgreSql, pulsar::Pulsar, redis::Redis,
1919
},
2020
},
2121
};
@@ -31,6 +31,7 @@ pub enum CustomResource {
3131
MongoDb,
3232
Pulsar,
3333
ConfigProvider,
34+
ElasticSearch,
3435
}
3536

3637
impl FromStr for CustomResource {
@@ -45,7 +46,8 @@ impl FromStr for CustomResource {
4546
"mongodb" => Ok(Self::MongoDb),
4647
"pulsar" => Ok(Self::Pulsar),
4748
"config-provider" => Ok(Self::ConfigProvider),
48-
_ => Err(format!("failed to parse '{}', available options are 'config-provider', 'pulsar', 'postgresql', 'redis', 'mysql' or 'mongodb", s).into()),
49+
"elasticsearch" => Ok(Self::ElasticSearch),
50+
_ => Err(format!("failed to parse '{}', available options are 'elasticsearch', 'config-provider', 'pulsar', 'postgresql', 'redis', 'mysql' or 'mongodb", s).into()),
4951
}
5052
}
5153
}
@@ -106,6 +108,8 @@ pub async fn view(
106108
.map_err(CustomResourceDefinitionError::Serialize)?,
107109
CustomResource::ConfigProvider => serde_yaml::to_string(&ConfigProvider::crd())
108110
.map_err(CustomResourceDefinitionError::Serialize)?,
111+
CustomResource::ElasticSearch => serde_yaml::to_string(&ElasticSearch::crd())
112+
.map_err(CustomResourceDefinitionError::Serialize)?,
109113
}]
110114
} else {
111115
vec![
@@ -121,6 +125,8 @@ pub async fn view(
121125
.map_err(CustomResourceDefinitionError::Serialize)?,
122126
serde_yaml::to_string(&ConfigProvider::crd())
123127
.map_err(CustomResourceDefinitionError::Serialize)?,
128+
serde_yaml::to_string(&ElasticSearch::crd())
129+
.map_err(CustomResourceDefinitionError::Serialize)?,
124130
]
125131
};
126132

0 commit comments

Comments
 (0)