karmada-io / karmada

Open, Multi-Cloud, Multi-Cluster Kubernetes Orchestration
https://karmada.io
Apache License 2.0
4.47k stars 884 forks source link

Env Overrider #5384

Open a7i opened 2 months ago

a7i commented 2 months ago

What would you like to be added:

Ability to override Envs per member cluster.

    // EnvOverrider represents the list of environment variables to override
    // +optional
    EnvOverrider []EnvOverrider `json:"envOverrider,omitempty"`
// EnvOverrider represents the rules to handling env overrides
type EnvOverrider struct {
    Operator string `json:"operator"`
        ContainerName `json:"containerName"`
        Values map[string]string `json:"values"` // where key is env.Name and value is env.Value
}

Why is this needed:

While PlainTextOverrider is helpful, we may not know exactly at which index position the ENV may be in (since it's an array). For example, we have an env called AUTH_BACKEND which is used to communicate with Vault and this is unique per cluster.

Unknowns/feedback-requested:

XiShanYongYe-Chang commented 2 months ago

/cc @chaunceyjiang

chaunceyjiang commented 2 months ago

I also considered implementing an EnvOverrider before, but I had not thought through another issue, which is how to better support third-party resources, such as https://github.com/openkruise/kruise/blob/master/apis/apps/v1alpha1/cloneset_types.go#L248. https://github.com/kubeflow/training-operator/blob/master/pkg/apis/kubeflow.org/v1/pytorch_types.go#L56.