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

Add support for configuring the K8s resources for injected collectors #247

Closed
jfiedler opened this issue Apr 13, 2021 · 2 comments · Fixed by #248
Closed

Add support for configuring the K8s resources for injected collectors #247

jfiedler opened this issue Apr 13, 2021 · 2 comments · Fixed by #248
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jfiedler
Copy link

It would be nice if K8s resources of the injected collectors (for sidecar mode) could be configured via the operator CRD. This is an important requirement when using horizontal pod autoscalers later on. Containers in a pod that have no resource requests can cause issues with HPA.

@jpkrohling jpkrohling added the enhancement New feature or request label Apr 13, 2021
@jpkrohling
Copy link
Member

Would you like to contribute with a PR? Should be relatively easy to do it: add a Resources node here, similar to what v1.Container has:

type OpenTelemetryCollectorSpec struct {
// Config is the raw JSON to be used as the collector's configuration. Refer to the OpenTelemetry Collector documentation for details.
// +required
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
Config string `json:"config,omitempty"`
// Args is the set of arguments to pass to the OpenTelemetry Collector binary
// +optional
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
Args map[string]string `json:"args,omitempty"`
// Replicas is the number of pod instances for the underlying OpenTelemetry Collector
// +optional
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
Replicas *int32 `json:"replicas,omitempty"`
// Image indicates the container image to use for the OpenTelemetry Collector.
// +optional
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
Image string `json:"image,omitempty"`
// Mode represents how the collector should be deployed (deployment, daemonset or sidecar)
// +optional
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
Mode Mode `json:"mode,omitempty"`
// ServiceAccount indicates the name of an existing service account to use with this instance.
// +optional
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
ServiceAccount string `json:"serviceAccount,omitempty"`
// VolumeMounts represents the mount points to use in the underlying collector deployment(s)
// +optional
// +listType=atomic
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
VolumeMounts []v1.VolumeMount `json:"volumeMounts,omitempty"`
// Volumes represents which volumes to use in the underlying collector deployment(s).
// +optional
// +listType=atomic
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
Volumes []v1.Volume `json:"volumes,omitempty"`
// Ports allows a set of ports to be exposed by the underlying v1.Service. By default, the operator
// will attempt to infer the required ports by parsing the .Spec.Config property but this property can be
// used to open aditional ports that can't be inferred by the operator, like for custom receivers.
// +optional
// +listType=atomic
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
Ports []v1.ServicePort `json:"ports,omitempty"`
// ENV vars to set on the OpenTelemetry Collector's Pods. These can then in certain cases be
// consumed in the config file for the Collector.
// +optional
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
Env []v1.EnvVar `json:"env,omitempty"`
}

Then apply it here:

return corev1.Container{
Name: naming.Container(),
Image: image,
VolumeMounts: volumeMounts,
Args: args,
Env: envVars,
}

@jpkrohling jpkrohling added the good first issue Good for newcomers label Apr 13, 2021
@jfiedler
Copy link
Author

Sure. I will give it a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants