Skip to content

Commit 7b1ca8d

Browse files
authored
operator: Move cli flags to component config (grafana#6433)
1 parent 4f4b42b commit 7b1ca8d

File tree

98 files changed

+563
-187
lines changed

Some content is hidden

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

98 files changed

+563
-187
lines changed

operator/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Main
22

33
- [6411](https://github.com/grafana/loki/pull/6411) **Red-GV**: Extend schema validation in LokiStack webhook
4+
- [6334](https://github.com/grafana/loki/pull/6433) **periklis**: Move operator cli flags to component config
45
- [6224](https://github.com/grafana/loki/pull/6224) **periklis**: Add support for GRPC over TLS for Loki components
56
- [5952](https://github.com/grafana/loki/pull/5952) **Red-GV**: Add api to change storage schema version
67
- [6363](https://github.com/grafana/loki/pull/6363) **periklis**: Allow optional installation of webhooks (Kind)

operator/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RUN go mod download
1111

1212
# Copy the go source
1313
COPY main.go main.go
14-
COPY api/ api/
14+
COPY apis/ apis/
1515
COPY controllers/ controllers/
1616
COPY internal/ internal/
1717

operator/PROJECT

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
componentConfig: true
12
domain: grafana.com
23
layout:
34
- go.kubebuilder.io/v3
5+
multigroup: true
46
plugins:
57
manifests.sdk.operatorframework.io/v2: {}
68
scorecard.sdk.operatorframework.io/v2: {}
@@ -14,7 +16,7 @@ resources:
1416
domain: grafana.com
1517
group: loki
1618
kind: LokiStack
17-
path: github.com/grafana/loki/operator/api/v1beta1
19+
path: github.com/grafana/loki/operator/apis/loki/v1beta1
1820
version: v1beta1
1921
- api:
2022
crdVersion: v1
@@ -23,7 +25,7 @@ resources:
2325
domain: grafana.com
2426
group: loki
2527
kind: AlertingRule
26-
path: github.com/grafana/loki/operator/api/v1beta1
28+
path: github.com/grafana/loki/operator/apis/loki/v1beta1
2729
version: v1beta1
2830
webhooks:
2931
validation: true
@@ -35,7 +37,7 @@ resources:
3537
domain: grafana.com
3638
group: loki
3739
kind: RecordingRule
38-
path: github.com/grafana/loki/operator/api/v1beta1
40+
path: github.com/grafana/loki/operator/apis/loki/v1beta1
3941
version: v1beta1
4042
webhooks:
4143
validation: true
@@ -47,6 +49,6 @@ resources:
4749
domain: grafana.com
4850
group: loki
4951
kind: RulerConfig
50-
path: github.com/grafana/loki/operator/api/v1beta1
52+
path: github.com/grafana/loki/operator/apis/loki/v1beta1
5153
version: v1beta1
5254
version: "3"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Package v1 contains API Schema definitions for the config v1 API group
2+
//+kubebuilder:object:generate=true
3+
//+groupName=config.loki.grafana.com
4+
package v1
5+
6+
import (
7+
"k8s.io/apimachinery/pkg/runtime/schema"
8+
"sigs.k8s.io/controller-runtime/pkg/scheme"
9+
)
10+
11+
var (
12+
// GroupVersion is group version used to register these objects
13+
GroupVersion = schema.GroupVersion{Group: "config.loki.grafana.com", Version: "v1"}
14+
15+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
16+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
17+
18+
// AddToScheme adds the types in this group-version to the given scheme.
19+
AddToScheme = SchemeBuilder.AddToScheme
20+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package v1
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
cfg "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
6+
)
7+
8+
// FeatureFlags is a set of operator feature flags.
9+
type FeatureFlags struct {
10+
EnableCertificateSigningService bool `json:"enableCertSigningService,omitempty"`
11+
EnableServiceMonitors bool `json:"enableServiceMonitors,omitempty"`
12+
EnableTLSServiceMonitorConfig bool `json:"enableTlsServiceMonitorConfig,omitempty"`
13+
EnableTLSGRPCServices bool `json:"enableTlsGrpcServices,omitempty"`
14+
EnablePrometheusAlerts bool `json:"enableLokiStackAlerts,omitempty"`
15+
EnableGateway bool `json:"enableLokiStackGateway,omitempty"`
16+
EnableGatewayRoute bool `json:"enableLokiStackGatewayRoute,omitempty"`
17+
EnableGrafanaLabsStats bool `json:"enableGrafanaLabsStats,omitempty"`
18+
EnableLokiStackWebhook bool `json:"enableLokiStackWebhook,omitempty"`
19+
EnableAlertingRuleWebhook bool `json:"enableAlertingRuleWebhook,omitempty"`
20+
EnableRecordingRuleWebhook bool `json:"enableRecordingRuleWebhook,omitempty"`
21+
}
22+
23+
//+kubebuilder:object:root=true
24+
25+
// ProjectConfig is the Schema for the projectconfigs API
26+
type ProjectConfig struct {
27+
metav1.TypeMeta `json:",inline"`
28+
29+
// ControllerManagerConfigurationSpec returns the contfigurations for controllers
30+
cfg.ControllerManagerConfigurationSpec `json:",inline"`
31+
32+
Flags FeatureFlags `json:"featureFlags,omitempty"`
33+
}
34+
35+
func init() {
36+
SchemeBuilder.Register(&ProjectConfig{})
37+
}

operator/apis/config/v1/zz_generated.deepcopy.go

+51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

operator/api/v1beta1/alertingrule_webhook_test.go renamed to operator/apis/loki/v1beta1/alertingrule_webhook_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package v1beta1_test
33
import (
44
"testing"
55

6-
"github.com/grafana/loki/operator/api/v1beta1"
6+
"github.com/grafana/loki/operator/apis/loki/v1beta1"
77
"github.com/stretchr/testify/require"
88

99
apierrors "k8s.io/apimachinery/pkg/api/errors"

operator/api/v1beta1/lokistack_webhook_test.go renamed to operator/apis/loki/v1beta1/lokistack_webhook_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package v1beta1_test
33
import (
44
"testing"
55

6-
"github.com/grafana/loki/operator/api/v1beta1"
6+
"github.com/grafana/loki/operator/apis/loki/v1beta1"
77
"github.com/stretchr/testify/require"
88

99
apierrors "k8s.io/apimachinery/pkg/api/errors"

operator/api/v1beta1/recordingrule_webhook_test.go renamed to operator/apis/loki/v1beta1/recordingrule_webhook_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package v1beta1_test
33
import (
44
"testing"
55

6-
"github.com/grafana/loki/operator/api/v1beta1"
6+
"github.com/grafana/loki/operator/apis/loki/v1beta1"
77
"github.com/stretchr/testify/require"
88

99
apierrors "k8s.io/apimachinery/pkg/api/errors"

operator/bundle/manifests/loki-operator-manager-config_v1_configmap.yaml

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
apiVersion: v1
22
data:
33
controller_manager_config.yaml: |
4-
apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
5-
kind: ControllerManagerConfig
4+
apiVersion: config.loki.grafana.com/v1
5+
kind: ProjectConfig
66
health:
77
healthProbeBindAddress: :8081
88
metrics:
9+
# Bind only on this host to allow accessing metrics
10+
# only via the kube-rbac-proxy sidecar.
911
bindAddress: 127.0.0.1:8080
1012
webhook:
1113
port: 9443
1214
leaderElection:
13-
leaderElect: true
15+
leaderElect: false
1416
resourceName: e3716011.grafana.com
17+
featureFlags:
18+
enableCertSigningService: true
19+
enableServiceMonitors: true
20+
enableTlsServiceMonitorConfig: true
21+
enableTlsGRPCServices: true
22+
enableLokiStackAlerts: true
23+
enableLokiStackGateway: true
24+
enableLokiStackGatewayRoute: true
25+
enableGrafanaLabsStats: true
26+
enableLokiStackWebhook: true
27+
enableAlertingRuleWebhook: true
28+
enableRecordingRuleWebhook: true
1529
kind: ConfigMap
1630
metadata:
1731
labels:

operator/bundle/manifests/loki-operator.clusterserviceversion.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1176,13 +1176,7 @@ spec:
11761176
spec:
11771177
containers:
11781178
- args:
1179-
- --with-lokistack-gateway
1180-
- --with-lokistack-gateway-route
1181-
- --with-cert-signing-service
1182-
- --with-tls-grpc-services
1183-
- --with-service-monitors
1184-
- --with-tls-service-monitors
1185-
- --with-prometheus-alerts
1179+
- --config=controller_manager_config.yaml
11861180
command:
11871181
- /manager
11881182
env:
@@ -1220,6 +1214,9 @@ spec:
12201214
- mountPath: /tmp/k8s-webhook-server/serving-certs
12211215
name: webhook-cert
12221216
readOnly: true
1217+
- mountPath: /controller_manager_config.yaml
1218+
name: manager-config
1219+
subPath: controller_manager_config.yaml
12231220
- args:
12241221
- --secure-listen-address=0.0.0.0:8443
12251222
- --upstream=http://127.0.0.1:8080/
@@ -1244,6 +1241,9 @@ spec:
12441241
secret:
12451242
defaultMode: 420
12461243
secretName: loki-operator-webhook-service
1244+
- configMap:
1245+
name: loki-operator-manager-config
1246+
name: manager-config
12471247
- name: loki-operator-metrics-cert
12481248
secret:
12491249
defaultMode: 420

operator/cmd/loki-broker/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
"github.com/ViaQ/logerr/v2/log"
1212
"github.com/go-logr/logr"
13-
"github.com/grafana/loki/operator/api/v1beta1"
13+
"github.com/grafana/loki/operator/apis/loki/v1beta1"
1414
"github.com/grafana/loki/operator/internal/manifests"
1515
"github.com/grafana/loki/operator/internal/manifests/storage"
1616
"sigs.k8s.io/yaml"

0 commit comments

Comments
 (0)