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

Support sidecar containers #325

Closed
Mossaka opened this issue Oct 14, 2024 · 1 comment
Closed

Support sidecar containers #325

Mossaka opened this issue Oct 14, 2024 · 1 comment

Comments

@Mossaka
Copy link
Member

Mossaka commented Oct 14, 2024

I would want the SpinApp CRD to be able to specify sidecar (Linux) containers that can run in the same pod as the the Spin App.

The main changes are

  1. A new field Containers in the spinapp_types.go that defines a list of sidecar containers to be included in the Deployment.
// Containers defines the list of sidecar containers to be included in the deployment.
//
// These containers will not include the main Spin App. They share the Spin App's
// environment variables and volumes.
// +kubebuilder:validation:Optional
Containers []corev1.Container `json:"containers,omitempty"`
  1. in spinapp_controller.go, adds containers to the deployment creation.
var containers []corev1.Container
if len(app.Spec.Containers) > 0 {
  for _, c := range app.Spec.Containers {
	  if c.Image == app.Spec.Image {
		  return nil, errors.New("container in app.Spec.Containers must have a different image than Spin App")
	  }
	  if c.Name == "" {
		  return nil, errors.New("container in app.Spec.Containers must have a name")
	  }
	  if c.Name == app.Name {
		  return nil, errors.New("container in app.Spec.Containers must have a different name than the Spin App")
	  }
	  c.Env = append(c.Env, env...)
	  c.VolumeMounts = append(c.VolumeMounts, volumeMounts...)
	  if c.Resources.Limits == nil && c.Resources.Requests == nil {
		  c.Resources = resources
	  }
	  if c.LivenessProbe == nil {
		  c.LivenessProbe = livenessProbe
	  }
	  if c.ReadinessProbe == nil {
		  c.ReadinessProbe = readinessProbe
	  }
	  containers = append(containers, c)
  }
}

I've done a bit prototype and you may check out the diff: main...Mossaka:spin-operator-msk:sidecars

@Mossaka
Copy link
Member Author

Mossaka commented Oct 18, 2024

Close this issue as we should move the discussion to spinkube/skips#11

@Mossaka Mossaka closed this as completed Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant