Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operator: Refactor handling of credentials in managed-auth mode #11920

Merged
merged 13 commits into from
Feb 13, 2024
1 change: 1 addition & 0 deletions operator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Main

- [11920](https://github.com/grafana/loki/pull/11920) **xperimental**: Refactor handling of credentials in managed-auth mode
- [11869](https://github.com/grafana/loki/pull/11869) **periklis**: Add support for running with Google Workload Identity
- [11868](https://github.com/grafana/loki/pull/11868) **xperimental**: Integrate support for OpenShift-managed credentials in Azure
- [11854](https://github.com/grafana/loki/pull/11854) **periklis**: Allow custom audience for managed-auth on STS
Expand Down
9 changes: 2 additions & 7 deletions operator/apis/config/v1/projectconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,11 @@ type OpenShiftFeatureGates struct {
// Dashboards enables the loki-mixin dashboards into the OpenShift Console
Dashboards bool `json:"dashboards,omitempty"`

// ManagedAuthEnv enabled when the operator installation is on OpenShift STS clusters.
// ManagedAuthEnv is true when OpenShift-functions are enabled and the operator has detected
// that it is running with some kind of "workload identity" (AWS STS, Azure WIF) enabled.
ManagedAuthEnv bool
}

// ManagedAuthEnabled returns true when OpenShift-functions are enabled and the operator has detected that it is
// running with some kind of "workload identity" (AWS STS, Azure WIF) enabled.
func (o *OpenShiftFeatureGates) ManagedAuthEnabled() bool {
return o.Enabled && o.ManagedAuthEnv
}

// FeatureGates is the supported set of all operator feature gates.
type FeatureGates struct {
// ServiceMonitors enables creating a Prometheus-Operator managed ServiceMonitor
Expand Down
27 changes: 27 additions & 0 deletions operator/apis/loki/v1/lokistack_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,27 @@ type LokiStackComponentStatus struct {
Ruler PodStatusMap `json:"ruler,omitempty"`
}

// CredentialMode represents the type of authentication used for accessing the object storage.
//
// +kubebuilder:validation:Enum=static;token;managed
type CredentialMode string

const (
// CredentialModeStatic represents the usage of static, long-lived credentials stored in a Secret.
// This is the default authentication mode and available for all supported object storage types.
CredentialModeStatic CredentialMode = "static"
// CredentialModeToken represents the usage of short-lived tokens retrieved from a credential source.
// In this mode the static configuration does not contain credentials needed for the object storage.
// Instead, they are generated during runtime using a service, which allows for shorter-lived credentials and
// much more granular control. This authentication mode is not supported for all object storage types.
CredentialModeToken CredentialMode = "token"
// CredentialModeManaged represents the usage of short-lived tokens retrieved from a credential source.
// This mode is similar to CredentialModeToken,but instead of having a user-configured credential source,
// it is configured by the environment, for example the Cloud Credential Operator in OpenShift.
// This mode is only supported for certain object storage types in certain runtime environments.
CredentialModeManaged CredentialMode = "managed"
)

// LokiStackStorageStatus defines the observed state of
// the Loki storage configuration.
type LokiStackStorageStatus struct {
Expand All @@ -1183,6 +1204,12 @@ type LokiStackStorageStatus struct {
// +optional
// +kubebuilder:validation:Optional
Schemas []ObjectStorageSchema `json:"schemas,omitempty"`

// CredentialMode contains the authentication mode used for accessing the object storage.
//
// +optional
// +kubebuilder:validation:Optional
CredentialMode CredentialMode `json:"credentialMode,omitempty"`
}

// LokiStackStatus defines the observed state of LokiStack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ metadata:
categories: OpenShift Optional, Logging & Tracing
certified: "false"
containerImage: docker.io/grafana/loki-operator:0.5.0
createdAt: "2024-01-31T16:48:07Z"
createdAt: "2024-02-12T14:48:52Z"
description: The Community Loki Operator provides Kubernetes native deployment
and management of Loki and related logging components.
features.operators.openshift.io/disconnected: "true"
Expand Down Expand Up @@ -1472,6 +1472,7 @@ spec:
- delete
- get
- list
- update
- watch
- apiGroups:
- config.openshift.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4064,6 +4064,14 @@ spec:
description: Storage provides summary of all changes that have occurred
to the storage configuration.
properties:
credentialMode:
description: CredentialMode contains the authentication mode used
for accessing the object storage.
enum:
- static
- token
- managed
type: string
schemas:
description: Schemas is a list of schemas which have been applied
to the LokiStack.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ metadata:
categories: OpenShift Optional, Logging & Tracing
certified: "false"
containerImage: docker.io/grafana/loki-operator:0.5.0
createdAt: "2024-01-31T16:48:04Z"
createdAt: "2024-02-12T14:48:49Z"
description: The Community Loki Operator provides Kubernetes native deployment
and management of Loki and related logging components.
operators.operatorframework.io/builder: operator-sdk-unknown
Expand Down Expand Up @@ -1452,6 +1452,7 @@ spec:
- delete
- get
- list
- update
- watch
- apiGroups:
- config.openshift.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4064,6 +4064,14 @@ spec:
description: Storage provides summary of all changes that have occurred
to the storage configuration.
properties:
credentialMode:
description: CredentialMode contains the authentication mode used
for accessing the object storage.
enum:
- static
- token
- managed
type: string
schemas:
description: Schemas is a list of schemas which have been applied
to the LokiStack.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ metadata:
categories: OpenShift Optional, Logging & Tracing
certified: "false"
containerImage: quay.io/openshift-logging/loki-operator:0.1.0
createdAt: "2024-01-31T16:48:10Z"
createdAt: "2024-02-12T14:48:55Z"
description: |
The Loki Operator for OCP provides a means for configuring and managing a Loki stack for cluster logging.
## Prerequisites and Requirements
Expand Down Expand Up @@ -1457,6 +1457,7 @@ spec:
- delete
- get
- list
- update
- watch
- apiGroups:
- config.openshift.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4064,6 +4064,14 @@ spec:
description: Storage provides summary of all changes that have occurred
to the storage configuration.
properties:
credentialMode:
description: CredentialMode contains the authentication mode used
for accessing the object storage.
enum:
- static
- token
- managed
type: string
schemas:
description: Schemas is a list of schemas which have been applied
to the LokiStack.
Expand Down
8 changes: 8 additions & 0 deletions operator/config/crd/bases/loki.grafana.com_lokistacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4046,6 +4046,14 @@ spec:
description: Storage provides summary of all changes that have occurred
to the storage configuration.
properties:
credentialMode:
description: CredentialMode contains the authentication mode used
for accessing the object storage.
enum:
- static
- token
- managed
type: string
schemas:
description: Schemas is a list of schemas which have been applied
to the LokiStack.
Expand Down
1 change: 1 addition & 0 deletions operator/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ rules:
- delete
- get
- list
- update
- watch
- apiGroups:
- config.openshift.io
Expand Down
82 changes: 0 additions & 82 deletions operator/controllers/loki/credentialsrequests_controller.go

This file was deleted.

Loading
Loading