如何在同一节点中部署多个Jenkins作业?

发布于 2025-01-23 08:50:04 字数 1579 浏览 2 评论 0原文

实际上,我已经在GKE群集中部署了Jenkins Master,我有一个名为Jenkins的Nodepool,带有2个节点最大值的自动化。因此,当我在詹金斯(Jenkins)上运行工作时,总是在使用那个nodepool,所以,这很酷,但是,我实际上遇到的问题是,当我运行工作时,詹金斯(Jenkins)使用1个节点,而不是使用1个节点每个两个或多个作业,如果a do a kubectl描述了节点nodeName,我可以看到我在每个kubernetes节点中只部署了1个Jenkins代理。

我如何同时使用1个节点对1个以上的詹金斯代理使用?因为实际上我会“不了解”我的詹金斯节点,因为每个节点只使用一半的节点资源。

kubectl的示例描述节点jenkinsnode(您可以看到该节点中只有1个Jenkins Pod):

  Namespace                   Name                                               CPU Requests  CPU Limits   Memory Requests  Memory Limits  Age
  ---------                   ----                                               ------------  ----------   ---------------  -------------  ---
  jenkins                     atlas-test-atlas-full-tests-2-mrc47-2h7fb-t1vdn    850m (21%)    1250m (31%)  1536Mi (54%)     2560Mi (91%)   118s
  kube-system                 fluentbit-gke-f296j                                100m (2%)     0 (0%)       200Mi (7%)       500Mi (17%)    5m8s
  kube-system                 gke-metadata-server-nc58q                          100m (2%)     100m (2%)    100Mi (3%)       100Mi (3%)     5m7s
  kube-system                 gke-metrics-agent-q6xl4                            3m (0%)       0 (0%)       50Mi (1%)        50Mi (1%)      5m8s
  kube-system                 kube-proxy-gke-develop-jenkins-eb1faad2-9m00       100m (2%)     0 (0%)       0 (0%)           0 (0%)         5m7s
  kube-system                 netd-s6v8s                                         0 (0%)        0 (0%)       0 (0%)           0 (0%)         5m7s

预先感谢

actually i have deployed jenkins master in a GKE cluster, i have a nodepool called jenkins with autoscaling with 2 nodes max. so when i run a job in jenkins, always is using that nodepool, so, thats cool, but, the problem that i have actually, is that when i run a job, jenkins is using 1 node per job, instead of use 1 node per two or more jobs, if a do a kubectl describe node nodename, i can see that i have only 1 jenkins agent deployed in each kubernetes node.

How can i fix this and use 1 node for more than 1 jenkins agent at the same time? because actually im "underusing" my jenkins nodes, because 1 job per node only use half of node resources.

Example of kubectl describe node jenkinsnode (you can see that only have 1 jenkins pod in that node):

  Namespace                   Name                                               CPU Requests  CPU Limits   Memory Requests  Memory Limits  Age
  ---------                   ----                                               ------------  ----------   ---------------  -------------  ---
  jenkins                     atlas-test-atlas-full-tests-2-mrc47-2h7fb-t1vdn    850m (21%)    1250m (31%)  1536Mi (54%)     2560Mi (91%)   118s
  kube-system                 fluentbit-gke-f296j                                100m (2%)     0 (0%)       200Mi (7%)       500Mi (17%)    5m8s
  kube-system                 gke-metadata-server-nc58q                          100m (2%)     100m (2%)    100Mi (3%)       100Mi (3%)     5m7s
  kube-system                 gke-metrics-agent-q6xl4                            3m (0%)       0 (0%)       50Mi (1%)        50Mi (1%)      5m8s
  kube-system                 kube-proxy-gke-develop-jenkins-eb1faad2-9m00       100m (2%)     0 (0%)       0 (0%)           0 (0%)         5m7s
  kube-system                 netd-s6v8s                                         0 (0%)        0 (0%)       0 (0%)           0 (0%)         5m7s

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦过后 2025-01-30 08:50:04

您可以使用

Kubernetes插件将Jenkins代理分配在Kubernetes Pods中。
在这些豆荚中,总是有一个特殊的容器JNLP
经营詹金斯代理。其他容器可以任意运行
您选择的过程,并且可以运行命令
在代理吊舱中的任何容器中动态。

示例:

pod.yaml

apiVersion: v1
kind: Pod
spec:
  containers:
  - name: maven
    image: maven:3.8.1-jdk-8
    command:
    - sleep
    args:
    - 99d
  - name: golang
    image: golang:1.16.5
    command:
    - sleep
    args:
    - 99d

jenkinsfile

podTemplate(yaml: readTrusted('pod.yaml')) {
  node(POD_LABEL) {
    // ...
  }
}

You can use the Kubernetes plugin for Jenkins, with it you can create a Kubernetes Pod for each agent started:

The Kubernetes plugin allocates Jenkins agents in Kubernetes pods.
Within these pods, there is always one special container jnlp that is
running the Jenkins agent. Other containers can run arbitrary
processes of your choosing, and it is possible to run commands
dynamically in any container in the agent pod.

Example:

pod.yaml

apiVersion: v1
kind: Pod
spec:
  containers:
  - name: maven
    image: maven:3.8.1-jdk-8
    command:
    - sleep
    args:
    - 99d
  - name: golang
    image: golang:1.16.5
    command:
    - sleep
    args:
    - 99d

Jenkinsfile

podTemplate(yaml: readTrusted('pod.yaml')) {
  node(POD_LABEL) {
    // ...
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文