Skip to content

Commit e133eee

Browse files
authored
Enabling ipFamilies and ipFamilyPolicy (#3087)
* Added IpFamily and IpFamilyPolicy Signed-off-by: Yuri Sa <[email protected]> * Added IpFamily and IpFamilyPolicy Signed-off-by: Yuri Sa <[email protected]> * Fix e2e Signed-off-by: Yuri Sa <[email protected]> * Fix e2e Signed-off-by: Yuri Sa <[email protected]> * Removed headless when using IPv6 Signed-off-by: Yuri Sa <[email protected]> * Removing Kubebuilder marks Signed-off-by: Yuri Sa <[email protected]> * Enabling IPv6 in Kind Signed-off-by: Yuri Sa <[email protected]> * Enabling IPv6 in Kind Signed-off-by: Yuri Sa <[email protected]> * Enabling IPv6 in Kind Signed-off-by: Yuri Sa <[email protected]> * Enabling IPv6 in Kind Signed-off-by: Yuri Sa <[email protected]> * Enabling IPv6 in Kind Signed-off-by: Yuri Sa <[email protected]> * Fix Chainsaw Signed-off-by: Yuri Sa <[email protected]> * Fix Chainsaw Signed-off-by: Yuri Sa <[email protected]> --------- Signed-off-by: Yuri Sa <[email protected]>
1 parent 09d25e1 commit e133eee

32 files changed

+391
-6
lines changed

.chloggen/add-ip-families.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: 'enhancement'
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: 'collector'
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: "Enabling ipFamilies and ipFamilyPolicy to be configured via OpenTelemetryCollector"
9+
10+
# One or more tracking issues related to the change
11+
issues: [2958]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ operator-sdk: $(LOCALBIN)
496496
# Generate bundle manifests and metadata, then validate generated files.
497497
.PHONY: generate-bundle
498498
generate-bundle: kustomize operator-sdk manifests set-image-controller api-docs
499-
sed -i 's/minKubeVersion: .*/minKubeVersion: $(MIN_KUBERNETES_VERSION)/' config/manifests/$(BUNDLE_VARIANT)/bases/opentelemetry-operator.clusterserviceversion.yaml
499+
sed -e 's/minKubeVersion: .*/minKubeVersion: $(MIN_KUBERNETES_VERSION)/' config/manifests/$(BUNDLE_VARIANT)/bases/opentelemetry-operator.clusterserviceversion.yaml
500500

501501
$(OPERATOR_SDK) generate kustomize manifests -q --input-dir $(MANIFESTS_DIR) --output-dir $(MANIFESTS_DIR)
502502
cd $(BUNDLE_DIR) && cp ../../PROJECT . && $(KUSTOMIZE) build ../../$(MANIFESTS_DIR) | $(OPERATOR_SDK) generate bundle $(BUNDLE_BUILD_GEN_FLAGS) && rm PROJECT

apis/v1alpha1/opampbridge_types.go

+6
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ type OpAMPBridgeSpec struct {
107107
TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
108108
// PodDNSConfig defines the DNS parameters of a pod in addition to those generated from DNSPolicy.
109109
PodDNSConfig v1.PodDNSConfig `json:"podDnsConfig,omitempty"`
110+
// IPFamily represents the IP Family (IPv4 or IPv6). This type is used
111+
// to express the family of an IP expressed by a type (e.g. service.spec.ipFamilies).
112+
// +optional
113+
IpFamilies []v1.IPFamily `json:"ipFamilies,omitempty"`
114+
// IPFamilyPolicy represents the dual-stack-ness requested or required by a Service
115+
IpFamilyPolicy *v1.IPFamilyPolicy `json:"ipFamilyPolicy,omitempty"`
110116
}
111117

112118
// OpAMPBridgeStatus defines the observed state of OpAMPBridge.

apis/v1alpha1/zz_generated.deepcopy.go

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1beta1/common.go

+8
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,14 @@ type OpenTelemetryCommonFields struct {
226226
AdditionalContainers []v1.Container `json:"additionalContainers,omitempty"`
227227
// PodDNSConfig defines the DNS parameters of a pod in addition to those generated from DNSPolicy.
228228
PodDNSConfig v1.PodDNSConfig `json:"podDnsConfig,omitempty"`
229+
// IPFamily represents the IP Family (IPv4 or IPv6). This type is used
230+
// to express the family of an IP expressed by a type (e.g. service.spec.ipFamilies).
231+
// +optional
232+
IpFamilies []v1.IPFamily `json:"ipFamilies,omitempty"`
233+
// IPFamilyPolicy represents the dual-stack-ness requested or required by a Service
234+
// +kubebuilder:default:=SingleStack
235+
// +optional
236+
IpFamilyPolicy *v1.IPFamilyPolicy `json:"ipFamilyPolicy,omitempty"`
229237
}
230238

231239
type StatefulSetCommonFields struct {

apis/v1beta1/zz_generated.deepcopy.go

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/community/manifests/opentelemetry.io_opampbridges.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,12 @@ spec:
592592
type: string
593593
imagePullPolicy:
594594
type: string
595+
ipFamilies:
596+
items:
597+
type: string
598+
type: array
599+
ipFamilyPolicy:
600+
type: string
595601
nodeSelector:
596602
additionalProperties:
597603
type: string

bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -6739,6 +6739,13 @@ spec:
67396739
- name
67406740
type: object
67416741
type: array
6742+
ipFamilies:
6743+
items:
6744+
type: string
6745+
type: array
6746+
ipFamilyPolicy:
6747+
default: SingleStack
6748+
type: string
67426749
lifecycle:
67436750
properties:
67446751
postStart:

bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ metadata:
9999
categories: Logging & Tracing,Monitoring
100100
certified: "false"
101101
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
102-
createdAt: "2024-07-18T14:09:56Z"
102+
createdAt: "2024-07-20T18:51:11Z"
103103
description: Provides the OpenTelemetry components, including the Collector
104104
operators.operatorframework.io/builder: operator-sdk-v1.29.0
105105
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3

bundle/openshift/manifests/opentelemetry.io_opampbridges.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,12 @@ spec:
592592
type: string
593593
imagePullPolicy:
594594
type: string
595+
ipFamilies:
596+
items:
597+
type: string
598+
type: array
599+
ipFamilyPolicy:
600+
type: string
595601
nodeSelector:
596602
additionalProperties:
597603
type: string

bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -6739,6 +6739,13 @@ spec:
67396739
- name
67406740
type: object
67416741
type: array
6742+
ipFamilies:
6743+
items:
6744+
type: string
6745+
type: array
6746+
ipFamilyPolicy:
6747+
default: SingleStack
6748+
type: string
67426749
lifecycle:
67436750
properties:
67446751
postStart:

config/crd/bases/opentelemetry.io_opampbridges.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,12 @@ spec:
589589
type: string
590590
imagePullPolicy:
591591
type: string
592+
ipFamilies:
593+
items:
594+
type: string
595+
type: array
596+
ipFamilyPolicy:
597+
type: string
592598
nodeSelector:
593599
additionalProperties:
594600
type: string

config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -6725,6 +6725,13 @@ spec:
67256725
- name
67266726
type: object
67276727
type: array
6728+
ipFamilies:
6729+
items:
6730+
type: string
6731+
type: array
6732+
ipFamilyPolicy:
6733+
default: SingleStack
6734+
type: string
67286735
lifecycle:
67296736
properties:
67306737
postStart:

config/crd/bases/opentelemetry.io_targetallocators.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,13 @@ spec:
19291929
- name
19301930
type: object
19311931
type: array
1932+
ipFamilies:
1933+
items:
1934+
type: string
1935+
type: array
1936+
ipFamilyPolicy:
1937+
default: SingleStack
1938+
type: string
19321939
lifecycle:
19331940
properties:
19341941
postStart:

docs/api.md

+32
Original file line numberDiff line numberDiff line change
@@ -4183,6 +4183,21 @@ typically used to set access tokens or other authorization headers.<br/>
41834183
ImagePullPolicy indicates the pull policy to be used for retrieving the container image (Always, Never, IfNotPresent)<br/>
41844184
</td>
41854185
<td>false</td>
4186+
</tr><tr>
4187+
<td><b>ipFamilies</b></td>
4188+
<td>[]string</td>
4189+
<td>
4190+
IPFamily represents the IP Family (IPv4 or IPv6). This type is used
4191+
to express the family of an IP expressed by a type (e.g. service.spec.ipFamilies).<br/>
4192+
</td>
4193+
<td>false</td>
4194+
</tr><tr>
4195+
<td><b>ipFamilyPolicy</b></td>
4196+
<td>string</td>
4197+
<td>
4198+
IPFamilyPolicy represents the dual-stack-ness requested or required by a Service<br/>
4199+
</td>
4200+
<td>false</td>
41864201
</tr><tr>
41874202
<td><b>nodeSelector</b></td>
41884203
<td>map[string]string</td>
@@ -30936,6 +30951,23 @@ an initContainer will lead to a restart of the Pod. More info:
3093630951
https://kubernetes.io/docs/concepts/workloads/pods/init-containers/<br/>
3093730952
</td>
3093830953
<td>false</td>
30954+
</tr><tr>
30955+
<td><b>ipFamilies</b></td>
30956+
<td>[]string</td>
30957+
<td>
30958+
IPFamily represents the IP Family (IPv4 or IPv6). This type is used
30959+
to express the family of an IP expressed by a type (e.g. service.spec.ipFamilies).<br/>
30960+
</td>
30961+
<td>false</td>
30962+
</tr><tr>
30963+
<td><b>ipFamilyPolicy</b></td>
30964+
<td>string</td>
30965+
<td>
30966+
IPFamilyPolicy represents the dual-stack-ness requested or required by a Service<br/>
30967+
<br/>
30968+
<i>Default</i>: SingleStack<br/>
30969+
</td>
30970+
<td>false</td>
3093930971
</tr><tr>
3094030972
<td><b><a href="#opentelemetrycollectorspeclifecycle-1">lifecycle</a></b></td>
3094130973
<td>object</td>

internal/manifests/collector/service.go

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ func MonitoringService(params manifests.Params) (*corev1.Service, error) {
9797
Name: "monitoring",
9898
Port: metricsPort,
9999
}},
100+
IPFamilies: params.OtelCol.Spec.IpFamilies,
101+
IPFamilyPolicy: params.OtelCol.Spec.IpFamilyPolicy,
100102
},
101103
}, nil
102104
}
@@ -163,6 +165,8 @@ func Service(params manifests.Params) (*corev1.Service, error) {
163165
Selector: manifestutils.SelectorLabels(params.OtelCol.ObjectMeta, ComponentOpenTelemetryCollector),
164166
ClusterIP: "",
165167
Ports: ports,
168+
IPFamilies: params.OtelCol.Spec.IpFamilies,
169+
IPFamilyPolicy: params.OtelCol.Spec.IpFamilyPolicy,
166170
},
167171
}, nil
168172
}

