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.
You must have Docker Engine installed to build the Splunk Operator.
This project uses Go modules,
and requires golang 1.17.3 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.15.0 https://github.com/operator-framework/operator-sdk
cd operator-sdk
make tidy
make install
You may need to add $GOPATH/bin
to you 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
git clone [email protected]:splunk/splunk-operator.git
cd splunk-operator
This repository consists of the following code used to build the splunk-operator binary:
main.go
: Provides the main() function, where everything beginsapis/
: Source code for the operator's custom resource definition typescontrollers/
: Used to register controllers that watch for changes to custom resourcespkg/splunk/enterprise/
: Source code for controllers that manage Splunk Enterprise resourcespkg/splunk/controller/
: Common code shared across Splunk controllerspkg/splunk/common/
: Common code used by most other splunk packagespkg/splunk/client/
: Simple client for Splunk Enterprise REST APIpkg/splunk/test/
: Common code used by other packages for unit testing
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:
tools
: Build scripts, templates, etc. used to build the container imageconfig
: Kubernetes YAML templates used to install the Splunk Operatordocs
: Getting Started Guide and other documentation in Markdown formattest
: Integration test framework built using Ginko. See docs for more info.
You can build the operator by just running make
.
Other make targets include (more info below):
make all
: buildsmanager
executablemake test
: Runs unit tests with Coveralls code coverage output to coverage.outmake scorecard
: Runs operator-sdk scorecard tests using OLM installation bundlemake generate
: runs operator-generate k8s, crds and csv commands, updating installation YAML files and OLM bundlemake docker-build
: generatessplunk-operator
container image examplemake docker-build IMG=docker.io/splunk/splunk-operator:1.1.0
make docker-push
: push docker image to given repository examplemake docker-push IMG=docker.io/splunk/splunk-operator:1.1.0
make clean
: removes the binary build output andsplunk-operator
container image examplemake docker-push IMG=docker.io/splunk/splunk-operator:1.1.0
make run
: runs the splunk operator locally, monitoring the Kubernetes cluster configured in your currentkubectl
contextmake fmt
: runsgo fmt
on all*.go
source files in this projectmake lint
: runs thegolint
utility on all*.go
source files in this projectmake bundle-build
: generatessplunk-operator-bundle
bundle container image for OLM examplemake bundle-build IMAGE_TAG_BASE=docker.io/splunk/splunk-operator VERSION=1.1.0 IMG=docker.io/splunk/splunk-operator:1.1.0
make bundle-push
: push OLM bundle docker image to given repository examplemake bundle-push IMAGE_TAG_BASE=docker.io/splunk/splunk-operator VERSION=1.1.0 IMG=docker.io/splunk/splunk-operator:1.1.0
make catalog-build
: generatessplunk-operator-catalog
catalog container image examplemake catalog-build IMAGE_TAG_BASE=docker.io/splunk/splunk-operator VERSION=1.1.0 IMG=docker.io/splunk/splunk-operator:1.1.0
make catalog-push
: push catalog docker image to given repository examplemake catalog-push IMAGE_TAG_BASE=docker.io/splunk/splunk-operator VERSION=1.1.0 IMG=docker.io/splunk/splunk-operator:1.1.0
Ensure that you have the Custom Resource Definitions and RBAC policies installed in your cluster:
make install
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.