Skip to content

Commit 4d507e1

Browse files
committed
merge upstream
2 parents bb126fa + db7535c commit 4d507e1

File tree

2,585 files changed

+407
-849848
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,585 files changed

+407
-849848
lines changed

.github/workflows/test.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Test
2+
on: [push]
3+
jobs:
4+
build:
5+
name: Build
6+
runs-on: ubuntu-latest
7+
env:
8+
OPERATOR_SDK_VERSION: v0.12.0
9+
steps:
10+
11+
- uses: actions/checkout@v1
12+
13+
- name: Set up Go 1.13
14+
uses: actions/setup-go@v1
15+
with:
16+
go-version: 1.13
17+
id: go
18+
19+
- name: Install modules
20+
run: go mod download
21+
22+
- name: Install operator-sdk
23+
run: |
24+
curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu
25+
chmod +x ./operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu
26+
27+
- name: Build operator
28+
run: ./operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu build tarantool/tarantool-operator:${GITHUB_SHA}
29+
30+
- name: Setup test kubernetes cluster
31+
uses: helm/kind-action@v1.0.0-rc.1
32+
with:
33+
cluster_name: kind
34+
35+
- name: Load operator image into test cluster
36+
run: kind load docker-image tarantool/tarantool-operator:${GITHUB_SHA}
37+
38+
- name: Create CRDs
39+
run: |
40+
kubectl create \
41+
-f deploy/crds/tarantool_v1alpha1_cluster_crd.yaml \
42+
-f deploy/crds/tarantool_v1alpha1_replicasettemplate_crd.yaml \
43+
-f deploy/crds/tarantool_v1alpha1_role_crd.yaml
44+
45+
- name: Test
46+
run: |
47+
./operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu test local \
48+
--image tarantool/tarantool-operator:${GITHUB_SHA} \
49+
./test/e2e

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ align="right">
55

66
# Tarantool Kubernetes operator
77

