Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
influxdb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
influxdb
Commits
bafe7447
Commit
bafe7447
authored
Jun 02, 2020
by
David McKay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(enterprise): use Perl to orchestrate entrypoint and cluster membership
parent
24ffe57c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
30 deletions
+85
-30
data-configmap.yaml
charts/influxdb-enterprise/templates/data-configmap.yaml
+40
-12
data-statefulset.yaml
charts/influxdb-enterprise/templates/data-statefulset.yaml
+2
-2
meta-configmap.yaml
charts/influxdb-enterprise/templates/meta-configmap.yaml
+41
-9
meta-statefulset.yaml
charts/influxdb-enterprise/templates/meta-statefulset.yaml
+2
-7
No files found.
charts/influxdb-enterprise/templates/data-configmap.yaml
View file @
bafe7447
...
...
@@ -29,19 +29,47 @@ data:
dir = "/var/lib/influxdb/data"
wal-dir = "/var/lib/influxdb/wal"
entrypoint.sh: |+
#!/usr/bin/env sh
entrypoint.pl: |+
META_LEADER=$(hostname -f | sed -r 's/-[0-9]+./-0./' | sed -r 's/data/meta/g')
#!/usr/bin/env perl
$ENV{INFLUXDB_HOSTNAME} = `hostname -f`;
$ENV{INFLUXDB_HOSTNAME} =~ s/\n$//;
n=0
until [ "$n" -ge 1000 ]
do
curl -XPOST -Faddr=$(hostname -f):8088 http://${META_LEADER}:8091/add-data && break
sleep 2
n=$((n+1))
done
$pid = fork();
export INFLUXDB_HOSTNAME=$(hostname -f)
exec influxd
# Inside this conditional is our child process, which
# will return `influxd-meta`
if($pid == 0) {
exec('influxd') or die("Failed to execute influxd: $!\n");
}
$SIG{HUP} = sub { kill 'HUP', $pid };
$SIG{TERM} = sub { kill 'TERM', $pid };
$SIG{KILL} = sub { kill 'KILL', $pid };
# Register data node with meta leader
my $meta_leader = $ENV{INFLUXDB_HOSTNAME};
$meta_leader =~ s/-[0-9]+./-0./;
$meta_leader =~ s/data/meta/g;
# We're not going to define an exit strategy for failure here.
# This should be handled by the probes on the pods
while (true) {
# There's no LWP/Simple available in our images, so forking out to curl 😥
print "Attempting to register with meta service ...\n";
system('echo', 'curl', '-XPOST', "-Faddr=$ENV{INFLUXDB_HOSTNAME}:8088", "http://idb-meta:8091/add-data");
system('curl', '-XPOST', "-Faddr=$ENV{INFLUXDB_HOSTNAME}:8088", "http://idb-meta:8091/add-data");
if ($? == 0) {
print "Success\n";
last;
}
print "Failed: $!\n";
# Wait a few seconds and try again
# Maybe we should implement some rudamentary backoff
sleep(2);
}
waitpid($pid, 0);
exit $?
charts/influxdb-enterprise/templates/data-statefulset.yaml
View file @
bafe7447
...
...
@@ -35,9 +35,9 @@ spec:
containers
:
-
name
:
{{
.Chart.Name
}}
command
:
-
"
/
bin/sh
"
-
"
/
usr/bin/perl
"
args
:
-
"
/etc/influxdb/entrypoint.
sh
"
-
"
/etc/influxdb/entrypoint.
pl
"
securityContext
:
{{
- toYaml .Values.data.securityContext | nindent 12
}}
image
:
"
{{
.Values.data.image.repository
|
default
"influxdb" }}:{{ .Values.data.image.tag | default (printf "%s-%s" .Chart.AppVersion "data") }}"
...
...
charts/influxdb-enterprise/templates/meta-configmap.yaml
View file @
bafe7447
...
...
@@ -22,12 +22,44 @@ data:
[meta]
dir = "/var/lib/influxdb/meta"
entrypoint.sh: |+
#!/usr/bin/env sh
set -e
META_LEADER=$(hostname -f | sed -r 's/-[0-9]+./-0./')
if [ $META_LEADER != $(hostname -f) ]; then
influxd-ctl join ${META_LEADER}:8091
else
influxd-ctl add-meta $(hostname -f):8091
fi
entrypoint.pl: |+
#!/usr/bin/env perl
$ENV{INFLUXDB_HOSTNAME} = `hostname -f`;
$ENV{INFLUXDB_HOSTNAME} =~ s/\n$//;
$pid = fork();
# Inside this conditional is our child process, which
# will return `influxd-meta`
if($pid == 0) {
exec('influxd-meta') or die("Failed to execute influxd-meta: $!\n");
}
$SIG{HUP} = sub { kill 'HUP', $pid };
$SIG{TERM} = sub { kill 'TERM', $pid };
$SIG{KILL} = sub { kill 'KILL', $pid };
# Register meta node
my $meta_leader = $ENV{INFLUXDB_HOSTNAME};
$meta_leader =~ s/-[0-9]+./-0./;
# We're not going to define an exit strategy for failure here.
# This should be handled by the probes on the pods
while (true) {
if($meta_leader eq $ENV{INFLUXDB_HOSTNAME}) {
system('influxd-ctl', 'add-meta', "$ENV{INFLUXDB_HOSTNAME}:8091");
} else {
system('influxd-ctl', 'join', "$meta_leader:8091");
}
if ($? == 0) {
last;
}
# Wait a few seconds and try again
# Maybe we should implement some rudamentary backoff
sleep(2);
}
waitpid($pid, 0);
exit $?
charts/influxdb-enterprise/templates/meta-statefulset.yaml
View file @
bafe7447
...
...
@@ -37,18 +37,13 @@ spec:
containers
:
-
name
:
{{
.Chart.Name
}}
command
:
-
"
/
bin/sh
"
-
"
/
usr/bin/perl
"
args
:
-
"
-c"
-
"
INFLUXDB_HOSTNAME=$(hostname
-f)
influxd-meta"
-
"
/etc/influxdb/entrypoint.pl"
securityContext
:
{{
- toYaml .Values.meta.securityContext | nindent 12
}}
image
:
"
{{
.Values.meta.image.repository
|
default
"influxdb" }}:{{ .Values.meta.image.tag | default (printf "%s-%s" .Chart.AppVersion "meta") }}"
imagePullPolicy
:
{{
.Values.meta.image.pullPolicy
}}
lifecycle
:
postStart
:
exec
:
command
:
[
"
/bin/sh"
,
"
/etc/influxdb/entrypoint.sh"
]
ports
:
-
name
:
http
containerPort
:
8091
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment