Add support for Kubernetes to the build-jenkins.sh
Added a template for the Jenkins' Kubernetes objects.
Updated the kubernetes-launch.sh to allow for the build-jenkins.sh to
use it to launch the template.
Change-Id: I12412a1d06b1179a5d61a6e23e19cd07bf35617d
Signed-off-by: Alanny Lopez <alannyglopez@gmail.com>
diff --git a/build-jenkins.sh b/build-jenkins.sh
index 341f89a..2442a2a 100755
--- a/build-jenkins.sh
+++ b/build-jenkins.sh
@@ -258,7 +258,5 @@
elif [[ ${launch} == "k8s" ]]; then
# launch using the k8s template
- echo "Not yet Implemented"
- exit 1
source ${build_scripts_dir}/kubernetes/kubernetes-launch.sh Build-Jenkins false false
fi
diff --git a/kubernetes/Templates/Build-Jenkins-k8s.yaml b/kubernetes/Templates/Build-Jenkins-k8s.yaml
new file mode 100644
index 0000000..44b52e7
--- /dev/null
+++ b/kubernetes/Templates/Build-Jenkins-k8s.yaml
@@ -0,0 +1,65 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+ name: ${deploy_name}
+ namespace: openbmc
+ labels:
+ app: ${deploy_name}
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: ${deploy_name}
+ template:
+ metadata:
+ labels:
+ app: ${deploy_name}
+ spec:
+ volumes:
+ - name: config
+ persistentVolumeClaim:
+ claimName: ${h_claim}
+ containers:
+ - env:
+ - name: JAVA_OPTS
+ value: ${java_options}
+ - name: JENKINS_OPTS
+ value: ${jenkins_options}
+ name: ${pod_name}
+ image: ${img_name}
+ ports:
+ - containerPort: ${http_port}
+ protocol: TCP
+ name: ui
+ - containerPort: ${agent_port}
+ protocol: TCP
+ name: slave-listener
+ resources: {}
+ volumeMounts:
+ - name: config
+ mountPath: ${j_home}
+ nodeSelector:
+ beta.kubernetes.io/arch: ${ARCH}
+---
+apiVersion: v1
+kind: Service
+metadata:
+ labels:
+ app: jenkins-master
+ name: jenkins-master
+ namespace: openbmc
+spec:
+ clusterIP: ${cluster_ip}
+ ports:
+ - name: ui
+ port: ${http_port}
+ nodePort: ${http_nodeport}
+ protocol: TCP
+ - name: slave-listener
+ port: ${agent_port}
+ nodePort: ${agent_nodeport}
+ protocol: TCP
+ selector:
+ app: jenkins-master
+ sessionAffinity: None
+ type: NodePort
diff --git a/kubernetes/kubernetes-launch.sh b/kubernetes/kubernetes-launch.sh
index fd8e95c..a9b0c5f 100755
--- a/kubernetes/kubernetes-launch.sh
+++ b/kubernetes/kubernetes-launch.sh
@@ -86,6 +86,15 @@
# Set the variables for the specific invoker to fill in the YAML template
# Other variables in the template not declared here are declared by invoker
case ${invoker} in
+ Build-Jenkins)
+ deploy_name=${deploy_name:-jenkins-master}
+ pod_name=${pod_name:-jenkins-master-pod}
+ new_img_name="${img_repo}jenkins-master-${ARCH}:${j_vrsn}"
+ h_claim=${h_claim:-jenkins-home}
+ cluster_ip=${cluster_ip:-10.0.0.175}
+ http_nodeport=${http_nodeport:-32222}
+ agent_nodeport=${agent_nodeport:-32223}
+ ;;
OpenBMC-build)
w_claim=${w_claim:-jenkins-slave-space}
s_claim=${s_claim:-shared-state-cache}
@@ -147,7 +156,7 @@
sleep 1
let job_timeout-=1
fi
- replace=$(kubectl get pods -n ${namespaces} | grep ${pod_name} | awk 'print $1')
+ replace=$(kubectl get pods -n ${namespace} | grep ${pod_name} | awk 'print $1')
done
pod_name=${replace}
fi