Skip to content

Commit

Permalink
Merge pull request grafana#381 from periklis/backport-pr-14447-5.9
Browse files Browse the repository at this point in the history
[release-5.9] Backport PR grafana#14447
  • Loading branch information
periklis authored Oct 24, 2024
2 parents 64a3eb2 + 6c4b614 commit a1c77d2
Show file tree
Hide file tree
Showing 201 changed files with 1,957 additions and 1,800 deletions.
6 changes: 3 additions & 3 deletions operator/.bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ $(KIND): $(BINGO_DIR)/kind.mod
@echo "(re)installing $(GOBIN)/kind-v0.23.0"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kind.mod -o=$(GOBIN)/kind-v0.23.0 "sigs.k8s.io/kind"

KUSTOMIZE := $(GOBIN)/kustomize-v4.5.7
KUSTOMIZE := $(GOBIN)/kustomize-v5.4.3
$(KUSTOMIZE): $(BINGO_DIR)/kustomize.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/kustomize-v4.5.7"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kustomize.mod -o=$(GOBIN)/kustomize-v4.5.7 "sigs.k8s.io/kustomize/kustomize/v4"
@echo "(re)installing $(GOBIN)/kustomize-v5.4.3"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kustomize.mod -o=$(GOBIN)/kustomize-v5.4.3 "sigs.k8s.io/kustomize/kustomize/v5"

OPERATOR_SDK := $(GOBIN)/operator-sdk-v1.37.0
$(OPERATOR_SDK): $(BINGO_DIR)/operator-sdk.mod
Expand Down
8 changes: 2 additions & 6 deletions operator/.bingo/kustomize.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.17
go 1.22.5

exclude sigs.k8s.io/kustomize/api v0.2.0

exclude sigs.k8s.io/kustomize/cmd/config v0.2.0

require sigs.k8s.io/kustomize/kustomize/v4 v4.5.7
require sigs.k8s.io/kustomize/kustomize/v5 v5.4.3
471 changes: 58 additions & 413 deletions operator/.bingo/kustomize.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion operator/.bingo/operator-sdk.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.22.8
go 1.22.5

require github.com/operator-framework/operator-sdk v1.37.0 // cmd/operator-sdk
2 changes: 1 addition & 1 deletion operator/.bingo/variables.env
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ JSONNETFMT="${GOBIN}/jsonnetfmt-v0.20.0"

KIND="${GOBIN}/kind-v0.23.0"

KUSTOMIZE="${GOBIN}/kustomize-v4.5.7"
KUSTOMIZE="${GOBIN}/kustomize-v5.4.3"

OPERATOR_SDK="${GOBIN}/operator-sdk-v1.37.0"

Expand Down
1 change: 1 addition & 0 deletions operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Release 5.9.9