internal/manifests/collector/service_test.go

+40
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,43 @@ func serviceWithInternalTrafficPolicy(name string, ports []v1beta1.PortsSpec, in
351351
},
352352
}
353353
}
354+
355+
func TestServiceWithIpFamily(t *testing.T) {
356+
t.Run("should return IPFamilies for IPV4 and IPV6", func(t *testing.T) {
357+
params := deploymentParams()
358+
params.OtelCol.Spec.IpFamilies = []v1.IPFamily{
359+
"IPv4",
360+
"IPv6",
361+
}
362+
actual, err := Service(params)
363+
assert.NoError(t, err)
364+
assert.Equal(t, actual.Spec.IPFamilies, []v1.IPFamily{
365+
"IPv4",
366+
"IPv6",
367+
})
368+
})
369+
t.Run("should return IPPolicy SingleStack", func(t *testing.T) {
370+
params := deploymentParams()
371+
baseIpFamily := v1.IPFamilyPolicySingleStack
372+
params.OtelCol.Spec.IpFamilyPolicy = &baseIpFamily
373+
actual, err := Service(params)
374+
assert.NoError(t, err)
375+
assert.Equal(t, actual.Spec.IPFamilyPolicy, params.OtelCol.Spec.IpFamilyPolicy)
376+
})
377+
t.Run("should return IPPolicy PreferDualStack", func(t *testing.T) {
378+
params := deploymentParams()
379+
baseIpFamily := v1.IPFamilyPolicyPreferDualStack
380+
params.OtelCol.Spec.IpFamilyPolicy = &baseIpFamily
381+
actual, err := Service(params)
382+
assert.NoError(t, err)
383+
assert.Equal(t, actual.Spec.IPFamilyPolicy, params.OtelCol.Spec.IpFamilyPolicy)
384+
})
385+
t.Run("should return IPPolicy RequireDualStack ", func(t *testing.T) {
386+
params := deploymentParams()
387+
baseIpFamily := v1.IPFamilyPolicyRequireDualStack
388+
params.OtelCol.Spec.IpFamilyPolicy = &baseIpFamily
389+
actual, err := Service(params)
390+
assert.NoError(t, err)
391+
assert.Equal(t, actual.Spec.IPFamilyPolicy, params.OtelCol.Spec.IpFamilyPolicy)
392+
})
393+
}

