From 06d7cf1d418ac5d793ace80c83958dd1cc8b84e3 Mon Sep 17 00:00:00 2001 From: Mike Aizatsky Date: Wed, 20 Jul 2016 15:51:51 -0700 Subject: [PATCH] [infra] using replication controller for jenkins-master --- infra/jenkins-cluster/Dockerfile | 7 +++++ infra/jenkins-cluster/build-images.sh | 24 ++++++++++++++ .../{start_cluster.sh => create-cluster.sh} | 9 ++---- infra/jenkins-cluster/jenkins-master.yaml | 31 +++++++++---------- 4 files changed, 49 insertions(+), 22 deletions(-) create mode 100755 infra/jenkins-cluster/build-images.sh rename infra/jenkins-cluster/{start_cluster.sh => create-cluster.sh} (85%) diff --git a/infra/jenkins-cluster/Dockerfile b/infra/jenkins-cluster/Dockerfile index 685613a75..d87970c17 100644 --- a/infra/jenkins-cluster/Dockerfile +++ b/infra/jenkins-cluster/Dockerfile @@ -15,4 +15,11 @@ ################################################################################ FROM jenkins +MAINTAINER mike.aizatsky@gmail.com USER root + +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update && apt-get upgrade -y + +# /var/run/docker.sock will be bound to a pod. +RUN apt-get install -y docker.io diff --git a/infra/jenkins-cluster/build-images.sh b/infra/jenkins-cluster/build-images.sh new file mode 100755 index 000000000..1ed9e6a64 --- /dev/null +++ b/infra/jenkins-cluster/build-images.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +set -e -x + +PROJECT="gcr.io/meta-iterator-105109" +DIR=$(dirname $0) + +docker build --pull -t $PROJECT/jenkins $DIR/ +gcloud docker push $PROJECT/jenkins diff --git a/infra/jenkins-cluster/start_cluster.sh b/infra/jenkins-cluster/create-cluster.sh similarity index 85% rename from infra/jenkins-cluster/start_cluster.sh rename to infra/jenkins-cluster/create-cluster.sh index d9b63ab9e..abe452bb3 100755 --- a/infra/jenkins-cluster/start_cluster.sh +++ b/infra/jenkins-cluster/create-cluster.sh @@ -17,14 +17,11 @@ set -x -PROJECT="gcr.io/meta-iterator-105109" DIR=$(dirname $0) - -docker build --pull -t $PROJECT/jenkins $DIR/ -gcloud docker push $PROJECT/jenkins +$DIR/build-images.sh # delete jenkins-master if it exists before starting -kubectl get petset jenkins-master +kubectl get rc jenkins-master if [ $? -eq 0 ] then kubectl delete -f $DIR/jenkins-master.yaml @@ -43,5 +40,5 @@ then kubectl create -f $DIR/service-jenkins-master.yaml fi -kubectl describe petset jenkins-master +kubectl describe rc jenkins-master kubectl describe service jenkins-http diff --git a/infra/jenkins-cluster/jenkins-master.yaml b/infra/jenkins-cluster/jenkins-master.yaml index f56a9cc80..93f700eeb 100644 --- a/infra/jenkins-cluster/jenkins-master.yaml +++ b/infra/jenkins-cluster/jenkins-master.yaml @@ -1,19 +1,18 @@ -apiVersion: apps/v1alpha1 -kind: PetSet +kind: ReplicationController +apiVersion: v1 metadata: name: jenkins-master spec: - serviceName: "jenkins-master" replicas: 1 + selector: + app: jenkins-master template: metadata: + name: jenkins-master labels: app: jenkins-master - annotations: - pod.alpha.kubernetes.io/initialized: "true" spec: - terminationGracePeriodSeconds: 0 containers: - name: jenkins-master image: gcr.io/meta-iterator-105109/jenkins @@ -34,6 +33,8 @@ spec: volumeMounts: - name: jenkins-work mountPath: "/var/jenkins_home" + - name: docker-sock + mountPath: "/var/run/docker.sock" livenessProbe: httpGet: path: "/login" @@ -45,13 +46,11 @@ spec: memory: "4Gi" securityContext: privileged: true - volumeClaimTemplates: - - metadata: - name: jenkins-work - annotations: - volume.alpha.kubernetes.io/storage-class: anything - spec: - accessModes: [ "ReadWriteOnce" ] - resources: - requests: - storage: 250Gi + volumes: + - name: jenkins-work + gcePersistentDisk: + pdName: jenkins-work + fsType: ext4 + - name: docker-sock + hostPath: + path: /var/run/docker.sock