Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: splunk.com
layout:
- go.kubebuilder.io/v4
multigroup: true
plugins:
manifests.sdk.operatorframework.io/v2: {}
scorecard.sdk.operatorframework.io/v2: {}
Expand Down Expand Up @@ -109,4 +114,12 @@ resources:
kind: LicenseManager
path: github.com/splunk/splunk-operator/api/v4
version: v4
- api:
crdVersion: v1
namespaced: true
controller: true
domain: splunk.com
kind: KVService
path: github.com/splunk/splunk-operator/api/v4
version: v4
version: "3"
92 changes: 92 additions & 0 deletions api/v4/kvservice_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
Copyright 2021.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v4

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// KVServiceSpec defines the desired state of KVService
type KVServiceSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// The following markers will use OpenAPI v3 schema to validate the value
// More info: https://book.kubebuilder.io/reference/markers/crd-validation.html

// foo is an example field of KVService. Edit kvservice_types.go to remove/update
// +optional
Foo *string `json:"foo,omitempty"`
}

// KVServiceStatus defines the observed state of KVService.
type KVServiceStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

// For Kubernetes API conventions, see:
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties

// conditions represent the current state of the KVService resource.
// Each condition has a unique type and reflects the status of a specific aspect of the resource.
//
// Standard condition types include:
// - "Available": the resource is fully functional
// - "Progressing": the resource is being created or updated
// - "Degraded": the resource failed to reach or maintain its desired state
//
// The status of each condition is one of True, False, or Unknown.
// +listType=map
// +listMapKey=type
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// KVService is the Schema for the kvservices API
type KVService struct {
metav1.TypeMeta `json:",inline"`

// metadata is a standard object metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitzero"`

// spec defines the desired state of KVService
// +required
Spec KVServiceSpec `json:"spec"`

// status defines the observed state of KVService
// +optional
Status KVServiceStatus `json:"status,omitzero"`
}

// +kubebuilder:object:root=true

// KVServiceList contains a list of KVService
type KVServiceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitzero"`
Items []KVService `json:"items"`
}

func init() {
SchemeBuilder.Register(&KVService{}, &KVServiceList{})
}
102 changes: 102 additions & 0 deletions api/v4/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import (
"os"
"time"

"sigs.k8s.io/controller-runtime/pkg/metrics/filters"

intController "github.com/splunk/splunk-operator/internal/controller"
"github.com/splunk/splunk-operator/internal/controller/debug"
"github.com/splunk/splunk-operator/pkg/config"
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
Expand All @@ -47,6 +48,8 @@ import (

enterpriseApiV3 "github.com/splunk/splunk-operator/api/v3"
enterpriseApi "github.com/splunk/splunk-operator/api/v4"
splunkcomv4 "github.com/splunk/splunk-operator/api/v4"
"github.com/splunk/splunk-operator/internal/controller"
//+kubebuilder:scaffold:imports
//extapi "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
)
Expand All @@ -60,6 +63,7 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(enterpriseApi.AddToScheme(scheme))
utilruntime.Must(enterpriseApiV3.AddToScheme(scheme))
utilruntime.Must(splunkcomv4.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
//utilruntime.Must(extapi.AddToScheme(scheme))
}
Expand Down Expand Up @@ -107,11 +111,11 @@ func main() {
// as certificates issued by a trusted Certificate Authority (CA). The primary risk is potentially allowing
// unauthorized access to sensitive metrics data. Consider replacing with CertDir, CertName, and KeyName
// to provide certificates, ensuring the server communicates using trusted and secure certificates.
TLSOpts: tlsOpts,
TLSOpts: tlsOpts,
FilterProvider: filters.WithAuthenticationAndAuthorization,
}

// TODO: enable https for /metrics endpoint by default
// TODO: enable https for /metrics endpoint by default
// if secureMetrics {
// // FilterProvider is used to protect the metrics endpoint with authn/authz.
// // These configurations ensure that only authorized users and service accounts
Expand Down Expand Up @@ -221,6 +225,13 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Standalone")
os.Exit(1)
}
if err := (&controller.KVServiceReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "KVService")
os.Exit(1)
}
//+kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Expand Down
Loading
Loading