Skip to content

Commit fd9d3ef

Browse files
committed
chore(vlab): add lgtm observability node
Signed-off-by: Pau Capdevila <[email protected]>
1 parent e1a48f1 commit fd9d3ef

40 files changed

+29964
-83
lines changed

api/fabricator/v1beta1/fabnode_types.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,20 @@ type FabNodeSpec struct {
2121
Roles []FabNodeRole `json:"roles"`
2222
Bootstrap ControlNodeBootstrap `json:"bootstrap,omitempty"`
2323
Management ControlNodeManagement `json:"management,omitempty"`
24+
External ControlNodeExternal `json:"external,omitempty"`
2425
Dummy ControlNodeDummy `json:"dummy,omitempty"`
2526
}
2627

2728
type FabNodeRole string
2829

2930
const (
30-
NodeRoleGateway FabNodeRole = "gateway"
31+
NodeRoleGateway FabNodeRole = "gateway"
32+
NodeRoleObservability FabNodeRole = "observability"
3133
)
3234

3335
var NodeRoles = []FabNodeRole{
3436
NodeRoleGateway,
37+
NodeRoleObservability,
3538
}
3639

3740
// FabNodeStatus defines the observed state of Node.
@@ -85,6 +88,9 @@ func (n *FabNode) Validate(ctx context.Context, fabCfg *FabConfig, allowNotHydra
8588
return fmt.Errorf("unexpected node roles %q", n.Spec.Roles) //nolint:goerr113
8689
}
8790

