Skip to content

Commit e9b2e9c

Browse files
kubebuilder v4 + dependencies upgrade (#978)
1 parent 5cef723 commit e9b2e9c

File tree

168 files changed

+13590
-9541
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+13590
-9541
lines changed

Dockerfile.build

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.15 as builder
2+
FROM golang:1.22 as builder
33

44
WORKDIR /workspace
55
# Copy the Go Modules manifests
@@ -10,12 +10,11 @@ COPY go.sum go.sum
1010
RUN go mod download
1111

1212
# Copy the go source
13-
COPY main.go main.go
13+
COPY cmd/main.go cmd/main.go
1414
COPY api/ api/
15-
COPY controllers/ controllers/
1615
COPY internal/ internal/
1716
# Build
18-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -trimpath -a -o manager main.go
17+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -trimpath -a -o manager cmd/main.go
1918

2019
# Use distroless as minimal base image to package the manager binary
2120
# Refer to https://github.com/GoogleContainerTools/distroless for more details

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ e2e-local: fmt vet manifests patch_crds
266266
$(GOCMD) tool cover -func coverage.txt | grep total
267267

268268
lint:
269-
golangci-lint run --exclude '(SA1019):' -E typecheck -E gosimple -E gocritic --timeout 5m ./controllers/... ./internal/...
270-
golint ./controllers/...
269+
golangci-lint run --exclude '(SA1019):' -E typecheck -E gosimple -E gocritic --timeout 5m ./internal/...
270+
golint ./internal/controller/...
271271

272272
.PHONY:clean
273273
clean:
@@ -280,12 +280,12 @@ all: build
280280
# Run tests
281281
test: manifests generate fmt vet patch_crds
282282
echo 'mode: atomic' > coverage.txt && \
283-
$(TEST_ARGS) $(REPO)/controllers/... $(REPO)/api/...
283+
$(TEST_ARGS) $(REPO)/internal/controller/... $(REPO)/api/...
284284
$(GOCMD) tool cover -func coverage.txt | grep total
285285

286286
# Build manager binary
287287
manager: fmt vet
288-
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} $(GOBUILD) -o bin/manager main.go
288+
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} $(GOBUILD) -o bin/manager cmd/main.go
289289

290290
# Run against the configured Kubernetes cluster in ~/.kube/config
291291
run: manager
@@ -344,7 +344,7 @@ ifeq (, $(shell which kustomize))
344344
KUSTOMIZE_GEN_TMP_DIR=$$(mktemp -d) ;\
345345
cd $$KUSTOMIZE_GEN_TMP_DIR ;\
346346
go mod init tmp ;\
347-
go install sigs.k8s.io/kustomize/kustomize/[email protected] ;\
347+
go install sigs.k8s.io/kustomize/kustomize/[email protected] ;\
348348
rm -rf $$KUSTOMIZE_GEN_TMP_DIR ;\
349349
}
350350
KUSTOMIZE=$(GOBIN)/kustomize
@@ -397,7 +397,7 @@ docker-build-arch:
397397
.
398398

399399
package-arch:
400-
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} $(GOBUILD) -o bin/manager-$(GOARCH) main.go
400+
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} $(GOBUILD) -o bin/manager-$(GOARCH) cmd/main.go
401401

402402

403403
build-operator-crosscompile: fmt vet

