splunk / splunk-operator

Splunk Operator for Kubernetes
Other
210 stars 115 forks source link

Splunk Operator for Kubernetes

License PkgGoDev Go Report Card CircleCI Coverage Status FOSSA Status

The Splunk Operator for Kubernetes (SOK) makes it easy for Splunk Administrators to deploy and operate Enterprise deployments in a Kubernetes infrastructure. Packaged as a container, it uses the operator pattern to manage Splunk-specific custom resources, following best practices to manage all the underlying Kubernetes objects for you.

This repository is used to build the Splunk Operator for Kubernetes (SOK). If you are just looking for documentation on how to deploy and use the latest release, please see the Getting Started Documentation.

Prerequisites

You must have Docker Engine installed to build the Splunk Operator.

This project uses Go modules, and requires golang 1.23.0 or later. You must export GO111MODULE=on if cloning these repositories into your $GOPATH (not recommended).

The Kubernetes Operator SDK must also be installed to build this project.

git clone -b v1.31.0 https://github.com/operator-framework/operator-sdk
cd operator-sdk
make tidy
make install

You may need to add $GOPATH/bin to your path to run the operator-sdk command line tool:

export PATH=${PATH}:${GOPATH}/bin

It is also recommended that you install the following golang tools, which are used by various make targets:

go install golang.org/x/lint/golint
go install golang.org/x/tools/cmd/cover
go install github.com/mattn/goveralls
go get -u github.com/mikefarah/yq/v3
go get -u github.com/go-delve/delve/cmd/dlv

Cloning this repository

git clone git@github.com:splunk/splunk-operator.git
cd splunk-operator

Repository overview

This repository consists of the following code used to build the splunk-operator binary:

main() uses controllers to register all the enterprise controllers that manage custom resources by watching for Kubernetes events. The enterprise controllers are implemented using common code provided by the controllers package. The enterprise controllers also use the REST API client provided in the pkg/splunk/client package. The types provided by apis/ and common code in the pkg/splunk/common/ package are used universally. Note that the source code for main() is generated from a template provided by the Operator SDK.

In addition to the source code, this repository includes:

Building the operator

You can build the operator by just running make.

Other make targets include (more info below):

Deploying the Splunk Operator

make deploy command will deploy all the necessary resources to run Splunk Operator like RBAC policies, services, configmaps, deployment. Operator will be installed in splunk-operator namespace. If splunk-operator namespace does not exist, it will create the namespace. By default make deploy will install operator clusterwide. Operator will watch all the namespaces for any splunk enterprise custom resources.

make deploy IMG=docker.io/splunk/splunk-operator:<tag name>

If you want operator for specific namespace then you must pass WATCH_NAMESPACE parameter to make deploy command

make deploy IMG=docker.io/splunk/splunk-operator:<tag name> WATCH_NAMESPACE="namespace1"

If you want operator to use specific version of splunk instance, then you must pass RELATED_IMAGE_SPLUNK_ENTERPRISE parameter to make deploy command

make deploy IMG=docker.io/splunk/splunk-operator:<tag name> WATCH_NAMESPACE="namespace1" RELATED_IMAGE_SPLUNK_ENTERPRISE="splunk/splunk:edge"

Use this to run the operator as a local foreground process on your machine:

make run

This will use your current Kubernetes context from ~/.kube/config to manage resources in your current namespace.

Please see the Getting Started Documentation for more information, including instructions on how to install the operator in your cluster.

License

FOSSA Status