feat: convert jenkins to Helm chart (helm/jenkins/) #6
100
helm/jenkins/templates/deployment.yaml
Normal file
100
helm/jenkins/templates/deployment.yaml
Normal file
@@ -0,0 +1,100 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "jenkins.name" . }}
|
||||
namespace: {{ .Values.namespace }}
|
||||
labels:
|
||||
{{- include "jenkins.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "jenkins.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "jenkins.selectorLabels" . | nindent 8 }}
|
||||
spec:
|
||||
serviceAccountName: {{ include "jenkins.serviceAccountName" . }}
|
||||
securityContext:
|
||||
fsGroup: {{ .Values.securityContext.fsGroup }}
|
||||
initContainers:
|
||||
{{- if .Values.initContainers.installDocker.enabled }}
|
||||
- name: install-docker
|
||||
image: {{ .Values.initContainers.installDocker.image }}
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
echo "Installing Docker CLI..."
|
||||
cp /usr/local/bin/docker /tmp/tools-bin/
|
||||
chmod +x /tmp/tools-bin/docker
|
||||
echo "Docker CLI installed"
|
||||
volumeMounts:
|
||||
- name: tools-bin
|
||||
mountPath: /tmp/tools-bin
|
||||
{{- end }}
|
||||
{{- if .Values.initContainers.installKubectl.enabled }}
|
||||
- name: install-kubectl
|
||||
image: {{ .Values.initContainers.installKubectl.image }}
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
echo "Installing kubectl {{ .Values.initContainers.installKubectl.kubectlVersion }}..."
|
||||
wget -q -O /tmp/tools-bin/kubectl \
|
||||
"https://dl.k8s.io/release/{{ .Values.initContainers.installKubectl.kubectlVersion }}/bin/linux/amd64/kubectl"
|
||||
chmod +x /tmp/tools-bin/kubectl
|
||||
echo "kubectl installed"
|
||||
volumeMounts:
|
||||
- name: tools-bin
|
||||
mountPath: /tmp/tools-bin
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ include "jenkins.name" . }}
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ .Values.service.httpPort }}
|
||||
- name: agent
|
||||
containerPort: {{ .Values.service.agentPort }}
|
||||
env:
|
||||
{{- toYaml .Values.extraEnv | nindent 12 }}
|
||||
{{- if .Values.containerd.enabled }}
|
||||
- name: DOCKER_HOST
|
||||
value: "unix:///var/run/containerd.sock"
|
||||
{{- end }}
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
export PATH="/tmp/tools-bin:$PATH"
|
||||
exec /usr/local/bin/jenkins.sh
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
volumeMounts:
|
||||
- name: jenkins-home
|
||||
mountPath: /var/jenkins_home
|
||||
{{- if .Values.containerd.enabled }}
|
||||
- name: docker-sock
|
||||
mountPath: /var/run/containerd.sock
|
||||
{{- end }}
|
||||
- name: tools-bin
|
||||
mountPath: /tmp/tools-bin
|
||||
volumes:
|
||||
- name: jenkins-home
|
||||
{{- if .Values.persistence.enabled }}
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ .Values.persistence.claimName }}
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- if .Values.containerd.enabled }}
|
||||
- name: docker-sock
|
||||
hostPath:
|
||||
path: {{ .Values.containerd.socketPath }}
|
||||
type: Socket
|
||||
{{- end }}
|
||||
- name: tools-bin
|
||||
emptyDir: {}
|
||||
Reference in New Issue
Block a user