Skip to content

Commit c8ff19c

Browse files
committed
Bump operator-sdk for storage-operator to v1.38.0
1 parent 01499a9 commit c8ff19c

21 files changed

+248
-177
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
[1.17.1](https://github.com/cert-manager/cert-manager/releases/tag/v1.17.1)
4343
(PR[#4579](https://github.com/scality/metalk8s/pull/4579))
4444

45-
- Bump Operator-SDK used by `metalk8s-operator` to
45+
- Bump Operator-SDK used by `metalk8s-operator` and `storage-operator` to
4646
[1.38.0](https://github.com/operator-framework/operator-sdk/releases/tag/v1.38.0)
4747
The Go version has been bumped accordingly to
4848
[1.22](https://golang.org/doc/devel/release.html#go1.22.minor)

storage-operator/.golangci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ linters:
2121
enable:
2222
- dupl
2323
- errcheck
24-
- exportloopref
24+
- ginkgolinter
2525
- goconst
2626
- gocyclo
2727
- gofmt
@@ -33,8 +33,14 @@ linters:
3333
- misspell
3434
- nakedret
3535
- prealloc
36+
- revive
3637
- staticcheck
3738
- typecheck
3839
- unconvert
3940
- unparam
4041
- unused
42+
43+
linters-settings:
44+
revive:
45+
rules:
46+
- name: comment-spacings

storage-operator/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.21 as builder
2+
FROM golang:1.22 as builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

storage-operator/Makefile

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ OPERATOR_SDK_VERSION ?= v1.37.0
5353
# Image URL to use all building/pushing image targets
5454
IMG ?= controller:latest
5555
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
56-
ENVTEST_K8S_VERSION = 1.29.0
56+
ENVTEST_K8S_VERSION = 1.30.0
5757

5858
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
5959
ifeq (,$(shell go env GOBIN))
@@ -203,16 +203,16 @@ $(LOCALBIN):
203203

204204
## Tool Binaries
205205
KUBECTL ?= kubectl
206-
KUSTOMIZE ?= $(LOCALBIN)/kustomize-$(KUSTOMIZE_VERSION)
207-
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen-$(CONTROLLER_TOOLS_VERSION)
208-
ENVTEST ?= $(LOCALBIN)/setup-envtest-$(ENVTEST_VERSION)
209-
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
206+
KUSTOMIZE ?= $(LOCALBIN)/kustomize
207+
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
208+
ENVTEST ?= $(LOCALBIN)/setup-envtest
209+
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
210210

211211
## Tool Versions
212-
KUSTOMIZE_VERSION ?= v5.3.0
213-
CONTROLLER_TOOLS_VERSION ?= v0.14.0
214-
ENVTEST_VERSION ?= release-0.17
215-
GOLANGCI_LINT_VERSION ?= v1.57.2
212+
KUSTOMIZE_VERSION ?= v5.4.2
213+
CONTROLLER_TOOLS_VERSION ?= v0.15.0
214+
ENVTEST_VERSION ?= release-0.18
215+
GOLANGCI_LINT_VERSION ?= v1.59.1
216216

217217
.PHONY: kustomize
218218
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -239,13 +239,15 @@ $(GOLANGCI_LINT): $(LOCALBIN)
239239
# $2 - package url which can be installed
240240
# $3 - specific version of package
241241
define go-install-tool
242-
@[ -f $(1) ] || { \
242+
@[ -f "$(1)-$(3)" ] || { \
243243
set -e; \
244244
package=$(2)@$(3) ;\
245245
echo "Downloading $${package}" ;\
246+
rm -f $(1) || true ;\
246247
GOBIN=$(LOCALBIN) go install $${package} ;\
247-
mv "$$(echo "$(1)" | sed "s/-$(3)$$//")" $(1) ;\
248-
}
248+
mv $(1) $(1)-$(3) ;\
249+
} ;\
250+
ln -sf $(1)-$(3) $(1)
249251
endef
250252

251253
.PHONY: operator-sdk

storage-operator/cmd/main.go

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
ctrl "sigs.k8s.io/controller-runtime"
3232
"sigs.k8s.io/controller-runtime/pkg/healthz"
3333
"sigs.k8s.io/controller-runtime/pkg/log/zap"
34+
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
3435
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3536

3637
storagev1alpha1 "github.com/scality/metalk8s/storage-operator/api/v1alpha1"
@@ -56,13 +57,15 @@ func main() {
5657
var probeAddr string
5758
var secureMetrics bool
5859
var enableHTTP2 bool
59-
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
60+
var tlsOpts []func(*tls.Config)
61+
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
62+
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
6063
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
6164
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
6265
"Enable leader election for controller manager. "+
6366
"Enabling this will ensure there is only one active controller manager.")
64-
flag.BoolVar(&secureMetrics, "metrics-secure", false,
65-
"If set the metrics endpoint is served securely")
67+
flag.BoolVar(&secureMetrics, "metrics-secure", true,
68+
"If set the metrics endpoint is served securely via HTTPS. Use --metrics-secure=false to use HTTP instead.")
6669
flag.BoolVar(&enableHTTP2, "enable-http2", false,
6770
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
6871
opts := zap.Options{
@@ -84,18 +87,37 @@ func main() {
8487
c.NextProtos = []string{"http/1.1"}
8588
}
8689

87-
tlsOpts := []func(*tls.Config){}
8890
if !enableHTTP2 {
8991
tlsOpts = append(tlsOpts, disableHTTP2)
9092
}
9193

94+
// Metrics endpoint is enabled in 'config/default/kustomization.yaml'. The Metrics options configure the server.
95+
// More info:
96+
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.18.4/pkg/metrics/server
97+
// - https://book.kubebuilder.io/reference/metrics.html
98+
metricsServerOptions := metricsserver.Options{
99+
BindAddress: metricsAddr,
100+
SecureServing: secureMetrics,
101+
// TODO(user): TLSOpts is used to allow configuring the TLS config used for the server. If certificates are
102+
// not provided, self-signed certificates will be generated by default. This option is not recommended for
103+
// production environments as self-signed certificates do not offer the same level of trust and security
104+
// as certificates issued by a trusted Certificate Authority (CA). The primary risk is potentially allowing
105+
// unauthorized access to sensitive metrics data. Consider replacing with CertDir, CertName, and KeyName
106+
// to provide certificates, ensuring the server communicates using trusted and secure certificates.
107+
TLSOpts: tlsOpts,
108+
}
109+
110+
if secureMetrics {
111+
// FilterProvider is used to protect the metrics endpoint with authn/authz.
112+
// These configurations ensure that only authorized users and service accounts
113+
// can access the metrics endpoint. The RBAC are configured in 'config/rbac/kustomization.yaml'. More info:
114+
// https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.18.4/pkg/metrics/filters#WithAuthenticationAndAuthorization
115+
metricsServerOptions.FilterProvider = filters.WithAuthenticationAndAuthorization
116+
}
117+
92118
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
93-
Scheme: scheme,
94-
Metrics: metricsserver.Options{
95-
BindAddress: metricsAddr,
96-
SecureServing: secureMetrics,
97-
TLSOpts: tlsOpts,
98-
},
119+
Scheme: scheme,
120+
Metrics: metricsServerOptions,
99121
HealthProbeBindAddress: probeAddr,
100122
LeaderElection: enableLeaderElection,
101123
LeaderElectionID: "3d70a492.metalk8s.scality.com",

storage-operator/config/crd/bases/storage.metalk8s.scality.com_volumes.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.14.0
6+
controller-gen.kubebuilder.io/version: v0.15.0
77
name: volumes.storage.metalk8s.scality.com
88
spec:
99
group: storage.metalk8s.scality.com
@@ -122,6 +122,7 @@ spec:
122122
items:
123123
type: string
124124
type: array
125+
x-kubernetes-list-type: atomic
125126
awsElasticBlockStore:
126127
description: |-
127128
awsElasticBlockStore represents an AWS Disk resource that is attached to a
@@ -242,6 +243,7 @@ spec:
242243
items:
243244
type: string
244245
type: array
246+
x-kubernetes-list-type: atomic
245247
path:
246248
description: 'path is Optional: Used as the mounted root,
247249
rather than the full Ceph tree, default is /'
@@ -520,13 +522,15 @@ spec:
520522
items:
521523
type: string
522524
type: array
525+
x-kubernetes-list-type: atomic
523526
wwids:
524527
description: |-
525528
wwids Optional: FC volume world wide identifiers (wwids)
526529
Either wwids or combination of targetWWNs and lun must be set, but not both simultaneously.
527530
items:
528531
type: string
529532
type: array
533+
x-kubernetes-list-type: atomic
530534
type: object
531535
flexVolume:
532536
description: |-
@@ -729,6 +733,7 @@ spec:
729733
items:
730734
type: string
731735
type: array
736+
x-kubernetes-list-type: atomic
732737
readOnly:
733738
description: |-
734739
readOnly here will force the ReadOnly setting in VolumeMounts.
@@ -785,6 +790,7 @@ spec:
785790
items:
786791
type: string
787792
type: array
793+
x-kubernetes-list-type: atomic
788794
nfs:
789795
description: |-
790796
nfs represents an NFS mount on the host. Provisioned by an admin.
@@ -855,11 +861,13 @@ spec:
855861
items:
856862
type: string
857863
type: array
864+
x-kubernetes-list-type: atomic
858865
required:
859866
- key
860867
- operator
861868
type: object
862869
type: array
870+
x-kubernetes-list-type: atomic
863871
matchFields:
864872
description: A list of node selector requirements
865873
by node's fields.
@@ -887,14 +895,17 @@ spec:
887895
items:
888896
type: string
889897
type: array
898+
x-kubernetes-list-type: atomic
890899
required:
891900
- key
892901
- operator
893902
type: object
894903
type: array
904+
x-kubernetes-list-type: atomic
895905
type: object
896906
x-kubernetes-map-type: atomic
897907
type: array
908+
x-kubernetes-list-type: atomic
898909
required:
899910
- nodeSelectorTerms
900911
type: object
@@ -1015,6 +1026,7 @@ spec:
10151026
items:
10161027
type: string
10171028
type: array
1029+
x-kubernetes-list-type: atomic
10181030
pool:
10191031
description: |-
10201032
pool is the rados pool name.

storage-operator/config/default/kustomization.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ resources:
2525
#- ../certmanager
2626
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
2727
#- ../prometheus
28+
# [METRICS] Expose the controller manager metrics service.
29+
- metrics_service.yaml
2830

31+
# Uncomment the patches line if you enable Metrics, and/or are using webhooks and cert-manager
2932
patches:
30-
# Protect the /metrics endpoint by putting it behind auth.
31-
# If you want your controller-manager to expose the /metrics
32-
# endpoint w/o any authn/z, please comment the following line.
33-
- path: manager_auth_proxy_patch.yaml
33+
# [METRICS] The following patch will enable the metrics endpoint using HTTPS and the port :8443.
34+
# More info: https://book.kubebuilder.io/reference/metrics
35+
- path: manager_metrics_patch.yaml
36+
target:
37+
kind: Deployment
3438

3539
# Mount the controller config file for loading manager configurations
3640
# through a ComponentConfig type

storage-operator/config/default/manager_auth_proxy_patch.yaml

Lines changed: 0 additions & 39 deletions
This file was deleted.

storage-operator/config/default/manager_config_patch.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This patch adds the args to allow exposing the metrics endpoint using HTTPS
2+
- op: add
3+
path: /spec/template/spec/containers/0/args/0
4+
value: --metrics-bind-address=:8443

0 commit comments

Comments
 (0)