Skip to content
This repository has been archived by the owner on Jun 22, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' into feature/mesos-0.28
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-sandor authored Jul 6, 2016
2 parents 94d40c3 + fd646b3 commit 4f29da9
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 13 deletions.
2 changes: 1 addition & 1 deletion minimesos/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ group = "com.containersol.minimesos"

dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.5'
compile 'com.github.docker-java:docker-java:2.2.3'
compile 'com.github.docker-java:docker-java:3.0.0'
compile 'junit:junit:4.11'
compile 'com.jayway.awaitility:awaitility:1.6.3'
compile 'com.mashape.unirest:unirest-java:1.4.8'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import com.containersol.minimesos.config.ClusterConfig;
import com.containersol.minimesos.state.State;
import com.containersol.minimesos.util.Predicate;
import com.github.dockerjava.api.InternalServerErrorException;
import com.github.dockerjava.api.NotFoundException;
import com.github.dockerjava.api.exception.InternalServerErrorException;
import com.github.dockerjava.api.exception.NotFoundException;
import com.jayway.awaitility.Awaitility;
import com.mashape.unirest.http.exceptions.UnirestException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public class DockerClientFactory {

public static DockerClient build() {
if (dockerClient == null) {
DockerClientConfig.DockerClientConfigBuilder builder = DockerClientConfig.createDefaultConfigBuilder();
DockerClientConfig.DockerClientConfigBuilder builder = DockerClientConfig.createDefaultConfigBuilder().withApiVersion("1.12");

String dockerHostEnv = System.getenv("DOCKER_HOST");
if (StringUtils.isBlank(dockerHostEnv)) {
builder.withUri("unix:///var/run/docker.sock");
builder.withDockerHost("unix:///var/run/docker.sock");
}

DockerClientConfig config = builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import java.util.concurrent.TimeoutException;

import com.containersol.minimesos.MinimesosException;
import com.github.dockerjava.api.DockerException;
import com.github.dockerjava.api.command.InspectContainerResponse;
import com.github.dockerjava.api.command.LogContainerCmd;
import com.github.dockerjava.api.exception.DockerException;
import com.github.dockerjava.api.model.Container;
import com.github.dockerjava.api.model.Frame;
import com.github.dockerjava.api.model.PullResponseItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

import static com.containersol.minimesos.config.MarathonConfig.*;
import static com.jayway.awaitility.Awaitility.await;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;

Expand Down Expand Up @@ -92,10 +93,10 @@ public void deleteApp(String app) {

@Override
protected CreateContainerCmd dockerCommand() {
ExposedPort exposedPort = ExposedPort.tcp(MarathonConfig.MARATHON_PORT);
ExposedPort exposedPort = ExposedPort.tcp(MARATHON_PORT);
Ports portBindings = new Ports();
if (getCluster().isMapPortsToHost()) {
portBindings.bind(exposedPort, new Ports.Binding(MarathonConfig.MARATHON_PORT));
portBindings.bind(exposedPort, Ports.Binding.bindPort(MARATHON_PORT));
}
return DockerClientFactory.build().createContainerCmd(config.getImageName() + ":" + config.getImageTag())
.withName(getName())
Expand Down Expand Up @@ -196,7 +197,7 @@ public void killAllApps() {

@Override
protected int getServicePort() {
return MarathonConfig.MARATHON_PORT;
return MARATHON_PORT;
}

public void waitFor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.containersol.minimesos.marathon.MarathonContainer;
import com.github.dockerjava.api.model.Container;

import com.github.dockerjava.api.model.ContainerPort;
import org.apache.commons.io.IOUtils;

/**
Expand Down Expand Up @@ -111,9 +112,9 @@ private void restoreMesosVersion(MesosCluster cluster, MesosMaster master) {

private void restoreMapToPorts(MesosCluster cluster, Container container) {
// Restore "map ports to host" attribute
Container.Port[] ports = container.getPorts();
ContainerPort[] ports = container.getPorts();
if (ports != null) {
for (Container.Port port : ports) {
for (ContainerPort port : ports) {
if (port.getIp() != null && port.getPrivatePort() == MesosMasterConfig.MESOS_MASTER_PORT) {
cluster.setMapPortsToHost(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected CreateContainerCmd dockerCommand() {

Ports portBindings = new Ports();
if (getCluster().isMapPortsToHost()) {
portBindings.bind(exposedPort, new Ports.Binding(port));
portBindings.bind(exposedPort, Ports.Binding.bindPort(port));
}

return DockerClientFactory.build().createContainerCmd(getImageName() + ":" + getImageTag())
Expand Down
7 changes: 7 additions & 0 deletions sonar/DockerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM sonarqube:5.3
MAINTAINER Container Solutions BV <[email protected]>

ADD sonar-plugins/sonar-github-plugin-1.1.jar /opt/sonarqube/extensions/plugins
ADD sonar-plugins/sonar-java-plugin-3.7.1.jar /opt/sonarqube/extensions/plugins
ADD sonar-plugins/sonar-scm-git-plugin-1.0.jar /opt/sonarqube/extensions/plugins
ADD sonar-plugins/sonar-scm-svn-plugin-1.2.jar /opt/sonarqube/extensions/plugins
33 changes: 33 additions & 0 deletions sonar/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
### Create Persistent Disk
`gcloud compute disks create --size 200GB minimesos-sonar-postgres-disk`

### Attach created disk to linux instance for formatting and data transfer
`gcloud compute instances attach-disk jenkins-ci-4 --disk minimesos-sonar-postgres-disk --device-name postgresdisk`

### Mount and format disk
``/usr/share/google/safe_format_and_mount /dev/disk/by-id/google-postgresdisk /postgresdisk`

### Detach Disk from linux instance
`gcloud compute instances detach-disk jenkins-ci-4 --disk minimesos-sonar-postgres-disk`

### Create cluster

Did this one from the web console, so couldn't record the command. Here are the details of the cluster:
Cluster size: 1
Node type: n1-standard-2 (2 vCPUs, 7.5 GB memory)
Master zone: europe-west1-d
Node zones: europe-west1-d
Network: ci-network

### Create database password secret
This password gets applied to the postgres database on first start, changin it later is not possible as it's persisted
to the persistent disk

echo -n "thepassword" > password
`kubectl create secret generic postgres-pwd --from-file=./password`

### TODO

1. Create new domain name as old one can't be shared anymore between Jenkins and Sonar. sonar.minimesos.ci.container-solutions.com
2. Make https work for sonar
3. User management in sonar?
28 changes: 28 additions & 0 deletions sonar/sonar-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: sonar
spec:
replicas: 1
template:
metadata:
name: sonar
labels:
name: sonar
spec:
containers:
- image: containersol/minimesos-sonar
args:
- -Dsonar.web.context=/sonar
name: sonar
env:
- name: SONARQUBE_JDBC_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-pwd
key: password
- name: SONARQUBE_JDBC_URL
value: jdbc:postgresql://sonar-postgres:5432/sonar
ports:
- containerPort: 9000
name: sonar
Binary file added sonar/sonar-plugins/sonar-github-plugin-1.1.jar
Binary file not shown.
Binary file added sonar/sonar-plugins/sonar-java-plugin-3.7.1.jar
Binary file not shown.
Binary file added sonar/sonar-plugins/sonar-scm-git-plugin-1.0.jar
Binary file not shown.
Binary file added sonar/sonar-plugins/sonar-scm-svn-plugin-1.2.jar
Binary file not shown.
36 changes: 36 additions & 0 deletions sonar/sonar-postgres-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: sonar-postgres
spec:
replicas: 1
template:
metadata:
name: sonar-postgres
labels:
name: sonar-postgres
spec:
containers:
- image: postgres:9.5.3
name: sonar-postgres
env:
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-pwd
key: password
- name: POSTGRES_USER
value: sonar
ports:
- containerPort: 5432
name: postgresport
volumeMounts:
# This name must match the volumes.name below.
- name: data-disk
mountPath: /var/lib/postgresql/data
volumes:
- name: data-disk
gcePersistentDisk:
# This disk must already exist.
pdName: minimesos-sonar-postgres-disk
fsType: ext4
11 changes: 11 additions & 0 deletions sonar/sonar-postgres-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
labels:
name: sonar-postgres
name: sonar-postgres
spec:
ports:
- port: 5432
selector:
name: sonar-postgres
14 changes: 14 additions & 0 deletions sonar/sonar-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
labels:
name: sonar
name: sonar
spec:
ports:
- port: 80
targetPort: 9000
name: sonarport
selector:
name: sonar
type: LoadBalancer
2 changes: 1 addition & 1 deletion test-framework-docker/system-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies {
compile project(':test-framework-docker:executor')
compile project(':minimesos')

compile 'com.github.docker-java:docker-java:2.2.3'
compile 'com.github.docker-java:docker-java:3.0.0'
compile 'com.jayway.awaitility:awaitility:1.6.3'

compile 'org.slf4j:jul-to-slf4j:1.7.12'
Expand Down

0 comments on commit 4f29da9

Please sign in to comment.