0

I deploy my Spring projects to Kubernetes with Jenkins. I have k8smaster and 3 worker servers. It sometimes writes .m2 files under the k8smaster server. How can I prevent this? So I want it to write only on worker servers.

kubernetes nodes

enter image description here

I defined a label with a special name in Jenkins so that the job does not run on the master server, but it still works like a worker. enter image description here enter image description here

Jenkins List of volumes to mount in agent pod enter image description here

Pod Template Settings enter image description here

Example pipeline

node ("zrgl-label") {
    stage('Checkout'){
        cleanWs()
        withCredentials([gitUsernamePassword(credentialsId: 'zrgl.jenkins')]){
            sh 'git clone -b ..'
        }
    }
    stage('Kubernetes Deployment'){
            container('kubectl'){
                 ...
            }
    }
}

1 Answer 1

0

As far as I understand, you don't like that Jenkins will run jobs on K8S master. If so, I suggest just don't run Jenkins on K8S master.

4
  • Actually, I don't want k8smaster to run the pods, after all, the master server has the "control-plane" role. I want it to work only in workers. I shared the details in the topic I opened for this. I want the pods to run only in the workers and write the .m2 files only to the workers where the pods are deployed, not to the master.
    – kernel
    Nov 28 at 15:16
  • I see. Good point! AFAIK, K8S doesn't run pods on the master. I suggest to check if 'NoSchedule' taint is configured on your master - gauravguptacloud.medium.com/…. Nov 28 at 17:24
  • Why doesn't the label definition in Jenkins provide this? Also, how do you think I should introduce my master's degree? Do I need to do anything in my Deployment.yaml files after defining Taint?
    – kernel
    Nov 28 at 17:58
  • "Why doesn't the label definition in Jenkins provide this? " - I'm not sure. But as I said I suggest to read link I shared, or just google "how to prevent pods from running on k8s master". Jenkins is just one application, obviously you'll have more deployments in your k8s. Nov 29 at 8:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .