Skip to content

Commit 046259e

Browse files
committed
add-config
Signed-off-by: Andreas Karis <[email protected]>
1 parent e992dca commit 046259e

File tree

3 files changed

+237
-0
lines changed

3 files changed

+237
-0
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
Copyright 2023 The bpfman Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// +genclient
24+
// +genclient:nonNamespaced
25+
// +kubebuilder:object:root=true
26+
// +kubebuilder:subresource:status
27+
// +kubebuilder:resource:scope=Cluster
28+
29+
// Config holds the configuration for bpfman-operator.
30+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
31+
// +kubebuilder:printcolumn:name="Progressing",type="string",JSONPath=".status.conditions[?(@.type=='Progressing')].status"
32+
// +kubebuilder:printcolumn:name="Available",type="string",JSONPath=".status.conditions[?(@.type=='Available')].status"
33+
type Config struct {
34+
metav1.TypeMeta `json:",inline"`
35+
metav1.ObjectMeta `json:"metadata,omitempty"`
36+
37+
Spec ConfigSpec `json:"spec,omitempty"`
38+
Status ConfigStatus `json:"status,omitempty"`
39+
}
40+
41+
// spec defines the desired state of the bpfman-operator.
42+
type ConfigSpec struct {
43+
// agent specifies the configuration for the bpfman agent DaemonSet.
44+
// +required
45+
Agent AgentSpec `json:"agent"`
46+
// configuration specifies the content of bpfman.toml configuration file used by the bpfman DaemonSet.
47+
// +required
48+
// +kubebuilder:validation:MinLength=1
49+
Configuration string `json:"configuration"`
50+
// image specifies the container image for the bpfman DaemonSet.
51+
// +required
52+
// +kubebuilder:validation:MinLength=1
53+
Image string `json:"image"`
54+
// logLevel specifies the log level for the bpfman DaemonSet via the RUST_LOG environment variable.
55+
// The RUST_LOG environment variable controls logging with the syntax: RUST_LOG=[target][=][level][,...].
56+
// For further information, see https://docs.rs/env_logger/latest/env_logger/.
57+
// +optional
58+
LogLevel string `json:"logLevel,omitempty"`
59+
// namespace specifies the namespace where bpfman-operator resources will be deployed.
60+
// If not specified, resources will be deployed in the default bpfman namespace.
61+
// +optional
62+
Namespace string `json:"namespace,omitempty"`
63+
}
64+
65+
// AgentSpec defines the desired state of the bpfman agent.
66+
type AgentSpec struct {
67+
// healthProbePort specifies the port on which the bpfman agent's health probe endpoint will listen.
68+
// If unspecified, the default port will be used.
69+
// +optional
70+
// +kubebuilder:validation:Minimum=0
71+
// +kubebuilder:validation:Maximum=65535
72+
HealthProbePort int32 `json:"healthProbePort,omitempty"`
73+
// image specifies the container image for the bpfman agent DaemonSet.
74+
// +required
75+
Image string `json:"image"`
76+
// logLevel specifies the verbosity of logs produced by the bpfman agent.
77+
// Valid values are: "", "info", "debug", "trace".
78+
// +optional
79+
// +kubebuilder:validation:Enum="";info;debug;trace
80+
LogLevel string `json:"logLevel,omitempty"`
81+
}
82+
83+
// status reflects the status of the bpfman-operator configuration.
84+
type ConfigStatus struct {
85+
// conditions represents the current state conditions of the bpfman-operator and its components.
86+
// +patchMergeKey=type
87+
// +patchStrategy=merge
88+
// +listType=map
89+
// +listMapKey=type
90+
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
91+
92+
// components represents the operational status of each individual bpfman-operator component such as the deployed
93+
// DaemonSets.
94+
// +optional
95+
Components map[string]ConfigComponentStatus `json:"components,omitempty"`
96+
}
97+
98+
// +kubebuilder:object:root=true
99+
// ConfigList contains a list of Configs.
100+
type ConfigList struct {
101+
metav1.TypeMeta `json:",inline"`
102+
metav1.ListMeta `json:"metadata,omitempty"`
103+
Items []Config `json:"items"`
104+
}
105+
106+
// ConfigComponentStatus holds the status of a single Config component.
107+
type ConfigComponentStatus string
108+
109+
const (
110+
// ConfigStatusUnknown indicates the component state cannot be determined.
111+
ConfigStatusUnknown ConfigComponentStatus = "Unknown"
112+
// ConfigStatusProgressing indicates the component is being updated or reconciled.
113+
ConfigStatusProgressing ConfigComponentStatus = "Progressing"
114+
// ConfigStatusReady indicates the component is fully operational and ready.
115+
ConfigStatusReady ConfigComponentStatus = "Ready"
116+
)

bpfman-operator/apis/v1alpha1/zz_generated.deepcopy.go

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

bpfman-operator/apis/v1alpha1/zz_generated.register.go

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

0 commit comments

Comments
 (0)