Skip to content

Commit

Permalink
feat: create service for extensions
Browse files Browse the repository at this point in the history
Signed-off-by: Ankit152 <ankitkurmi152@gmail.com>
  • Loading branch information
Ankit152 committed Oct 29, 2024
1 parent 34b8ee8 commit 3ab8c98
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apis/v1beta1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ func (c *Config) getPortsForComponentKinds(logger logr.Logger, componentKinds ..
case KindProcessor:
continue
case KindExtension:
continue
retriever = extensions.ParserFor
cfg = *c.Extensions
}
for componentName := range enabledComponents[componentKind] {
// TODO: Clean up the naming here and make it simpler to use a retriever.
Expand Down Expand Up @@ -282,6 +283,10 @@ func (c *Config) GetExporterPorts(logger logr.Logger) ([]corev1.ServicePort, err
return c.getPortsForComponentKinds(logger, KindExporter)
}

func (c *Config) GetExtensionPorts(logger logr.Logger) ([]corev1.ServicePort, error) {
return c.getPortsForComponentKinds(logger, KindExtension)
}

func (c *Config) GetAllPorts(logger logr.Logger) ([]corev1.ServicePort, error) {
return c.getPortsForComponentKinds(logger, KindReceiver, KindExporter)
}
Expand Down
3 changes: 3 additions & 0 deletions internal/components/extensions/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ var (
return components.ParseSingleEndpointSilent(logger, name, defaultPort, &config.SingleEndpointConfig)
}).
MustBuild(),
components.NewSinglePortParserBuilder("jaeger_query", 16686).
WithTargetPort(16686).
MustBuild(),
}
)

Expand Down
28 changes: 28 additions & 0 deletions internal/manifests/collector/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,34 @@ func MonitoringService(params manifests.Params) (*corev1.Service, error) {
}, nil
}

func ExtensionService(params manifests.Params) (*corev1.Service, error) {
name := naming.Service(params.OtelCol.Name)
labels := manifestutils.Labels(params.OtelCol.ObjectMeta, name, params.OtelCol.Spec.Image, ComponentOpenTelemetryCollector, []string{})

annotations, err := manifestutils.Annotations(params.OtelCol, params.Config.AnnotationsFilter())
if err != nil {
return nil, err
}

ports, err := params.OtelCol.Spec.Config.GetExtensionPorts(params.Log)
if err != nil {
return nil, err
}

return &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: params.OtelCol.Namespace,
Labels: labels,
Annotations: annotations,
},
Spec: corev1.ServiceSpec{
Ports: ports,
Selector: manifestutils.SelectorLabels(params.OtelCol.ObjectMeta, ComponentOpenTelemetryCollector),
},
}, nil
}

func Service(params manifests.Params) (*corev1.Service, error) {
name := naming.Service(params.OtelCol.Name)
labels := manifestutils.Labels(params.OtelCol.ObjectMeta, name, params.OtelCol.Spec.Image, ComponentOpenTelemetryCollector, []string{})
Expand Down

0 comments on commit 3ab8c98

Please sign in to comment.