feat(jenkins): Add kubectl installation via init container and mount kubeconfig
This commit is contained in:
@@ -16,17 +16,25 @@ spec:
|
||||
securityContext:
|
||||
fsGroup: 1000
|
||||
initContainers:
|
||||
- name: install-docker-cli
|
||||
image: docker:24-cli
|
||||
- name: install-tools
|
||||
image: alpine:3.19
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
cp /usr/local/bin/docker /tmp/docker-bin/
|
||||
chmod +x /tmp/docker-bin/docker
|
||||
# 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: docker-cli
|
||||
mountPath: /tmp/docker-bin
|
||||
- name: tools-bin
|
||||
mountPath: /tmp/tools-bin
|
||||
containers:
|
||||
- name: jenkins
|
||||
image: jenkins/jenkins:lts-jdk17
|
||||
@@ -42,15 +50,18 @@ spec:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
export PATH="/tmp/docker-bin:$PATH"
|
||||
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: docker-cli
|
||||
mountPath: /tmp/docker-bin
|
||||
- name: tools-bin
|
||||
mountPath: /tmp/tools-bin
|
||||
- name: kubeconfig
|
||||
mountPath: /root/.kube
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: jenkins-home
|
||||
persistentVolumeClaim:
|
||||
@@ -59,5 +70,9 @@ spec:
|
||||
hostPath:
|
||||
path: /var/run/docker.sock
|
||||
type: Socket
|
||||
- name: docker-cli
|
||||
- name: tools-bin
|
||||
emptyDir: {}
|
||||
- name: kubeconfig
|
||||
hostPath:
|
||||
path: /root/.kube
|
||||
type: Directory
|
||||
|
||||
Reference in New Issue
Block a user