Skip to content

Commit

Permalink
Update controller-gen, improve kind deployment (netobserv#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
jotak authored Apr 5, 2024
1 parent 734a9ee commit dcaf464
Show file tree
Hide file tree
Showing 11 changed files with 2,619 additions and 1,532 deletions.
3 changes: 2 additions & 1 deletion .mk/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ local-deploy-operator:
@echo "====> Done"

.PHONY: deploy-kind
deploy-kind: generate kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
deploy-kind: install-cert-manager kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
kubectl create namespace netobserv || true
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMAGE}
$(SED) -i -r 's~ebpf-agent:.+~ebpf-agent:main~' ./config/manager/manager.yaml
$(SED) -i -r 's~flowlogs-pipeline:.+~flowlogs-pipeline:main~' ./config/manager/manager.yaml
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ BUNDLE_CONFIG ?= config/openshift-olm
# Image URL to use all building/pushing image targets
IMAGE ?= $(IMAGE_TAG_BASE):$(VERSION)
OCI_BUILD_OPTS ?=
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.23
GOLANGCI_LINT_VERSION = v1.53.3
Expand Down Expand Up @@ -199,7 +197,7 @@ $(CONVERSION_GEN): ## Build conversion-gen from tools folder.

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.1)
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0)

KUSTOMIZE = $(shell pwd)/bin/kustomize
kustomize: ## Download kustomize locally if necessary.
Expand Down Expand Up @@ -257,7 +255,7 @@ endif

##@ Code / files generation
manifests: YQ controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(YQ) -i 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.processor.properties.kafkaConsumerAutoscaler.properties.metrics.items | .. | select(has("description")) | .description)' config/crd/bases/flows.netobserv.io_flowcollectors.yaml
$(YQ) -i 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.consolePlugin.properties.autoscaler.properties.metrics.items | .. | select(has("description")) | .description)' config/crd/bases/flows.netobserv.io_flowcollectors.yaml
$(YQ) -i 'del(.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.agent.properties.ebpf.properties.advanced.properties.affinity.properties | .. | select(has("description")) | .description)' config/crd/bases/flows.netobserv.io_flowcollectors.yaml
Expand Down
1 change: 0 additions & 1 deletion apis/flowcollector/v1beta1/zz_generated.deepcopy.go

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

1 change: 0 additions & 1 deletion apis/flowcollector/v1beta2/zz_generated.deepcopy.go

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

1 change: 0 additions & 1 deletion apis/flowmetrics/v1alpha1/zz_generated.deepcopy.go

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

1,886 changes: 909 additions & 977 deletions bundle/manifests/flows.netobserv.io_flowcollectors.yaml

Large diffs are not rendered by default.

