Skip to content
Merged
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
48 changes: 33 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

.PHONY: all builder builder-image image package local clean run fmt lint

all: builder builder-image
all: image

builder: deploy/all-in-one-scoped.yaml deploy/all-in-one-cluster.yaml
builder:
@echo Creating container image to build splunk-operator
@docker build -f ./build/Dockerfile.builder -t splunk/splunk-operator-builder .

Expand All @@ -15,22 +15,48 @@ builder-image:

builder-test:
@echo Running unit tests for splunk-operator inside of builder container
@docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${PWD}:/opt/app-root/src/splunk-operator -w /opt/app-root/src/splunk-operator -u root -it splunk/splunk-operator-builder bash -c "go test -v -covermode=count -coverprofile=coverage.out --timeout=300s github.com/splunk/splunk-operator/pkg/splunk/resources github.com/splunk/splunk-operator/pkg/splunk/spark github.com/splunk/splunk-operator/pkg/splunk/enterprise github.com/splunk/splunk-operator/pkg/splunk/deploy"
@docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${PWD}:/opt/app-root/src/splunk-operator -w /opt/app-root/src/splunk-operator -u root -it splunk/splunk-operator-builder bash -c "go test -v -covermode=count -coverprofile=coverage.out --timeout=300s github.com/splunk/splunk-operator/pkg/splunk/resources github.com/splunk/splunk-operator/pkg/splunk/spark github.com/splunk/splunk-operator/pkg/splunk/enterprise github.com/splunk/splunk-operator/pkg/splunk/reconcile"

image: deploy/all-in-one-scoped.yaml deploy/all-in-one-cluster.yaml
image:
@echo Building splunk-operator image
@operator-sdk build --verbose splunk/splunk-operator

local: deploy/all-in-one-scoped.yaml deploy/all-in-one-cluster.yaml
local:
@echo Building splunk-operator-local binary only
@mkdir -p ./build/_output/bin
@go build -v -o ./build/_output/bin/splunk-operator-local ./cmd/manager

test:
@echo Running unit tests for splunk-operator
@go test -v -covermode=count -coverprofile=coverage.out --timeout=300s github.com/splunk/splunk-operator/pkg/splunk/resources github.com/splunk/splunk-operator/pkg/splunk/spark github.com/splunk/splunk-operator/pkg/splunk/enterprise github.com/splunk/splunk-operator/pkg/splunk/deploy
@go test -v -covermode=count -coverprofile=coverage.out --timeout=300s github.com/splunk/splunk-operator/pkg/splunk/resources github.com/splunk/splunk-operator/pkg/splunk/spark github.com/splunk/splunk-operator/pkg/splunk/enterprise github.com/splunk/splunk-operator/pkg/splunk/reconcile

