Skip to content

Commit bb126fa

Browse files
committed
move the example cluster to use helm
1 parent e4eb088 commit bb126fa

File tree

14 files changed

+528
-293
lines changed

14 files changed

+528
-293
lines changed

README.md

Lines changed: 85 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ align="right">
66
# Tarantool Kubernetes operator
77

88
The Tarantool Operator provides automation that simplifies the administration
9-
of [Tarantool Cartridge](https://github.com/tarantool/cartridge)-based clusters
10-
on Kubernetes.
9+
of [Tarantool Cartridge](https://github.com/tarantool/cartridge)-based cluster on Kubernetes.
1110

1211
The Operator introduces new API version `tarantool.io/v1alpha1` and installs
1312
custom resources for objects of three custom types: Cluster, Role, and
@@ -45,71 +44,61 @@ will be removed.
4544

4645
## Deploying the Tarantool operator on minikube
4746

48-
1. Install the required software:
47+
1. Install the required deployment utilities:
4948

50-
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl)
49+
* [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl)
50+
* [helm](https://helm.sh/docs/intro/install/)
5151

52-
- [minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/)
52+
Pick one of these to run a local kubernetes cluster
53+
* [minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/)
54+
* [Windows Docker Desktop](https://docs.docker.com/docker-for-windows/#kubernetes)
55+
* [OSX Docker Desktop](https://docs.docker.com/docker-for-mac/#kubernetes)
5356

54-
1. Create a `minikube` cluster:
57+
To install and configure a local minikube installation:
5558

56-
```shell
57-
minikube start --memory=4096
58-
```
59+
1. Create a `minikube` cluster:
5960

60-
You will need 4Gb of RAM allocated to the `minikube` cluster to run examples.
61+
```shell
62+
minikube start --memory=4096
63+
```
6164

62-
Ensure `minikube` is up and running:
65+
You will need 4Gb of RAM allocated to the `minikube` cluster to run examples.
6366

64-
```shell
65-
minikube status
66-
```
67+
Ensure `minikube` is up and running:
6768

68-
In case of success you will see this output:
69+
```shell
70+
minikube status
71+
```
6972

70-
```shell
71-
host: Running
72-
kubelet: Running
73-
apiserver: Running
74-
```
73+
In case of success you will see this output:
7574

76-
1. Enable Ingress add-on:
75+
```shell
76+
host: Running
77+
kubelet: Running
78+
apiserver: Running
79+
```
7780

78-
```shell
79-
minikube addons enable ingress
80-
```
81+
2. Enable minikube Ingress add-on:
8182

82-
1. Create operator resources:
83-
84-
```shell
85-
kubectl create -f deploy/service_account.yaml
86-
kubectl create -f deploy/role.yaml
87-
kubectl create -f deploy/role_binding.yaml
88-
```
89-
90-
1. Create Tarantool Operator CRD's (Custom Resource Definitions):
91-
92-
```shell
93-
kubectl create -f deploy/crds/tarantool_v1alpha1_cluster_crd.yaml
94-
kubectl create -f deploy/crds/tarantool_v1alpha1_role_crd.yaml
95-
kubectl create -f deploy/crds/tarantool_v1alpha1_replicasettemplate_crd.yaml
96-
```
83+
```shell
84+
minikube addons enable ingress
85+
```
9786

98-
1. Start the operator:
87+
2. Install the operator
9988

10089
```shell
101-
kubectl create -f deploy/operator.yaml
90+
helm install tarantool-operator ci/helm-chart --namespace tarantool --create-namespace
10291
```
10392

10493
Ensure the operator is up:
10594

10695
```shell
107-
kubectl get pods --watch
96+
watch kubectl get pods -n tarantool
10897
```
10998

11099
Wait for `tarantool-operator-xxxxxx-xx` Pod's status to become `Running`.
111100
112-
## Example: key-value storage
101+
## Example Application: key-value storage
113102
114103
`examples/kv` contains a Tarantool-based distributed key-value storage.
115104
Data are accessed via HTTP REST API.
@@ -126,19 +115,19 @@ Tarantool Operator is up and running.
126115
1. Create a cluster:
127116
128117
```shell
129-
kubectl create -f examples/kv/deployment.yaml
118+
helm install examples-kv-cluster examples/kv/helm-chart --namespace tarantool
130119
```
131120
132-
Wait until all the cluster Pods are up (status becomes `Running`):
121+
Wait until all the cluster Pods are up (status becomes `Running`):
133122
134-
```shell
135-
kubectl get pods --watch
136-
```
123+
```shell
124+
watch kubectl -n tarantool get pods
125+
```
137126
138-
1. Ensure cluster became operational:
127+
2. Ensure cluster became operational:
139128
140129
```shell
141-
kubectl describe clusters.tarantool.io examples-kv-cluster
130+
kubectl -n tarantool describe clusters.tarantool.io examples-kv-cluster
142131
```
143132
144133
wait until Status.State is Ready:
@@ -150,25 +139,35 @@ Tarantool Operator is up and running.
150139
...
151140
```
152141
153-
1. Access the cluster web UI:
142+
3. Access the cluster web UI:
154143
155-
1. Get `minikube` vm IP-address:
144+
* If using minikube:
156145
157-
```shell
158-
minikube ip
159-
```
146+
* Get `minikube` vm IP-address:
147+
148+
```shell
149+
minikube ip
150+
```
151+
152+
* Open **http://MINIKUBE_IP** in your browser.
153+
Replace MINIKUBE_IP with the IP-address reported by the previous command.
154+
155+
![Web UI](./assets/kv_web_ui.png)
156+
157+
> **_NOTE:_** Due to a recent
158+
> [bug in Ingress](https://github.com/kubernetes/minikube/issues/2840),
159+
> web UI may be inaccessible. If needed, you can try this
160+
> [workaround](https://github.com/kubernetes/minikube/issues/2840#issuecomment-492454708).
160161
161-
1. Open **http://MINIKUBE_IP** in your browser.
162-
Replace MINIKUBE_IP with the IP-address reported by the previous command.
162+
* If using kubernetes in docker-desktop
163163
164-
![Web UI](./assets/kv_web_ui.png)
164+
Run: (MINIKUBE_IP will be localhost:8081 in this case)
165165
166-
> **_NOTE:_** Due to a recent
167-
> [bug in Ingress](https://github.com/kubernetes/minikube/issues/2840),
168-
> web UI may be inaccessible. If needed, you can try this
169-
> [workaround](https://github.com/kubernetes/minikube/issues/2840#issuecomment-492454708).
166+
```shell
167+
kc port-forward -n tarantool routers-0-0 8081:8081
168+
````
170169
171-
1. Access the key-value API:
170+
4. Access the key-value API:
172171
173172
1. Store some value:
174173
@@ -182,7 +181,7 @@ Tarantool Operator is up and running.
182181
{"info":"Successfully created"}
183182
```
184183
185-
1. Access stored values:
184+
2. Access stored values:
186185
187186
```shell
188187
curl http://MINIKUBE_IP/kv_dump
@@ -198,49 +197,45 @@ Tarantool Operator is up and running.
198197
199198
1. Increase the number of replica sets in Storages Role:
200199
201-
```shell
202-
kubectl edit roles.tarantool.io storage
200+
in the examples-kv helm chart, edit the `examples/kv/helm-chart/values.yaml` file to be
201+
202+
```yaml
203+
- RoleName: storage
204+
ReplicaCount: 1
205+
ReplicaSetCount: 2
203206
```
204207
205-
This will open the resource in a text editor.
206-
Change `spec.numReplicasets` field value to 3:
208+
Then run:
207209
208210
```shell
209-
spec:
210-
numReplicasets: 3
211+
helm upgrade examples-kv-cluster examples/kv/helm-chart --namespace tarantool
211212
```
212213
213-
Save your changes and exit the editor.
214+
This will add another storage role replica set to the existing cluster. View the new cluster topology via the cluster web UI.
214215
215-
This will add new replica sets to the existing cluster.
216+
2. Increase the number of replicas across all Storages Role replica sets:
216217
217-
View the new cluster topology via the cluster web UI.
218+
in the examples-kv helm chart, edit the `examples/kv/helm-chart/values.yaml` file to be
218219
219-
1. Increase the number of replicas across all Storages Role replica sets:
220-
221-
```shell
222-
kubectl edit replicasettemplates.tarantool.io storage-template
220+
```yaml
221+
- RoleName: storage
222+
ReplicaCount: 2
223+
ReplicaSetCount: 2
223224
```
224225
225-
This will open the resource in a text editor.
226-
Change `spec.replicas` field value to 3:
226+
Then run:
227227
228228
```shell
229-
spec:
230-
replicas: 3
229+
helm upgrade examples-kv-cluster examples/kv/helm-chart --namespace tarantool
231230
```
232231
233-
Save your changes and exit the editor.
232+
This will add one more replica to each Storages Role replica set. View the new cluster topology via the cluster web UI.
234233
235-
This will add one more replica to each Storages Role replica set.
234+
### Building tarantool-operator docker image
236235
237-
View the new cluster topology via the cluster web UI.
238-
239-
> **_NOTE:_** When `kubectl` 1.16 is out, you will be able to scale the
240-
> application with a single `kubectl scale` command, for example
241-
> `kubectl scale roles.tarantool.io storage --replicas=3`.
242-
> With younger versions of `kubectl` this is impossible due to
243-
> [this bug](https://github.com/kubernetes/kubernetes/issues/80515).
236+
```shell
237+
docker build -f build/Dockerfile -t tarantool-operator .
238+
```
244239
245240
### Running tests
246241

assets/kv_web_ui.png

102 KB
Loading
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: clusters.tarantool.io
5+
spec:
6+
additionalPrinterColumns:
7+
- JSONPath: .status.state
8+
name: State
9+
type: string
10+
- JSONPath: .metadata.creationTimestamp
11+
name: Age
12+
type: date
13+
group: tarantool.io
14+
names:
15+
kind: Cluster
16+
listKind: ClusterList
17+
plural: clusters
18+
singular: cluster
19+
scope: Namespaced
20+
subresources:
21+
status: {}
22+
validation:
23+
openAPIV3Schema:
24+
properties:
25+
apiVersion:
26+
description:
27+
"APIVersion defines the versioned schema of this representation
28+
of an object. Servers should convert recognized schemas to the latest
29+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources"
30+
type: string
31+
kind:
32+
description:
33+
"Kind is a string value representing the REST resource this
34+
object represents. Servers may infer this from the endpoint the client
35+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds"
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
properties:
41+
selector:
42+
description:
43+
'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
44+
Important: Run "operator-sdk generate k8s" to regenerate code after
45+
modifying this file Add custom validation using kubebuilder tags:
46+
https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html'
47+
type: object
48+
type: object
49+
status:
50+
properties:
51+
state:
52+
description:
53+
'INSERT ADDITIONAL STATUS FIELD - define observed state
54+
of cluster Important: Run "operator-sdk generate k8s" to regenerate
55+
code after modifying this file Add custom validation using kubebuilder
56+
tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html'
57+
type: string
58+
type: object
59+
version: v1alpha1
60+
versions:
61+
- name: v1alpha1
62+
served: true
63+
storage: true
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1beta1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
name: replicasettemplates.tarantool.io
6+
spec:
7+
group: tarantool.io
8+
names:
9+
kind: ReplicasetTemplate
10+
listKind: ReplicasetTemplateList
11+
plural: replicasettemplates
12+
singular: replicasettemplate
13+
scope: Namespaced
14+
subresources:
15+
status: {}
16+
validation:
17+
openAPIV3Schema:
18+
properties:
19+
apiVersion:
20+
description:
21+
"APIVersion defines the versioned schema of this representation
22+
of an object. Servers should convert recognized schemas to the latest
23+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources"
24+
type: string
25+
kind:
26+
description:
27+
"Kind is a string value representing the REST resource this
28+
object represents. Servers may infer this from the endpoint the client
29+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds"
30+
type: string
31+
metadata:
32+
type: object
33+
spec:
34+
type: object
35+
status:
36+
type: object
37+
version: v1alpha1
38+
versions:
39+
- name: v1alpha1
40+
served: true
41+
storage: true
42+
---

0 commit comments

Comments
 (0)