91 changes: 46 additions & 45 deletions bundle/manifests/flows.netobserv.io_flowmetrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.6.1
controller-gen.kubebuilder.io/version: v0.14.0
creationTimestamp: null
name: flowmetrics.flows.netobserv.io
spec:
Expand All @@ -20,25 +20,29 @@ spec:
description: FlowMetric is the Schema for the flowmetrics API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: 'FlowMetricSpec defines the desired state of FlowMetric The
provided API allows you to customize these metrics according to your
needs.<br> When adding new metrics or modifying existing labels, you
must carefully monitor the memory usage of Prometheus workloads as this
could potentially have a high impact. Cf https://rhobs-handbook.netlify.app/products/openshiftmonitoring/telemetry.md/#what-is-the-cardinality-of-a-metric<br>
To check the cardinality of all NetObserv metrics, run as `promql`:
`count({__name__=~"netobserv.*"}) by (__name__)`.'
description: |-
FlowMetricSpec defines the desired state of FlowMetric
The provided API allows you to customize these metrics according to your needs.<br>
When adding new metrics or modifying existing labels, you must carefully monitor the memory
usage of Prometheus workloads as this could potentially have a high impact. Cf https://rhobs-handbook.netlify.app/products/openshiftmonitoring/telemetry.md/#what-is-the-cardinality-of-a-metric<br>
To check the cardinality of all NetObserv metrics, run as `promql`: `count({__name__=~"netobserv.*"}) by (__name__)`.
properties:
buckets:
description: A list of buckets to use when `type` is "Histogram".
Expand All @@ -49,21 +53,20 @@ spec:
type: array
direction:
default: Any
description: 'Filter for ingress, egress or any direction flows. When
set to `Ingress`, it is equivalent to adding the regex filter on
`FlowDirection`: `0|2`. When set to `Egress`, it is equivalent to
adding the regex filter on `FlowDirection`: `1|2`.'
description: |-
Filter for ingress, egress or any direction flows.
When set to `Ingress`, it is equivalent to adding the regex filter on `FlowDirection`: `0|2`.
When set to `Egress`, it is equivalent to adding the regex filter on `FlowDirection`: `1|2`.
enum:
- Any
- Egress
- Ingress
type: string
filters:
description: '`filters` is a list of fields and values used to restrict
which flows are taken into account. Oftentimes, these filters must
be used to eliminate duplicates: `Duplicate != "true"` and `FlowDirection
= "0"`. Refer to the documentation for the list of available fields:
https://docs.openshift.com/container-platform/latest/networking/network_observability/json-flows-format-reference.html.'
description: |-
`filters` is a list of fields and values used to restrict which flows are taken into account. Oftentimes, these filters must
be used to eliminate duplicates: `Duplicate != "true"` and `FlowDirection = "0"`.
Refer to the documentation for the list of available fields: https://docs.openshift.com/container-platform/latest/networking/network_observability/json-flows-format-reference.html.
items:
properties:
field:
Expand All @@ -89,20 +92,18 @@ spec:
type: object
type: array
includeDuplicates:
description: When set to `true`, flows duplicated across several interfaces
will add up in the generated metrics. When set to `false` (default),
it is equivalent to adding the exact filter on `Duplicate` != `true`.
description: |-
When set to `true`, flows duplicated across several interfaces will add up in the generated metrics.
When set to `false` (default), it is equivalent to adding the exact filter on `Duplicate` != `true`.
type: boolean
labels:
description: '`labels` is a list of fields that should be used as
Prometheus labels, also known as dimensions. From choosing labels
results the level of granularity of this metric, as well as the
available aggregations at query time. It must be done carefully
as it impacts the metric cardinality (cf https://rhobs-handbook.netlify.app/products/openshiftmonitoring/telemetry.md/#what-is-the-cardinality-of-a-metric).
In general, avoid setting very high cardinality labels such as IP
or MAC addresses. "SrcK8S_OwnerName" or "DstK8S_OwnerName" should
be preferred over "SrcK8S_Name" or "DstK8S_Name" as much as possible.
Refer to the documentation for the list of available fields: https://docs.openshift.com/container-platform/latest/network_observability/json-flows-format-reference.html.'
description: |-
`labels` is a list of fields that should be used as Prometheus labels, also known as dimensions.
From choosing labels results the level of granularity of this metric, as well as the available aggregations at query time.
It must be done carefully as it impacts the metric cardinality (cf https://rhobs-handbook.netlify.app/products/openshiftmonitoring/telemetry.md/#what-is-the-cardinality-of-a-metric).
In general, avoid setting very high cardinality labels such as IP or MAC addresses.
"SrcK8S_OwnerName" or "DstK8S_OwnerName" should be preferred over "SrcK8S_Name" or "DstK8S_Name" as much as possible.
Refer to the documentation for the list of available fields: https://docs.openshift.com/container-platform/latest/network_observability/json-flows-format-reference.html.
items:
type: string
type: array
Expand All @@ -111,19 +112,19 @@ spec:
prefixed with "netobserv_".
type: string
type:
description: 'Metric type: "Counter" or "Histogram". Use "Counter"
for any value that increases over time and on which you can compute
a rate, such as Bytes or Packets. Use "Histogram" for any value
that must be sampled independently, such as latencies.'
description: |-
Metric type: "Counter" or "Histogram".
Use "Counter" for any value that increases over time and on which you can compute a rate, such as Bytes or Packets.
Use "Histogram" for any value that must be sampled independently, such as latencies.
enum:
- Counter
- Histogram
type: string
valueField:
description: '`valueField` is the flow field that must be used as
a value for this metric. This field must hold numeric values. Leave
empty to count flows rather than a specific value per flow. Refer
to the documentation for the list of available fields: https://docs.openshift.com/container-platform/latest/networking/network_observability/json-flows-format-reference.html.'
description: |-
`valueField` is the flow field that must be used as a value for this metric. This field must hold numeric values.
Leave empty to count flows rather than a specific value per flow.
Refer to the documentation for the list of available fields: https://docs.openshift.com/container-platform/latest/networking/network_observability/json-flows-format-reference.html.
type: string
required:
- metricName
Expand All @@ -141,5 +142,5 @@ status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
conditions: null
storedVersions: null
Loading

0 comments on commit dcaf464

Please sign in to comment.