Skip to content
Closed
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,3 +1,7 @@
# 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
Expand Down Expand Up @@ -109,4 +113,13 @@ resources:
kind: LicenseManager
path: github.com/splunk/splunk-operator/api/v4
version: v4
- api:
crdVersion: v1
namespaced: true
controller: true
domain: splunk.com
group: enterprise
kind: KVService
path: github.com/splunk/splunk-operator/api/v4
version: v4
version: "3"
1 change: 1 addition & 0 deletions PROJECT.multigroup
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
multigroup: true
64 changes: 64 additions & 0 deletions api/v4/kvservice_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
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

// Foo is an example field of KVService. Edit kvservice_types.go to remove/update
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
}

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

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

Spec KVServiceSpec `json:"spec,omitempty"`
Status KVServiceStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&KVService{}, &KVServiceList{})
}
89 changes: 89 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"
enterprisev4 "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(enterprisev4.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
54 changes: 54 additions & 0 deletions config/crd/bases/enterprise.splunk.com_kvservices.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.1
name: kvservices.enterprise.splunk.com
spec:
group: enterprise.splunk.com
names:
kind: KVService
listKind: KVServiceList
plural: kvservices
singular: kvservice
scope: Namespaced
versions:
- name: v4
schema:
openAPIV3Schema:
description: KVService is the Schema for the kvservices API
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: KVServiceSpec defines the desired state of KVService
properties:
foo:
description: Foo is an example field of KVService. Edit kvservice_types.go
to remove/update
type: string
type: object
status:
description: KVServiceStatus defines the observed state of KVService
type: object
type: object
served: true
storage: true
subresources:
status: {}
3 changes: 3 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ resources:
- bases/enterprise.splunk.com_monitoringconsoles.yaml
- bases/enterprise.splunk.com_searchheadclusters.yaml
- bases/enterprise.splunk.com_standalones.yaml
- bases/enterprise.splunk.com_kvservices.yaml
#+kubebuilder:scaffold:crdkustomizeresource


Expand All @@ -25,6 +26,7 @@ patchesStrategicMerge:
#- patches/webhook_in_monitoringconsoles.yaml
#- patches/webhook_in_searchheadclusters.yaml
#- patches/webhook_in_standalones.yaml
#- patches/webhook_in_kvservices.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
Expand All @@ -37,6 +39,7 @@ patchesStrategicMerge:
#- patches/cainjection_in_monitoringconsoles.yaml
#- patches/cainjection_in_searchheadclusters.yaml
#- patches/cainjection_in_standalones.yaml
#- patches/cainjection_in_kvservices.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
7 changes: 7 additions & 0 deletions config/crd/patches/cainjection_in_kvservices.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME
name: kvservices.enterprise.splunk.com
16 changes: 16 additions & 0 deletions config/crd/patches/webhook_in_kvservices.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The following patch enables a conversion webhook for the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: kvservices.enterprise.splunk.com
spec:
conversion:
strategy: Webhook
webhook:
clientConfig:
service:
namespace: system
name: webhook-service
path: /convert
conversionReviewVersions:
- v1
31 changes: 31 additions & 0 deletions config/rbac/kvservice_editor_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# permissions for end users to edit kvservices.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: kvservice-editor-role
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: splunk-operator
app.kubernetes.io/part-of: splunk-operator
app.kubernetes.io/managed-by: kustomize
name: kvservice-editor-role
rules:
- apiGroups:
- enterprise.splunk.com
resources:
- kvservices
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- enterprise.splunk.com
resources:
- kvservices/status
verbs:
- get
Loading
Loading