Skip to content

Commit

Permalink
k3s: jenkins server pod is working now with pre-installed plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
LiberatorUSA committed Sep 29, 2024
1 parent 347fd49 commit 1658fd6
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 50 deletions.
55 changes: 12 additions & 43 deletions projects/k3s/jenkins/jenkins_config.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,12 @@
# jenkins.yaml
jenkins:
securityRealm:
local:
allowsSignup: true
users:
- id: "admin"
password: "admin_password"
authorizationStrategy:
loggedInUsersCanDoAnything:
allowAnonymousRead: true
systemMessage: "Welcome to Jenkins!"
plugin:
required:
- configuration-as-code
- structs
- kubernetes
- disk-usage
- jquery3-api
- git
- scm-api
- script-security
- durable-task
- checks-api
- github-checks
- junit
- xunit
- autograding
- workflow-aggregator
- workflow-step-api
- workflow-api
- workflow-support
- docker-commons
- docker-plugin
- docker-workflow
- pipeline-stage-step
- pipeline-build-step
- pipeline-input-step
- pipeline-rest-api
- pipeline-stage-view
- pipeline-graph-view
- pipeline-github
- pipeline-config-history
# jenkins.yaml
jenkins:
securityRealm:
local:
allowsSignup: true
users:
- id: "admin"
password: "admin_password"
authorizationStrategy:
loggedInUsersCanDoAnything:
allowAnonymousRead: true
systemMessage: "Welcome to Jenkins!"
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ mv -f /var/jenkins_home/plugins/* /var/jenkins_home/data/plugins/ || echo "No pl
echo "Moving pre-installed config to mounted casc volume if no config is present there"
mv -vn /var/jenkins_home/jenkins_config.yaml /var/jenkins_home/casc_configs/jenkins_config.yaml

jenkins_home_contents=$(find ${JENKINS_HOME}/ | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/")
echo "files structure now in JENKINS_HOME: ${jenkins_home_contents}"
29 changes: 29 additions & 0 deletions projects/k3s/jenkins/jenkins_preinstalled_plugins.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
configuration-as-code
structs
kubernetes
disk-usage
jquery3-api
git
scm-api
script-security
durable-task
checks-api
github-checks
junit
xunit
autograding
workflow-aggregator
workflow-step-api
workflow-api
workflow-support
docker-commons
docker-plugin
docker-workflow
pipeline-stage-step
pipeline-build-step
pipeline-input-step
pipeline-rest-api
pipeline-stage-view
pipeline-graph-view
pipeline-github
pipeline-config-history
4 changes: 2 additions & 2 deletions projects/k3s/jenkins/jenkins_server_build_image.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ COPY ["jenkins_config.yaml", "/var/jenkins_home/"]

# Copy our plugin bootstrap helper script into the image and execute it
COPY ["jenkins-plugin-stuffer.sh", "/var/jenkins_home/"]
#RUN /var/jenkins_home/jenkins-plugin-stuffer.sh configuration-as-code
RUN jenkins-plugin-cli --plugins configuration-as-code
COPY ["jenkins_preinstalled_plugins.txt", "/var/jenkins_home/"]
RUN jenkins-plugin-cli --plugin-file /var/jenkins_home/jenkins_preinstalled_plugins.txt

# Switch to root to perform file operations
USER root
Expand Down
11 changes: 6 additions & 5 deletions projects/k3s/jenkins/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sudo kubectl get pods -n devops-tools
# create the jenkins server image we wil use for our pod
# this is imported to the k3s installation and made available as a known image
./create_jenkins_server_image.sh
rm -f ./vanvelzen-jenkins-server-base-latest.tar
#rm -f ./vanvelzen-jenkins-server-base-latest.tar

# create a namespace to host Jenkins resources.
sudo kubectl create namespace devops-tools
Expand All @@ -21,12 +21,13 @@ sudo kubectl apply -f jenkins-service.yaml -n devops-tools
sudo kubectl apply -f jenkins-deployment.yaml -n devops-tools

# extract the config from the pod so we can check it
rm -f ./jenkins_config_from_pod.yaml
./extract_jenkins_config.sh
#rm -f ./jenkins_config_from_pod.yaml
#./extract_jenkins_config.sh

# extract the admin password from the pod so we can check it
rm -f ./initialAdminPassword
./extract_initial_admin_password.sh
# note: when setting a admin password via config as we are this should not be needed and no such file would be generated
#rm -f ./initialAdminPassword
#./extract_initial_admin_password.sh

# print the list of resources again after the above
sudo kubectl get services -n devops-tools
Expand Down

0 comments on commit 1658fd6

Please sign in to comment.