-
Notifications
You must be signed in to change notification settings - Fork 0
Add new job-agent-mode flag #269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6ad4d8e
add escalated privileges for jobs using coding-agent image
derek-etherton-opslevel 5f6d11a
prune back coding agent capabilities to just privileged + root user
derek-etherton-opslevel 521aeb6
add basic securityContext unit test
derek-etherton-opslevel 0bce102
add new --job-agent-mode flag to control privileging of pods
derek-etherton-opslevel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| kind: Feature | ||
| body: Add a new --job-agent-mode option, for creating privileged pods capable of container-in-container management | ||
| time: 2025-12-10T09:18:50.207809-08:00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,6 +153,27 @@ func executable() *int32 { | |
| func (s *JobRunner) getPodObject(identifier string, labels map[string]string, job opslevel.RunnerJob) *corev1.Pod { | ||
| // TODO: Allow configuration of Labels | ||
| // TODO: Allow configuration of Pod Command | ||
|
|
||
| podSecurityContext := s.podConfig.SecurityContext | ||
| if s.podConfig.AgentMode { | ||
| // Agent mode jobs need root user for Docker daemon | ||
| runAsUser := int64(0) | ||
| fsGroup := int64(0) | ||
| podSecurityContext = corev1.PodSecurityContext{ | ||
| RunAsUser: &runAsUser, | ||
| FSGroup: &fsGroup, | ||
| } | ||
| } | ||
|
|
||
| var containerSecurityContext *corev1.SecurityContext | ||
| if s.podConfig.AgentMode { | ||
| // Agent mode jobs need privileged mode for creating containers within container | ||
| privileged := true | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have an existing network policy for runner-jobs blocking egress to internal networks: https://gitlab.com/jklabsinc/opslevel-kubernetes/-/tree/main/clusters/new-prod-runners/runner-jobs?ref_type=heads |
||
| containerSecurityContext = &corev1.SecurityContext{ | ||
| Privileged: &privileged, | ||
| } | ||
| } | ||
|
|
||
| return &corev1.Pod{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: identifier, | ||
|
|
@@ -163,7 +184,7 @@ func (s *JobRunner) getPodObject(identifier string, labels map[string]string, jo | |
| Spec: corev1.PodSpec{ | ||
| TerminationGracePeriodSeconds: &s.podConfig.TerminationGracePeriodSeconds, | ||
| RestartPolicy: corev1.RestartPolicyNever, | ||
| SecurityContext: &s.podConfig.SecurityContext, | ||
| SecurityContext: &podSecurityContext, | ||
| ServiceAccountName: s.podConfig.ServiceAccountName, | ||
| NodeSelector: s.podConfig.NodeSelector, | ||
| InitContainers: []corev1.Container{ | ||
|
|
@@ -195,8 +216,9 @@ func (s *JobRunner) getPodObject(identifier string, labels map[string]string, jo | |
| "-c", | ||
| fmt.Sprintf("sleep %d", s.podConfig.Lifetime), | ||
| }, | ||
| Resources: s.podConfig.Resources, | ||
| Env: s.getPodEnv(job.Variables), | ||
| Resources: s.podConfig.Resources, | ||
| Env: s.getPodEnv(job.Variables), | ||
| SecurityContext: containerSecurityContext, | ||
| VolumeMounts: []corev1.VolumeMount{ | ||
| { | ||
| Name: "scripts", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that we're using a job arg, we can be oober confident that nothing will use this mode until we explicitly add it to
opslevel-kubernetes👍so sequencing will be:
--job-agent-modeflaga. since the feature isn't "on" yet we can get away with this teeny gap.