自定义的流水线pod
pipeline {
agent {
kubernetes {
label 'mypod'
yaml '''
apiVersion: v1
kind: Pod
spec:
volumes:
- name: volume-0
hostPath:
path: /var/run/docker.sock
type: ''
containers:
- name: go1-16
image: 172.18.0.131:5000/czm/gobuildalpine:v1.16
tty: true
imagePullPolicy: IfNotPresent
command:
- cat
volumeMounts:
- name: volume-0
mountPath: /var/run/docker.sock
nodeSelector:
kubernetes.io/hostname: k8s-m
'''
}
}

kind: Pod
apiVersion: v1
metadata:
name: mypod-79j09-llsxh
namespace: kubesphere-devops-system
labels:
jenkins: slave
jenkins/label: mypod
jenkins/label-digest: 151e26c22cfdf1016d63f0cc3b4c6eeaf431ba3c
annotations:
buildUrl: >-
http://ks-jenkins.kubesphere-devops-system:80/job/czm-prohzkzt/job/newgobuildtest/10/
runUrl: job/czm-prohzkzt/job/newgobuildtest/10/
spec:
volumes:
- name: volume-0
hostPath:
path: /var/run/docker.sock
type: ''
- name: workspace-volume
emptyDir: {}
- name: default-token-wtsfc
secret:
secretName: default-token-wtsfc
defaultMode: 420
containers:
- name: go1-16
image: '172.18.0.131:5000/czm/gobuildalpine:v1.16'
command:
- cat
resources: {}
volumeMounts:
- name: volume-0
mountPath: /var/run/docker.sock
- name: workspace-volume
mountPath: /home/jenkins/agent
- name: default-token-wtsfc
readOnly: true
mountPath: /var/run/secrets/kubernetes.io/serviceaccount
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
tty: true
- name: jnlp
image: 'jenkins/inbound-agent:4.3-4'
env:
- name: JENKINS_SECRET
value: 396d1b3bc528f6e1a1fd0e2132faba273cdd63758acb9980d1fbf1817a998815
- name: JENKINS_TUNNEL
value: 'ks-jenkins-agent.kubesphere-devops-system:50000'
- name: JENKINS_AGENT_NAME
value: mypod-79j09-llsxh
- name: JENKINS_NAME
value: mypod-79j09-llsxh
- name: JENKINS_AGENT_WORKDIR
value: /home/jenkins/agent
- name: JENKINS_URL
value: 'http://ks-jenkins.kubesphere-devops-system:80/'
resources:
requests:
cpu: 100m
memory: 256Mi
volumeMounts:
- name: workspace-volume
mountPath: /home/jenkins/agent
- name: default-token-wtsfc
readOnly: true
mountPath: /var/run/secrets/kubernetes.io/serviceaccount
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
restartPolicy: Never
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
nodeSelector:
kubernetes.io/hostname: k8s-m
serviceAccountName: default
serviceAccount: default
securityContext: {}
schedulerName: default-scheduler
tolerations:
- key: node.kubernetes.io/not-ready
operator: Exists
effect: NoExecute
tolerationSeconds: 300
- key: node.kubernetes.io/unreachable
operator: Exists
effect: NoExecute
tolerationSeconds: 300
priority: 0
enableServiceLinks: true
preemptionPolicy: PreemptLowerPriority