- [14447](https://github.com/grafana/loki/pull/14447) **periklis**: refactor(operator)!: Migrate project layout to kubebuilder go/v4
- [14526](https://github.com/grafana/loki/pull/14526) **periklis**: feat(operator): Update Loki operand to v3.2.1
- [14445](https://github.com/grafana/loki/pull/14445) **periklis**: chore(operator): Upgrade operator-sdk 1.37.0 and kind 0.23.0

Expand Down
7 changes: 3 additions & 4 deletions operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@ FROM golang:1.22.8 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
COPY apis/ apis/
COPY api/ api/
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY controllers/ controllers/
COPY cmd/loki-operator/main.go cmd/loki-operator/main.go
COPY internal/ internal/

# Build
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -mod=readonly -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -mod=readonly -a -o manager cmd/loki-operator/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
7 changes: 3 additions & 4 deletions operator/Dockerfile.cross
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ FROM --platform=linux/amd64 $BUILD_IMAGE as builder
COPY --from=goenv /goarch /goarm /
WORKDIR /workspace
# Copy the Go Modules manifests
COPY apis/ apis/
COPY api/ api/
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY controllers/ controllers/
COPY cmd/loki-operator/main.go cmd/loki-operator/main.go
COPY internal/ internal/

# Build
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on GOARCH=$(cat /goarch) GOARM=$(cat /goarm) go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on GOARCH=$(cat /goarch) GOARM=$(cat /goarm) go build -a -o manager cmd/loki-operator/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
24 changes: 12 additions & 12 deletions operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ deps: go.mod go.sum
go mod verify

.PHONY: deps-api
deps-api: apis/loki/go.mod apis/loki/go.sum
@cd ./apis/loki/ && go mod tidy
@cd ./apis/loki/ && go mod download
@cd ./apis/loki/ && go mod verify
deps-api: api/loki/go.mod api/loki/go.sum
@cd ./api/loki/ && go mod tidy
@cd ./api/loki/ && go mod download
@cd ./api/loki/ && go mod verify

.PHONY: cli
cli: deps bin/loki-broker ## Build loki-broker CLI binary
Expand All @@ -138,11 +138,11 @@ bin/loki-broker: $(GO_FILES) | generate

.PHONY: manager
manager: deps generate ## Build manager binary
go build -o bin/manager main.go
go build -o bin/manager ./cmd/loki-operator/main.go

.PHONY: size-calculator
size-calculator: deps generate ## Build size-calculator binary
go build -o bin/size-calculator main.go
go build -o bin/size-calculator ./cmd/size-calculator/main.go

.PHONY: go-generate
go-generate: ## Run go generate
Expand All @@ -163,7 +163,7 @@ test: $(GO_FILES)

.PHONY: test-unit-api
test-unit-api: $(GO_FILES)
@cd ./apis/loki/ && go test ./... -coverprofile cover.out
@cd ./api/loki/ && go test ./... -coverprofile cover.out

.PHONY: test-unit-prometheus
test-unit-prometheus: $(PROMTOOL) ## Run prometheus unit tests
Expand Down Expand Up @@ -237,7 +237,7 @@ quickstart-cleanup: $(KIND) ## Cleanup for quickstart set up

.PHONY: run
run: generate manifests ## Run against the configured Kubernetes cluster in ~/.kube/config
go run ./main.go
go run ./cmd/loki-operator/main.go

.PHONY: install
install: manifests $(KUSTOMIZE) ## Install CRDs into a cluster
Expand Down Expand Up @@ -312,17 +312,17 @@ oci-push-calculator: ## Push the calculator image
$(OCI_RUNTIME) push $(CALCULATOR_IMG)

##@ Website
TYPES_TARGET := $(shell find apis/loki -type f -iname "*_types.go")
TYPES_TARGET := $(shell find api/loki -type f -iname "*_types.go")
docs/operator/api.md: $(TYPES_TARGET) $(GEN_CRD_API_REFERENCE_DOCS)
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir "github.com/grafana/loki/operator/apis/loki/" -config "$(PWD)/config/docs/config.json" -template-dir "$(PWD)/config/docs/templates" -out-file "$(PWD)/$@"
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir "github.com/grafana/loki/operator/api/loki/" -config "$(PWD)/config/docs/config.json" -template-dir "$(PWD)/config/docs/templates" -out-file "$(PWD)/$@"
sed -i 's/+docs:/ docs:/' $@
sed -i 's/+parent:/ parent:/' $@
sed -i 's/##/\n##/' $@
sed -i 's/+newline/\n/' $@

FEATURE_GATES_TARGET := $(shell find apis/config -type f -iname "*_types.go")
FEATURE_GATES_TARGET := $(shell find api/config -type f -iname "*_types.go")
docs/operator/feature-gates.md: $(FEATURE_GATES_TARGET) $(GEN_CRD_API_REFERENCE_DOCS)
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir "github.com/grafana/loki/operator/apis/config/v1/" -config "$(PWD)/config/docs/config.json" -template-dir "$(PWD)/config/docs/templates" -out-file "$(PWD)/$@"
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir "github.com/grafana/loki/operator/api/config/v1/" -config "$(PWD)/config/docs/config.json" -template-dir "$(PWD)/config/docs/templates" -out-file "$(PWD)/$@"
sed -i 's/title: "API"/title: "Feature Gates"/' $@
sed -i 's/+docs:/ docs:/' $@
sed -i 's/+parent:/ parent:/' $@
Expand Down
18 changes: 9 additions & 9 deletions operator/PROJECT
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
componentConfig: true
domain: grafana.com
layout:
- go.kubebuilder.io/v3
- go.kubebuilder.io/v4
multigroup: true
plugins:
manifests.sdk.operatorframework.io/v2: {}
Expand All @@ -16,7 +16,7 @@ resources:
domain: grafana.com
group: loki
kind: LokiStack
path: github.com/grafana/loki/operator/apis/loki/v1beta1
path: github.com/grafana/loki/operator/api/loki/v1beta1
version: v1beta1
- api:
crdVersion: v1
Expand All @@ -25,7 +25,7 @@ resources:
domain: grafana.com
group: loki
kind: LokiStack
path: github.com/grafana/loki/operator/apis/loki/v1
path: github.com/grafana/loki/operator/api/loki/v1
version: v1
webhooks:
conversion: true
Expand All @@ -38,7 +38,7 @@ resources:
domain: grafana.com
group: loki
kind: AlertingRule
path: github.com/grafana/loki/operator/apis/loki/v1
path: github.com/grafana/loki/operator/api/loki/v1
version: v1
webhooks:
conversion: true
Expand All @@ -51,7 +51,7 @@ resources:
domain: grafana.com
group: loki
kind: AlertingRule
path: github.com/grafana/loki/operator/apis/loki/v1beta1
path: github.com/grafana/loki/operator/api/loki/v1beta1
version: v1beta1
webhooks:
validation: true
Expand All @@ -63,7 +63,7 @@ resources:
domain: grafana.com
group: loki
kind: RecordingRule
path: github.com/grafana/loki/operator/apis/loki/v1
path: github.com/grafana/loki/operator/api/loki/v1
version: v1
webhooks:
validation: true
Expand All @@ -76,7 +76,7 @@ resources:
domain: grafana.com
group: loki
kind: RecordingRule
path: github.com/grafana/loki/operator/apis/loki/v1beta1
path: github.com/grafana/loki/operator/api/loki/v1beta1
version: v1beta1
webhooks:
validation: true
Expand All @@ -88,7 +88,7 @@ resources:
domain: grafana.com
group: loki
kind: RulerConfig
path: github.com/grafana/loki/operator/apis/loki/v1
path: github.com/grafana/loki/operator/api/loki/v1
version: v1
- api:
crdVersion: v1
Expand All @@ -97,6 +97,6 @@ resources:
domain: grafana.com
group: loki
kind: RulerConfig
path: github.com/grafana/loki/operator/apis/loki/v1beta1
path: github.com/grafana/loki/operator/api/loki/v1beta1
version: v1beta1
version: "3"
File renamed without changes.
2 changes: 1 addition & 1 deletion operator/apis/loki/go.mod → operator/api/loki/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/grafana/loki/operator/apis/loki
module github.com/grafana/loki/operator/api/loki

go 1.19

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1beta1

import (
v1 "github.com/grafana/loki/operator/apis/loki/v1"
v1 "github.com/grafana/loki/operator/api/loki/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package v1beta1_test
import (
"testing"

v1 "github.com/grafana/loki/operator/apis/loki/v1"
"github.com/grafana/loki/operator/apis/loki/v1beta1"
v1 "github.com/grafana/loki/operator/api/loki/v1"
"github.com/grafana/loki/operator/api/loki/v1beta1"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1beta1

import (
v1 "github.com/grafana/loki/operator/apis/loki/v1"
v1 "github.com/grafana/loki/operator/api/loki/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/conversion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

v1 "github.com/grafana/loki/operator/apis/loki/v1"
"github.com/grafana/loki/operator/apis/loki/v1beta1"
v1 "github.com/grafana/loki/operator/api/loki/v1"
"github.com/grafana/loki/operator/api/loki/v1beta1"
)

func TestConvertToV1_LokiStack(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1beta1

import (
v1 "github.com/grafana/loki/operator/apis/loki/v1"
v1 "github.com/grafana/loki/operator/api/loki/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package v1beta1_test
import (
"testing"

v1 "github.com/grafana/loki/operator/apis/loki/v1"
"github.com/grafana/loki/operator/apis/loki/v1beta1"
v1 "github.com/grafana/loki/operator/api/loki/v1"
"github.com/grafana/loki/operator/api/loki/v1beta1"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1beta1

import (
v1 "github.com/grafana/loki/operator/apis/loki/v1"
v1 "github.com/grafana/loki/operator/api/loki/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package v1beta1_test
import (
"testing"

v1 "github.com/grafana/loki/operator/apis/loki/v1"
"github.com/grafana/loki/operator/apis/loki/v1beta1"
v1 "github.com/grafana/loki/operator/api/loki/v1"
"github.com/grafana/loki/operator/api/loki/v1beta1"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion operator/bundle/community-openshift/bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.bundle.channel.default.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-unknown
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v4

# Labels for testing.
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
secret:
key: service-ca.crt
name: loki-operator-controller-manager-metrics-token
serverName: loki-operator-controller-manager-metrics-service.kubernetes-operators.svc
serverName: loki-operator-controller-manager-metrics-service.openshift-operators-redhat.svc
selector:
matchLabels:
app.kubernetes.io/component: metrics
Expand Down
Loading

0 comments on commit a1c77d2

Please sign in to comment.