Exemplo n.º 1
0
class GerritFrontendPod(PodUnit):
  APP_CONTAINER = "crewjam/gerrit"

  def __init__(self, service_name):
    service_name = service_name or "gerrit"
    PodUnit.__init__(self, service_name=service_name)

    self.app = ContainerRunnerUnit(container=self.APP_CONTAINER,
      name=service_name + "-app")
    self.app.ports.append("8080:8080")
    self.app.ports.append("29418:29418")
    self.AddChild(self.app)

    self.app_presence = PresenceUnit(self.app)
    self.AddChild(self.app_presence, bind=True)

    # TODO(ross): what if we need access to multiple postgres instances? We
    #   should use docker --link instead I think, if we can get it to work
    self.postgres_amb = MasterOnlyAmbassadorUnit(
      foreign_service_name=service_name + "-db",
      local_service_name=service_name,
      port=5432)
    self.AddChild(self.postgres_amb)
    self.app.set("Unit", "After", self.postgres_amb.name + "@%i.service")
    self.app.environment["POSTGRES_SERVER"] = "${COREOS_PRIVATE_IPV4}"
    self.app.environment["SERVICE_NAME"] = service_name

    self.data_volume = DataVolumeUnit(
      volume_name=service_name + "-git",
      name=service_name + "-data-volume-git")
    self.AddChild(self.data_volume)
    self.app.set("Unit", "After", self.data_volume.name + "@%i.service")
    self.app.volumes.append((self.data_volume.host_path, "/data/git"))
Exemplo n.º 2
0
class GerritFrontendPod(PodUnit):
    APP_CONTAINER = "crewjam/gerrit"

    def __init__(self, service_name):
        service_name = service_name or "gerrit"
        PodUnit.__init__(self, service_name=service_name)

        self.app = ContainerRunnerUnit(container=self.APP_CONTAINER,
                                       name=service_name + "-app")
        self.app.ports.append("8080:8080")
        self.app.ports.append("29418:29418")
        self.AddChild(self.app)

        self.app_presence = PresenceUnit(self.app)
        self.AddChild(self.app_presence, bind=True)

        # TODO(ross): what if we need access to multiple postgres instances? We
        #   should use docker --link instead I think, if we can get it to work
        self.postgres_amb = MasterOnlyAmbassadorUnit(
            foreign_service_name=service_name + "-db",
            local_service_name=service_name,
            port=5432)
        self.AddChild(self.postgres_amb)
        self.app.set("Unit", "After", self.postgres_amb.name + "@%i.service")
        self.app.environment["POSTGRES_SERVER"] = "${COREOS_PRIVATE_IPV4}"
        self.app.environment["SERVICE_NAME"] = service_name

        self.data_volume = DataVolumeUnit(volume_name=service_name + "-git",
                                          name=service_name +
                                          "-data-volume-git")
        self.AddChild(self.data_volume)
        self.app.set("Unit", "After", self.data_volume.name + "@%i.service")
        self.app.volumes.append((self.data_volume.host_path, "/data/git"))
Exemplo n.º 3
0
class PostgresPod(PodUnit):
  APP_CONTAINER = "crewjam/postgres"

  def __init__(self, name):
    PodUnit.__init__(self, service_name=name)

    self.app = ContainerRunnerUnit(container=self.APP_CONTAINER,
      name=name)
    self.app.ports.append("${COREOS_PRIVATE_IPV4}:5432:5432")
    self.app.environment["SERVICE_NAME"] = name
    self.app.environment["INSTANCE"] = "%i"
    self.app.environment["PRIVATE_IP"] = "${COREOS_PRIVATE_IPV4}"

    # We rely on having etcd available either via etcd or etcd-amb
    self.app.environment["ETCDCTL_PEERS"] = "http://${COREOS_PRIVATE_IPV4}:4001"
    self.app.set("Unit", "After", "etcd-amb.service")
    self.app.set("Unit", "After", "etcd.service")
    self.AddChild(self.app)

    self.data_volume = DataVolumeUnit(
      volume_name=name,
      name=name + "-data-volume")
    self.AddChild(self.data_volume)
    self.app.set("Unit", "After", self.data_volume.name + "@%i.service")
    self.app.volumes.append((self.data_volume.host_path,
      "/var/lib/postgresql/data"))
Exemplo n.º 4
0
class PostgresPod(PodUnit):
    APP_CONTAINER = "crewjam/postgres"

    def __init__(self, name):
        PodUnit.__init__(self, service_name=name)

        self.app = ContainerRunnerUnit(container=self.APP_CONTAINER, name=name)
        self.app.ports.append("${COREOS_PRIVATE_IPV4}:5432:5432")
        self.app.environment["SERVICE_NAME"] = name
        self.app.environment["INSTANCE"] = "%i"
        self.app.environment["PRIVATE_IP"] = "${COREOS_PRIVATE_IPV4}"

        # We rely on having etcd available either via etcd or etcd-amb
        self.app.environment[
            "ETCDCTL_PEERS"] = "http://${COREOS_PRIVATE_IPV4}:4001"
        self.app.set("Unit", "After", "etcd-amb.service")
        self.app.set("Unit", "After", "etcd.service")
        self.AddChild(self.app)

        self.data_volume = DataVolumeUnit(volume_name=name,
                                          name=name + "-data-volume")
        self.AddChild(self.data_volume)
        self.app.set("Unit", "After", self.data_volume.name + "@%i.service")
        self.app.volumes.append(
            (self.data_volume.host_path, "/var/lib/postgresql/data"))