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