惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
IT之家
IT之家
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
美团技术团队
小众软件
小众软件
博客园 - 叶小钗
WordPress大学
WordPress大学
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 三生石上(FineUI控件)
罗磊的独立博客
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
博客园 - 【当耐特】
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理

陈少文的网站

巨变与机遇的未来十年 Kubernetes 平台管理软件压力测试方案 使用镜像部署 Hexo 静态页面 终于等到你 - GitHub 镜像仓库服务(ghcr.io) 一起来学 Go --(6)Interface 一起来学 Go --(5)Goroutine 和 Channel 什么是函数式编程 如何在 Kubernetes 集群集成 Kata 柯里化与偏函数 使用 PyGithub 自动创建 Label 软件产品是团队能力的输出 Helm 2 、Helm 3 比较 IoT 变现 Kubernetes 中的 DNS 服务 国内的 Helm 镜像源 Harbor 使用自签证书支持 Https 访问 DevOps 工具链之 Prow 如何使用 kfctl 安装 Kubeflow VS Code 无法下载 Go 插件的工具包 工程师更应具有服务精神 你不知道的 Docker 使用技巧 使用 Docker 运行 Tensorflow 论中国 什么是左移 如何清空 Git 仓库全部历史记录 一禅小和尚 有风吹过厨房 时间的玫瑰 如何在 CentOS 安装 GPU 驱动 开发 Tips(19)
Kubernetes Windows 节点动态提供 Jenkins Agent
微信公众号 · 2020-06-14 · via 陈少文的网站

在前面两篇文档,在 Kubernetes 上动态创建 Jenkins SlaveKubernetes 添加 Windows 节点提供 Jenkins 构建动态 Agent 的基础之上,本篇文档主要尝试在 Kubernetes 上动态提供 Windows 构建 Agent 。

1. 新增流水线

Kubernetes 与 Jenkins 集成部分可以参考上面的两篇文档,这里直接新建两条流水线进行测试。

  • windows - jenkins 内置的流水线示例
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * Runs a build on a Windows pod.
 * Tested in EKS: https://docs.aws.amazon.com/eks/latest/userguide/windows-support.html
 */
podTemplate(yaml: '''
apiVersion: v1
kind: Pod
spec:
  containers:
  - name: jnlp
    image: jenkins/inbound-agent:windowsservercore-1809
  - name: shell
    image: mcr.microsoft.com/powershell:preview-windowsservercore-1809
    command:
    - powershell
    args:
    - Start-Sleep
    - 999999
  nodeSelector:
    kubernetes.io/os: windows
''') {
    node(POD_LABEL) {
        container('shell') {
            powershell 'Get-ChildItem Env: | Sort Name'
        }
    }
}
  • windows-dotnet

使用 dotnet 镜像进行构建

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
pipeline {
  agent {
    kubernetes {
      yaml """
apiVersion: v1
kind: Pod
metadata:
  name: windows
spec:
  containers:
  - name: jnlp
    image: jenkins/inbound-agent:windowsservercore-1809
    tty: true
  - name: windows-dotnet
    image: mcr.microsoft.com/dotnet/core/sdk:2.1
    tty: true
  nodeSelector:
    kubernetes.io/os: windows
"""
    }
  }
  stages {
    stage('Run on windows') {
      steps {
        container(name:'windows-dotnet'){
          bat 'dotnet -h'
        }
      }
    }
  }
}

2. 查看结果

  • windows

  • windows-dotnet

  • 查看 Windows 下载的镜像
1
2
3
4
5
6
docker images

REPOSITORY                          TAG                              IMAGE ID            CREATED             SIZE
mcr.microsoft.com/powershell        preview-windowsservercore-1809   ff3a59b7e85e        3 days ago          5.24GB
mcr.microsoft.com/dotnet/core/sdk   2.1                              4ca3f3cfa1e2        4 days ago          1.66GB
jenkins/inbound-agent               windowsservercore-1809           45f5745f2aab        4 days ago          4.09GB

Windows 节点的磁盘空间一定要很大才行。

3. 参考