91+
// Check if this is an observability node
92+
isObservability := len(n.Spec.Roles) > 0 && n.Spec.Roles[0] == NodeRoleObservability
93+
8894
if !allowNotHydrated {
8995
dummyAddr, err := n.Spec.Dummy.IP.Parse()
9096
if err != nil {
@@ -168,6 +174,17 @@ func (n *FabNode) Validate(ctx context.Context, fabCfg *FabConfig, allowNotHydra
168174
}
169175
}
170176

177+
// Observability nodes need external interface validation
178+
if isObservability {
179+
if _, _, err := n.Spec.External.IP.Parse(); err != nil {
180+
return fmt.Errorf("parsing external IP: %w", err)
181+
}
182+
183+
if n.Spec.External.Interface == "" {
184+
return fmt.Errorf("external interface must be set for observability node") //nolint:goerr113
185+
}
186+
}
187+
171188
if n.Spec.Management.Interface == "" {
172189
return fmt.Errorf("management interface must be set") //nolint:goerr113
173190
}

api/fabricator/v1beta1/fabricator_types.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ type FabConfig struct {
141141
Fabric FabricConfig `json:"fabric,omitempty"`
142142
Gateway GatewayConfig `json:"gateway,omitempty"`
143143
Observability ObservabilityConfig `json:"observability,omitempty"`
144+
LGTM LGTMConfig `json:"lgtm,omitempty"`
144145
}
145146

146147
type ControlConfig struct {
@@ -276,12 +277,46 @@ type ObservabilityConfig struct {
276277
Targets alloy.Targets `json:"targets,omitempty"`
277278
}
278279

280+
type LGTMConfig struct {
281+
Enable bool `json:"enable,omitempty"`
282+
Grafana GrafanaConfig `json:"grafana,omitempty"`
283+
Loki LokiConfig `json:"loki,omitempty"`
284+
Tempo TempoConfig `json:"tempo,omitempty"`
285+
Prometheus PrometheusConfig `json:"prometheus,omitempty"`
286+
}
287+
288+
type GrafanaConfig struct {
289+
Enabled bool `json:"enabled,omitempty"`
290+
AdminUser string `json:"adminUser,omitempty"`
291+
AdminPassword string `json:"adminPassword,omitempty"`
292+
}
293+
294+
type LokiConfig struct {
295+
Enabled bool `json:"enabled,omitempty"`
296+
}
297+
298+
type TempoConfig struct {
299+
Enabled bool `json:"enabled,omitempty"`
300+
}
301+
302+
type PrometheusConfig struct {
303+
Enabled bool `json:"enabled,omitempty"`
304+
}
305+
306+
type LGTMVersions struct {
307+
Grafana meta.Version `json:"grafana,omitempty"`
308+
Loki meta.Version `json:"loki,omitempty"`
309+
Tempo meta.Version `json:"tempo,omitempty"`
310+
Prometheus meta.Version `json:"prometheus,omitempty"`
311+
}
312+
279313
type Versions struct {
280314
Platform PlatformVersions `json:"platform,omitempty"`
281315
Fabricator FabricatorVersions `json:"fabricator,omitempty"`
282316
Fabric FabricVersions `json:"fabric,omitempty"`
283317
Gateway GatewayVersions `json:"gateway,omitempty"`
284318
VLAB VLABVersions `json:"vlab,omitempty"`
319+
LGTM LGTMVersions `json:"lgtm,omitempty"`
285320
}
286321

287322
type PlatformVersions struct {
@@ -468,6 +503,14 @@ func (f *Fabricator) Default() {
468503
}
469504
}
470505

506+
// Enable all LGTM subcomponents by default when LGTM is enabled
507+
if f.Spec.Config.LGTM.Enable {
508+
f.Spec.Config.LGTM.Grafana.Enabled = true
509+
f.Spec.Config.LGTM.Loki.Enabled = true
510+
f.Spec.Config.LGTM.Tempo.Enabled = true
511+
f.Spec.Config.LGTM.Prometheus.Enabled = true
512+
}
513+
471514
if f.Spec.Config.Observability.Targets.Prometheus == nil {
472515
f.Spec.Config.Observability.Targets.Prometheus = map[string]alloy.PrometheusTarget{}
473516
}

api/fabricator/v1beta1/zz_generated.deepcopy.go

Lines changed: 97 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/hhfab/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const (
5151
FlagIncludeCLS = "include-cls"
5252
FlagControlNodeMgmtLink = "control-node-mgmt-link"
5353
FlagGateway = "gateway"
54+
FlagObservability = "obs"
5455
FlagNameFabricMode = "fabric-mode"
5556
FlagNameCount = "count"
5657
FlagNameKillStale = "kill-stale"
@@ -556,6 +557,13 @@ func Run(ctx context.Context) error {
556557
Usage: "[PREVIEW] add and enable gateway node",
557558
EnvVars: []string{"HHFAB_GATEWAY"},
558559
},
560+
&cli.BoolFlag{
561+
Category: FlagCatGenConfig,
562+
Name: FlagObservability,
563+
Hidden: !preview,
564+
Usage: "[PREVIEW] add and enable observability node with LGTM stack (Loki, Grafana, Tempo, Prometheus)",
565+
EnvVars: []string{"HHFAB_OBS"},
566+
},
559567
}),
560568
Before: before(false),
561569
Action: func(c *cli.Context) error {
@@ -578,6 +586,7 @@ func Run(ctx context.Context) error {
578586
IncludeCLS: c.Bool(FlagIncludeCLS),
579587
ControlNodeManagementLink: c.String(FlagControlNodeMgmtLink),
580588
Gateway: c.Bool(FlagGateway),
589+
LGTM: c.Bool(FlagObservability),
581590
Preview: preview,
582591
JoinToken: joinToken,
583592
SaveJoinToken: saveJoinToken,

config/crd/bases/fabricator.githedgehog.com_fabnodes.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ spec:
6464
ip:
6565
type: string
6666
type: object
67+
external:
68+
properties:
69+
dns:
70+
items:
71+
type: string
72+
type: array
73+
gateway:
74+
type: string
75+
interface:
76+
type: string
77+
ip:
78+
type: string
79+
type: object
6780
management:
6881
properties:
6982
interface:

config/crd/bases/fabricator.githedgehog.com_fabricators.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,35 @@ spec:
416416
type: object
417417
type: object
418418
type: object
419+
lgtm:
420+
properties:
421+
enable:
422+
type: boolean
423+
grafana:
424+
properties:
425+
adminPassword:
426+
type: string
427+
adminUser:
428+
type: string
429+
enabled:
430+
type: boolean
431+
type: object
432+
loki:
433+
properties:
434+
enabled:
435+
type: boolean
436+
type: object
437+
prometheus:
438+
properties:
439+
enabled:
440+
type: boolean
441+
type: object
442+
tempo:
443+
properties:
444+
enabled:
445+
type: boolean
446+
type: object
447+
type: object
419448
observability:
420449
properties:
421450
targets:
@@ -552,6 +581,17 @@ spec:
552581
frr:
553582
type: string
554583
type: object
584+
lgtm:
585+
properties:
586+
grafana:
587+
type: string
588+
loki:
589+
type: string
590+
prometheus:
591+
type: string
592+
tempo:
593+
type: string
594+
type: object
555595
platform:
556596
properties:
557597
alloy:
@@ -772,6 +812,17 @@ spec:
772812
frr:
773813
type: string
774814
type: object
815+
lgtm:
816+
properties:
817+
grafana:
818+
type: string
819+
loki:
820+
type: string
821+
prometheus:
822+
type: string
823+
tempo:
824+
type: string
825+
type: object
775826
platform:
776827
properties:
777828
alloy:

0 commit comments

Comments
 (0)