first commit
This commit is contained in:
43
vars/homelabK8sAgent.groovy
Normal file
43
vars/homelabK8sAgent.groovy
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Returns a K8s pod YAML string for use in agent { kubernetes { yaml ... } }
|
||||
*
|
||||
* config keys (all optional):
|
||||
* nodeImage - default: node:18-slim
|
||||
* harborRegistry - default: harbor-core.harbor.svc.cluster.local
|
||||
* withTools - include alpine/git container, default: false
|
||||
*/
|
||||
def call(Map config = [:]) {
|
||||
def nodeImage = config.nodeImage ?: 'node:18-slim'
|
||||
def harborReg = config.harborRegistry ?: 'harbor-core.harbor.svc.cluster.local'
|
||||
def withTools = config.withTools ?: false
|
||||
|
||||
def toolsBlock = withTools ? """
|
||||
- name: tools
|
||||
image: alpine/git
|
||||
command:
|
||||
- sleep
|
||||
args:
|
||||
- infinity""" : ""
|
||||
|
||||
return """
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
spec:
|
||||
containers:
|
||||
- name: node
|
||||
image: ${nodeImage}
|
||||
command:
|
||||
- sleep
|
||||
args:
|
||||
- infinity
|
||||
- name: docker
|
||||
image: docker:dind
|
||||
securityContext:
|
||||
privileged: true
|
||||
env:
|
||||
- name: DOCKER_TLS_CERTDIR
|
||||
value: ""
|
||||
args:
|
||||
- --insecure-registry=${harborReg}${toolsBlock}
|
||||
""".stripIndent()
|
||||
}
|
||||
Reference in New Issue
Block a user