Skip to content

Commit 7d46274

Browse files
Add Syslog resource and controller
1 parent 41d3355 commit 7d46274

24 files changed

+1164
-281
lines changed

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,13 @@ resources:
9191
kind: SNMP
9292
path: github.com/ironcore-dev/network-operator/api/v1alpha1
9393
version: v1alpha1
94+
- api:
95+
crdVersion: v1
96+
namespaced: true
97+
controller: true
98+
domain: cloud.sap
99+
group: networking
100+
kind: Syslog
101+
path: github.com/ironcore-dev/network-operator/api/v1alpha1
102+
version: v1alpha1
94103
version: "3"

Tiltfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ k8s_resource(new_name='trustpoint', objects=['network-operator:issuer', 'network
5555
k8s_yaml('./config/samples/v1alpha1_snmp.yaml')
5656
k8s_resource(new_name='snmp', objects=['snmp:snmp'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
5757

58+
k8s_yaml('./config/samples/v1alpha1_syslog.yaml')
59+
k8s_resource(new_name='syslog', objects=['syslog:syslog'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
60+
5861
print('🚀 network-operator development environment')
5962
print('👉 Edit the code inside the api/, cmd/, or internal/ directories')
6063
print('👉 Tilt will automatically rebuild and redeploy when changes are detected')

api/v1alpha1/device_types.go

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ type DeviceSpec struct {
1919
// +optional
2020
Bootstrap *Bootstrap `json:"bootstrap,omitempty"`
2121

22-
// Top-level logging configuration for the device.
23-
// +optional
24-
Logging *Logging `json:"logging,omitempty"`
25-
2622
// Configuration for the gRPC server on the device.
2723
// Currently, only a single "default" gRPC server is supported.
2824
// +optional
@@ -63,63 +59,6 @@ type Bootstrap struct {
6359
Template *TemplateSource `json:"template"`
6460
}
6561

66-
type Logging struct {
67-
// Servers is a list of remote log servers to which the device will send logs.
68-
// +kubebuilder:validation:MinItems=1
69-
// +required
70-
Servers []*LogServer `json:"servers"`
71-
72-
// Facilities is a list of log facilities to configure on the device.
73-
// +kubebuilder:validation:MinItems=1
74-
// +required
75-
Facilities []*LogFacility `json:"facilities"`
76-
}
77-
78-
type LogServer struct {
79-
// IP address or hostname of the remote log server
80-
// +required
81-
Address string `json:"address"`
82-
83-
// The servity level of the log messages sent to the server.
84-
// +required
85-
Severity Severity `json:"severity"`
86-
87-
// The network instance used to reach the log server.
88-
// +required
89-
NetworkInstance string `json:"networkInstance,omitempty"`
90-
91-
// The destination port number for syslog UDP messages to
92-
// the server. The default is 514.
93-
// +kubebuilder:default=514
94-
// +optional
95-
Port int64 `json:"port"`
96-
}
97-
98-
type LogFacility struct {
99-
// The name of the log facility.
100-
// +required
101-
Name string `json:"name"`
102-
103-
// The severity level of the log messages for this facility.
104-
// +required
105-
Severity Severity `json:"severity"`
106-
}
107-
108-
// Severity represents the severity level of a log message.
109-
// +kubebuilder:validation:Enum=Debug;Info;Notice;Warning;Error;Critical;Alert;Emergency
110-
type Severity string
111-
112-
const (
113-
SeverityDebug Severity = "Debug"
114-
SeverityInfo Severity = "Info"
115-
SeverityNotice Severity = "Notice"
116-
SeverityWarning Severity = "Warning"
117-
SeverityError Severity = "Error"
118-
SeverityCritical Severity = "Critical"
119-
SeverityAlert Severity = "Alert"
120-
SeverityEmergency Severity = "Emergency"
121-
)
122-
12362
type GRPC struct {
12463
// The TCP port on which the gRPC server should listen.
12564
// The range of port-id is from 1024 to 65535.

api/v1alpha1/syslog_types.go

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package v1alpha1
5+
6+
import (
7+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
8+
)
9+
10+
// SyslogSpec defines the desired state of Syslog
11+
type SyslogSpec struct {
12+
// DeviceName is the name of the Device this object belongs to. The Device object must exist in the same namespace.
13+
// Immutable.
14+
// +required
15+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="DeviceRef is immutable"
16+
DeviceRef LocalObjectReference `json:"deviceRef"`
17+
18+
// ProviderConfigRef is a reference to a resource holding the provider-specific configuration of this interface.
19+
// This reference is used to link the Interface to its provider-specific configuration.
20+
// +optional
21+
ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"`
22+
23+
// Servers is a list of remote log servers to which the device will send logs.
24+
// +required
25+
// +kubebuilder:validation:MinItems=1
26+
// +kubebuilder:validation:MaxItems=16
27+
Servers []LogServer `json:"servers"`
28+
29+
// Facilities is a list of log facilities to configure on the device.
30+
// +required
31+
// +kubebuilder:validation:MinItems=1
32+
// +kubebuilder:validation:MaxItems=64
33+
Facilities []LogFacility `json:"facilities"`
34+
}
35+
36+
type LogServer struct {
37+
// IP address or hostname of the remote log server
38+
// +required
39+
// +kubebuilder:validation:MinLength=1
40+
// +kubebuilder:validation:MaxLength=253
41+
Address string `json:"address"`
42+
43+
// The servity level of the log messages sent to the server.
44+
// +required
45+
Severity Severity `json:"severity"`
46+
47+
// The name of the vrf used to reach the log server.
48+
// +required
49+
// +kubebuilder:validation:MinLength=1
50+
// +kubebuilder:validation:MaxLength=63
51+
VrfName string `json:"vrfName"`
52+
53+
// The destination port number for syslog UDP messages to
54+
// the server. The default is 514.
55+
// +optional
56+
// +kubebuilder:default=514
57+
Port int32 `json:"port"`
58+
}
59+
60+
type LogFacility struct {
61+
// The name of the log facility.
62+
// +required
63+
// +kubebuilder:validation:MinLength=1
64+
// +kubebuilder:validation:MaxLength=63
65+
Name string `json:"name"`
66+
67+
// The severity level of the log messages for this facility.
68+
// +required
69+
Severity Severity `json:"severity"`
70+
}
71+
72+
// Severity represents the severity level of a log message.
73+
// +kubebuilder:validation:Enum=Debug;Info;Notice;Warning;Error;Critical;Alert;Emergency
74+
type Severity string
75+
76+
const (
77+
SeverityDebug Severity = "Debug"
78+
SeverityInfo Severity = "Info"
79+
SeverityNotice Severity = "Notice"
80+
SeverityWarning Severity = "Warning"
81+
SeverityError Severity = "Error"
82+
SeverityCritical Severity = "Critical"
83+
SeverityAlert Severity = "Alert"
84+
SeverityEmergency Severity = "Emergency"
85+
)
86+
87+
// SyslogStatus defines the observed state of Syslog.
88+
type SyslogStatus struct {
89+
// The conditions are a list of status objects that describe the state of the Banner.
90+
//+listType=map
91+
//+listMapKey=type
92+
//+patchStrategy=merge
93+
//+patchMergeKey=type
94+
//+optional
95+
Conditions []metav1.Condition `json:"conditions,omitempty"`
96+
}
97+
98+
// +kubebuilder:object:root=true
99+
// +kubebuilder:subresource:status
100+
// +kubebuilder:printcolumn:name="Device",type=string,JSONPath=`.spec.deviceName`
101+
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
102+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
103+
104+
// Syslog is the Schema for the syslogs API
105+
type Syslog struct {
106+
metav1.TypeMeta `json:",inline"`
107+
metav1.ObjectMeta `json:"metadata,omitempty"`
108+
109+
// Specification of the desired state of the resource.
110+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
111+
// +required
112+
Spec SyslogSpec `json:"spec,omitempty"`
113+
114+
// Status of the resource. This is set and updated automatically.
115+
// Read-only.
116+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
117+
// +optional
118+
Status SyslogStatus `json:"status,omitempty,omitzero"`
119+
}
120+
121+
// +kubebuilder:object:root=true
122+
123+
// SyslogList contains a list of Syslog
124+
type SyslogList struct {
125+
metav1.TypeMeta `json:",inline"`
126+
metav1.ListMeta `json:"metadata,omitempty"`
127+
Items []Syslog `json:"items"`
128+
}
129+
130+
func init() {
131+
SchemeBuilder.Register(&Syslog{}, &SyslogList{})
132+
}

0 commit comments

Comments
 (0)