Exemplo n.º 1
0
import copy
import os
import re
import subprocess
from time import sleep

from flask import json

from aws import AwsConnector
from log import DeployerLogger
from recipe import Recipe
from yml import ByPath
from yml import FileYmlCreator
from yml import find_node

logger = DeployerLogger('k8s').getLogger()
CLUSTER_IP_SERVICE = 'ClusterIP'
LOAD_BALANCER_SERVICE = 'LoadBalancer'


class PodHealthChecker(object):
    def __init__(self, connector):
        self.connector = connector

    def health_check(self, pod_name):
        concrete_pod_name = self.__extract_pod_name(pod_name).strip()
        return 'UP' in self.connector.check_pods_health(concrete_pod_name, pod_name)

    def __extract_pod_name(self, pod_name):
        match = re.search(r"Name:\s(.*)", self.connector.describe_pod(pod_name))
        if match:
Exemplo n.º 2
0
import os

from git_util import GitClient
from log import DeployerLogger
from util import EnvironmentParser
from yml import YmlReader

logger = DeployerLogger(__name__).getLogger()

SERVICES_FOLDER = 'services'


class ConfigUploader:
    def __init__(self, connector):
        self.connector = connector

    def upload_config(self, config_file_path):
        self.connector.upload_config_map(config_file_path)


class GlobalConfigFetcher:
    def __init__(self, git_repository):
        self.git_client = GitClient(git_repository)

    def checkout(self):
        self.git_client.checkout()

    def fetch_global_configuration_for(self, target):
        return self.__fetch_for(target, 'global-configs')

    def fetch_jobs_for(self, target):
Exemplo n.º 3
0
import os
from exceptions import Exception

import yaml

from log import DeployerLogger

logger = DeployerLogger('yml').getLogger()


class NodeNotFoundError(Exception):
    def __init(self, message):
        super(NodeNotFoundError, self).__init__(message)


class YmlCreator(object):
    def __init__(self, base_yml):
        self.base_yml = base_yml
        self.configuration = {}
        self.nodes = []

    def config(self, properties):
        self.configuration.update(properties)
        return self

    def append(self, element, location):
        self.nodes.append({'yml': element, 'locator': ByPath(location), 'config': {}})
        return self

    def create(self):
Exemplo n.º 4
0
import time

import boto3 as boto3

from log import DeployerLogger

logger = DeployerLogger('deployer').getLogger()


class AwsConnector(object):
    def get_certificate_for(self, domain):
        acm_client = boto3.client('acm')
        certificates = acm_client.list_certificates()
        return next((certificate['CertificateArn']
                     for certificate in certificates['CertificateSummaryList']
                     if certificate['DomainName'] == domain), None)