1
1
# Enhancement Proposal-928: Control Plane Dynamic Configuration
2
2
3
3
- Issue: https://github.com/nginxinc/nginx-kubernetes-gateway/issues/928
4
- - Status: Provisional
4
+ - Status: Implementable
5
5
6
6
## Summary
7
7
@@ -17,3 +17,99 @@ option that we will support is log level.
17
17
## Non-Goals
18
18
19
19
This proposal is * not* defining a way to dynamically configure the data plane.
20
+
21
+ ## Introduction
22
+
23
+ The NKG control plane will evolve to have various user-configurable options. These could include, but are not
24
+ limited to, log level, tracing, or metrics. For the best user experience, these options should be able to be
25
+ changed at runtime, to avoid having to restart NKG. The first option that we will allow users to configure is the
26
+ log level. The easiest and most intuitive way to implement a Kubernetes-native API is through a CRD.
27
+
28
+ In this doc, the term "user" will refer to the cluster operator (the person who installs and manages NKG). The
29
+ cluster operator owns this CRD resource.
30
+
31
+ ## API, Customer Driven Interfaces, and User Experience
32
+
33
+ The API would be provided in a CRD. An authorized user would interact with this CRD using ` kubectl ` to ` get `
34
+ or ` edit ` the configuration.
35
+
36
+ Proposed configuration CRD example:
37
+
38
+ ``` yaml
39
+ apiVersion : gateway.nginx.org/v1alpha1
40
+ kind : NginxGateway
41
+ metadata :
42
+ name : nginx-gateway-config
43
+ namespace : nginx-gateway
44
+ spec :
45
+ logging :
46
+ level : info
47
+ ...
48
+ status :
49
+ conditions :
50
+ ...
51
+ ```
52
+
53
+ - The CRD would be Namespace-scoped, living in the same Namespace as the controller that it applies to.
54
+ - CRD is initialized and created when NKG is deployed.
55
+ - NKG references the name of this CRD via CLI arg (` --nginx-gateway-config-name ` ), and only watches this CRD.
56
+ If the resource doesn't exist, then an error is logged and event created, and default values are used.
57
+ - If user deletes resource, NKG logs an error and creates an event. NKG will revert to default values.
58
+
59
+ This resource won't be referenced in the ` parametersRef ` of the GatewayClass, reserving that option for a data
60
+ plane CRD. The control plane may end up supporting multiple GatewayClasses, so linking the control CRD to a
61
+ GatewayClass wouldn't make sense. Referencing the CRD via a CLI argument ensures we only support one instance of
62
+ the CRD per control plane.
63
+
64
+ For discussion with team:
65
+
66
+ - kind name
67
+ - default resource name
68
+
69
+ ## Use Cases
70
+
71
+ The high level use case for dynamically changing settings in the NKG control plane is to allow users to alter
72
+ behavior without the need for restarting NKG and experiencing downtime.
73
+
74
+ For the specific log level use case, users may be experiencing problems with NKG that require more information to
75
+ diagnose. These problems could include:
76
+
77
+ - Not seeing or processing Kubernetes resources that it should be.
78
+ - Configuring the data plane incorrectly based on the defined Kubernetes resources.
79
+ - Crashes or errors without enough detail.
80
+
81
+ Being able to dynamically change the log level can allow for a quick way to obtain more information about
82
+ the state of the control plane without losing that state due to a required restart.
83
+
84
+ ## Testing
85
+
86
+ Unit tests can be leveraged for verifying that NKG properly watches and acts on CRD changes. These tests would
87
+ be similar in behavior as the current unit tests that verify Gateway API resource processing.
88
+
89
+ ## Security Considerations
90
+
91
+ We need to ensure that any configurable fields that are exposed to a user are:
92
+
93
+ - Properly validated. This means that the fields should be the correct type (integer, string, etc.), have appropriate
94
+ length, and use regex patterns or enums to prevent any unwanted input. This will initially be done through
95
+ OpenAPI schema validation. If necessary as the CRD evolves, CEL or webhooks could be used.
96
+ - Have a valid use case. The more fields we expose, the more attack vectors we create. We should only be exposing
97
+ fields that are genuinely useful for a user to change dynamically.
98
+
99
+ RBAC via the Kubernetes API server will ensure that only authorized users can update the CRD containing NKG control
100
+ plane configuration.
101
+
102
+ ## Alternatives
103
+
104
+ - ConfigMap
105
+ A ConfigMap is another type of resource that a user can provide configuration options within, however it lacks the
106
+ benefits of a CRD, specifically built-in schema validation, versioning, and conversion webhooks.
107
+
108
+ - Custom API server
109
+ The NKG control plane could implement its own custom API server. However the overhead of implementing this, which
110
+ would include auth, validation, endpoints, and so on, would not be worth it due to the fact that the Kubernetes
111
+ API server already does all of these things for us.
112
+
113
+ ## References
114
+
115
+ - [ Kubernetes Custom Resources] ( https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/ )
0 commit comments