Skip to content

Commit eadbf8e

Browse files
committed
dns resolve: decrease ndots resolver parameter to 1
1 parent 4004d7b commit eadbf8e

File tree

7 files changed

+75
-17
lines changed

7 files changed

+75
-17
lines changed

deploy/crds/tarantool_v1alpha1_role_crd.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ spec:
3333
spec:
3434
properties:
3535
replicas:
36-
description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
37-
Important: Run "operator-sdk generate k8s" to regenerate code after
38-
modifying this file Add custom validation using kubebuilder tags:
39-
https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html'
36+
description: Replicas is a number of StatefulSets (Tarantol replicasets)
37+
created under this Role
4038
format: int32
4139
type: integer
4240
selector:
41+
description: Selector is a LabelSelector to find ReplicasetTemplate
42+
resources from which StatefulSet created
4343
type: object
4444
storageTemplate:
4545
properties:

deploy/operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec:
1515
serviceAccountName: tarantool-operator
1616
containers:
1717
- name: tarantool-operator
18-
image: vasiliyt/tarantool-operator:latest
18+
image: vasiliyt/tarantool-operator:dev
1919
command:
2020
- tarantool-operator
2121
imagePullPolicy: Always

examples/kv/deployment.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,13 @@ spec:
6363
tarantool.io/pod-template: "storage-pod-template"
6464
spec:
6565
terminationGracePeriodSeconds: 10
66+
dnsConfig:
67+
options:
68+
- name: ndots
69+
value: "1"
6670
containers:
6771
- name: pim-storage
68-
image: vasiliyt/tarantool-example-kv:latest
72+
image: vasiliyt/tarantool-operator-example-kv:devel
6973
volumeMounts:
7074
- mountPath: "/tarantool/data"
7175
name: www
@@ -118,9 +122,13 @@ spec:
118122
tarantool.io/pod-template: "router-pod-template"
119123
spec:
120124
terminationGracePeriodSeconds: 10
125+
dnsConfig:
126+
options:
127+
- name: ndots
128+
value: "1"
121129
containers:
122130
- name: pim-router
123-
image: vasiliyt/tarantool-example-kv:latest
131+
image: vasiliyt/tarantool-operator-example-kv:devel
124132
volumeMounts:
125133
- mountPath: "/tarantool/data"
126134
name: www

examples/kv/key-value-store/init.lua

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,53 @@ local memtx_memory = tonumber(os.getenv("TARANTOOL_MEMTX_MEMORY")) or (128 * 102
2222

2323
local http_port = os.getenv("TARANTOOL_HTTP_PORT") or 8081
2424

25-
fiber.sleep(10)
26-
local ok, err = cartridge.cfg({
25+
local fiber = require('fiber')
26+
local log = require('log')
27+
28+
local http_client = require('http.client')
29+
local http_server = require('http.server')
30+
31+
local function resolve_uri(uri, timeout)
32+
if not uri then
33+
return nil, "Pass URI in the next format: uri:port"
34+
end
35+
36+
timeout = timeout or 10
37+
-- local uri, port = uri:match("(^.*)%:(.*)")
38+
local resolved = false
39+
40+
local server_options = {
41+
log_errors = true,
42+
log_requests = log.debug
43+
}
44+
45+
local srv = http_server.new("0.0.0.0", "3301", server_options)
46+
srv:route({ path = '/dns_resolver', method = 'GET' }, function(_) return { status = 200, text = 'Success' } end)
47+
srv:start()
48+
49+
local time = 0
50+
while time < timeout do
51+
local resp = http_client.get(uri .. '/dns_resolver')
52+
if resp.status ~= nil and resp.status == 200 then
53+
resolved = true
54+
break
55+
else
56+
print('Not resolved yet')
57+
end
58+
59+
fiber.sleep(1)
60+
time = time + 1
61+
end
62+
srv:stop()
63+
64+
return resolved
65+
end
66+
67+
local t = resolve_uri(advertise_uri, 50)
68+
if not t then os.exit(1) end
69+
fiber.sleep(5)
70+
71+
local ok, err = cluster.cfg({
2772
alias = instance_name,
2873
workdir = work_dir,
2974
advertise_uri = advertise_uri,

pkg/apis/tarantool/v1alpha1/role_types.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ import (
77
// RoleSpec defines the desired state of Role
88
// +k8s:openapi-gen=true
99
type RoleSpec struct {
10-
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
11-
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
12-
// Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
13-
Replicas *int32 `json:"replicas,omitempty"`
14-
StorageTemplate *ReplicasetTemplate `json:"storageTemplate,omitempty"`
15-
Selector *metav1.LabelSelector `json:"selector,omitempty"`
10+
// Replicas is a number of StatefulSets (Tarantol replicasets) created under this Role
11+
Replicas *int32 `json:"replicas,omitempty"`
12+
StorageTemplate *ReplicasetTemplate `json:"storageTemplate,omitempty"`
13+
// Selector is a LabelSelector to find ReplicasetTemplate resources from which StatefulSet created
14+
Selector *metav1.LabelSelector `json:"selector,omitempty"`
1615
}
1716

1817
// RoleStatus defines the observed state of Role

pkg/apis/tarantool/v1alpha1/zz_generated.openapi.go

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/controller/cluster/cluster_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ func (r *ReconcileCluster) Reconcile(request reconcile.Request) (reconcile.Resul
198198
Port: 3301,
199199
Protocol: "UDP",
200200
},
201+
{
202+
Name: "bin-tcp",
203+
Port: 3302,
204+
Protocol: "TCP",
205+
},
201206
},
202207
}
203208
if err := controllerutil.SetControllerReference(cluster, svc, r.scheme); err != nil {

0 commit comments

Comments
 (0)