79 lines
1.9 KiB
YAML
79 lines
1.9 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: jenkins
|
|
namespace: jenkins
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: jenkins
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: jenkins
|
|
spec:
|
|
securityContext:
|
|
fsGroup: 1000
|
|
initContainers:
|
|
- name: install-tools
|
|
image: alpine:3.19
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
# Install Docker CLI
|
|
apk add --no-cache docker-cli
|
|
cp /usr/bin/docker /tmp/tools-bin/
|
|
|
|
# Install kubectl
|
|
wget -O /tmp/tools-bin/kubectl "https://dl.k8s.io/release/v1.28.0/bin/linux/amd64/kubectl"
|
|
chmod +x /tmp/tools-bin/kubectl
|
|
|
|
echo "✅ Docker and kubectl installed"
|
|
ls -la /tmp/tools-bin/
|
|
volumeMounts:
|
|
- name: tools-bin
|
|
mountPath: /tmp/tools-bin
|
|
containers:
|
|
- name: jenkins
|
|
image: jenkins/jenkins:lts-jdk17
|
|
ports:
|
|
- containerPort: 8080
|
|
- containerPort: 50000
|
|
env:
|
|
- name: JENKINS_OPTS
|
|
value: "--httpPort=8080"
|
|
- name: DOCKER_HOST
|
|
value: "unix:///var/run/docker.sock"
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
export PATH="/tmp/tools-bin:$PATH"
|
|
exec /usr/local/bin/jenkins.sh
|
|
volumeMounts:
|
|
- name: jenkins-home
|
|
mountPath: /var/jenkins_home
|
|
- name: docker-sock
|
|
mountPath: /var/run/docker.sock
|
|
- name: tools-bin
|
|
mountPath: /tmp/tools-bin
|
|
- name: kubeconfig
|
|
mountPath: /root/.kube
|
|
readOnly: true
|
|
volumes:
|
|
- name: jenkins-home
|
|
persistentVolumeClaim:
|
|
claimName: jenkins-home
|
|
- name: docker-sock
|
|
hostPath:
|
|
path: /var/run/docker.sock
|
|
type: Socket
|
|
- name: tools-bin
|
|
emptyDir: {}
|
|
- name: kubeconfig
|
|
hostPath:
|
|
path: /root/.kube
|
|
type: Directory
|