Skip to content
Open
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"
70 changes: 70 additions & 0 deletions api/v4/kvservice_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
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.

const (
// KVServicePausedAnnotation is the annotation that pauses the reconciliation (triggers
// an immediate requeue)
KVServicePausedAnnotation = "kvservice.enterprise.splunk.com/paused"
)

// 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.

13 changes: 12 additions & 1 deletion 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 @@ -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.18.0
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: {}
2 changes: 2 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 Down Expand Up @@ -37,6 +38,7 @@ patchesStrategicMerge:
#- patches/cainjection_in_monitoringconsoles.yaml
#- patches/cainjection_in_searchheadclusters.yaml
#- patches/cainjection_in_standalones.yaml
#- path: patches/cainjection_in_kvservices.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
9 changes: 8 additions & 1 deletion config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ resources:
# More info: https://book.kubebuilder.io/reference/metrics.html
- metrics_auth_role.yaml
- metrics_auth_role_binding.yaml
- metrics_reader_role.yaml
- metrics_reader_role.yaml
# For each CRD, "Editor" and "Viewer" roles are scaffolded by
# default, aiding admins in cluster management. Those roles are
# not used by the Project itself. You can comment the following lines
# if you do not want those helpers be installed with your Project.
- kvservice_editor_role.yaml
- kvservice_viewer_role.yaml

27 changes: 27 additions & 0 deletions config/rbac/kvservice_editor_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# permissions for end users to edit kvservices.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the RBAC updates should be added to the helm chart as well in https://github.com/splunk/splunk-operator/tree/main/helm-chart/splunk-operator/templates/rbac.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rlieberman-splunk , thanks for taking a look. KVService CR is is internally created and managed by the SOK. i.e Customer will not manage it. In that case, do we need them for helm charts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we do. When customers deploy via helm charts, the operator will need the RBAC configurations on those systems as well to create and manage the CRs.

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: 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
23 changes: 23 additions & 0 deletions config/rbac/kvservice_viewer_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# permissions for end users to view kvservices.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: splunk-operator
app.kubernetes.io/managed-by: kustomize
name: kvservice-viewer-role
rules:
- apiGroups:
- enterprise.splunk.com
resources:
- kvservices
verbs:
- get
- list
- watch
- apiGroups:
- enterprise.splunk.com
resources:
- kvservices/status
verbs:
- get
3 changes: 3 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ rules:
- clustermanagers
- clustermasters
- indexerclusters
- kvservices
- licensemanagers
- licensemasters
- monitoringconsoles
Expand All @@ -69,6 +70,7 @@ rules:
- clustermanagers/finalizers
- clustermasters/finalizers
- indexerclusters/finalizers
- kvservices/finalizers
- licensemanagers/finalizers
- licensemasters/finalizers
- monitoringconsoles/finalizers
Expand All @@ -82,6 +84,7 @@ rules:
- clustermanagers/status
- clustermasters/status
- indexerclusters/status
- kvservices/status
- licensemanagers/status
- licensemasters/status
- monitoringconsoles/status
Expand Down
Loading
Loading