feat: add node init config to k8s plugin

This commit is contained in:
2026-04-30 11:40:25 +02:00
parent 97cc9058d3
commit 272e924792
4 changed files with 60 additions and 1 deletions

View File

@@ -7,5 +7,5 @@ RUN go mod download
COPY . .
RUN go build -v -o /usr/local/bin/agent ./...
CMD ["app"]
CMD ["agent"]

View File

@@ -16,6 +16,7 @@
package nextflow.k8s
import nextflow.config.scopes.Config
import nextflow.k8s.client.K8sRetryConfig
import javax.annotation.Nullable
@@ -211,6 +212,10 @@ class K8sConfig implements ConfigScope {
""")
final String workDir
@ConfigOption
@Description("Node initialization config")
final K8sNodeInitConfig nodeInit
/* required by extension point -- do not remove */
K8sConfig() {
this(Collections.emptyMap())
@@ -260,6 +265,8 @@ class K8sConfig implements ConfigScope {
pod.securityContext = new PodSecurityContext(runAsUser)
else if( securityContext )
pod.securityContext = new PodSecurityContext(securityContext)
nodeInit = new K8sNodeInitConfig(opts.nodeInit as Map ?: Collections.emptyMap())
}
private PodOptions createPodOptions( value ) {

View File

@@ -0,0 +1,42 @@
package nextflow.k8s
import groovy.util.logging.Slf4j
import nextflow.config.scopes.Config
import nextflow.config.spec.ConfigScope
import nextflow.config.spec.ScopeName
import nextflow.config.spec.ConfigOption
import groovy.transform.CompileStatic
import nextflow.script.dsl.Description
@CompileStatic
@Slf4j
@ScopeName("nodeInit")
@Description("The nodeInit scope contains options for the pre-workflow execution initialization of nodes")
class K8sNodeInitConfig implements ConfigScope {
@ConfigOption
@Description("enables the pre-workflow execution deployment of pods")
final boolean enabled;
@ConfigOption
@Description("the used image")
final String image;
@ConfigOption
@Description("the start-command")
final List<String> command;
@ConfigOption
@Description("the pod state to wait on")
final String wait;
K8sNodeInitConfig() {
this(Collections.emptyMap())
}
K8sNodeInitConfig(Map opts) {
enabled = opts.enabled as boolean
image = opts.image as String
command = opts.command as List<String>
wait = opts.wait as String
}
}

View File

@@ -484,4 +484,14 @@ class K8sConfigTest extends Specification {
cfg.clientRefreshInterval == Duration.of('1h')
}
def 'should have nodeInit image' () {
when:
def cfg = new K8sConfig(
nodeInit: [
image: 'some-image:0'
]
)
then:
cfg.nodeInit.image == 'some-image:0'
}
}