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
102 changes: 95 additions & 7 deletions api/v4/kvservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v4

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

Expand All @@ -29,19 +30,77 @@ const (
KVServicePausedAnnotation = "kvservice.enterprise.splunk.com/paused"
)

// KVServiceSpec defines the desired state of KVService
// CommonSplunkSpec defines the desired state of parameters that are common across all Splunk Enterprise CRD types
type KVServiceSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
Spec `json:",inline"`

// Foo is an example field of KVService. Edit kvservice_types.go to remove/update
Foo string `json:"foo,omitempty"`
// List of one or more Kubernetes volumes. These will be mounted in all pod containers as as /mnt/<name>
Volumes []corev1.Volume `json:"volumes"`

// Inline map of default.yml overrides used to initialize the environment
Defaults string `json:"defaults"`

// Full path or URL for one or more default.yml files, separated by commas
DefaultsURL string `json:"defaultsUrl"`

// Full path or URL for a Splunk Enterprise license file
LicenseURL string `json:"licenseUrl"`

// Mock to differentiate between UTs and actual reconcile
Mock bool `json:"Mock"`

// ServiceAccount is the service account used by the pods deployed by the CRD.
// If not specified uses the default serviceAccount for the namespace as per
// https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#use-the-default-service-account-to-access-the-api-server
ServiceAccount string `json:"serviceAccount"`

// ExtraEnv refers to extra environment variables to be passed to the Splunk instance containers
// WARNING: Setting environment variables used by Splunk or Ansible will affect Splunk installation and operation
ExtraEnv []corev1.EnvVar `json:"extraEnv,omitempty"`

// ReadinessInitialDelaySeconds defines initialDelaySeconds(See https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes) for Readiness probe
// Note: If needed, Operator overrides with a higher value
// +kubebuilder:validation:Minimum=0
ReadinessInitialDelaySeconds int32 `json:"readinessInitialDelaySeconds"`

// LivenessInitialDelaySeconds defines initialDelaySeconds(See https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-liveness-command) for the Liveness probe
// Note: If needed, Operator overrides with a higher value
// +kubebuilder:validation:Minimum=0
LivenessInitialDelaySeconds int32 `json:"livenessInitialDelaySeconds"`

// LivenessProbe as defined in https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-liveness-command
LivenessProbe *Probe `json:"livenessProbe,omitempty"`

// ReadinessProbe as defined in https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes
ReadinessProbe *Probe `json:"readinessProbe,omitempty"`

// Sets imagePullSecrets if image is being pulled from a private registry.
// See https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`

// Number of standalone pods
Replicas int32 `json:"replicas"`
}

// 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
// current phase of the standalone instances
Phase Phase `json:"phase"`

// number of desired standalone instances
Replicas int32 `json:"replicas"`

// current number of ready standalone instances
ReadyReplicas int32 `json:"readyReplicas"`

// selector for pods, used by HorizontalPodAutoscaler
Selector string `json:"selector"`

// Resource Revision tracker
ResourceRevMap map[string]string `json:"resourceRevMap"`

// Auxillary message describing CR status
Message string `json:"message"`
}

// +kubebuilder:object:root=true
Expand All @@ -68,3 +127,32 @@ type KVServiceList struct {
func init() {
SchemeBuilder.Register(&KVService{}, &KVServiceList{})
}

// NewEvent creates a new event associated with the object and ready
// to be published to the kubernetes API.
func (kvs *KVService) NewEvent(eventType, reason, message string) corev1.Event {
t := metav1.Now()
return corev1.Event{
ObjectMeta: metav1.ObjectMeta{
GenerateName: reason + "-",
Namespace: kvs.ObjectMeta.Namespace,
},
InvolvedObject: corev1.ObjectReference{
Kind: "KVService",
Namespace: kvs.Namespace,
Name: kvs.Name,
UID: kvs.UID,
APIVersion: GroupVersion.String(),
},
Reason: reason,
Message: message,
Source: corev1.EventSource{
Component: "splunk-standalone-controller",
},
FirstTimestamp: t,
LastTimestamp: t,
Count: 1,
Type: eventType,
ReportingController: "enterprise.splunk.com/standalone-controller",
}
}
41 changes: 39 additions & 2 deletions api/v4/zz_generated.deepcopy.go

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

Loading
Loading