PROJECT

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,137 @@
1+
# Code generated by tool. DO NOT EDIT.
2+
# This file is used to track the info used to scaffold your project
3+
# and allow the plugins properly work.
4+
# More info: https://book.kubebuilder.io/reference/project-config.html
15
domain: victoriametrics.com
2-
layout: go.kubebuilder.io/v2
6+
layout:
7+
- go.kubebuilder.io/v4
38
projectName: victoriametrics-operator
49
repo: github.com/VictoriaMetrics/operator
510
resources:
6-
-
11+
- api:
12+
crdVersion: v1
13+
namespaced: true
714
controller: true
815
domain: victoriametrics.com
916
group: operator
1017
kind: VMAgent
1118
path: github.com/VictoriaMetrics/operator/api/v1beta1
1219
version: v1beta1
13-
-
20+
- api:
21+
crdVersion: v1
22+
namespaced: true
1423
controller: true
1524
domain: victoriametrics.com
1625
group: operator
1726
kind: VMAlert
1827
path: github.com/VictoriaMetrics/operator/api/v1beta1
1928
version: v1beta1
20-
-
29+
- api:
30+
crdVersion: v1
31+
namespaced: true
2132
controller: true
2233
domain: victoriametrics.com
2334
group: operator
2435
kind: VMAlertmanager
2536
path: github.com/VictoriaMetrics/operator/api/v1beta1
2637
version: v1beta1
27-
-
38+
- api:
39+
crdVersion: v1
40+
namespaced: true
2841
controller: true
2942
domain: victoriametrics.com
3043
group: operator
3144
kind: VMAlertmanagerConfig
3245
path: github.com/VictoriaMetrics/operator/api/v1beta1
3346
version: v1beta1
34-
-
47+
- api:
48+
crdVersion: v1
49+
namespaced: true
3550
controller: true
3651
domain: victoriametrics.com
3752
group: operator
3853
kind: VMPodScrape
3954
path: github.com/VictoriaMetrics/operator/api/v1beta1
4055
version: v1beta1
41-
-
56+
- api:
57+
crdVersion: v1
58+
namespaced: true
4259
controller: true
4360
domain: victoriametrics.com
4461
group: operator
4562
kind: VMRule
4663
path: github.com/VictoriaMetrics/operator/api/v1beta1
4764
version: v1beta1
48-
-
65+
- api:
66+
crdVersion: v1
67+
namespaced: true
4968
controller: true
5069
domain: victoriametrics.com
5170
group: operator
5271
kind: VMServiceScrape
5372
path: github.com/VictoriaMetrics/operator/api/v1beta1
5473
version: v1beta1
55-
-
74+
- api:
75+
crdVersion: v1
76+
namespaced: true
5677
controller: true
5778
domain: victoriametrics.com
5879
group: operator
5980
kind: VMSingle
6081
path: github.com/VictoriaMetrics/operator/api/v1beta1
6182
version: v1beta1
62-
-
83+
- api:
84+
crdVersion: v1
85+
namespaced: true
6386
controller: true
6487
domain: victoriametrics.com
6588
group: operator
6689
kind: VMCluster
6790
path: github.com/VictoriaMetrics/operator/api/v1beta1
6891
version: v1beta1
69-
-
92+
- api:
93+
crdVersion: v1
94+
namespaced: true
7095
controller: true
7196
domain: victoriametrics.com
7297
group: operator
7398
kind: VMProbe
7499
path: github.com/VictoriaMetrics/operator/api/v1beta1
75100
version: v1beta1
76-
-
101+
- api:
102+
crdVersion: v1
103+
namespaced: true
77104
controller: true
78105
domain: victoriametrics.com
79106
group: operator
80107
kind: VMNodeScrape
81108
path: github.com/VictoriaMetrics/operator/api/v1beta1
82109
version: v1beta1
83-
-
110+
- api:
111+
crdVersion: v1
112+
namespaced: true
84113
controller: true
85114
domain: victoriametrics.com
86115
group: operator
87116
kind: VMStaticScrape
88117
path: github.com/VictoriaMetrics/operator/api/v1beta1
89118
version: v1beta1
90-
-
119+
- api:
120+
crdVersion: v1
121+
namespaced: true
91122
controller: true
92123
domain: victoriametrics.com
93124
group: operator
94125
kind: VMUser
95126
path: github.com/VictoriaMetrics/operator/api/v1beta1
96127
version: v1beta1
97-
-
128+
- api:
129+
crdVersion: v1
130+
namespaced: true
98131
controller: true
99132
domain: victoriametrics.com
100133
group: operator
101134
kind: VMAuth
102135
path: github.com/VictoriaMetrics/operator/api/v1beta1
103136
version: v1beta1
104137
version: "3"
105-
plugins:
106-
go.operator-sdk.io/v2-alpha: {}
File renamed without changes.

config/certmanager/certificate.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
# More document can be found at https://docs.cert-manager.io
33
# WARNING: Targets CertManager 0.11 check https://docs.cert-manager.io/en/latest/tasks/upgrading/index.html for
44
# breaking changes
5-
apiVersion: cert-manager.io/v1alpha2
5+
apiVersion: cert-manager.io/v1
66
kind: Issuer
77
metadata:
88
name: selfsigned-issuer
99
namespace: system
1010
spec:
1111
selfSigned: {}
1212
---
13-
apiVersion: cert-manager.io/v1alpha2
13+
apiVersion: cert-manager.io/v1
1414
kind: Certificate
1515
metadata:
1616
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml

