From 1658fd646e477124a8ff266e07518fb5f8839e42 Mon Sep 17 00:00:00 2001 From: Dinand Vanvelzen Date: Sun, 29 Sep 2024 00:46:38 -0500 Subject: [PATCH] k3s: jenkins server pod is working now with pre-installed plugins --- projects/k3s/jenkins/jenkins_config.yaml | 55 ++++--------------- .../jenkins_container_entrypoint_bootstrap.sh | 2 + .../jenkins/jenkins_preinstalled_plugins.txt | 29 ++++++++++ .../jenkins_server_build_image.dockerfile | 4 +- projects/k3s/jenkins/setup.sh | 11 ++-- 5 files changed, 51 insertions(+), 50 deletions(-) create mode 100644 projects/k3s/jenkins/jenkins_preinstalled_plugins.txt diff --git a/projects/k3s/jenkins/jenkins_config.yaml b/projects/k3s/jenkins/jenkins_config.yaml index eb8d53e41..0d5a71e06 100644 --- a/projects/k3s/jenkins/jenkins_config.yaml +++ b/projects/k3s/jenkins/jenkins_config.yaml @@ -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!" diff --git a/projects/k3s/jenkins/jenkins_container_entrypoint_bootstrap.sh b/projects/k3s/jenkins/jenkins_container_entrypoint_bootstrap.sh index e4bc48c4b..c94e14598 100755 --- a/projects/k3s/jenkins/jenkins_container_entrypoint_bootstrap.sh +++ b/projects/k3s/jenkins/jenkins_container_entrypoint_bootstrap.sh @@ -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}" diff --git a/projects/k3s/jenkins/jenkins_preinstalled_plugins.txt b/projects/k3s/jenkins/jenkins_preinstalled_plugins.txt new file mode 100644 index 000000000..48c1d5c9e --- /dev/null +++ b/projects/k3s/jenkins/jenkins_preinstalled_plugins.txt @@ -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 \ No newline at end of file diff --git a/projects/k3s/jenkins/jenkins_server_build_image.dockerfile b/projects/k3s/jenkins/jenkins_server_build_image.dockerfile index 1f61a2264..7f517e76e 100644 --- a/projects/k3s/jenkins/jenkins_server_build_image.dockerfile +++ b/projects/k3s/jenkins/jenkins_server_build_image.dockerfile @@ -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 diff --git a/projects/k3s/jenkins/setup.sh b/projects/k3s/jenkins/setup.sh index 3a836d6ce..e866f197f 100755 --- a/projects/k3s/jenkins/setup.sh +++ b/projects/k3s/jenkins/setup.sh @@ -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 @@ -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