internal/manifests/opampbridge/service.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ func Service(params manifests.Params) *corev1.Service {
4444
Labels: labels,
4545
},
4646
Spec: corev1.ServiceSpec{
47-
Selector: selector,
48-
Ports: ports,
47+
Selector: selector,
48+
Ports: ports,
49+
IPFamilies: params.OpAMPBridge.Spec.IpFamilies,
50+
IPFamilyPolicy: params.OpAMPBridge.Spec.IpFamilyPolicy,
4951
},
5052
}
5153
}

internal/manifests/targetallocator/service.go

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ func Service(params Params) *corev1.Service {
4141
Port: 80,
4242
TargetPort: intstr.FromString("http"),
4343
}},
44+
IPFamilies: params.TargetAllocator.Spec.IpFamilies,
45+
IPFamilyPolicy: params.TargetAllocator.Spec.IpFamilyPolicy,
4446
},
4547
}
4648
}

kind-1.23.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
kind: Cluster
22
apiVersion: kind.x-k8s.io/v1alpha4
3+
networking:
4+
ipFamily: dual
35
nodes:
46
- role: control-plane
57
image: kindest/node:v1.23.17@sha256:14d0a9a892b943866d7e6be119a06871291c517d279aedb816a4b4bc0ec0a5b3
@@ -15,4 +17,4 @@ nodes:
1517
protocol: TCP
1618
- containerPort: 443
1719
hostPort: 443
18-
protocol: TCP
20+
protocol: TCP

kind-1.24.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
kind: Cluster
22
apiVersion: kind.x-k8s.io/v1alpha4
3+
networking:
4+
ipFamily: dual
35
nodes:
46
- role: control-plane
57
image: kindest/node:v1.24.15@sha256:7db4f8bea3e14b82d12e044e25e34bd53754b7f2b0e9d56df21774e6f66a70ab

kind-1.25.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
kind: Cluster
22
apiVersion: kind.x-k8s.io/v1alpha4
3+
networking:
4+
ipFamily: dual
35
nodes:
46
- role: control-plane
57
image: kindest/node:v1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8

kind-1.26.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
kind: Cluster
22
apiVersion: kind.x-k8s.io/v1alpha4
3+
networking:
4+
ipFamily: dual
35
nodes:
46
- role: control-plane
57
image: kindest/node:v1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb

kind-1.27.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
kind: Cluster
22
apiVersion: kind.x-k8s.io/v1alpha4
3+
networking:
4+
ipFamily: dual
35
nodes:
46
- role: control-plane
57
image: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72

kind-1.28.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
kind: Cluster
22
apiVersion: kind.x-k8s.io/v1alpha4
3+
networking:
4+
ipFamily: dual
35
nodes:
46
- role: control-plane
57
image: kindest/node:v1.28.0@sha256:b7a4cad12c197af3ba43202d3efe03246b3f0793f162afb40a33c923952d5b31

kind-1.29.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
kind: Cluster
22
apiVersion: kind.x-k8s.io/v1alpha4
3+
networking:
4+
ipFamily: dual
35
nodes:
46
- role: control-plane
57
image: kindest/node:v1.29.0@sha256:eaa1450915475849a73a9227b8f201df25e55e268e5d619312131292e324d570

kind-1.30.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
kind: Cluster
22
apiVersion: kind.x-k8s.io/v1alpha4
3+
networking:
4+
ipFamily: dual
35
nodes:
46
- role: control-plane
5-
image: kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e
7+
image: kindest/node:v1.30.2@sha256:ecfe5841b9bee4fe9690f49c118c33629fa345e3350a0c67a5a34482a99d6bba
68
kubeadmConfigPatches:
79
- |
810
kind: InitConfiguration

0 commit comments

Comments
 (0)