Skip to content

Commit 7edb81b

Browse files
committed
CSPL-4022 Introduce BusConfiguration CR
1 parent d21a9a3 commit 7edb81b

39 files changed

+1676
-531
lines changed

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,13 @@ resources:
122122
kind: IngestorCluster
123123
path: github.com/splunk/splunk-operator/api/v4
124124
version: v4
125+
- api:
126+
crdVersion: v1
127+
namespaced: true
128+
controller: true
129+
domain: splunk.com
130+
group: enterprise
131+
kind: BusConfiguration
132+
path: github.com/splunk/splunk-operator/api/v4
133+
version: v4
125134
version: "3"

api/v4/busconfiguration_types.go

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/*
2+
Copyright 2025.
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 v4
18+
19+
import (
20+
corev1 "k8s.io/api/core/v1"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
"k8s.io/apimachinery/pkg/runtime"
23+
)
24+
25+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
26+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
27+
28+
const (
29+
// BusConfigurationPausedAnnotation is the annotation that pauses the reconciliation (triggers
30+
// an immediate requeue)
31+
BusConfigurationPausedAnnotation = "busconfiguration.enterprise.splunk.com/paused"
32+
)
33+
34+
// BusConfigurationSpec defines the desired state of BusConfiguration
35+
type BusConfigurationSpec struct {
36+
Type string `json:"type"`
37+
38+
SQS SQSSpec `json:"sqs"`
39+
}
40+
41+
type SQSSpec struct {
42+
QueueName string `json:"queueName"`
43+
44+
AuthRegion string `json:"authRegion"`
45+
46+
Endpoint string `json:"endpoint"`
47+
48+
LargeMessageStoreEndpoint string `json:"largeMessageStoreEndpoint"`
49+
50+
LargeMessageStorePath string `json:"largeMessageStorePath"`
51+
52+
DeadLetterQueueName string `json:"deadLetterQueueName"`
53+
}
54+
55+
// BusConfigurationStatus defines the observed state of BusConfiguration.
56+
type BusConfigurationStatus struct {
57+
// Phase of the bus configuration
58+
Phase Phase `json:"phase"`
59+
60+
// Resource revision tracker
61+
ResourceRevMap map[string]string `json:"resourceRevMap"`
62+
63+
// Auxillary message describing CR status
64+
Message string `json:"message"`
65+
}
66+
67+
// +kubebuilder:object:root=true
68+
// +kubebuilder:subresource:status
69+
70+
// BusConfiguration is the Schema for a Splunk Enterprise bus configuration
71+
// +k8s:openapi-gen=true
72+
// +kubebuilder:subresource:status
73+
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector
74+
// +kubebuilder:resource:path=busconfigurations,scope=Namespaced,shortName=bus
75+
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase",description="Status of bus configuration"
76+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age of bus configuration resource"
77+
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message",description="Auxillary message describing CR status"
78+
// +kubebuilder:storageversion
79+
80+
// BusConfiguration is the Schema for the busconfigurations API
81+
type BusConfiguration struct {
82+
metav1.TypeMeta `json:",inline"`
83+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
84+
85+
Spec BusConfigurationSpec `json:"spec"`
86+
Status BusConfigurationStatus `json:"status,omitempty,omitzero"`
87+
}
88+
89+
// DeepCopyObject implements runtime.Object
90+
func (in *BusConfiguration) DeepCopyObject() runtime.Object {
91+
if c := in.DeepCopy(); c != nil {
92+
return c
93+
}
94+
return nil
95+
}
96+
97+
// +kubebuilder:object:root=true
98+
99+
// BusConfigurationList contains a list of BusConfiguration
100+
type BusConfigurationList struct {
101+
metav1.TypeMeta `json:",inline"`
102+
metav1.ListMeta `json:"metadata,omitempty"`
103+
Items []BusConfiguration `json:"items"`
104+
}
105+
106+
func init() {
107+
SchemeBuilder.Register(&BusConfiguration{}, &BusConfigurationList{})
108+
}
109+
110+
// NewEvent creates a new event associated with the object and ready
111+
// to be published to Kubernetes API
112+
func (bc *BusConfiguration) NewEvent(eventType, reason, message string) corev1.Event {
113+
t := metav1.Now()
114+
return corev1.Event{
115+
ObjectMeta: metav1.ObjectMeta{
116+
GenerateName: reason + "-",
117+
Namespace: bc.ObjectMeta.Namespace,
118+
},
119+
InvolvedObject: corev1.ObjectReference{
120+
Kind: "BusConfiguration",
121+
Namespace: bc.Namespace,
122+
Name: bc.Name,
123+
UID: bc.UID,
124+
APIVersion: GroupVersion.String(),
125+
},
126+
Reason: reason,
127+
Message: message,
128+
Source: corev1.EventSource{
129+
Component: "splunk-busconfiguration-controller",
130+
},
131+
FirstTimestamp: t,
132+
LastTimestamp: t,
133+
Count: 1,
134+
Type: eventType,
135+
ReportingController: "enterprise.splunk.com/busconfiguration-controller",
136+
}
137+
}

api/v4/indexercluster_types.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ const (
3838
type IndexerClusterSpec struct {
3939
CommonSplunkSpec `json:",inline"`
4040

41-
PullBus PushBusSpec `json:"pullBus,omitempty"`
41+
// Bus configuration reference
42+
BusConfigurationRef corev1.ObjectReference `json:"busConfigurationRef,omitempty"`
4243

4344
// Number of search head pods; a search head cluster will be created if > 1
4445
Replicas int32 `json:"replicas"`
@@ -111,11 +112,11 @@ type IndexerClusterStatus struct {
111112
// status of each indexer cluster peer
112113
Peers []IndexerClusterMemberStatus `json:"peers"`
113114

114-
// Pull Bus status
115-
PullBus PushBusSpec `json:"pullBus,omitempty"`
116-
117115
// Auxillary message describing CR status
118116
Message string `json:"message"`
117+
118+
// Bus configuration
119+
BusConfiguration BusConfigurationSpec `json:"busConfiguration,omitempty"`
119120
}
120121

121122
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

api/v4/ingestorcluster_types.go

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,8 @@ type IngestorClusterSpec struct {
4242
// Splunk Enterprise app repository that specifies remote app location and scope for Splunk app management
4343
AppFrameworkConfig AppFrameworkSpec `json:"appRepo,omitempty"`
4444

45-
// Push Bus spec
46-
PushBus PushBusSpec `json:"pushBus"`
47-
}
48-
49-
// Helper types
50-
// Only SQS as of now
51-
type PushBusSpec struct {
52-
Type string `json:"type"`
53-
54-
SQS SQSSpec `json:"sqs"`
55-
}
56-
57-
type SQSSpec struct {
58-
QueueName string `json:"queueName"`
59-
60-
AuthRegion string `json:"authRegion"`
61-
62-
Endpoint string `json:"endpoint"`
63-
64-
LargeMessageStoreEndpoint string `json:"largeMessageStoreEndpoint"`
65-
66-
LargeMessageStorePath string `json:"largeMessageStorePath"`
67-
68-
DeadLetterQueueName string `json:"deadLetterQueueName"`
45+
// Bus configuration reference
46+
BusConfigurationRef corev1.ObjectReference `json:"busConfigurationRef"`
6947
}
7048

7149
// IngestorClusterStatus defines the observed state of Ingestor Cluster
@@ -94,8 +72,8 @@ type IngestorClusterStatus struct {
9472
// Auxillary message describing CR status
9573
Message string `json:"message"`
9674

97-
// Push Bus status
98-
PushBus PushBusSpec `json:"pushBus"`
75+
// Bus configuration
76+
BusConfiguration BusConfigurationSpec `json:"busConfiguration,omitempty"`
9977
}
10078

10179
// +kubebuilder:object:root=true

api/v4/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)