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
3 changes: 3 additions & 0 deletions .changes/unreleased/Feature-20260218-130149.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Feature
body: Add the ability to override the helper image
time: 2026-02-18T13:01:49.668464-05:00
3 changes: 3 additions & 0 deletions .changes/unreleased/Feature-20260218-130222.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Feature
body: Add the ability to set the k8s api QPS
time: 2026-02-18T13:02:22.885166-05:00
8 changes: 8 additions & 0 deletions src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ func init() {
rootCmd.PersistentFlags().Int("job-pod-log-max-interval", 30, "The max amount of time between when pod logs are shipped to OpsLevel. Works in tandem with 'job-pod-log-max-size'")
rootCmd.PersistentFlags().Int("job-pod-log-max-size", 1000000, "The max amount in bytes to buffer before pod logs are shipped to OpsLevel. Works in tandem with 'job-pod-log-max-interval'")
rootCmd.PersistentFlags().Bool("job-agent-mode", false, "Enable agent mode with privileged security context for Container-in-Container support. WARNING: This grants elevated privileges and should only be enabled for trusted workloads.")
rootCmd.PersistentFlags().String("job-pod-helper-image", "", "Override the helper init container image. Defaults to the published ECR image matching the runner version. Useful for local development with kind.")
rootCmd.PersistentFlags().String("queue", "", "The queue this runner should process jobs from. Empty means the default queue.")

rootCmd.PersistentFlags().Int("k8s-api-qps", 50, "The maximum sustained queries per second to the Kubernetes API server.")
rootCmd.PersistentFlags().Int("k8s-api-burst", 100, "The maximum burst of queries to the Kubernetes API server.")

rootCmd.PersistentFlags().String("runner-pod-name", "", "overrides environment variable 'RUNNER_POD_NAME'")
rootCmd.PersistentFlags().String("runner-pod-namespace", "default", "The kubernetes namespace the runner pod is deployed in. Overrides environment variable 'RUNNER_POD_NAMESPACE'")
rootCmd.PersistentFlags().String("runner-deployment", "runner", "The runner's kubernetes deployment name")
Expand All @@ -74,8 +78,12 @@ func init() {
viper.BindEnv("job-pod-log-max-interval", "OPSLEVEL_JOB_POD_LOG_MAX_INTERVAL")
viper.BindEnv("job-pod-log-max-size", "OPSLEVEL_JOB_POD_LOG_MAX_SIZE")
viper.BindEnv("job-agent-mode", "OPSLEVEL_JOB_AGENT_MODE")
viper.BindEnv("job-pod-helper-image", "OPSLEVEL_JOB_POD_HELPER_IMAGE")
viper.BindEnv("queue", "OPSLEVEL_QUEUE")

viper.BindEnv("k8s-api-qps", "OPSLEVEL_K8S_API_QPS")
viper.BindEnv("k8s-api-burst", "OPSLEVEL_K8S_API_BURST")

viper.BindEnv("runner-pod-name", "RUNNER_POD_NAME")
viper.BindEnv("runner-pod-namespace", "RUNNER_POD_NAMESPACE")
viper.BindEnv("runner-deployment", "RUNNER_DEPLOYMENT")
Expand Down
4 changes: 3 additions & 1 deletion src/pkg/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (s *JobRunner) getPodObject(identifier string, labels map[string]string, jo
InitContainers: []corev1.Container{
{
Name: ContainerNameHelper,
Image: fmt.Sprintf("public.ecr.aws/opslevel/opslevel-runner:v%s", ImageTagVersion),
Image: s.podConfig.helperImage(),
ImagePullPolicy: s.podConfig.PullPolicy,
Command: []string{
"cp",
Expand Down Expand Up @@ -368,6 +368,8 @@ func GetKubernetesConfig() (*rest.Config, error) {
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
configOverrides := &clientcmd.ConfigOverrides{}
config, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides).ClientConfig()
config.QPS = float32(viper.GetInt("k8s-api-qps"))
config.Burst = viper.GetInt("k8s-api-burst")
config.Timeout = time.Second * time.Duration(viper.GetInt("job-pod-exec-max-wait"))
if err != nil {
return nil, err
Expand Down
10 changes: 10 additions & 0 deletions src/pkg/k8s_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pkg

import (
"fmt"
"os"

"github.com/spf13/viper"
Expand All @@ -27,6 +28,7 @@ type K8SPodConfig struct {
SecurityContext corev1.PodSecurityContext `yaml:"securityContext"`
NodeSelector map[string]string `yaml:"nodeSelector"`
AgentMode bool `yaml:"agentMode"`
HelperImage string `yaml:"helperImage"`
}

func ReadPodConfig(path string) (*K8SPodConfig, error) {
Expand All @@ -48,6 +50,7 @@ func ReadPodConfig(path string) (*K8SPodConfig, error) {
},
TerminationGracePeriodSeconds: 5,
AgentMode: viper.GetBool("job-agent-mode"),
HelperImage: viper.GetString("job-pod-helper-image"),
},
}
// Early out with viper defaults if config file doesn't exist
Expand All @@ -65,3 +68,10 @@ func ReadPodConfig(path string) (*K8SPodConfig, error) {

return &config.Kubernetes, nil
}

func (c *K8SPodConfig) helperImage() string {
if c.HelperImage != "" {
return c.HelperImage
}
return fmt.Sprintf("public.ecr.aws/opslevel/opslevel-runner:v%s", ImageTagVersion)
}
Loading