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(hatchery:k8s): allow to add custom annotations #6407

Merged
merged 1 commit into from
Jan 5, 2023
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 engine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ func configSetStartupData(conf *Configuration) (string, error) {
privateKey, _ := jws.NewRandomRSAKey()
privateKeyPEM, _ := jws.ExportPrivateKey(privateKey)
h.Kubernetes.RSAPrivateKey = string(privateKeyPEM)
var a kubernetes.CustomAnnotation
defaults.SetDefaults(&a)
conf.Hatchery.Kubernetes.CustomAnnotations = append(conf.Hatchery.Kubernetes.CustomAnnotations, a)
}
}

Expand Down
7 changes: 7 additions & 0 deletions engine/hatchery/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@ func (h *HatcheryKubernetes) SpawnWorker(ctx context.Context, spawnArgs hatchery
},
}

// Set custom annotation on pod if needed
for _, a := range h.Config.CustomAnnotations {
if a.Key != "" && a.Value != "" {
podSchema.Annotations[a.Key] = a.Value
}
}

// Check here to add secret if needed
if spawnArgs.Model.ModelDocker.Private {
secretRegistryName, err := h.createRegistrySecret(ctx, *spawnArgs.Model)
Expand Down
7 changes: 7 additions & 0 deletions engine/hatchery/kubernetes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ type HatcheryConfiguration struct {
KubernetesClientCertData string `mapstructure:"clientCertData" toml:"clientCertData" default:"" commented:"true" comment:"Client certificate data (content, not path and not base64 encoded) for tls kubernetes (optional if no tls needed)" json:"-"`
// KubernetesKeyData Client certificate data for tls kubernetes (optional if no tls needed)
KubernetesClientKeyData string `mapstructure:"clientKeyData" toml:"clientKeyData" default:"" commented:"true" comment:"Client certificate data (content, not path and not base64 encoded) for tls kubernetes (optional if no tls needed)" json:"-"`
// CustomAnnotations that will be added to pods spawned by the hatchery
CustomAnnotations []CustomAnnotation `mapstructure:"customAnnotations" toml:"customAnnotations" default:"" commented:"true" comment:"CustomAnnotations that will be added to pods spawned by the hatchery" json:"-"`
}

type CustomAnnotation struct {
Key string `mapstructure:"key" toml:"key" default:"" commented:"true" json:"-"`
Value string `mapstructure:"value" toml:"value" default:"" commented:"true" json:"-"`
}

// HatcheryKubernetes implements HatcheryMode interface for local usage
Expand Down