Skip to content
Merged
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
41 changes: 40 additions & 1 deletion docs/book/src/developer/providers/v1.1-to-v1.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,43 @@ in ClusterAPI are kept in sync with the versions used by `sigs.k8s.io/controller

### Other

-
- Logging:
- To align with the upstream Kubernetes community CAPI now configures logging via `component-base/logs`.
This provides advantages like support for the JSON logging format (via `--logging-format=json`) and automatic
deprecation of klog flags aligned to the upstream Kubernetes deprecation period.
<details>
<summary>View <code>main.go</code> diff</summary>

```diff
var (
...
+ logOptions = logs.NewOptions()
)

func init() {
- klog.InitFlags(nil)

func InitFlags(fs *pflag.FlagSet) {
+ logs.AddFlags(fs, logs.SkipLoggingConfigurationFlags())
+ logOptions.AddFlags(fs)

func main() {
...
pflag.Parse()

+ if err := logOptions.ValidateAndApply(); err != nil {
+ setupLog.Error(err, "unable to start manager")
+ os.Exit(1)
+ }
+
+ // Set the Klog format, as the Serialize format shouldn't be used anymore.
+ // This makes sure that the logs are formatted correctly, i.e.:
+ // * JSON logging format: msg isn't serialized twice
+ // * text logging format: values are formatted with their .String() func.
+ ctrl.SetLogger(klogr.NewWithOptions(klogr.WithFormat(klogr.FormatKlog)))
- ctrl.SetLogger(klogr.New())
```
</details>

This change has been introduced in CAPI in the following PRs: [#6072](https://github.com/kubernetes-sigs/cluster-api/pull/6072), [#6190](https://github.com/kubernetes-sigs/cluster-api/pull/6190).</br>
**Note**: This change is not mandatory for providers, but highly recommended.