Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bubuku-48: add docker-compose support
- Loading branch information
Showing
15 changed files
with
367 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,6 @@ | |
*.pyc | ||
.eggs/ | ||
bubuku.egg-info/ | ||
.cache/ | ||
.cache/ | ||
build/ | ||
dist/ |
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,30 @@ | ||
FROM registry.opensource.zalan.do/stups/python:3.5.1-23 | ||
MAINTAINER Team Aruha, team-aruha@zalando.de | ||
|
||
ENV KAFKA_VERSION="0.9.0.1" SCALA_VERSION="2.11" JOLOKIA_VERSION="1.3.3" | ||
ENV KAFKA_DIR="/opt/kafka" | ||
|
||
RUN apt-get update && apt-get install wget openjdk-8-jre -y --force-yes && apt-get clean | ||
ADD download_kafka.sh /tmp/download_kafka.sh | ||
|
||
RUN sh /tmp/download_kafka.sh ${SCALA_VERSION} ${KAFKA_VERSION} ${KAFKA_DIR} | ||
|
||
ADD server.properties ${KAFKA_DIR}/config/ | ||
|
||
RUN wget -O /tmp/jolokia-jvm-agent.jar http://search.maven.org/remotecontent?filepath=org/jolokia/jolokia-jvm/$JOLOKIA_VERSION/jolokia-jvm-$JOLOKIA_VERSION-agent.jar | ||
|
||
ENV KAFKA_OPTS="-server -Dlog4j.configuration=file:${KAFKA_DIR}/config/log4j.properties -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=32M -javaagent:/tmp/jolokia-jvm-agent.jar=host=0.0.0.0" | ||
ENV KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" | ||
|
||
RUN mkdir -p $KAFKA_DIR/logs/ | ||
|
||
ENV KAFKA_SETTINGS="${KAFKA_DIR}/config/server.properties" | ||
ADD server.properties ${KAFKA_SETTINGS} | ||
ADD log4j.properties ${KAFKA_DIR}/config/ | ||
|
||
RUN mkdir /bubuku/ | ||
WORKDIR /bubuku/ | ||
ADD ./ /bubuku/ | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
CMD python3 setup.py develop && bubuku |
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,85 @@ | ||
import json | ||
import logging | ||
|
||
import boto3 | ||
import requests | ||
|
||
from bubuku.zookeeper.exhibior import AWSExhibitorAddressProvider | ||
from bubuku.zookeeper.exhibior import LocalAddressProvider | ||
from bubuku.config import Config | ||
|
||
_LOG = logging.getLogger('bubuku.amazon') | ||
|
||
|
||
class EnvProvider(object): | ||
def get_own_ip(self) -> str: | ||
raise NotImplementedError('Not implemented') | ||
|
||
def get_address_provider(self, config: Config): | ||
raise NotImplementedError('Not implemented') | ||
|
||
@staticmethod | ||
def create_env_provider(dev_mode: bool): | ||
return LocalEnvProvider() if dev_mode else AmazonEnvProvider() | ||
|
||
|
||
class AmazonEnvProvider(EnvProvider): | ||
NONE = object() | ||
|
||
def __init__(self): | ||
self.document = None | ||
self.aws_addr = '169.254.169.254' | ||
|
||
def _get_document(self) -> dict: | ||
if not self.document: | ||
try: | ||
self.document = requests.get( | ||
'http://{}/latest/dynamic/instance-identity/document'.format(self.aws_addr), | ||
timeout=5).json() | ||
_LOG.info("Amazon specific information loaded from AWS: {}".format( | ||
json.dumps(self.document, indent=2))) | ||
except Exception as ex: | ||
_LOG.warn('Failed to download AWS document', exc_info=ex) | ||
self.document = AmazonEnvProvider.NONE | ||
return self.document if self.document != AmazonEnvProvider.NONE else None | ||
|
||
def get_aws_region(self) -> str: | ||
doc = self._get_document() | ||
return doc['region'] if doc else None | ||
|
||
def get_own_ip(self) -> str: | ||
doc = self._get_document() | ||
return doc['privateIp'] if doc else '127.0.0.1' | ||
|
||
def get_addresses_by_lb_name(self, lb_name) -> list: | ||
region = self.get_aws_region() | ||
|
||
private_ips = [] | ||
|
||
if region is not None: | ||
elb = boto3.client('elb', region_name=region) | ||
ec2 = boto3.client('ec2', region_name=region) | ||
|
||
response = elb.describe_instance_health(LoadBalancerName=lb_name) | ||
|
||
for instance in response['InstanceStates']: | ||
if instance['State'] == 'InService': | ||
private_ips.append(ec2.describe_instances( | ||
InstanceIds=[instance['InstanceId']])['Reservations'][0]['Instances'][0]['PrivateIpAddress']) | ||
|
||
else: | ||
private_ips = [lb_name] | ||
_LOG.info("Ip addresses for {} are: {}".format(lb_name, private_ips)) | ||
return private_ips | ||
|
||
def get_address_provider(self, config: Config): | ||
return AWSExhibitorAddressProvider(self, config.zk_stack_name) | ||
|
||
|
||
class LocalEnvProvider(EnvProvider): | ||
def get_own_ip(self) -> str: | ||
return '127.0.0.1' | ||
|
||
def get_address_provider(self, config: Config): | ||
return LocalAddressProvider() | ||
|
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
Oops, something went wrong.