-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed an old bug that resurfaced itself, causing the operator to fail…
… when run in cluster-scope. Default client tries to cache all objects from all namespaces when WATCH_NAMESPACE is empty, causing auth failures. The fix bypasses this (broken) cache, allowing permissions to be approrpiately scoped to namespaces. Added build/make_bundle.sh which uses the "operator-sdk generate csv" command to generate a splunk OLM bundle in the deploy/olm-catalog/splunk directory. This is executed as part of the "make generate" command. You can now use OLM to install the splunk operator bundle to your Kubernetes cluster. If you do not have OLM installed, you can use "operator-sdk olm install" to install it (see "operator-sdk olm --help" for more). Once you have OLM installed, ensure that your ~/.kube/config context points to a clean namespace and then run "operator-sdk run --olm --manifests=deploy/olm-catalog/splunk --operator-version=0.1.0" Just delete the namespace when you are done testing. All the deploy/*.yaml files are now sources used to construct the OLM bundle and/or standalone YAML installation files (which are generated via build/package.sh). Removed deploy/cluster_operator.yaml and deploy/namespace_operator.yaml since these have become redundant files. They are no longer necessary because the build/package.sh script now constructs all the proper install/release YAML files from sources located in deploy/*.yaml. Changed splunk:operator:namespace-manager from a ClusterRole to a Role, since this is easier for reuse across tools and it is not required to be a ClusterRole. Removed splunk:operator:resource-manager from the YAML used for namespace-scoped installs, since it only is required for cluster-scoped. These changes also made the "splunk-operator-rbac.yaml" install resource unnecessary, since CRDS are now the only cluster-admin resources that need to be installed for namespace-scoped deployments. Note that these changes involve more YAML processing than what we previously did, so the "yq" utilitity is now a required development tool. Updated README for install instructions. Added build/run_scorecard.sh script which can be used to run the operator-sdk scorecard test suite. You can also use "make scorecard" to run this. Note that this requires having OLM installed in your Kubernetes cluster and that your ~/.kube/config context points to a clean namespace. Also note that the "statusdescriptorstest" test currently fails due to missing descriptors for some of the status fields. I didn't fix this because it would require a CRD update.
- Loading branch information
1 parent
a5a2560
commit 4cf969e
Showing
33 changed files
with
10,649 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,8 @@ tags | |
|
||
.idea | ||
.DS_Store | ||
.osdk-scorecard.yaml | ||
.yq_script.yaml | ||
Gopkg.lock | ||
vendor/ | ||
push_targets | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/bin/bash | ||
# Script to update OLM bundle in deploy/olm-catalog/splunk-operator | ||
|
||
# exit when any command fails | ||
set -e | ||
|
||
VERSION=`grep "Version.*=.*\".*\"" version/version.go | sed "s,.*Version.*=.*\"\(.*\)\".*,\1,"` | ||
IMAGE="docker.io/splunk/splunk-operator:${VERSION}" | ||
YAML_SCRIPT_FILE=.yq_script.yaml | ||
|
||
RESOURCES=" | ||
- kind: StatefulSets | ||
version: apps/v1 | ||
- kind: Deployments | ||
version: apps/v1 | ||
- kind: Pods | ||
version: v1 | ||
- kind: Services | ||
version: v1 | ||
- kind: ConfigMaps | ||
version: v1 | ||
- kind: Secrets | ||
version: v1 | ||
" | ||
|
||
cat << EOF >$YAML_SCRIPT_FILE | ||
- command: update | ||
path: spec.install.spec.deployments[0].spec.template.spec.containers[0].image | ||
value: $IMAGE | ||
- command: update | ||
path: spec.install.spec.permissions[0].serviceAccountName | ||
value: splunk-operator | ||
- command: update | ||
path: spec.customresourcedefinitions.owned[0].resources | ||
value: $RESOURCES | ||
- command: update | ||
path: spec.customresourcedefinitions.owned[1].resources | ||
value: $RESOURCES | ||
- command: update | ||
path: spec.customresourcedefinitions.owned[2].resources | ||
value: $RESOURCES | ||
- command: update | ||
path: spec.customresourcedefinitions.owned[3].resources | ||
value: $RESOURCES | ||
- command: update | ||
path: spec.customresourcedefinitions.owned[4].resources | ||
value: $RESOURCES | ||
- command: update | ||
path: metadata.annotations.alm-examples | ||
value: |- | ||
[{ | ||
"apiVersion": "enterprise.splunk.com/v1alpha2", | ||
"kind": "IndexerCluster", | ||
"metadata": { | ||
"name": "example" | ||
}, | ||
"spec": {} | ||
}, | ||
{ | ||
"apiVersion": "enterprise.splunk.com/v1alpha2", | ||
"kind": "LicenseMaster", | ||
"metadata": { | ||
"name": "example" | ||
}, | ||
"spec": {} | ||
}, | ||
{ | ||
"apiVersion": "enterprise.splunk.com/v1alpha2", | ||
"kind": "SearchHeadCluster", | ||
"metadata": { | ||
"name": "example" | ||
}, | ||
"spec": {} | ||
}, | ||
{ | ||
"apiVersion": "enterprise.splunk.com/v1alpha2", | ||
"kind": "Spark", | ||
"metadata": { | ||
"name": "example" | ||
}, | ||
"spec": {} | ||
}, | ||
{ | ||
"apiVersion": "enterprise.splunk.com/v1alpha2", | ||
"kind": "Standalone", | ||
"metadata": { | ||
"name": "example" | ||
}, | ||
"spec": {} | ||
}] | ||
EOF | ||
|
||
operator-sdk generate csv --csv-version $VERSION --operator-name splunk --update-crds --verbose | ||
yq w -i -s $YAML_SCRIPT_FILE deploy/olm-catalog/splunk/$VERSION/splunk.v${VERSION}.clusterserviceversion.yaml | ||
|
||
rm -f $YAML_SCRIPT_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
# Script to scorecard tests | ||
# Reference: https://github.com/operator-framework/operator-sdk/blob/v0.15.1/doc/test-framework/scorecard.md | ||
|
||
# exit when any command fails | ||
set -e | ||
|
||
VERSION=`grep "Version.*=.*\".*\"" version/version.go | sed "s,.*Version.*=.*\"\(.*\)\".*,\1,"` | ||
IMAGE="docker.io/splunk/splunk-operator:${VERSION}" | ||
CONFIG_FILE=.osdk-scorecard.yaml | ||
ARGS=$@ | ||
if [ $# = 0 ]; then | ||
ARGS="--output text --verbose" | ||
fi | ||
|
||
for crd in deploy/examples/*; do | ||
for f in $crd/*.yaml; do | ||
MANIFESTS="${MANIFESTS} - $f | ||
" | ||
done | ||
done | ||
|
||
cat << EOF >$CONFIG_FILE | ||
scorecard: | ||
bundle: "deploy/olm-catalog/splunk" | ||
plugins: | ||
- basic: | ||
cr-manifest: | ||
$MANIFESTS | ||
- olm: | ||
cr-manifest: | ||
$MANIFESTS | ||
csv-path: "deploy/olm-catalog/splunk/${VERSION}/splunk.v${VERSION}.clusterserviceversion.yaml" | ||
EOF | ||
|
||
operator-sdk scorecard $ARGS | ||
|
||
rm $CONFIG_FILE |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRole | ||
metadata: | ||
labels: | ||
rbac.authorization.k8s.io/aggregate-to-admin: "true" | ||
name: splunk:operator:resource-manager | ||
rules: | ||
- apiGroups: | ||
- enterprise.splunk.com | ||
resources: | ||
- '*' | ||
verbs: | ||
- '*' | ||
- apiGroups: | ||
- apps | ||
resources: | ||
- deployments | ||
- statefulsets | ||
verbs: | ||
- list | ||
- get | ||
- watch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: splunk:operator:resource-manager | ||
subjects: | ||
- kind: ServiceAccount | ||
name: splunk-operator | ||
namespace: splunk-operator | ||
roleRef: | ||
kind: ClusterRole | ||
name: splunk:operator:resource-manager | ||
apiGroup: rbac.authorization.k8s.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: enterprise.splunk.com/v1alpha2 | ||
kind: IndexerCluster | ||
metadata: | ||
name: test | ||
spec: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: enterprise.splunk.com/v1alpha2 | ||
kind: LicenseMaster | ||
metadata: | ||
name: test | ||
spec: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: enterprise.splunk.com/v1alpha2 | ||
kind: SearchHeadCluster | ||
metadata: | ||
name: test | ||
spec: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: enterprise.splunk.com/v1alpha2 | ||
kind: Spark | ||
metadata: | ||
name: test | ||
spec: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: enterprise.splunk.com/v1alpha2 | ||
kind: Standalone | ||
metadata: | ||
name: test | ||
spec: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: splunk-operator |
Oops, something went wrong.