-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba2b055
commit 448cee9
Showing
11 changed files
with
270 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Kafka Manager | ||
|
||
- https://github.com/yahoo/kafka-manager | ||
|
||
## Configuration | ||
|
||
- https://github.com/yahoo/kafka-manager#configuration | ||
|
||
See `lib/kafka/kafka_manager_configure.rake` | ||
|
||
Look for "kafka_manager" in: | ||
- `config/settings/{stage}.yml` | ||
- `config/deploy/{stage}.rb` | ||
|
||
## Capistrano tasks | ||
|
||
```bash | ||
$ bundle exec cap -T | grep kafka_manager | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
require_relative 'kafka_manager_helpers' | ||
|
||
# Kafka Manager Configuration | ||
# https://github.com/yahoo/kafka-manager#configuration | ||
# | ||
namespace :kafka_manager do | ||
namespace :service do | ||
def kafka_manager_conf | ||
@kafka_manager_conf ||= capture('ls /usr/share/kafka-manager/conf/application.conf') | ||
end | ||
|
||
# basicAuthentication | ||
# basicAuthentication.enabled=false | ||
# basicAuthentication.username="admin" | ||
# basicAuthentication.password="password" | ||
# basicAuthentication.realm="Kafka-Manager" | ||
# basicAuthentication.excluded=["/api/health"] # ping the health of your instance without authentification | ||
def kafka_manager_authentication | ||
return unless configuration.basicAuthentication.enabled | ||
enabled = "basicAuthentication.enabled=#{configuration.basicAuthentication.enabled}" | ||
sudo("sed -i -e 's#basicAuthentication.enabled=.*##{enabled}#' #{kafka_manager_conf}") | ||
# basicAuthentication.username="admin" | ||
username = "basicAuthentication.username=\"#{configuration.basicAuthentication.username}\"" | ||
sudo("sed -i -e 's#basicAuthentication.username=.*##{username}#' #{kafka_manager_conf}") | ||
# basicAuthentication.password="password" | ||
password = "basicAuthentication.password=\"#{configuration.basicAuthentication.password}\"" | ||
sudo("sed -i -e 's#basicAuthentication.password=.*##{password}#' #{kafka_manager_conf}") | ||
end | ||
|
||
# application.features=["KMClusterManagerFeature","KMTopicManagerFeature", | ||
# "KMPreferredReplicaElectionFeature","KMReassignPartitionsFeature"] | ||
# | ||
# KMClusterManagerFeature - allows adding, updating, deleting cluster from Kafka Manager | ||
# KMTopicManagerFeature - allows adding, updating, deleting topic from a Kafka cluster | ||
# KMPreferredReplicaElectionFeature - allows running of preferred replica election for a Kafka cluster | ||
# KMReassignPartitionsFeature - allows generating partition assignments and reassigning partitions | ||
def kafka_manager_features | ||
features = "application.features=[#{configuration.features.join(',')}]" | ||
sudo("sed -i -e 's#application.features=.*##{features}#' #{kafka_manager_conf}") | ||
end | ||
|
||
# Set kafka-manager.zkhosts (note the /kafka chroot path) | ||
# - for multiple ZooKeeper instances, the kafka-manager.zkhosts should be a | ||
# comma-separated string listing the IP addresses and port numbers | ||
# of all the ZooKeeper instances. | ||
def kafka_manager_zookeeper_connect | ||
# Note the use of a '#' in sed delimiter, because connections may contain `/` chars | ||
zk = ZookeeperHelpers.connections(false).join(',') | ||
zoo_connect = "kafka-manager.zkhosts=#{zk}/kafka" | ||
sudo("sed -i -e 's#kafka-manager.zkhosts=.*##{zoo_connect}#' #{kafka_manager_conf}") | ||
end | ||
|
||
desc 'Configure Kafka Manager' | ||
task :configure do | ||
on roles(:kafka_manager), in: :parallel do |host| | ||
kafka_manager_features | ||
kafka_manager_zookeeper_connect | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
# Utilities for working with Kafka | ||
module KafkaManagerHelpers | ||
|
||
module_function | ||
|
||
SERVICE = 'kafka_manager'.freeze | ||
|
||
# KAFKA_HOME_DEFAULT = '/opt/kafka'.freeze | ||
|
||
def settings | ||
@settings ||= ServiceSettings.new SERVICE | ||
end | ||
|
||
def manager | ||
@manager ||= ServiceManager.new SERVICE | ||
end | ||
|
||
def configuration | ||
settings.configuration | ||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require_relative 'kafka_manager_helpers' | ||
|
||
# Kafka Manager Installation | ||
# https://github.com/yahoo/kafka-manager | ||
# | ||
namespace :kafka_manager do | ||
namespace :service do | ||
def install_kafka_manager | ||
install_java8 | ||
sudo(ubuntu_helper.sbt) | ||
sudo(ubuntu_helper.kafka_manager) | ||
end | ||
|
||
desc 'Install Kafka Manager service' | ||
task :install do | ||
on roles(:kafka_manager), in: :parallel do |host| | ||
install_kafka_manager | ||
KafkaManagerHelpers.manager.reboot_node(host_settings) | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require_relative 'kafka_manager_helpers' | ||
|
||
namespace :kafka_manager do | ||
namespace :nodes do | ||
desc 'List settings in this project' | ||
task :check_settings do | ||
KafkaManagerHelpers.settings.nodes.each do |params| | ||
puts JSON.pretty_generate(JSON.parse(params.to_json)) | ||
end | ||
end | ||
|
||
desc 'Create nodes' | ||
task :create do | ||
KafkaManagerHelpers.manager.create_nodes | ||
end | ||
|
||
desc 'Find and describe all nodes' | ||
task :find do | ||
KafkaManagerHelpers.manager.describe_nodes | ||
end | ||
|
||
desc 'Reboot Kafka systems - WARNING, can reset IPs' | ||
task :reboot do | ||
KafkaManagerHelpers.manager.reboot_nodes | ||
end | ||
|
||
desc 'Terminate nodes' | ||
task :terminate do | ||
KafkaManagerHelpers.manager.terminate_nodes | ||
end | ||
|
||
desc 'Compose public entries for ~/.ssh/config for nodes' | ||
task :ssh_config_public do | ||
puts KafkaManagerHelpers.manager.ssh_config | ||
end | ||
|
||
desc 'Compose entries for /etc/hosts using public IPs' | ||
task :etc_hosts_public do | ||
puts KafkaManagerHelpers.manager.etc_hosts.join("\n") | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require_relative 'kafka_manager_helpers' | ||
|
||
namespace :kafka_manager do | ||
namespace :service do | ||
def kafka_manager_running? | ||
pid = capture('ls /usr/share/kafka-manager/RUNNING_PID') | ||
! pid.nil? | ||
end | ||
|
||
desc 'Start Kafka Manager' | ||
task :start do | ||
on roles(:kafka_manager) do |host| | ||
# TODO: Create 'kafka' user/group to run the service | ||
if kafka_manager_running? | ||
puts "#{host.hostname} is already running Kafka Manager" | ||
else | ||
sudo('kafka-manager') | ||
end | ||
end | ||
end | ||
|
||
desc 'Status of Kafka Manager' | ||
task :status do | ||
on roles(:kafka_manager) do |host| | ||
if kafka_running? | ||
puts "#{host.hostname} is running Kafka Manager" | ||
else | ||
puts "#{host.hostname} is not running Kafka Manager" | ||
end | ||
end | ||
end | ||
|
||
desc 'Stop Kafka Manager' | ||
task :stop do | ||
on roles(:kafka_manager) do | ||
# Ignore the exit(1) status when it's not running already | ||
sudo('${KAFKA_BIN}/kafka-server-stop.sh || true') | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters