Skip to content

Commit

Permalink
Enabling ipFamilies and ipFamilyPolicy (#3087)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
yuriolisa committed Jul 23, 2024
1 parent 09d25e1 commit e133eee
Show file tree
Hide file tree
Showing 32 changed files with 391 additions and 6 deletions.
16 changes: 16 additions & 0 deletions .chloggen/add-ip-families.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'enhancement'

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: 'collector'

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Enabling ipFamilies and ipFamilyPolicy to be configured via OpenTelemetryCollector"

# One or more tracking issues related to the change
issues: [2958]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ operator-sdk: $(LOCALBIN)
# Generate bundle manifests and metadata, then validate generated files.
.PHONY: generate-bundle
generate-bundle: kustomize operator-sdk manifests set-image-controller api-docs
sed -i 's/minKubeVersion: .*/minKubeVersion: $(MIN_KUBERNETES_VERSION)/' config/manifests/$(BUNDLE_VARIANT)/bases/opentelemetry-operator.clusterserviceversion.yaml
sed -e 's/minKubeVersion: .*/minKubeVersion: $(MIN_KUBERNETES_VERSION)/' config/manifests/$(BUNDLE_VARIANT)/bases/opentelemetry-operator.clusterserviceversion.yaml

$(OPERATOR_SDK) generate kustomize manifests -q --input-dir $(MANIFESTS_DIR) --output-dir $(MANIFESTS_DIR)
cd $(BUNDLE_DIR) && cp ../../PROJECT . && $(KUSTOMIZE) build ../../$(MANIFESTS_DIR) | $(OPERATOR_SDK) generate bundle $(BUNDLE_BUILD_GEN_FLAGS) && rm PROJECT
Expand Down
6 changes: 6 additions & 0 deletions apis/v1alpha1/opampbridge_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ type OpAMPBridgeSpec struct {
TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
// PodDNSConfig defines the DNS parameters of a pod in addition to those generated from DNSPolicy.
PodDNSConfig v1.PodDNSConfig `json:"podDnsConfig,omitempty"`
// IPFamily represents the IP Family (IPv4 or IPv6). This type is used
// to express the family of an IP expressed by a type (e.g. service.spec.ipFamilies).
// +optional
IpFamilies []v1.IPFamily `json:"ipFamilies,omitempty"`
// IPFamilyPolicy represents the dual-stack-ness requested or required by a Service
IpFamilyPolicy *v1.IPFamilyPolicy `json:"ipFamilyPolicy,omitempty"`
}

// OpAMPBridgeStatus defines the observed state of OpAMPBridge.
Expand Down
10 changes: 10 additions & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions apis/v1beta1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ type OpenTelemetryCommonFields struct {
AdditionalContainers []v1.Container `json:"additionalContainers,omitempty"`
// PodDNSConfig defines the DNS parameters of a pod in addition to those generated from DNSPolicy.
PodDNSConfig v1.PodDNSConfig `json:"podDnsConfig,omitempty"`
// IPFamily represents the IP Family (IPv4 or IPv6). This type is used
// to express the family of an IP expressed by a type (e.g. service.spec.ipFamilies).
// +optional
IpFamilies []v1.IPFamily `json:"ipFamilies,omitempty"`
// IPFamilyPolicy represents the dual-stack-ness requested or required by a Service
// +kubebuilder:default:=SingleStack
// +optional
IpFamilyPolicy *v1.IPFamilyPolicy `json:"ipFamilyPolicy,omitempty"`
}

type StatefulSetCommonFields struct {
Expand Down
10 changes: 10 additions & 0 deletions apis/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions bundle/community/manifests/opentelemetry.io_opampbridges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,12 @@ spec:
type: string
imagePullPolicy:
type: string
ipFamilies:
items:
type: string
type: array
ipFamilyPolicy:
type: string
nodeSelector:
additionalProperties:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6739,6 +6739,13 @@ spec:
- name
type: object
type: array
ipFamilies:
items:
type: string
type: array
ipFamilyPolicy:
default: SingleStack
type: string
lifecycle:
properties:
postStart:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ metadata:
categories: Logging & Tracing,Monitoring
certified: "false"
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
createdAt: "2024-07-18T14:09:56Z"
createdAt: "2024-07-20T18:51:11Z"
description: Provides the OpenTelemetry components, including the Collector
operators.operatorframework.io/builder: operator-sdk-v1.29.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand Down
6 changes: 6 additions & 0 deletions bundle/openshift/manifests/opentelemetry.io_opampbridges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,12 @@ spec:
type: string
imagePullPolicy:
type: string
ipFamilies:
items:
type: string
type: array
ipFamilyPolicy:
type: string
nodeSelector:
additionalProperties:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6739,6 +6739,13 @@ spec:
- name
type: object
type: array
ipFamilies:
items:
type: string
type: array
ipFamilyPolicy:
default: SingleStack
type: string
lifecycle:
properties:
postStart:
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/opentelemetry.io_opampbridges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,12 @@ spec:
type: string
imagePullPolicy:
type: string
ipFamilies:
items:
type: string
type: array
ipFamilyPolicy:
type: string
nodeSelector:
additionalProperties:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6725,6 +6725,13 @@ spec:
- name
type: object
type: array
ipFamilies:
items:
type: string
type: array
ipFamilyPolicy:
default: SingleStack
type: string
lifecycle:
properties:
postStart:
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/opentelemetry.io_targetallocators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,13 @@ spec:
- name
type: object
type: array
ipFamilies:
items:
type: string
type: array
ipFamilyPolicy:
default: SingleStack
type: string
lifecycle:
properties:
postStart:
Expand Down
32 changes: 32 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4183,6 +4183,21 @@ typically used to set access tokens or other authorization headers.<br/>
ImagePullPolicy indicates the pull policy to be used for retrieving the container image (Always, Never, IfNotPresent)<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>ipFamilies</b></td>
<td>[]string</td>
<td>
IPFamily represents the IP Family (IPv4 or IPv6). This type is used
to express the family of an IP expressed by a type (e.g. service.spec.ipFamilies).<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>ipFamilyPolicy</b></td>
<td>string</td>
<td>
IPFamilyPolicy represents the dual-stack-ness requested or required by a Service<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>nodeSelector</b></td>
<td>map[string]string</td>
Expand Down Expand Up @@ -30936,6 +30951,23 @@ an initContainer will lead to a restart of the Pod. More info:
https://kubernetes.io/docs/concepts/workloads/pods/init-containers/<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>ipFamilies</b></td>
<td>[]string</td>
<td>
IPFamily represents the IP Family (IPv4 or IPv6). This type is used
to express the family of an IP expressed by a type (e.g. service.spec.ipFamilies).<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>ipFamilyPolicy</b></td>
<td>string</td>
<td>
IPFamilyPolicy represents the dual-stack-ness requested or required by a Service<br/>
<br/>
<i>Default</i>: SingleStack<br/>
</td>
<td>false</td>
</tr><tr>
<td><b><a href="#opentelemetrycollectorspeclifecycle-1">lifecycle</a></b></td>
<td>object</td>
Expand Down
4 changes: 4 additions & 0 deletions internal/manifests/collector/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ func MonitoringService(params manifests.Params) (*corev1.Service, error) {
Name: "monitoring",
Port: metricsPort,
}},
IPFamilies: params.OtelCol.Spec.IpFamilies,
IPFamilyPolicy: params.OtelCol.Spec.IpFamilyPolicy,
},
}, nil
}
Expand Down Expand Up @@ -163,6 +165,8 @@ func Service(params manifests.Params) (*corev1.Service, error) {
Selector: manifestutils.SelectorLabels(params.OtelCol.ObjectMeta, ComponentOpenTelemetryCollector),
ClusterIP: "",
Ports: ports,
IPFamilies: params.OtelCol.Spec.IpFamilies,
IPFamilyPolicy: params.OtelCol.Spec.IpFamilyPolicy,
},
}, nil
}
Expand Down
40 changes: 40 additions & 0 deletions internal/manifests/collector/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,43 @@ func serviceWithInternalTrafficPolicy(name string, ports []v1beta1.PortsSpec, in
},
}
}

