84 lines
2.2 KiB
YAML
84 lines
2.2 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:
|
|
serviceAccountName: jenkins
|
|
securityContext:
|
|
fsGroup: 1000
|
|
initContainers:
|
|
- name: install-docker
|
|
image: docker:24-cli
|
|
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
|
|
- name: install-kubectl
|
|
image: alpine:3.19
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
echo "Installing kubectl..."
|
|
wget -q -O /tmp/tools-bin/kubectl "https://dl.k8s.io/release/v1.28.0/bin/linux/amd64/kubectl"
|
|
chmod +x /tmp/tools-bin/kubectl
|
|
echo "✅ kubectl installed"
|
|
ls -lh /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"
|
|
echo "PATH: $PATH"
|
|
which docker || echo "Docker not in PATH"
|
|
which kubectl || echo "kubectl not in 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
|
|
volumes:
|
|
- name: jenkins-home
|
|
persistentVolumeClaim:
|
|
claimName: jenkins-home
|
|
- name: docker-sock
|
|
hostPath:
|
|
path: /var/run/docker.sock
|
|
type: Socket
|
|
- name: tools-bin
|
|
emptyDir: {}
|