Skip to content

Commit 2af7963

Browse files
committed
NLB-6740 docstrings updates
Updating the original NLK docstrings to bring them in line with the latest architectural changes.
1 parent 09bfd04 commit 2af7963

File tree

7 files changed

+36
-49
lines changed

7 files changed

+36
-49
lines changed

charts/nlk/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ nlk:
3333
## trace,debug,info,warn,error,fatal,panic
3434
logLevel: "info"
3535

36-
## the nginx hosts (comma-separated) to send upstream updates to
36+
## the nginx hosts to send upstream updates to. For multiple hosts, use a sequence
3737
nginxHosts: ""
3838
## Sets the annotation value that NLK is looking for to watch a Service
3939
# serviceAnnotationMatch: nginxaas

internal/application/application_constants.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,16 @@
55

66
package application
77

8-
// These constants are intended for use in the Annotations field of the Service definition.
9-
// They determine which Border Server client will be used.
10-
// To use these values, add the following annotation to the Service definition:
8+
// These constants determine which Border Server client will be used. The name
9+
// of the port on the desired service needs to be formattted as follows:
10+
// "http-tea", where the first part is the protocol ("http" or "stream") and the
11+
// second part is the name of the upstream (in this case "tea").
1112
//
12-
// annotations:
13-
// nginxinc.io/nlk-<upstream name>: <value>
14-
//
15-
// where <upstream name> is the name of the upstream in the NGINX Plus configuration
16-
// and <value> is one of the constants below.
17-
//
18-
// Note, this is an extensibility point. To add a Border Server client...
19-
// 1. Create a module that implements the BorderClient interface;
20-
// 2. Add a new constant to this group that acts as a key for selecting the client;
21-
// 3. Update the NewBorderClient factory method in border_client.go that returns the client;
13+
// Note, this is an extensibility point. To add a Border Server client... 1.
14+
// Create a module that implements the BorderClient interface; 2. Add a new
15+
// constant to this group that acts as a key for selecting the client; 3. Update
16+
// the NewBorderClient factory method in border_client.go that returns the
17+
// client;
2218
const (
2319

2420
// ClientTypeNginxStream creates a NginxStreamBorderClient that uses the Stream* methods of the NGINX Plus client.

internal/application/doc.go

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,22 @@
33
* Use of this source code is governed by the Apache License that can be found in the LICENSE file.
44
*/
55

6-
/*
7-
Package application includes support for applying updates to the Border servers.
8-
9-
"Border Servers" are servers that are exposed to the outside world and direct traffic into the cluster.
10-
11-
The BorderClient module defines an interface that can be implemented to support other Border Server types.
12-
To add a Border Server client...
13-
1. Create a module that implements the BorderClient interface;
14-
2. Add a new constant in application_constants.go that acts as a key for selecting the client;
15-
3. Update the NewBorderClient factory method in border_client.go that returns the client;
16-
17-
At this time the only supported Border Servers are NGINX Plus servers.
6+
// Package application includes support for applying updates to the Border servers.
187

19-
The two Border Server clients for NGINX Plus are:
20-
- NginxHTTPBorderClient: updates NGINX Plus servers using HTTP Upstream methods on the NGINX Plus API.
21-
- NginxStreamBorderClient: updates NGINX Plus servers using Stream Upstream methods on the NGINX Plus API.
8+
// "Border Servers" are servers that are exposed to the outside world and direct traffic into the cluster.
229

23-
Both of these implementations use the NGINX Plus client module to communicate with the NGINX Plus server.
10+
// The BorderClient module defines an interface that can be implemented to support other Border Server types.
11+
// To add a Border Server client...
12+
// 1. Create a module that implements the BorderClient interface;
13+
// 2. Add a new constant in application_constants.go that acts as a key for selecting the client;
14+
// 3. Update the NewBorderClient factory method in border_client.go that returns the client;
2415

25-
Selection of the appropriate client is based on the Annotations present on the Service definition, e.g.:
16+
// At this time the only supported Border Servers are NGINX Plus servers.
2617

27-
annotations:
28-
nginxinc.io/nlk-<upstream name>: <value>
18+
// The two Border Server clients for NGINX Plus are:
19+
// - NginxHTTPBorderClient: updates NGINX Plus servers using HTTP Upstream methods on the NGINX Plus API.
20+
// - NginxStreamBorderClient: updates NGINX Plus servers using Stream Upstream methods on the NGINX Plus API.
2921

30-
where <upstream name> is the name of the upstream in the NGINX Plus configuration
31-
and <value> is one of the constants in application_constants.go.
32-
*/
22+
// Both of these implementations use the NGINX Plus client module to communicate with the NGINX Plus server.
3323

3424
package application

internal/observation/watcher.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ import (
2121
"k8s.io/client-go/tools/cache"
2222
)
2323

24-
// Watcher is responsible for watching for changes to Kubernetes resources.
25-
// Particularly, Services in the namespace defined in the WatcherSettings::NginxIngressNamespace setting.
26-
// When a change is detected, an Event is generated and added to the Handler's queue.
24+
// Watcher is responsible for watching for changes to kubernetes services marked
25+
// with the correct annotation. NLK watches for changes to the services
26+
// themselves, but also changes to the nodes, endpoint slices and load balancers
27+
// associated with those services. When a change is detected, an Event is
28+
// generated and added to the synchronizer's queue.
2729
type Watcher struct {
2830
synchronizer synchronization.Interface
2931

internal/synchronization/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
/*
7-
Package synchronization includes functionality to synchronize Ingress events to NGINX+ Configuration API commands.
7+
Package synchronization includes functionality to synchronize kubernetes service events to NGINX upstream updates.
88
*/
99

1010
package synchronization

internal/translation/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
/*
7-
Package translation includes functionality to translate Ingress events to target system definitions.
7+
Package translation includes functionality to translate service events into NGINX upstream server updates.
88
*/
99

1010
package translation

internal/translation/translator.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,19 @@ func NewTranslator(
3333
}
3434
}
3535

36-
// Translate transforms event data into an intermediate format that can be consumed by the BorderClient implementations
37-
// and used to update the Border Servers.
36+
// Translate transforms service events into upstream server updates that can be implemented by the border client.
3837
func (t *Translator) Translate(event *core.Event) (core.ServerUpdateEvents, error) {
3938
slog.Debug("Translate::Translate")
4039

4140
return t.buildServerUpdateEvents(event.Service.Spec.Ports, event)
4241
}
4342

44-
// buildServerUpdateEvents builds a list of ServerUpdateEvents based on the event type
45-
// The NGINX+ Client uses a list of servers for Created and Updated events.
46-
// The client performs reconciliation between the list of servers in the NGINX+ Client call
47-
// and the list of servers in NGINX+.
48-
// The NGINX+ Client uses a single server for Deleted events;
49-
// so the list of servers is broken up into individual events.
43+
// buildServerUpdateEvents builds a list of ServerUpdateEvents based on the
44+
// event type. The NGINX+ Client uses a list of servers for Created and Updated
45+
// events. The client performs reconciliation between the list of servers in the
46+
// NGINX+ Client call and the list of servers in NGINX+. If a delete event is
47+
// received, the translator generates an empty list of servers: the client
48+
// reconciliation will then cause all servers to be deleted.
5049
func (t *Translator) buildServerUpdateEvents(ports []v1.ServicePort, event *core.Event,
5150
) (events core.ServerUpdateEvents, err error) {
5251
slog.Debug("Translate::buildServerUpdateEvents", "ports", ports)

0 commit comments

Comments
 (0)