Skip to content

Commit c0f8e03

Browse files
authored
[chore] Add v1alpha2 types (#2283)
* Add v1alpha2 types Signed-off-by: Israel Blancas <[email protected]> * Fix lint Signed-off-by: Israel Blancas <[email protected]> --------- Signed-off-by: Israel Blancas <[email protected]>
1 parent 3d16cee commit c0f8e03

5 files changed

+1254
-0
lines changed

apis/v1alpha1/opentelemetrycollector_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ type OpenTelemetryCollectorStatus struct {
401401
}
402402

403403
// +kubebuilder:object:root=true
404+
// +kubebuilder:storageversion
404405
// +kubebuilder:resource:shortName=otelcol;otelcols
405406
// +kubebuilder:subresource:status
406407
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.scale.replicas,selectorpath=.status.scale.selector

apis/v1alpha2/groupversion_info.go

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright The OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Package v1alpha2 contains API Schema definitions for the v1alpha2 API group
16+
// +kubebuilder:object:generate=true
17+
// +groupName=opentelemetry.io
18+
package v1alpha2
19+
20+
import (
21+
"k8s.io/apimachinery/pkg/runtime/schema"
22+
"sigs.k8s.io/controller-runtime/pkg/scheme"
23+
)
24+
25+
var (
26+
// GroupVersion is group version used to register these objects.
27+
GroupVersion = schema.GroupVersion{Group: "opentelemetry.io", Version: "v1alpha2"}
28+
29+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
30+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
31+
32+
// AddToScheme adds the types in this group-version to the given scheme.
33+
AddToScheme = SchemeBuilder.AddToScheme
34+
)
+325
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,325 @@
1+
// Copyright The OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// +kubebuilder:skip
16+
17+
package v1alpha2
18+
19+
import (
20+
corev1 "k8s.io/api/core/v1"
21+
"k8s.io/apimachinery/pkg/api/resource"
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
24+
"github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1"
25+
)
26+
27+
// InstrumentationSpec defines the desired state of OpenTelemetry SDK and instrumentation.
28+
type InstrumentationSpec struct {
29+
// Exporter defines exporter configuration.
30+
// +optional
31+
Exporter `json:"exporter,omitempty"`
32+
33+
// Resource defines the configuration for the resource attributes, as defined by the OpenTelemetry specification.
34+
// +optional
35+
Resource Resource `json:"resource,omitempty"`
36+
37+
// Propagators defines inter-process context propagation configuration.
38+
// Values in this list will be set in the OTEL_PROPAGATORS env var.
39+
// Enum=tracecontext;baggage;b3;b3multi;jaeger;xray;ottrace;none
40+
// +optional
41+
Propagators []v1alpha1.Propagator `json:"propagators,omitempty"`
42+
43+
// Sampler defines sampling configuration.
44+
// +optional
45+
Sampler `json:"sampler,omitempty"`
46+
47+
// Env defines common env vars. There are four layers for env vars' definitions and
48+
// the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs' vars`.
49+
// If the former var had been defined, then the other vars would be ignored.
50+
// +optional
51+
Env []corev1.EnvVar `json:"env,omitempty"`
52+
53+
// Java defines configuration for java auto-instrumentation.
54+
// +optional
55+
Java Java `json:"java,omitempty"`
56+
57+
// NodeJS defines configuration for nodejs auto-instrumentation.
58+
// +optional
59+
NodeJS NodeJS `json:"nodejs,omitempty"`
60+
61+
// Python defines configuration for python auto-instrumentation.
62+
// +optional
63+
Python Python `json:"python,omitempty"`
64+
65+
// DotNet defines configuration for DotNet auto-instrumentation.
66+
// +optional
67+
DotNet DotNet `json:"dotnet,omitempty"`
68+
69+
// Go defines configuration for Go auto-instrumentation.
70+
// When using Go auto-instrumentation you must provide a value for the OTEL_GO_AUTO_TARGET_EXE env var via the
71+
// Instrumentation env vars or via the instrumentation.opentelemetry.io/otel-go-auto-target-exe pod annotation.
72+
// Failure to set this value causes instrumentation injection to abort, leaving the original pod unchanged.
73+
// +optional
74+
Go Go `json:"go,omitempty"`
75+
76+
// ApacheHttpd defines configuration for Apache HTTPD auto-instrumentation.
77+
// +optional
78+
ApacheHttpd ApacheHttpd `json:"apacheHttpd,omitempty"`
79+
80+
// Nginx defines configuration for Nginx auto-instrumentation.
81+
// +optional
82+
Nginx Nginx `json:"nginx,omitempty"`
83+
}
84+
85+
// Resource defines the configuration for the resource attributes, as defined by the OpenTelemetry specification.
86+
// See also: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/overview.md#resources
87+
type Resource struct {
88+
// Attributes defines attributes that are added to the resource.
89+
// For example environment: dev
90+
// +optional
91+
Attributes map[string]string `json:"resourceAttributes,omitempty"`
92+
93+
// AddK8sUIDAttributes defines whether K8s UID attributes should be collected (e.g. k8s.deployment.uid).
94+
// +optional
95+
AddK8sUIDAttributes bool `json:"addK8sUIDAttributes,omitempty"`
96+
}
97+
98+
// Exporter defines OTLP exporter configuration.
99+
type Exporter struct {
100+
// Endpoint is address of the collector with OTLP endpoint.
101+
// +optional
102+
Endpoint string `json:"endpoint,omitempty"`
103+
}
104+
105+
// Sampler defines sampling configuration.
106+
type Sampler struct {
107+
// Type defines sampler type.
108+
// The value will be set in the OTEL_TRACES_SAMPLER env var.
109+
// The value can be for instance parentbased_always_on, parentbased_always_off, parentbased_traceidratio...
110+
// +optional
111+
Type v1alpha1.SamplerType `json:"type,omitempty"`
112+
113+
// Argument defines sampler argument.
114+
// The value depends on the sampler type.
115+
// For instance for parentbased_traceidratio sampler type it is a number in range [0..1] e.g. 0.25.
116+
// The value will be set in the OTEL_TRACES_SAMPLER_ARG env var.
117+
// +optional
118+
Argument string `json:"argument,omitempty"`
119+
}
120+
121+
// Java defines Java SDK and instrumentation configuration.
122+
type Java struct {
123+
// Image is a container image with javaagent auto-instrumentation JAR.
124+
// +optional
125+
Image string `json:"image,omitempty"`
126+
127+
// VolumeSizeLimit defines size limit for volume used for auto-instrumentation.
128+
// The default size is 200Mi.
129+
VolumeSizeLimit *resource.Quantity `json:"volumeLimitSize,omitempty"`
130+
131+
// Env defines java specific env vars. There are four layers for env vars' definitions and
132+
// the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs' vars`.
133+
// If the former var had been defined, then the other vars would be ignored.
134+
// +optional
135+
Env []corev1.EnvVar `json:"env,omitempty"`
136+
137+
// Resources describes the compute resource requirements.
138+
// +optional
139+
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
140+
}
141+
142+
// NodeJS defines NodeJS SDK and instrumentation configuration.
143+
type NodeJS struct {
144+
// Image is a container image with NodeJS SDK and auto-instrumentation.
145+
// +optional
146+
Image string `json:"image,omitempty"`
147+
148+
// VolumeSizeLimit defines size limit for volume used for auto-instrumentation.
149+
// The default size is 200Mi.
150+
VolumeSizeLimit *resource.Quantity `json:"volumeLimitSize,omitempty"`
151+
152+
// Env defines nodejs specific env vars. There are four layers for env vars' definitions and
153+
// the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs' vars`.
154+
// If the former var had been defined, then the other vars would be ignored.
155+
// +optional
156+
Env []corev1.EnvVar `json:"env,omitempty"`
157+
158+
// Resources describes the compute resource requirements.
159+
// +optional
160+
Resources corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
161+
}
162+
163+
// Python defines Python SDK and instrumentation configuration.
164+
type Python struct {
165+
// Image is a container image with Python SDK and auto-instrumentation.
166+
// +optional
167+
Image string `json:"image,omitempty"`
168+
169+
// VolumeSizeLimit defines size limit for volume used for auto-instrumentation.
170+
// The default size is 200Mi.
171+
VolumeSizeLimit *resource.Quantity `json:"volumeLimitSize,omitempty"`
172+
173+
// Env defines python specific env vars. There are four layers for env vars' definitions and
174+
// the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs' vars`.
175+
// If the former var had been defined, then the other vars would be ignored.
176+
// +optional
177+
Env []corev1.EnvVar `json:"env,omitempty"`
178+
179+
// Resources describes the compute resource requirements.
180+
// +optional
181+
Resources corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
182+
}
183+
184+
// DotNet defines DotNet SDK and instrumentation configuration.
185+
type DotNet struct {
186+
// Image is a container image with DotNet SDK and auto-instrumentation.
187+
// +optional
188+
Image string `json:"image,omitempty"`
189+
190+
// VolumeSizeLimit defines size limit for volume used for auto-instrumentation.
191+
// The default size is 200Mi.
192+
VolumeSizeLimit *resource.Quantity `json:"volumeLimitSize,omitempty"`
193+
194+
// Env defines DotNet specific env vars. There are four layers for env vars' definitions and
195+
// the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs' vars`.
196+
// If the former var had been defined, then the other vars would be ignored.
197+
// +optional
198+
Env []corev1.EnvVar `json:"env,omitempty"`
199+
// Resources describes the compute resource requirements.
200+
// +optional
201+
Resources corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
202+
}
203+
204+
type Go struct {
205+
// Image is a container image with Go SDK and auto-instrumentation.
206+
// +optional
207+
Image string `json:"image,omitempty"`
208+
209+
// VolumeSizeLimit defines size limit for volume used for auto-instrumentation.
210+
// The default size is 200Mi.
211+
VolumeSizeLimit *resource.Quantity `json:"volumeLimitSize,omitempty"`
212+
213+
// Env defines Go specific env vars. There are four layers for env vars' definitions and
214+
// the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs' vars`.
215+
// If the former var had been defined, then the other vars would be ignored.
216+
// +optional
217+
Env []corev1.EnvVar `json:"env,omitempty"`
218+
219+
// Resources describes the compute resource requirements.
220+
// +optional
221+
Resources corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
222+
}
223+
224+
// ApacheHttpd defines Apache SDK and instrumentation configuration.
225+
type ApacheHttpd struct {
226+
// Image is a container image with Apache SDK and auto-instrumentation.
227+
// +optional
228+
Image string `json:"image,omitempty"`
229+
230+
// VolumeSizeLimit defines size limit for volume used for auto-instrumentation.
231+
// The default size is 200Mi.
232+
VolumeSizeLimit *resource.Quantity `json:"volumeLimitSize,omitempty"`
233+
234+
// Env defines Apache HTTPD specific env vars. There are four layers for env vars' definitions and
235+
// the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs' vars`.
236+
// If the former var had been defined, then the other vars would be ignored.
237+
// +optional
238+
Env []corev1.EnvVar `json:"env,omitempty"`
239+
240+
// Attrs defines Apache HTTPD agent specific attributes. The precedence is:
241+
// `agent default attributes` > `instrument spec attributes` .
242+
// Attributes are documented at https://github.com/open-telemetry/opentelemetry-cpp-contrib/tree/main/instrumentation/otel-webserver-module
243+
// +optional
244+
Attrs []corev1.EnvVar `json:"attrs,omitempty"`
245+
246+
// Apache HTTPD server version. One of 2.4 or 2.2. Default is 2.4
247+
// +optional
248+
Version string `json:"version,omitempty"`
249+
250+
// Location of Apache HTTPD server configuration.
251+
// Needed only if different from default "/usr/local/apache2/conf"
252+
// +optional
253+
ConfigPath string `json:"configPath,omitempty"`
254+
255+
// Resources describes the compute resource requirements.
256+
// +optional
257+
Resources corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
258+
}
259+
260+
// Nginx defines Nginx SDK and instrumentation configuration.
261+
type Nginx struct {
262+
// Image is a container image with Nginx SDK and auto-instrumentation.
263+
// +optional
264+
Image string `json:"image,omitempty"`
265+
266+
// VolumeSizeLimit defines size limit for volume used for auto-instrumentation.
267+
// The default size is 200Mi.
268+
VolumeSizeLimit *resource.Quantity `json:"volumeLimitSize,omitempty"`
269+
270+
// Env defines Nginx specific env vars. There are four layers for env vars' definitions and
271+
// the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs' vars`.
272+
// If the former var had been defined, then the other vars would be ignored.
273+
// +optional
274+
Env []corev1.EnvVar `json:"env,omitempty"`
275+
276+
// Attrs defines Nginx agent specific attributes. The precedence order is:
277+
// `agent default attributes` > `instrument spec attributes` .
278+
// Attributes are documented at https://github.com/open-telemetry/opentelemetry-cpp-contrib/tree/main/instrumentation/otel-webserver-module
279+
// +optional
280+
Attrs []corev1.EnvVar `json:"attrs,omitempty"`
281+
282+
// Location of Nginx configuration file.
283+
// Needed only if different from default "/etx/nginx/nginx.conf"
284+
// +optional
285+
ConfigFile string `json:"configFile,omitempty"`
286+
287+
// Resources describes the compute resource requirements.
288+
// +optional
289+
Resources corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
290+
}
291+
292+
// InstrumentationStatus defines status of the instrumentation.
293+
type InstrumentationStatus struct {
294+
}
295+
296+
// +kubebuilder:object:root=true
297+
// +kubebuilder:resource:shortName=otelinst;otelinsts
298+
// +kubebuilder:subresource:status
299+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
300+
// +kubebuilder:printcolumn:name="Endpoint",type="string",JSONPath=".spec.exporter.endpoint"
301+
// +kubebuilder:printcolumn:name="Sampler",type="string",JSONPath=".spec.sampler.type"
302+
// +kubebuilder:printcolumn:name="Sampler Arg",type="string",JSONPath=".spec.sampler.argument"
303+
// +operator-sdk:csv:customresourcedefinitions:displayName="OpenTelemetry Instrumentation"
304+
// +operator-sdk:csv:customresourcedefinitions:resources={{Pod,v1}}
305+
306+
// Instrumentation is the spec for OpenTelemetry instrumentation.
307+
type Instrumentation struct {
308+
Status InstrumentationStatus `json:"status,omitempty"`
309+
metav1.TypeMeta `json:",inline"`
310+
Spec InstrumentationSpec `json:"spec,omitempty"`
311+
metav1.ObjectMeta `json:"metadata,omitempty"`
312+
}
313+
314+
// +kubebuilder:object:root=true
315+
316+
// InstrumentationList contains a list of Instrumentation.
317+
type InstrumentationList struct {
318+
metav1.TypeMeta `json:",inline"`
319+
metav1.ListMeta `json:"metadata,omitempty"`
320+
Items []Instrumentation `json:"items"`
321+
}
322+
323+
func init() {
324+
SchemeBuilder.Register(&Instrumentation{}, &InstrumentationList{})
325+
}

0 commit comments

Comments
 (0)