Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qg-dockerfiles
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
qg-dockerfiles
Commits
a41a0ff7
Commit
a41a0ff7
authored
Apr 04, 2018
by
kalvin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert
parent
019303d9
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1752 additions
and
0 deletions
+1752
-0
Dockfile
baseimg/tools/redis/Dockfile
+11
-0
redis-master.conf
baseimg/tools/redis/redis-master.conf
+828
-0
redis-slave.conf
baseimg/tools/redis/redis-slave.conf
+828
-0
run.sh
baseimg/tools/redis/run.sh
+85
-0
No files found.
baseimg/tools/redis/Dockfile
0 → 100644
View file @
a41a0ff7
FROM alpine:3.4
RUN apk add --no-cache redis sed bash
COPY redis-master.conf /redis-master/redis.conf
COPY redis-slave.conf /redis-slave/redis.conf
COPY run.sh /run.sh
CMD [ "/run.sh" ]
ENTRYPOINT [ "bash", "-c" ]
\ No newline at end of file
baseimg/tools/redis/redis-master.conf
0 → 100644
View file @
a41a0ff7
This diff is collapsed.
Click to expand it.
baseimg/tools/redis/redis-slave.conf
0 → 100644
View file @
a41a0ff7
This diff is collapsed.
Click to expand it.
baseimg/tools/redis/run.sh
0 → 100755
View file @
a41a0ff7
#!/bin/bash
# Copyright 2014 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
function
launchmaster
()
{
if
[[
!
-e
/redis-master-data
]]
;
then
echo
"Redis master data doesn't exist, data won't be persistent!"
mkdir
/redis-master-data
fi
redis-server /redis-master/redis.conf
--protected-mode
no
}
function
launchsentinel
()
{
while
true
;
do
master
=
$(
redis-cli
-h
${
REDIS_SENTINEL_SERVICE_HOST
}
-p
${
REDIS_SENTINEL_SERVICE_PORT
}
--csv
SENTINEL get-master-addr-by-name mymaster |
tr
','
' '
|
cut
-d
' '
-f1
)
if
[[
-n
${
master
}
]]
;
then
master
=
"
${
master
//\
"}"
else
master=
$(
hostname
-i
)
fi
redis-cli -h
${
master
}
INFO
if [[
"
$?
"
==
"0"
]]; then
break
fi
echo
"Connecting to master failed. Waiting..."
sleep 10
done
sentinel_conf=sentinel.conf
echo
"sentinel monitor mymaster
${
master
}
6379 2"
>
${
sentinel_conf
}
echo
"sentinel down-after-milliseconds mymaster 60000"
>>
${
sentinel_conf
}
echo
"sentinel failover-timeout mymaster 180000"
>>
${
sentinel_conf
}
echo
"sentinel parallel-syncs mymaster 1"
>>
${
sentinel_conf
}
echo
"bind 0.0.0.0"
>>
${
sentinel_conf
}
redis-sentinel
${
sentinel_conf
}
--protected-mode no
}
function launchslave() {
while true; do
master=
$(
redis-cli
-h
${
REDIS_SENTINEL_SERVICE_HOST
}
-p
${
REDIS_SENTINEL_SERVICE_PORT
}
--csv
SENTINEL get-master-addr-by-name mymaster |
tr
','
' '
|
cut
-d
' '
-f1
)
if [[ -n
${
master
}
]]; then
master="
${
master
//\
"}"
else
echo
"Failed to find master."
sleep 60
exit 1
fi
redis-cli -h
${
master
}
INFO
if [[
"
$?
"
==
"0"
]]; then
break
fi
echo
"Connecting to master failed. Waiting..."
sleep 10
done
sed -i
"s/%master-ip%/
${
master
}
/"
/redis-slave/redis.conf
sed -i
"s/%master-port%/6379/"
/redis-slave/redis.conf
redis-server /redis-slave/redis.conf --protected-mode no
}
if
[[
"
${
MASTER
}
"
==
"true"
]]
;
then
launchmaster
exit
0
fi
if
[[
"
${
SENTINEL
}
"
==
"true"
]]
;
then
launchsentinel
exit
0
fi
launchslave
\ No newline at end of file
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