Make initContainerName configurable
Hi, any chance we can make the pod init-image configurable? Maybe readable from an env variable?
Today is hard-coded to ghcr.io/srl-labs/init-wait:latest, but ghcr.io might not be accessible in highly controlled environments where container images are hosted in private repositories. Thanks!
controllers/srlinux_controller.go
const (
// ...
initContainerName = "ghcr.io/srl-labs/init-wait:latest"
)
controllers/pod.go
func createInitContainers(s *srlinuxv1.Srlinux) []corev1.Container {
return []corev1.Container{{
Name: fmt.Sprintf("init-%s", s.Name),
Image: initContainerName,
// ...
}}
}
yeah, I agree, it makes sense to have this configurable, and env var based config sounds like a reasonable approach
Thanks @hellt
The other option is you add an InitContainerImage string field to your NodeConfig.
srl-controller/api/v1/types.go
type NodeConfig struct {
Command []string `json:"command,omitempty"` // Command to pass into pod.
Args []string `json:"args,omitempty"` // Command args to pass into the pod.
Image string `json:"image,omitempty"` // Docker image to use with pod.
// ...
}
Then you can honor the value KNE would pass you if we add InitContainerImage: n.GetProto().GetConfig().GetInitImage() to the Nokia node definition.
kne/topo/node/nokia/nokia.go
func (n *Node) Create(ctx context.Context) error {
// ....
srl := &srlinuxv1.Srlinux{
TypeMeta: metav1.TypeMeta{
Kind: "Srlinux",
APIVersion: "kne.srlinux.dev/v1",
},
// ...
Spec: srlinuxv1.SrlinuxSpec{
NumInterfaces: len(n.GetProto().GetInterfaces()),
Config: &srlinuxv1.NodeConfig{
Command: n.GetProto().GetConfig().GetCommand(),
Args: n.GetProto().GetConfig().GetArgs(),
Image: n.GetProto().GetConfig().GetImage(),
// .... InitContainerImage HERE ....
Env: n.GetProto().GetConfig().GetEnv(),
// ....