Skip to content
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

feat: set default runner image in global config #371

Merged
merged 2 commits into from
Oct 29, 2024
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
6 changes: 6 additions & 0 deletions deploy/charts/burrito/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ TLS certificates
{{- $_ := set $config.datastore "certificateSecretName" .Values.datastore.tls.secretName }}
{{- end }}

{{/*
Runner
*/}}
{{ if eq .Values.config.burrito.runner.image.tag "" }}
{{- $_ := set $config.runner.image "tag" .Chart.AppVersion }}
{{- end }}

apiVersion: v1
kind: ConfigMap
Expand Down
5 changes: 5 additions & 0 deletions deploy/charts/burrito/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ config:
runner:
# -- Configmap name to store the SSH known hosts in the runner
sshKnownHostsConfigMapName: burrito-ssh-known-hosts
image:
# -- Default image to use for runners, can be overriden with spec.OverrideRunnerSpec in repositories and layer definitions
repository: ghcr.io/padok-team/burrito
tag: "" # By default use Chart's appVersion
pullPolicy: Always

hermitcrab:
# -- Enable/Disable Hermitcrab (terraform provider cache in cluster)
Expand Down
7 changes: 7 additions & 0 deletions internal/burrito/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,17 @@ type RunnerConfig struct {
Run string `mapstructure:"run"`
Repository RepositoryConfig `mapstructure:"repository"`
SSHKnownHostsConfigMapName string `mapstructure:"sshKnownHostsConfigMapName"`
Image ImageConfig `mapstructure:"image"`
RunnerBinaryPath string `mapstructure:"runnerBinaryPath"`
RepositoryPath string `mapstructure:"repositoryPath"`
}

type ImageConfig struct {
Repository string `mapstructure:"repository"`
Tag string `mapstructure:"tag"`
PullPolicy string `mapstructure:"pullPolicy"`
}

type Layer struct {
Name string `mapstructure:"name"`
Namespace string `mapstructure:"namespace"`
Expand Down
13 changes: 13 additions & 0 deletions internal/burrito/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ func TestConfig_FromYamlFile(t *testing.T) {
Name: "test",
Namespace: "default",
},
Image: config.ImageConfig{
Repository: "test-repository",
Tag: "test-tag",
PullPolicy: "Always",
},
Repository: config.RepositoryConfig{
SSHPrivateKey: "private-key",
Username: "test",
Expand Down Expand Up @@ -130,6 +135,9 @@ func TestConfig_EnvVarOverrides(t *testing.T) {
setEnvVar(t, "BURRITO_RUNNER_REPOSITORY_USERNAME", "other-username", &envVarList)
setEnvVar(t, "BURRITO_RUNNER_REPOSITORY_PASSWORD", "other-password", &envVarList)
setEnvVar(t, "BURRITO_RUNNER_REPOSITORY_SSHPRIVATEKEY", "other-private-key", &envVarList)
setEnvVar(t, "BURRITO_RUNNER_IMAGE_REPOSITORY", "other-repository", &envVarList)
setEnvVar(t, "BURRITO_RUNNER_IMAGE_TAG", "other-tag", &envVarList)
setEnvVar(t, "BURRITO_RUNNER_IMAGE_PULLPOLICY", "Always", &envVarList)
// Controller
setEnvVar(t, "BURRITO_CONTROLLER_TYPES", "layer,repository", &envVarList)
setEnvVar(t, "BURRITO_CONTROLLER_NAMESPACES", "default,burrito,other", &envVarList)
Expand Down Expand Up @@ -176,6 +184,11 @@ func TestConfig_EnvVarOverrides(t *testing.T) {
Name: "other-layer",
Namespace: "other-namespace",
},
Image: config.ImageConfig{
Repository: "other-repository",
Tag: "other-tag",
PullPolicy: "Always",
},
Repository: config.RepositoryConfig{
SSHPrivateKey: "other-private-key",
Username: "other-username",
Expand Down
4 changes: 4 additions & 0 deletions internal/burrito/config/testdata/test-config-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ runner:
layer:
name: test
namespace: default
image:
repository: test-repository
tag: test-tag
pullPolicy: Always
repository:
sshPrivateKey: "private-key"
username: "test"
Expand Down
5 changes: 2 additions & 3 deletions internal/controllers/terraformrun/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

configv1alpha1 "github.com/padok-team/burrito/api/v1alpha1"
"github.com/padok-team/burrito/internal/burrito/config"
"github.com/padok-team/burrito/internal/version"
log "github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -284,8 +283,8 @@ func defaultPodSpec(config *config.Config, layer *configv1alpha1.TerraformLayer,
Containers: []corev1.Container{
{
Name: "runner",
Image: fmt.Sprintf("ghcr.io/padok-team/burrito:%s", version.Version),
ImagePullPolicy: corev1.PullIfNotPresent,
Image: fmt.Sprintf("%s:%s", config.Runner.Image.Repository, config.Runner.Image.Tag),
ImagePullPolicy: corev1.PullPolicy(config.Runner.Image.PullPolicy),
Args: []string{"runner", "start"},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down