config/default/manager_auth_proxy_patch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ spec:
2121
name: https
2222
- name: manager
2323
args:
24-
- "--metrics-addr=127.0.0.1:8080"
24+
- "--metrics-bind-address=127.0.0.1:8080"

config/deployments/webhook/webhookcainjection_patch.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# This patch add annotation to admission webhook config and
22
# the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize.
3-
#apiVersion: admissionregistration.k8s.io/v1beta1
3+
#apiVersion: admissionregistration.k8s.io/v1
44
#kind: MutatingWebhookConfiguration
55
#metadata:
66
# name: mutating-webhook-configuration
77
# annotations:
88
# cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
99
---
10-
apiVersion: admissionregistration.k8s.io/v1beta1
10+
apiVersion: admissionregistration.k8s.io/v1
1111
kind: ValidatingWebhookConfiguration
1212
metadata:
1313
name: validating-webhook-configuration

config/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ spec:
2222
command:
2323
- manager
2424
args:
25-
- "--enable-leader-election"
25+
- "--leader-elect"
2626
image: manager
2727
env:
2828
- name: WATCH_NAMESPACE

config/rbac/kustomization.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,35 @@ resources:
33
- role_binding.yaml
44
- leader_election_role.yaml
55
- leader_election_role_binding.yaml
6+
- vmuser_editor_role.yaml
7+
- vmuser_viewer_role.yaml
8+
- vmauth_editor_role.yaml
9+
- vmauth_viewer_role.yaml
10+
- vmstaticscrape_editor_role.yaml
11+
- vmstaticscrape_viewer_role.yaml
12+
- vmnodescrape_editor_role.yaml
13+
- vmnodescrape_viewer_role.yaml
14+
- vmprobe_editor_role.yaml
15+
- vmprobe_viewer_role.yaml
16+
- vmcluster_editor_role.yaml
17+
- vmcluster_viewer_role.yaml
18+
- vmsingle_editor_role.yaml
19+
- vmsingle_viewer_role.yaml
20+
- vmservicescrape_editor_role.yaml
21+
- vmservicescrape_viewer_role.yaml
22+
- vmrule_editor_role.yaml
23+
- vmrule_viewer_role.yaml
24+
- vmpodscrape_editor_role.yaml
25+
- vmpodscrape_viewer_role.yaml
26+
- vmalertmanagerconfig_editor_role.yaml
27+
- vmalertmanagerconfig_viewer_role.yaml
28+
- vmalertmanager_editor_role.yaml
29+
- vmalertmanager_viewer_role.yaml
30+
- vmalert_editor_role.yaml
31+
- vmalert_viewer_role.yaml
32+
- vmagent_editor_role.yaml
33+
- vmagent_viewer_role.yaml
34+
635
# Comment the following 4 lines if you want to disable
736
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
837
# which protects your /metrics endpoint.
@@ -20,3 +49,7 @@ patches:
2049
- path: service_account_patch.yaml
2150
target:
2251
name: vm-operator-manager-rolebinding
52+
# For each CRD, "Editor" and "Viewer" roles are scaffolded by
53+
# default, aiding admins in cluster management. Those roles are
54+
# not used by the Project itself. You can comment the following lines
55+
# if you do not want those helpers be installed with your Project.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# permissions for end users to edit vmclusters.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
labels:
6+
app.kubernetes.io/name: victoriametrics-operator
7+
app.kubernetes.io/managed-by: kustomize
8+
name: vmcluster-editor-role
9+
rules:
10+
- apiGroups:
11+
- operator.victoriametrics.com
12+
resources:
13+
- vmclusters
14+
verbs:
15+
- create
16+
- delete
17+
- get
18+
- list
19+
- patch
20+
- update
21+
- watch
22+
- apiGroups:
23+
- operator.victoriametrics.com
24+
resources:
25+
- vmclusters/status
26+
verbs:
27+
- get

0 commit comments

Comments
 (0)