func TestServiceWithIpFamily(t *testing.T) {
t.Run("should return IPFamilies for IPV4 and IPV6", func(t *testing.T) {
params := deploymentParams()
params.OtelCol.Spec.IpFamilies = []v1.IPFamily{
"IPv4",
"IPv6",
}
actual, err := Service(params)
assert.NoError(t, err)
assert.Equal(t, actual.Spec.IPFamilies, []v1.IPFamily{
"IPv4",
"IPv6",
})
})
t.Run("should return IPPolicy SingleStack", func(t *testing.T) {
params := deploymentParams()
baseIpFamily := v1.IPFamilyPolicySingleStack
params.OtelCol.Spec.IpFamilyPolicy = &baseIpFamily
actual, err := Service(params)
assert.NoError(t, err)
assert.Equal(t, actual.Spec.IPFamilyPolicy, params.OtelCol.Spec.IpFamilyPolicy)
})
t.Run("should return IPPolicy PreferDualStack", func(t *testing.T) {
params := deploymentParams()
baseIpFamily := v1.IPFamilyPolicyPreferDualStack
params.OtelCol.Spec.IpFamilyPolicy = &baseIpFamily
actual, err := Service(params)
assert.NoError(t, err)
assert.Equal(t, actual.Spec.IPFamilyPolicy, params.OtelCol.Spec.IpFamilyPolicy)
})
t.Run("should return IPPolicy RequireDualStack ", func(t *testing.T) {
params := deploymentParams()
baseIpFamily := v1.IPFamilyPolicyRequireDualStack
params.OtelCol.Spec.IpFamilyPolicy = &baseIpFamily
actual, err := Service(params)
assert.NoError(t, err)
assert.Equal(t, actual.Spec.IPFamilyPolicy, params.OtelCol.Spec.IpFamilyPolicy)
})
}
6 changes: 4 additions & 2 deletions internal/manifests/opampbridge/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ func Service(params manifests.Params) *corev1.Service {
Labels: labels,
},
Spec: corev1.ServiceSpec{
Selector: selector,
Ports: ports,
Selector: selector,
Ports: ports,
IPFamilies: params.OpAMPBridge.Spec.IpFamilies,
IPFamilyPolicy: params.OpAMPBridge.Spec.IpFamilyPolicy,
},
}
}
2 changes: 2 additions & 0 deletions internal/manifests/targetallocator/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ func Service(params Params) *corev1.Service {
Port: 80,
TargetPort: intstr.FromString("http"),
}},
IPFamilies: params.TargetAllocator.Spec.IpFamilies,
IPFamilyPolicy: params.TargetAllocator.Spec.IpFamilyPolicy,
},
}
}
4 changes: 3 additions & 1 deletion kind-1.23.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
ipFamily: dual
nodes:
- role: control-plane
image: kindest/node:v1.23.17@sha256:14d0a9a892b943866d7e6be119a06871291c517d279aedb816a4b4bc0ec0a5b3
Expand All @@ -15,4 +17,4 @@ nodes:
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
protocol: TCP
2 changes: 2 additions & 0 deletions kind-1.24.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
ipFamily: dual
nodes:
- role: control-plane
image: kindest/node:v1.24.15@sha256:7db4f8bea3e14b82d12e044e25e34bd53754b7f2b0e9d56df21774e6f66a70ab
Expand Down
2 changes: 2 additions & 0 deletions kind-1.25.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
ipFamily: dual
nodes:
- role: control-plane
image: kindest/node:v1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8
Expand Down
2 changes: 2 additions & 0 deletions kind-1.26.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
ipFamily: dual
nodes:
- role: control-plane
image: kindest/node:v1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb
Expand Down
2 changes: 2 additions & 0 deletions kind-1.27.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
ipFamily: dual
nodes:
- role: control-plane
image: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
Expand Down
2 changes: 2 additions & 0 deletions kind-1.28.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
ipFamily: dual
nodes:
- role: control-plane
image: kindest/node:v1.28.0@sha256:b7a4cad12c197af3ba43202d3efe03246b3f0793f162afb40a33c923952d5b31
Expand Down
2 changes: 2 additions & 0 deletions kind-1.29.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
ipFamily: dual
nodes:
- role: control-plane
image: kindest/node:v1.29.0@sha256:eaa1450915475849a73a9227b8f201df25e55e268e5d619312131292e324d570
Expand Down
4 changes: 3 additions & 1 deletion kind-1.30.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
ipFamily: dual
nodes:
- role: control-plane
image: kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e
image: kindest/node:v1.30.2@sha256:ecfe5841b9bee4fe9690f49c118c33629fa345e3350a0c67a5a34482a99d6bba
kubeadmConfigPatches:
- |
kind: InitConfiguration
Expand Down
Loading

0 comments on commit e133eee

Please sign in to comment.