Name: leader
Owner: Rancher
Description: Simple leader election for services in Rancher
Created: 2015-11-07 06:00:37.0
Updated: 2018-03-23 16:45:44.0
Pushed: 2015-12-12 20:09:46.0
Homepage: null
Size: 46
Language: Go
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This is very simple approach to leader election that uses Rancher Meta-data. Every container in a service is given a create_index that increments with each container that is launched in the service. The container with the lowest create_index will be chosen as the master.
This binary is expected to be ran as an ENTRYPOINT
to your container. For example
service
https://github.com/rancher/leader/releases/download/v0.1.0/leader /usr/bin/
chmod +x /usr/bin/leader
YPOINT ["leader"]
["service", "args"]
On startup the leader
binary will check metadata and see if this container is the leader.
If it is the leader the arguments to leader
will be executed. If the container is not the
leader it will just wait until it becomes the leader (ie has the lowest create_index).
You can pass --proxy-tcp-port 8080
to the leader
program and that will make all non-leader
containers just forward traffic to port 8080
of the leader.
Additionally you can just run leader -check
to check if this container is the leader or not.
If it is the leader it will exit with status code 0, otherwise 1.
:
/dist/artifacts/leader - Simple leader election with Rancher
E:
/dist/artifacts/leader [global options] command [command options] [arguments...]
ANDS:
elp, h Shows a list of commands or help for one command
AL OPTIONS:
-proxy-tcp-port "0" Port to proxy to the leader
-check Check if we are the leader and exit
-help, -h show help
-generate-bash-completion
-version, -v print the version
Copyright (c) 2014-2015 Rancher Labs, Inc.
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.