Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions components/operator/internal/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ func (b *Builder) WithLogFormat(logFormat string) *Builder {
return b
}

// WithLogFormatRestartAnnotation sets the restart annotation value which triggers a pod restart when logFormat changes
func (b *Builder) WithLogFormatRestartAnnotation(logFormat string) *Builder {
if logFormat != "" {
b.With("containers.manager.logConfiguration.restartAnnotationValue", logFormat)
}

return b
}

// TODO: remove this method when buildless is enabled by default
func (b *Builder) WithChartPath(chartPath string) *Builder {
b.With("chartPath", chartPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ func configureControllerConfigurationFlags(s *systemState) {
s.instance.Status.DefaultRuntimePodPreset,
).
WithLogLevel(s.instance.Status.LogLevel).
WithLogFormat(s.instance.Status.LogFormat)
WithLogFormat(s.instance.Status.LogFormat).
WithLogFormatRestartAnnotation(s.instance.Status.LogFormat)
}

func getNodesLen(ctx context.Context, c client.Client) (int, error) {
Expand Down
1 change: 1 addition & 0 deletions config/buildless-serverless/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
annotations:
kubectl.kubernetes.io/default-container: manager
sidecar.istio.io/inject: "false"
serverless.kyma-project.io/log-format: "{{ .Values.containers.manager.logConfiguration.restartAnnotationValue }}"
labels:
control-plane: controller-manager
networking.serverless.kyma-project.io/to-apiserver: allowed
Expand Down
1 change: 1 addition & 0 deletions config/buildless-serverless/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ global:
containers:
manager:
logConfiguration:
restartAnnotationValue: "json"
data:
logLevel: "info"
logFormat: "json"
Expand Down
4 changes: 3 additions & 1 deletion docs/user/00-20-configure-serverless.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ You can configure the desired log format to be used.

```yaml
spec:
logFormat: "yaml"
logFormat: "json"
```

For more details, see [Configuring Serverless Logging](00-70-configuring-logging.md).

### Disabling Buildless Mode

Serverless buildless mode is enabled by default. To use the legacy image-building Serverless functionality, disable buildless mode through an annotation.
Expand Down
24 changes: 14 additions & 10 deletions docs/user/00-70-configuring-logging.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Configuring Logging

This document describes how to configure logging for Serverless components. The Serverless module supports dynamic log reconfiguration through Kubernetes ConfigMaps.
This document describes how to configure logging for Serverless components. The Serverless module supports dynamic log reconfiguration through the Serverless custom resource (CR).


> [NOTE]
> It is not possible to dynamically change the log format. If you want to change it, update the ConfigMap and restart the Pods.
> [!NOTE]
> - **logLevel** changes are applied dynamically without restarting the Serverless Pods
> - **logFormat** changes automatically restart the Serverless Pods to apply the new format

## Supported Log Levels

Expand All @@ -17,17 +18,17 @@ From the least to the most verbose: `fatal`, `panic`, `dpanic`, `error`, `warn`,

## Configure Serverless Controller

Update the log configuration in the `serverless-log-config` ConfigMap in the `kyma-system` namespace:
Update the log configuration by modifying the Serverless CR in the `kyma-system` namespace:

```bash
# Change log level
kubectl patch configmap serverless-log-config -n kyma-system --type merge -p '{"data":{"log-config.yaml":"logLevel: debug"}}'
# Change log level (updates ConfigMap without restarting Pods)
kubectl patch serverless -n kyma-system default --type merge -p '{"spec":{"logLevel":"debug"}}'

# Change log format
kubectl patch configmap serverless-log-config -n kyma-system --type merge -p '{"data":{"log-config.yaml":"logFormat: console"}}'
# Change log format (updates ConfigMap and restarts Pods)
kubectl patch serverless -n kyma-system default --type merge -p '{"spec":{"logFormat":"console"}}'

# Change both, level and format
kubectl patch configmap serverless-log-config -n kyma-system --type merge -p '{"data":{"log-config.yaml":"logLevel: info\nlogFormat: json"}}'
# Change both level and format
kubectl patch serverless -n kyma-system default --type merge -p '{"spec":{"logLevel":"debug","logFormat":"console"}}'
```

Verify the change:
Expand All @@ -53,3 +54,6 @@ Verify the change:
```bash
kubectl logs -n kyma-system -l control-plane=operator
```

> [!NOTE]
> It is not possible to dynamically change the log format for the Serverless Operator. If you want to change it, update the ConfigMap and restart the Pods.
Loading