Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import jakarta.validation.constraints.NotNull;
import lombok.*;
import lombok.experimental.SuperBuilder;
import io.kestra.core.models.annotations.PluginProperty;

@SuperBuilder
@ToString
Expand All @@ -25,6 +26,7 @@ public abstract class AbstractConnection extends Task {
title = "Kubernetes connection",
description = "Connection settings for the cluster. If omitted, the client resolves credentials in order: system properties, environment variables, kubeconfig, then in-cluster service account."
)
@PluginProperty(group = "advanced")
private Connection connection;

@Schema(
Expand All @@ -33,6 +35,7 @@ public abstract class AbstractConnection extends Task {
)
@NotNull
@Builder.Default
@PluginProperty(group = "main")
protected final Property<Duration> waitUntilRunning = Property.ofValue(Duration.ofMinutes(10));

@Schema(
Expand All @@ -41,6 +44,7 @@ public abstract class AbstractConnection extends Task {
)
@NotNull
@Builder.Default
@PluginProperty(group = "main")
protected final Property<Duration> waitRunning = Property.ofValue(Duration.ofHours(1));

protected ListOptions listOptions(RunContext runContext) throws IllegalVariableEvaluationException {
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/io/kestra/plugin/kubernetes/AbstractPod.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,22 @@ public abstract class AbstractPod extends AbstractConnection {
)
@NotNull
@Builder.Default
@PluginProperty(group = "main")
protected Property<String> namespace = Property.ofValue("default");

@Schema(
title = "The files from the container filesystem to send to Kestra's internal storage",
description = "Only files created inside the `kestra/working-dir` directory of the container can be retrieved.\n" +
"Must be a list of [glob](https://en.wikipedia.org/wiki/Glob_(programming)) expressions relative to the current working directory, some examples: `my-dir/**`, `my-dir/*/**` or `my-dir/my-file.txt`.."
)
@PluginProperty(group = "destination")
protected Property<List<String>> outputFiles;

@Schema(
title = "The files to create on the local filesystem – it can be a map or a JSON object.",
description = "The files will be available inside the `kestra/working-dir` directory of the container. You can use the special variable `{{workingDir}}` in your command to refer to it."
)
@PluginProperty(
@PluginProperty(group = "source",
additionalProperties = String.class,
dynamic = true
)
Expand All @@ -76,7 +78,7 @@ public abstract class AbstractPod extends AbstractConnection {
@Schema(
title = "The configuration of the file sidecar container that handles the download and upload of files"
)
@PluginProperty
@PluginProperty(group = "advanced")
@Builder.Default
protected SideCar fileSidecar = SideCar.builder().build();

Expand All @@ -88,6 +90,7 @@ public abstract class AbstractPod extends AbstractConnection {
"Supports Pods, StatefulSets, and custom resources that use the Ready condition. " +
"Note: Deployments are not supported as they use the Available condition instead of Ready."
)
@PluginProperty(group = "advanced")
protected Property<Duration> waitUntilReady = Property.ofValue(Duration.ZERO);

@Schema(
Expand Down Expand Up @@ -132,6 +135,7 @@ public abstract class AbstractPod extends AbstractConnection {
```
"""
)
@PluginProperty(group = "advanced")
protected Property<Map<String, Object>> containerDefaultSpec;

@SuppressWarnings("ResultOfMethodCallIgnored")
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/io/kestra/plugin/kubernetes/core/PodCreate.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public class PodCreate extends AbstractPod implements RunnableTask<PodCreate.Out
title = "Pod metadata",
description = "Name, labels, and annotations applied to the pod. Name is auto-generated from the task run when omitted. Supports template expressions."
)
@PluginProperty(dynamic = true)
@PluginProperty(dynamic = true, group = "advanced")
private Map<String, Object> metadata;

@Schema(
Expand All @@ -274,7 +274,7 @@ public class PodCreate extends AbstractPod implements RunnableTask<PodCreate.Out
Additional containers you define alongside your main container are fully preserved as sidecars.
"""
)
@PluginProperty(dynamic = true)
@PluginProperty(dynamic = true, group = "main")
@NotNull
private Map<String, Object> spec;

Expand All @@ -284,6 +284,7 @@ public class PodCreate extends AbstractPod implements RunnableTask<PodCreate.Out
)
@NotNull
@Builder.Default
@PluginProperty(group = "advanced")
private final Property<Boolean> delete = Property.ofValue(true);

@Schema(
Expand All @@ -292,6 +293,7 @@ public class PodCreate extends AbstractPod implements RunnableTask<PodCreate.Out
)
@NotNull
@Builder.Default
@PluginProperty(group = "advanced")
private final Property<Boolean> resume = Property.ofValue(true);

@Schema(
Expand All @@ -300,6 +302,7 @@ public class PodCreate extends AbstractPod implements RunnableTask<PodCreate.Out
)
@NotNull
@Builder.Default
@PluginProperty(group = "execution")
private Property<Duration> waitForLogInterval = Property.ofValue(Duration.ofSeconds(30));

// Constants for file paths and working directory
Expand All @@ -308,9 +311,13 @@ public class PodCreate extends AbstractPod implements RunnableTask<PodCreate.Out
private static final String OUTPUT_FILES_VAR = "outputFiles";

// Kill handling state
@PluginProperty(group = "advanced")
private final AtomicBoolean killed = new AtomicBoolean(false);
@PluginProperty(group = "advanced")
private final AtomicReference<String> currentPodName = new AtomicReference<>();
@PluginProperty(group = "source")
private volatile String currentNamespace;
@PluginProperty(group = "connection")
private volatile Connection currentConnection;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/kestra/plugin/kubernetes/kubectl/Apply.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import jakarta.validation.constraints.NotNull;
import lombok.*;
import lombok.experimental.SuperBuilder;
import io.kestra.core.models.annotations.PluginProperty;

@SuperBuilder
@ToString
Expand Down Expand Up @@ -183,6 +184,7 @@ public class Apply extends AbstractPod implements RunnableTask<Apply.Output> {
title = "Resource manifest",
description = "YAML or JSON manifest to apply. Can include multiple documents separated by '---'. Supports template expressions before apply."
)
@PluginProperty(group = "main")
private Property<String> spec;

@Override
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/io/kestra/plugin/kubernetes/kubectl/Delete.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import io.kestra.core.models.annotations.PluginProperty;

@SuperBuilder
@ToString
Expand Down Expand Up @@ -88,25 +89,29 @@ public class Delete extends AbstractPod implements RunnableTask<VoidOutput> {
description = "Kubernetes kind (e.g., Pod, Deployment, Service). Case-insensitive."
)
@NotNull
@PluginProperty(group = "main")
private Property<String> resourceType;

@Schema(
title = "Resource names",
description = "List of resource names to delete in the target namespace."
)
@NotNull
@PluginProperty(group = "main")
private Property<List<String>> resourcesNames;

@Schema(
title = "API group",
description = "Group for the resource kind (empty for core resources)."
)
@PluginProperty(group = "advanced")
private Property<String> apiGroup;

@Schema(
title = "API version",
description = "Version for the resource kind. Defaults to v1 when omitted."
)
@PluginProperty(group = "advanced")
private Property<String> apiVersion;

@Override
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/io/kestra/plugin/kubernetes/kubectl/Get.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import reactor.core.publisher.FluxSink;

import static io.kestra.core.models.tasks.common.FetchType.NONE;
import io.kestra.core.models.annotations.PluginProperty;

@SuperBuilder
@ToString
Expand Down Expand Up @@ -177,24 +178,28 @@ public class Get extends AbstractPod implements RunnableTask<Get.Output> {
description = "Kubernetes kind (e.g., Pod, Deployment, Service). Case-insensitive."
)
@NotNull
@PluginProperty(group = "main")
private Property<String> resourceType;

@Schema(
title = "Resource names",
description = "Optional list of names to fetch. When empty, all resources of the kind in the namespace are returned."
)
@PluginProperty(group = "source")
private Property<List<String>> resourcesNames;

@Schema(
title = "API group",
description = "Group for the resource kind (empty for core resources)."
)
@PluginProperty(group = "advanced")
private Property<String> apiGroup;

@Schema(
title = "API version",
description = "Version for the resource kind. Defaults to v1 when omitted."
)
@PluginProperty(group = "advanced")
private Property<String> apiVersion;

@Schema(
Expand All @@ -203,6 +208,7 @@ public class Get extends AbstractPod implements RunnableTask<Get.Output> {
)
@NotNull
@Builder.Default
@PluginProperty(group = "processing")
protected Property<FetchType> fetchType = Property.ofValue(NONE);

@Override
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/io/kestra/plugin/kubernetes/kubectl/Patch.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import jakarta.validation.constraints.NotNull;
import lombok.*;
import lombok.experimental.SuperBuilder;
import io.kestra.core.models.annotations.PluginProperty;

@SuperBuilder
@ToString
Expand Down Expand Up @@ -216,38 +217,44 @@ public class Patch extends AbstractPod implements RunnableTask<Patch.Output> {
title = "Resource kind",
description = "Namespaced Kubernetes kind (e.g., Deployment, StatefulSet, Pod). Cluster-scoped kinds are not supported."
)
@PluginProperty(group = "main")
private Property<String> resourceType;

@NotNull
@Schema(
title = "Resource name"
)
@PluginProperty(group = "main")
private Property<String> resourceName;

@NotNull
@Schema(
title = "Patch content",
description = "The format depends on the patchStrategy. For STRATEGIC_MERGE and JSON_MERGE, provide a JSON object with the fields to update. For JSON_PATCH, provide a JSON array of operations with 'op', 'path', and 'value' fields."
)
@PluginProperty(group = "main")
private Property<String> patch;

@Builder.Default
@Schema(
title = "Patch strategy",
description = "STRATEGIC_MERGE (default): Kubernetes strategic merge patch, most user-friendly. Understands K8s resource structure and intelligently merges lists by merge keys. JSON_MERGE: Simple merge with null-deletion semantics (RFC 7386). JSON_PATCH: Precision operations with add/remove/replace/test (RFC 6902)."
)
@PluginProperty(group = "advanced")
private Property<PatchStrategy> patchStrategy = Property.ofValue(PatchStrategy.STRATEGIC_MERGE);

@Schema(
title = "API group",
description = "Group for the resource kind. Leave empty for core resources."
)
@PluginProperty(group = "advanced")
private Property<String> apiGroup;

@Schema(
title = "API version",
description = "Version for the resource kind (e.g., v1). Defaults to v1 when omitted."
)
@PluginProperty(group = "advanced")
private Property<String> apiVersion;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import io.kestra.core.models.annotations.PluginProperty;

@SuperBuilder
@ToString
Expand Down Expand Up @@ -58,10 +59,12 @@ public class Restart extends AbstractPod implements RunnableTask<VoidOutput> {

@Schema(title = "Workload type", description = "Deployment or StatefulSet.")
@NotNull
@PluginProperty(group = "main")
private Property<ResourceType> resourceType;

@Schema(title = "Resource names", description = "Names of workloads to restart in the namespace.")
@NotNull
@PluginProperty(group = "main")
private Property<List<String>> resourcesNames;

@Override
Expand Down
Loading
Loading