8+
[![Test][gh-actions-badge]][gh-actions-url]
9+
810
The Tarantool Operator provides automation that simplifies the administration
911
of [Tarantool Cartridge](https://github.com/tarantool/cartridge)-based cluster on Kubernetes.
1012

@@ -245,3 +247,6 @@ make start
245247
./bootstrap.sh
246248
make test
247249
```
250+
251+
[gh-actions-badge]: https://github.com/tarantool/tarantool-operator/workflows/Test/badge.svg
252+
[gh-actions-url]: https://github.com/tarantool/tarantool-operator/actions

deploy/operator.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ spec:
1717
- name: tarantool-operator
1818
image: null
1919
command:
20-
- tarantool-operator
21-
imagePullPolicy: Always
20+
- tarantool-operator
21+
imagePullPolicy: IfNotPresent
2222
env:
2323
- name: WATCH_NAMESPACE
2424
valueFrom:

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module github.com/tarantool/tarantool-operator
22

33
require (
4+
github.com/ghodss/yaml v1.0.0
45
github.com/go-openapi/spec v0.19.0
56
github.com/google/uuid v1.1.1
67
github.com/machinebox/graphql v0.2.2

go.sum

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ github.com/Azure/go-autorest v11.1.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSW
1515
github.com/Azure/go-autorest v11.5.2+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
1616
github.com/Azure/go-autorest v11.7.0+incompatible h1:gzma19dc9ejB75D90E5S+/wXouzpZyA+CV+/MJPSD/k=
1717
github.com/Azure/go-autorest v11.7.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
18+
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
1819
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
1920
github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E=
2021
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
@@ -80,6 +81,7 @@ github.com/emicklei/go-restful v2.9.3+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT
8081
github.com/emicklei/go-restful-swagger12 v0.0.0-20170926063155-7524189396c6/go.mod h1:qr0VowGBT4CS4Q8vFF8BSeKz34PuqKGxs/L0IAQA9DQ=
8182
github.com/evanphx/json-patch v3.0.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
8283
github.com/evanphx/json-patch v4.0.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
84+
github.com/evanphx/json-patch v4.1.0+incompatible h1:K1MDoo4AZ4wU0GIU/fPmtZg7VpzLjCxu+UwBD1FvwOc=
8385
github.com/evanphx/json-patch v4.1.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
8486
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4=
8587
github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc=
@@ -197,6 +199,7 @@ github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
197199
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
198200
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
199201
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
202+
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
200203
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
201204
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
202205
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
@@ -212,6 +215,7 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
212215
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
213216
github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
214217
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
218+
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
215219
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
216220
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
217221
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@@ -236,6 +240,7 @@ github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsO
236240
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
237241
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
238242
github.com/maxbrunsfeld/counterfeiter v0.0.0-20181017030959-1aadac120687/go.mod h1:aoVsckWnsNzazwF2kmD+bzgdr4GBlbK91zsdivQJ2eU=
243+
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
239244
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
240245
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
241246
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
@@ -314,12 +319,14 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm
314319
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
315320
github.com/sirupsen/logrus v1.1.1/go.mod h1:zrgwTnHtNr00buQ1vSptGe8m1f/BbgsPukg8qsT7A+A=
316321
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
322+
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
317323
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
318324
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
319325
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
320326
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
321327
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
322328
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
329+
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
323330
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
324331
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
325332
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=

test/e2e/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Tarantool Operator end-2-end tests
2+
3+
Testing strategy:
4+
5+
1. provision kubernetes resources from YAML manifest
6+
7+
1. act on provisioned resources
8+
9+
1. assert expected system state
10+
11+
1. clean up
12+
13+
Some conventions:
14+
15+
1. setup manifests located under `scenario` dir
16+
17+
1. tests must be independent and no reliance on previous tests allowed
18+
19+
1. tests must be able to run in parallel each test in it's own namespace
20+
21+
1. each setup manifest must be written in a way that allows to use it without tests

test/e2e/main_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package e2e
2+
3+
import (
4+
"testing"
5+
6+
f "github.com/operator-framework/operator-sdk/pkg/test"
7+
)
8+
9+
func TestMain(m *testing.M) {
10+
f.MainEntry(m)
11+
}

test/e2e/scenario/basic.yaml

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
apiVersion: tarantool.io/v1alpha1
2+
kind: Cluster
3+
metadata:
4+
name: examples-kv-cluster
5+
spec:
6+
selector:
7+
matchLabels:
8+
tarantool.io/cluster-id: "examples-kv-cluster"
9+
---
10+
apiVersion: tarantool.io/v1alpha1
11+
kind: Role
12+
metadata:
13+
name: storage
14+
labels:
15+
tarantool.io/cluster-id: "examples-kv-cluster"
16+
tarantool.io/role: "storage"
17+
spec:
18+
selector:
19+
matchLabels:
20+
tarantool.io/replicaset-template: "storage-template"
21+
numReplicasets: 1
22+
---
23+
apiVersion: tarantool.io/v1alpha1
24+
kind: Role
25+
metadata:
26+
name: routers
27+
labels:
28+
tarantool.io/cluster-id: "examples-kv-cluster"
29+
tarantool.io/role: "router"
30+
spec:
31+
selector:
32+
matchLabels:
33+
tarantool.io/replicaset-template: "router-template"
34+
numReplicasets: 1
35+
---
36+
apiVersion: tarantool.io/v1alpha1
37+
kind: ReplicasetTemplate
38+
metadata:
39+
name: storage-template
40+
labels:
41+
tarantool.io/cluster-id: "examples-kv-cluster"
42+
tarantool.io/replicaset-template: "storage-template"
43+
tarantool.io/role: "storage"
44+
spec:
45+
replicas: 1
46+
selector:
47+
matchLabels:
48+
tarantool.io/pod-template: "storage-pod-template"
49+
volumeClaimTemplates:
50+
- metadata:
51+
name: www
52+
spec:
53+
accessModes: [ "ReadWriteOnce" ]
54+
resources:
55+
requests:
56+
storage: 1Gi
57+
template:
58+
metadata:
59+
labels:
60+
tarantool.io/cluster-id: "examples-kv-cluster"
61+
tarantool.io/pod-template: "storage-pod-template"
62+
spec:
63+
terminationGracePeriodSeconds: 10
64+
dnsConfig:
65+
options:
66+
- name: ndots
67+
value: "1"
68+
containers:
69+
- name: pim-storage
70+
image: tarantool/tarantool-operator-examples-kv:0.0.2
71+
volumeMounts:
72+
- mountPath: "/var/lib/tarantool"
73+
name: www
74+
ports:
75+
- containerPort: 3301
76+
- containerPort: 8081
77+
env:
78+
- name: TARANTOOL_INSTANCE_NAME
79+
valueFrom:
80+
fieldRef:
81+
fieldPath: metadata.name
82+
- name: TARANTOOL_WORK_DIR
83+
value: "/var/lib/tarantool"
84+
- name: TARANTOOL_MEMTX_MEMORY
85+
value: "33554432"
86+
- name: TARANTOOL_LOG
87+
value: "/dev/stdout"
88+
- name: TARANTOOL_ADVERTISE_HOST
89+
valueFrom:
90+
fieldRef:
91+
fieldPath: metadata.name
92+
- name: TARANTOOL_ADVERTISE_URI
93+
value: "$(TARANTOOL_ADVERTISE_HOST).examples-kv-cluster:3301"
94+
---
95+
apiVersion: tarantool.io/v1alpha1
96+
kind: ReplicasetTemplate
97+
metadata:
98+
name: router-template
99+
labels:
100+
tarantool.io/cluster-id: "examples-kv-cluster"
101+
tarantool.io/replicaset-template: "router-template"
102+
tarantool.io/role: "router"
103+
spec:
104+
replicas: 1
105+
selector:
106+
matchLabels:
107+
tarantool.io/pod-template: "router-pod-template"
108+
volumeClaimTemplates:
109+
- metadata:
110+
name: www
111+
spec:
112+
accessModes: [ "ReadWriteOnce" ]
113+
resources:
114+
requests:
115+
storage: 1Gi
116+
template:
117+
metadata:
118+
labels:
119+
tarantool.io/cluster-id: "examples-kv-cluster"
120+
tarantool.io/pod-template: "router-pod-template"
121+
spec:
122+
terminationGracePeriodSeconds: 10
123+
dnsConfig:
124+
options:
125+
- name: ndots
126+
value: "1"
127+
containers:
128+
- name: pim-router
129+
image: tarantool/tarantool-operator-examples-kv:0.0.2
130+
volumeMounts:
131+
- mountPath: "/var/lib/tarantool"
132+
name: www
133+
ports:
134+
- containerPort: 3301
135+
- containerPort: 8081
136+
env:
137+
- name: TARANTOOL_INSTANCE_NAME
138+
valueFrom:
139+
fieldRef:
140+
fieldPath: metadata.name
141+
- name: TARANTOOL_WORK_DIR
142+
value: "/var/lib/tarantool"
143+
- name: TARANTOOL_MEMTX_MEMORY
144+
value: "33554432"
145+
- name: TARANTOOL_LOG
146+
value: "/dev/stdout"
147+
- name: TARANTOOL_ADVERTISE_HOST
148+
valueFrom:
149+
fieldRef:
150+
fieldPath: metadata.name
151+
- name: TARANTOOL_ADVERTISE_URI
152+
value: "$(TARANTOOL_ADVERTISE_HOST).examples-kv-cluster:3301"
153+
---
154+
apiVersion: networking.k8s.io/v1beta1
155+
kind: Ingress
156+
metadata:
157+
name: examples-kv-topology
158+
annotations:
159+
nginx.ingress.kubernetes.io/ssl-redirect: "false"
160+
spec:
161+
rules:
162+
- http:
163+
paths:
164+
- backend:
165+
serviceName: router
166+
servicePort: 8081
167+
path: /kv
168+
- backend:
169+
serviceName: router
170+
servicePort: 8081
171+
path: /kv_dump
172+
- backend:
173+
serviceName: router
174+
servicePort: 8081
175+
path: /
176+
---
177+
apiVersion: v1
178+
kind: Service
179+
metadata:
180+
name: router
181+
labels:
182+
tarantool.io/role: "router"
183+
spec:
184+
ports:
185+
- port: 8081
186+
name: web
187+
protocol: TCP
188+
selector:
189+
tarantool.io/role: "router"

0 commit comments

Comments
 (0)