Skip to content

Commit

Permalink
feat: container runtime expose runAs into task specs
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-s committed Dec 10, 2024
1 parent ae97821 commit ad0a6d6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public K8sDeploymentRunnable produce(Run run) {
.template(taskSpec.getProfile())
//securityContext
.fsGroup(taskSpec.getFsGroup())
.runAsGroup(taskSpec.getRunAsGroup())
.runAsUser(taskSpec.getRunAsUser())
//specific
.contextRefs(contextRefs)
.contextSources(contextSources)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public K8sRunnable produce(Run run) {
.template(taskSpec.getProfile())
//securityContext
.fsGroup(taskSpec.getFsGroup())
.runAsGroup(taskSpec.getRunAsGroup())
.runAsUser(taskSpec.getRunAsUser())
//specific
.contextRefs(contextRefs)
.contextSources(contextSources)
Expand Down Expand Up @@ -143,6 +145,8 @@ public K8sRunnable produce(Run run) {
.template(taskSpec.getProfile())
//securityContext
.fsGroup(taskSpec.getFsGroup())
.runAsGroup(taskSpec.getRunAsGroup())
.runAsUser(taskSpec.getRunAsUser())
//specific
.contextRefs(contextRefs)
.contextSources(contextSources)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public K8sServeRunnable produce(Run run) {
.template(taskSpec.getProfile())
//securityContext
.fsGroup(taskSpec.getFsGroup())
.runAsGroup(taskSpec.getRunAsGroup())
.runAsUser(taskSpec.getRunAsUser())
//specific
.contextRefs(contextRefs)
.contextSources(contextSources)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.smartcommunitylabdhub.runtime.container.specs;

import com.fasterxml.jackson.annotation.JsonProperty;
import it.smartcommunitylabdhub.commons.annotations.common.SpecType;
import it.smartcommunitylabdhub.commons.models.entities.EntityName;
import it.smartcommunitylabdhub.framework.k8s.base.K8sFunctionTaskBaseSpec;
Expand All @@ -22,9 +23,18 @@ public class ContainerDeployTaskSpec extends K8sFunctionTaskBaseSpec {
@Min(1)
private Integer replicas;

@JsonProperty("fs_group")
@Min(1)
private Integer fsGroup;

@JsonProperty("run_as_user")
@Min(1)
private Integer runAsUser;

@JsonProperty("run_as_group")
@Min(1)
private Integer runAsGroup;

public ContainerDeployTaskSpec(Map<String, Serializable> data) {
configure(data);
}
Expand All @@ -35,5 +45,8 @@ public void configure(Map<String, Serializable> data) {

ContainerDeployTaskSpec spec = mapper.convertValue(data, ContainerDeployTaskSpec.class);
this.replicas = spec.getReplicas();
this.fsGroup = spec.getFsGroup();
this.runAsGroup = spec.getRunAsUser();
this.runAsGroup = spec.getRunAsGroup();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ public class ContainerJobTaskSpec extends K8sFunctionTaskBaseSpec {
@Min(1)
private Integer fsGroup;

@JsonProperty("run_as_user")
@Min(1)
private Integer runAsUser;

@JsonProperty("run_as_group")
@Min(1)
private Integer runAsGroup;

public ContainerJobTaskSpec(Map<String, Serializable> data) {
configure(data);
}
Expand All @@ -47,5 +55,7 @@ public void configure(Map<String, Serializable> data) {
this.backoffLimit = spec.getBackoffLimit();
this.schedule = spec.getSchedule();
this.fsGroup = spec.getFsGroup();
this.runAsGroup = spec.getRunAsUser();
this.runAsGroup = spec.getRunAsGroup();
}
}

0 comments on commit ad0a6d6

Please sign in to comment.