package: deploy/all-in-one-scoped.yaml deploy/all-in-one-cluster.yaml
generate:
@echo Running operator-sdk generate k8s
@operator-sdk generate k8s
@echo Running operator-sdk generate crds
@cp deploy/rbac.yaml deploy/role.yaml
@operator-sdk generate crds
@rm -f deploy/role.yaml deploy/crds/*_cr.yaml
@echo " - name: v1alpha1\n served: true\n storage: false" >> deploy/crds/enterprise.splunk.com_splunkenterprises_crd.yaml
@echo Rebuilding deploy/crds/combined.yaml
@echo "---" > deploy/crds/combined.yaml
@cat deploy/crds/enterprise.splunk.com_splunkenterprises_crd.yaml >> deploy/crds/combined.yaml
@echo "---" >> deploy/crds/combined.yaml
@cat deploy/crds/enterprise.splunk.com_standalones_crd.yaml >> deploy/crds/combined.yaml
@echo "---" >> deploy/crds/combined.yaml
@cat deploy/crds/enterprise.splunk.com_licensemasters_crd.yaml >> deploy/crds/combined.yaml
@echo "---" >> deploy/crds/combined.yaml
@cat deploy/crds/enterprise.splunk.com_searchheads_crd.yaml >> deploy/crds/combined.yaml
@echo "---" >> deploy/crds/combined.yaml
@cat deploy/crds/enterprise.splunk.com_indexers_crd.yaml >> deploy/crds/combined.yaml
@echo "---" >> deploy/crds/combined.yaml
@cat deploy/crds/enterprise.splunk.com_sparks_crd.yaml >> deploy/crds/combined.yaml
@echo Rebuilding deploy/all-in-one-scoped.yaml
@cat deploy/crds/combined.yaml deploy/rbac.yaml deploy/operator.yaml > deploy/all-in-one-scoped.yaml
@echo Rebuilding deploy/all-in-one-cluster.yaml
@cat deploy/crds/combined.yaml deploy/rbac.yaml deploy/cluster_operator.yaml > deploy/all-in-one-cluster.yaml

package: lint fmt generate
@build/package.sh

clean:
Expand All @@ -45,11 +71,3 @@ fmt:

lint:
@golint ./...

deploy/all-in-one-scoped.yaml: deploy/crds/enterprise.splunk.com_splunkenterprises_crd.yaml deploy/rbac.yaml deploy/operator.yaml
@echo Rebuilding deploy/all-in-one-scoped.yaml
@cat deploy/crds/enterprise.splunk.com_splunkenterprises_crd.yaml deploy/rbac.yaml deploy/operator.yaml > deploy/all-in-one-scoped.yaml

deploy/all-in-one-cluster.yaml: deploy/crds/enterprise.splunk.com_splunkenterprises_crd.yaml deploy/rbac.yaml deploy/cluster_operator.yaml
@echo Rebuilding deploy/all-in-one-cluster.yaml
@cat deploy/crds/enterprise.splunk.com_splunkenterprises_crd.yaml deploy/rbac.yaml deploy/cluster_operator.yaml > deploy/all-in-one-cluster.yaml
40 changes: 33 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,47 @@ cd splunk-operator
```


## Repository overview

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

* `cmd/manager/main.go`: Provides the main() function, where everything begins
* `pkg/apis/`: Source code for the operator's custom resource definition types
* `pkg/controllers/`: Source code for CRD controllers that watch for changes
* `pkg/splunk/reconcile/`: Source code the controllers use to interact with Kubernetes APIs
* `pkg/splunk/enterprise/`: Source code for managing Splunk Enterprise deployments
* `pkg/splunk/spark/`: Source code for managing Spark cluster deployments
* `pkg/splunk/resources/`: Generic utility code used by other splunk modules

`main()` basically just instantiates the `controllers`, and the `controllers` call
into the `reconcile` module to perform actions. The `reconcile` module uses the `enterprise`
and `spark` modules. The types provided by `pkg/apis/` and generic utility code in
`pkg/splunk/resources/` are used universally. Note that the source code for `main()`,
`pkg/apis` and `pkg/controllers` are all generated from templates provided by the
Operator SDK.

In addition to the source code, this repository includes:

* `build`: Build scripts, templates, etc. used to build the container image
* `deploy`: Kubernetes YAML templates used to install the Splunk Operator
* `docs`: Getting Started Guide and other documentation in Markdown format


## Building the operator

You can build the operator by just running `make`.

Other make targets include (more info below):

* `make all`: builds `splunk/splunk-operator` using the `splunk/splunk-operator-builder` image (same as `make builder builder-image`)
* `make builder`: builds the `splunk/splunk-operator-builder` docker image
* `make all`: builds `splunk/splunk-operator` container image (same as `make image`)
* `make builder`: builds the `splunk/splunk-operator-builder` container image
* `make builder-image`: builds `splunk/splunk-operator` using the `splunk/splunk-operator-builder` image
* `make builder-test`: Runs unit tests using the `splunk/splunk-operator-builder` image
* `make image`: builds the `splunk/splunk-operator` docker image without using `splunk/splunk-operator-builder`
* `make image`: builds the `splunk/splunk-operator` container image without using `splunk/splunk-operator-builder`
* `make local`: builds the splunk-operator-local binary for test and debugging purposes
* `make test`: Runs unit tests with Coveralls code coverage output to coverage.out
* `make package`: generates tarball of the `splunk/splunk-operator` docker image and installation YAML file
* `make generate`: runs operator-generate k8s and crds commands, updating installation YAML files
* `make package`: generates tarball of the `splunk/splunk-operator` container image and installation YAML file
* `make clean`: removes the binary build output and `splunk/splunk-operator` container image
* `make run`: runs the splunk operator locally, monitoring the Kubernetes cluster configured in your current `kubectl` context
* `make fmt`: runs `go fmt` on all `*.go` source files in this project
Expand All @@ -78,11 +105,10 @@ Other make targets include (more info below):

## Running the Splunk Operator

Ensure that you have the `SplunkEnterprise` Custom Resource Definition installed
in your cluster:
Ensure that you have the Custom Resource Definitions installed in your cluster:

```
kubectl apply -f deploy/crds/enterprise_v1alpha1_splunkenterprise_crd.yaml
kubectl apply -f deploy/crds/
```

Use this to run the operator as a local foreground process on your machine:
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LABEL name="splunk" \
version="0.1.0" \
release="1" \
summary="Simplify the Deployment & Management of Splunk Products on Kubernetes" \
description="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."
description="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."

# install operator binary
COPY build/_output/bin/splunk-operator ${OPERATOR}
Expand Down
Loading