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

推荐订阅源

D
Docker
G
Google Developers Blog
J
Java Code Geeks
B
Blog
C
Check Point Blog
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
I
InfoQ
A
About on SuperTechFans
WordPress大学
WordPress大学
F
Fortinet All Blogs
S
SegmentFault 最新的问题
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
M
MIT News - Artificial intelligence
月光博客
月光博客
Y
Y Combinator Blog
Jina AI
Jina AI
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
Apple Machine Learning Research
Apple Machine Learning Research

陈少文的网站

巨变与机遇的未来十年 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. 参考