Skip to content

Commit c314b5f

Browse files
committed
Merge branch 'lkwd-upstream'
2 parents db7535c + ef2efc7 commit c314b5f

34 files changed

+1087
-382
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.git/
2+

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,11 @@ tags
7777
### MacOS specific ###
7878
.DS_Store
7979
# End of https://www.gitignore.io/api/go,vim,emacs,visualstudiocode
80+
kubeconfig.yaml
81+
./deployment.yaml
82+
./tarantool-operator
83+
helm_values.yaml
84+
deploy/*
85+
86+
ci/helm-chart/templates/crds/tarantool.io_*s_crd.yaml
87+
ci/helm-chart/templates/crds/tarantool_*_cr.yaml

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
docker:
2+
docker build -f build/Dockerfile -t tarantool-operator .
3+
4+
crds:
5+
operator-sdk generate crds
6+
cp -r deploy/* ./ci/helm-chart/templates/

README.md

Lines changed: 93 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ align="right">
88
[![Test][gh-actions-badge]][gh-actions-url]
99

1010
The Tarantool Operator provides automation that simplifies the administration
11-
of [Tarantool Cartridge](https://github.com/tarantool/cartridge)-based clusters
12-
on Kubernetes.
11+
of [Tarantool Cartridge](https://github.com/tarantool/cartridge)-based cluster on Kubernetes.
1312

1413
The Operator introduces new API version `tarantool.io/v1alpha1` and installs
1514
custom resources for objects of three custom types: Cluster, Role, and
@@ -47,71 +46,61 @@ will be removed.
4746

4847
## Deploying the Tarantool operator on minikube
4948

50-
1. Install the required software:
49+
1. Install the required deployment utilities:
5150

52-
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl)
51+
* [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl)
52+
* [helm](https://helm.sh/docs/intro/install/)
5353

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

56-
1. Create a `minikube` cluster:
59+
To install and configure a local minikube installation:
5760

58-
```shell
59-
minikube start --memory=4096
60-
```
61+
1. Create a `minikube` cluster:
6162

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

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

66-
```shell
67-
minikube status
68-
```
69+
Ensure `minikube` is up and running:
6970

70-
In case of success you will see this output:
71+
```shell
72+
minikube status
73+
```
7174

72-
```shell
73-
host: Running
74-
kubelet: Running
75-
apiserver: Running
76-
```
75+
In case of success you will see this output:
7776

78-
1. Enable Ingress add-on:
77+
```shell
78+
host: Running
79+
kubelet: Running
80+
apiserver: Running
81+
```
7982

80-
```shell
81-
minikube addons enable ingress
82-
```
83+
2. Enable minikube Ingress add-on:
8384

84-
1. Create operator resources:
85+
```shell
86+
minikube addons enable ingress
87+
```
8588

86-
```shell
87-
kubectl create -f deploy/service_account.yaml
88-
kubectl create -f deploy/role.yaml
89-
kubectl create -f deploy/role_binding.yaml
90-
```
91-
92-
1. Create Tarantool Operator CRD's (Custom Resource Definitions):
93-
94-
```shell
95-
kubectl create -f deploy/crds/tarantool_v1alpha1_cluster_crd.yaml
96-
kubectl create -f deploy/crds/tarantool_v1alpha1_role_crd.yaml
97-
kubectl create -f deploy/crds/tarantool_v1alpha1_replicasettemplate_crd.yaml
98-
```
99-
100-
1. Start the operator:
89+
2. Install the operator
10190

10291
```shell
103-
kubectl create -f deploy/operator.yaml
92+
helm install tarantool-operator ci/helm-chart --namespace tarantool --create-namespace
10493
```
10594

10695
Ensure the operator is up:
10796

10897
```shell
109-
kubectl get pods --watch
98+
watch kubectl get pods -n tarantool
11099
```
111100

112101
Wait for `tarantool-operator-xxxxxx-xx` Pod's status to become `Running`.
113102
114-
## Example: key-value storage
103+
## Example Application: key-value storage
115104
116105
`examples/kv` contains a Tarantool-based distributed key-value storage.
117106
Data are accessed via HTTP REST API.
@@ -128,19 +117,19 @@ Tarantool Operator is up and running.
128117
1. Create a cluster:
129118
130119
```shell
131-
kubectl create -f examples/kv/deployment.yaml
120+
helm install examples-kv-cluster examples/kv/helm-chart --namespace tarantool
132121
```
133122
134-
Wait until all the cluster Pods are up (status becomes `Running`):
123+
Wait until all the cluster Pods are up (status becomes `Running`):
135124
136-
```shell
137-
kubectl get pods --watch
138-
```
125+
```shell
126+
watch kubectl -n tarantool get pods
127+
```
139128
140-
1. Ensure cluster became operational:
129+
2. Ensure cluster became operational:
141130
142131
```shell
143-
kubectl describe clusters.tarantool.io examples-kv-cluster
132+
kubectl -n tarantool describe clusters.tarantool.io examples-kv-cluster
144133
```
145134
146135
wait until Status.State is Ready:
@@ -152,25 +141,35 @@ Tarantool Operator is up and running.
152141
...
153142
```
154143
155-
1. Access the cluster web UI:
144+
3. Access the cluster web UI:
156145
157-
1. Get `minikube` vm IP-address:
146+
* If using minikube:
158147
159-
```shell
160-
minikube ip
161-
```
148+
* Get `minikube` vm IP-address:
149+
150+
```shell
151+
minikube ip
152+
```
153+
154+
* Open **http://MINIKUBE_IP** in your browser.
155+
Replace MINIKUBE_IP with the IP-address reported by the previous command.
162156
163-
1. Open **http://MINIKUBE_IP** in your browser.
164-
Replace MINIKUBE_IP with the IP-address reported by the previous command.
157+
![Web UI](./assets/kv_web_ui.png)
165158
166-
![Web UI](./assets/kv_web_ui.png)
159+
> **_NOTE:_** Due to a recent
160+
> [bug in Ingress](https://github.com/kubernetes/minikube/issues/2840),
161+
> web UI may be inaccessible. If needed, you can try this
162+
> [workaround](https://github.com/kubernetes/minikube/issues/2840#issuecomment-492454708).
167163
168-
> **_NOTE:_** Due to a recent
169-
> [bug in Ingress](https://github.com/kubernetes/minikube/issues/2840),
170-
> web UI may be inaccessible. If needed, you can try this
171-
> [workaround](https://github.com/kubernetes/minikube/issues/2840#issuecomment-492454708).
164+
* If using kubernetes in docker-desktop
172165
173-
1. Access the key-value API:
166+
Run: (MINIKUBE_IP will be localhost:8081 in this case)
167+
168+
```shell
169+
kc port-forward -n tarantool routers-0-0 8081:8081
170+
````
171+
172+
4. Access the key-value API:
174173
175174
1. Store some value:
176175
@@ -184,7 +183,7 @@ Tarantool Operator is up and running.
184183
{"info":"Successfully created"}
185184
```
186185
187-
1. Access stored values:
186+
2. Access stored values:
188187
189188
```shell
190189
curl http://MINIKUBE_IP/kv_dump
@@ -200,53 +199,58 @@ Tarantool Operator is up and running.
200199
201200
1. Increase the number of replica sets in Storages Role:
202201
203-
```shell
204-
kubectl edit roles.tarantool.io storage
202+
in the examples-kv helm chart, edit the `examples/kv/helm-chart/values.yaml` file to be
203+
204+
```yaml
205+
- RoleName: storage
206+
ReplicaCount: 1
207+
ReplicaSetCount: 2
205208
```
206209
207-
This will open the resource in a text editor.
208-
Change `spec.numReplicasets` field value to 3:
210+
Then run:
209211
210212
```shell
211-
spec:
212-
numReplicasets: 3
213+
helm upgrade examples-kv-cluster examples/kv/helm-chart --namespace tarantool
213214
```
214215
215-
Save your changes and exit the editor.
216+
This will add another storage role replica set to the existing cluster. View the new cluster topology via the cluster web UI.
216217
217-
This will add new replica sets to the existing cluster.
218+
2. Increase the number of replicas across all Storages Role replica sets:
218219
219-
View the new cluster topology via the cluster web UI.
220+
in the examples-kv helm chart, edit the `examples/kv/helm-chart/values.yaml` file to be
220221
221-
1. Increase the number of replicas across all Storages Role replica sets:
222-
223-
```shell
224-
kubectl edit replicasettemplates.tarantool.io storage-template
222+
```yaml
223+
- RoleName: storage
224+
ReplicaCount: 2
225+
ReplicaSetCount: 2
225226
```
226227
227-
This will open the resource in a text editor.
228-
Change `spec.replicas` field value to 3:
228+
Then run:
229229
230230
```shell
231-
spec:
232-
replicas: 3
231+
helm upgrade examples-kv-cluster examples/kv/helm-chart --namespace tarantool
233232
```
234233
235-
Save your changes and exit the editor.
234+
This will add one more replica to each Storages Role replica set. View the new cluster topology via the cluster web UI.
235+
236+
## Development
237+
238+
### Regenerate the Custom Resource Definitions
236239
237-
This will add one more replica to each Storages Role replica set.
240+
```shell
241+
make crds
242+
```
238243
239-
View the new cluster topology via the cluster web UI.
244+
### Building tarantool-operator docker image
240245
241-
> **_NOTE:_** When `kubectl` 1.16 is out, you will be able to scale the
242-
> application with a single `kubectl scale` command, for example
243-
> `kubectl scale roles.tarantool.io storage --replicas=3`.
244-
> With younger versions of `kubectl` this is impossible due to
245-
> [this bug](https://github.com/kubernetes/kubernetes/issues/80515).
246+
```shell
247+
make docker
248+
```
246249
247250
### Running tests
248251
249252
```shell
253+
# In the examples/kv directory
250254
make build
251255
make start
252256
./bootstrap.sh

assets/kv_web_ui.png

102 KB
Loading

build/Dockerfile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
FROM registry.access.redhat.com/ubi7/ubi-minimal:latest
1+
FROM golang:1.13 AS builder
2+
3+
COPY . /app
4+
WORKDIR /app
5+
6+
ENV GO111MODULE=on
7+
8+
RUN GOOS=linux go build -o tarantool-operator cmd/manager/main.go
9+
10+
FROM centos:8 as runner
11+
12+
# install operator binary
13+
COPY --from=builder /app/tarantool-operator /usr/local/bin/tarantool-operator
14+
COPY --from=builder /app/build/bin/user_setup /usr/local/bin/user_setup
215

316
ENV OPERATOR=/usr/local/bin/tarantool-operator \
417
USER_UID=1001 \
518
USER_NAME=tarantool-operator
619

7-
# install operator binary
8-
COPY build/_output/bin/tarantool-operator ${OPERATOR}
9-
10-
COPY build/bin /usr/local/bin
1120
RUN /usr/local/bin/user_setup
1221

1322
ENTRYPOINT ["/usr/local/bin/entrypoint"]

ci/helm-chart/.helmignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
24+
# ignore the custom resource examples
25+
templates/crds/tarantool_*cr.yaml
26+
# Ignore plural definitions, not required
27+
templates/crds/tarantool.io_replicasettemplates_crd.yaml
28+
templates/crds/tarantool.io_roles_crd.yaml
29+
templates/crds/tarantool.io_clusters_crd.yaml

ci/helm-chart/Chart.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v2
2+
name: tarantool-operator
3+
description: kubernetes tarantool operator
4+
5+
type: application
6+
7+
# Helm chart Version
8+
version: 0.1.0
9+
10+
# Application version to be deployed
11+
appVersion: 1.16.0

0 commit comments

Comments
 (0)