Skip to content

Commit 9c99971

Browse files
Add configuration options (#276)
* Add the ability to override the helper image * Update k8s client throughput.
1 parent 87f5f52 commit 9c99971

5 files changed

Lines changed: 27 additions & 1 deletion

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Feature
2+
body: Add the ability to override the helper image
3+
time: 2026-02-18T13:01:49.668464-05:00
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Feature
2+
body: Add the ability to set the k8s api QPS
3+
time: 2026-02-18T13:02:22.885166-05:00

src/cmd/root.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ func init() {
5151
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'")
5252
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'")
5353
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.")
54+
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.")
5455
rootCmd.PersistentFlags().String("queue", "", "The queue this runner should process jobs from. Empty means the default queue.")
5556

57+
rootCmd.PersistentFlags().Int("k8s-api-qps", 50, "The maximum sustained queries per second to the Kubernetes API server.")
58+
rootCmd.PersistentFlags().Int("k8s-api-burst", 100, "The maximum burst of queries to the Kubernetes API server.")
59+
5660
rootCmd.PersistentFlags().String("runner-pod-name", "", "overrides environment variable 'RUNNER_POD_NAME'")
5761
rootCmd.PersistentFlags().String("runner-pod-namespace", "default", "The kubernetes namespace the runner pod is deployed in. Overrides environment variable 'RUNNER_POD_NAMESPACE'")
5862
rootCmd.PersistentFlags().String("runner-deployment", "runner", "The runner's kubernetes deployment name")
@@ -74,8 +78,12 @@ func init() {
7478
viper.BindEnv("job-pod-log-max-interval", "OPSLEVEL_JOB_POD_LOG_MAX_INTERVAL")
7579
viper.BindEnv("job-pod-log-max-size", "OPSLEVEL_JOB_POD_LOG_MAX_SIZE")
7680
viper.BindEnv("job-agent-mode", "OPSLEVEL_JOB_AGENT_MODE")
81+
viper.BindEnv("job-pod-helper-image", "OPSLEVEL_JOB_POD_HELPER_IMAGE")
7782
viper.BindEnv("queue", "OPSLEVEL_QUEUE")
7883

84+
viper.BindEnv("k8s-api-qps", "OPSLEVEL_K8S_API_QPS")
85+
viper.BindEnv("k8s-api-burst", "OPSLEVEL_K8S_API_BURST")
86+
7987
viper.BindEnv("runner-pod-name", "RUNNER_POD_NAME")
8088
viper.BindEnv("runner-pod-namespace", "RUNNER_POD_NAMESPACE")
8189
viper.BindEnv("runner-deployment", "RUNNER_DEPLOYMENT")

src/pkg/k8s.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func (s *JobRunner) getPodObject(identifier string, labels map[string]string, jo
211211
InitContainers: []corev1.Container{
212212
{
213213
Name: ContainerNameHelper,
214-
Image: fmt.Sprintf("public.ecr.aws/opslevel/opslevel-runner:v%s", ImageTagVersion),
214+
Image: s.podConfig.helperImage(),
215215
ImagePullPolicy: s.podConfig.PullPolicy,
216216
Command: []string{
217217
"cp",
@@ -368,6 +368,8 @@ func GetKubernetesConfig() (*rest.Config, error) {
368368
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
369369
configOverrides := &clientcmd.ConfigOverrides{}
370370
config, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides).ClientConfig()
371+
config.QPS = float32(viper.GetInt("k8s-api-qps"))
372+
config.Burst = viper.GetInt("k8s-api-burst")
371373
config.Timeout = time.Second * time.Duration(viper.GetInt("job-pod-exec-max-wait"))
372374
if err != nil {
373375
return nil, err

src/pkg/k8s_config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package pkg
22

33
import (
4+
"fmt"
45
"os"
56

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

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

6669
return &config.Kubernetes, nil
6770
}
71+
72+
func (c *K8SPodConfig) helperImage() string {
73+
if c.HelperImage != "" {
74+
return c.HelperImage
75+
}
76+
return fmt.Sprintf("public.ecr.aws/opslevel/opslevel-runner:v%s", ImageTagVersion)
77+
}

0 commit comments

Comments
 (0)