简体   繁体   English

使用自定义代理映像配置 Kubernetes 插件 Jenkins

[英]Configure Kubernetes plugin Jenkins with custom agent image

I'm trying to configure kubernetes plugin in Jenkins with a custom image but when I launch the pipeline I get this error:我正在尝试使用自定义映像在 Jenkins 中配置 kubernetes 插件,但是当我启动管道时出现此错误:

Started by user unknown or anonymous
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] podTemplate
[Pipeline] {
[Pipeline] node
Still waiting to schedule task
‘testjenkinsslaveagent-54-blfkj-1zp9j-lbn6q’ is offline

where testjenkinsslaveagent is my pipeline name.其中 testjenkinsslaveagent 是我的管道名称。 Kubernetes plugin is configured as bellow: Kubernetes 插件配置如下: 在此处输入图片说明 and the pipeline si defined like this:和管道 si 定义如下:

podTemplate(containers: [
        containerTemplate(name: 'jnlp', image: 'registry.gitlab.com/xxxx/dockerimages:latest', ttyEnabled: true, command: '/bin/sh'),
],volumes: [hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')]) {

    node(POD_LABEL) {
        stage('Run') {
            container('my-slave') {
                sh 'echo hello world'
                sh 'ifconfig'
                sh 'sudo docker images ls'
            }
        }

    }
}

Jenkins version is 2.176.3 with all plugins updated. Jenkins 版本为 2.176.3,所有插件均已更新。

Since I needed docker inside my agent I modifyed an existing Dockerimage like this (it works localy):因为我需要在我的代理中使用 docker,所以我修改了一个现有的 Dockerimage(它在本地工作):

ARG version=4.0.1-1
FROM jenkins/slave:$version

ARG version
MAINTAINER Oleg Nenashev <o.v.nenashev@gmail.com>
LABEL Description="This is a base image, which allows connecting Jenkins agents via JNLP protocols" Vendor="Jenkins project" Version="$version"

ARG user=jenkins

USER root

COPY jenkins-agent /usr/local/bin/jenkins-agent
RUN chmod +x /usr/local/bin/jenkins-agent &&\
    ln -s /usr/local/bin/jenkins-agent /usr/local/bin/jenkins-slave


# Install docker routine
RUN echo 'Installing docker routine ...'
RUN apt-get update && \
    apt-get -y install apt-transport-https \
    ca-certificates \
    curl \
    gnupg2 \
    software-properties-common && \
    curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
    add-apt-repository \
    "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
    $(lsb_release -cs) \
    stable" && \
    apt-get update && \
    apt-get -y install docker-ce
RUN usermod -a -G docker jenkins
RUN mkdir -p /home/jenkins/.ssh && \
    chown -R 1000:1000 /home/jenkins/.ssh

USER ${user}

ENTRYPOINT ["jenkins-agent"]

The problem is that my custom agent docker image is ignored and Kubertete's plugin default image is instanciate.问题是我的自定义代理 docker 映像被忽略,而 Kubertete 的插件默认映像是实例化的。 Any idea or any working tutorial on how to set up correctly these?关于如何正确设置这些的任何想法或任何工作教程? Thank谢谢

您需要在 jenkinsfile 中更新 POD_LABEL: node(POD_LABEL) { 这应该使用您的 pod 标签名称更新为 node(jnlp-slave) {

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Jenkins代理docker映像中运行业力测试时,ChromeHeadless挂起(使用Kubernetes插件) - ChromeHeadless hangs when running karma tests inside Jenkins agent docker image (with Kubernetes plugin) Kubernetes Jenkins插件-等待启动:尝试并无法拉取图像 - Kubernetes Jenkins plugin - waiting to start: trying and failing to pull image 无法使用Jenkins的kubernetes-plugin构建docker映像 - Can't build docker image with kubernetes-plugin for Jenkins Jenkins Kubernetes插件不执行Docker映像的入口点 - Jenkins Kubernetes Plugin doesn't executre entrypoint of Docker image 为什么 Kubernetes 中的 jenkins 代理有多个容器? - Why multiple containers for a jenkins agent in Kubernetes? jenkins kubernetes插件执行问题 - jenkins kubernetes plugin execution issues Jenkins Kubernetes 插件安全上下文 - Jenkins Kubernetes Plugin Security Context 图片权限在 jenkins docker 代理 - Image permission in jenkins docker agent Jenkins Kubernetes 插件:如何从 Dockerfile 构建映像并在映像内运行步骤 - Jenkins Kubernetes plugin: How to build image from Dockerfile and run steps inside the image 如何使用 Jenkins docker-swarm-plugin 使用 docker 图像 jenkins/jnlp-slave(传递代理名称) - How can I user docker image jenkins/jnlp-slave with Jenkins docker-swarm-plugin (pass agent name)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM