Skip to content

Commit 74ed9db

Browse files
Merge master1.0.1 (#370)
1.0.1 Release
1 parent e61ecd8 commit 74ed9db

File tree

63 files changed

+39131
-23439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+39131
-23439
lines changed

.circleci/config.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ executors:
105105
# Set cluster workers to 5 (5 cluster nodes)
106106
# NUM_NODES represent number of parallel test executions
107107
# NUM_WORKERS represent number of nodes in a k8 cluster
108-
NUM_NODES: 4
109-
NUM_WORKERS: 5
108+
NUM_NODES: 5
109+
NUM_WORKERS: 8
110+
CLUSTER_NAME: eks-integration-test-cluster
110111
ENTERPRISE_IMAGE_NAME: splunk/splunk:edge
111112
IMAGE_NAME: splunk/splunk-operator
112113
IMAGE_FILENAME: splunk-operator
@@ -433,4 +434,4 @@ jobs:
433434
name: Delete cluster
434435
command: |
435436
make cluster-down
436-
no_output_timeout: 30m
437+
no_output_timeout: 30m

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The following components are licensed under Apache 2.0:
2121
go-logr v0.1.0
2222
https://github.com/go-logr/logr
2323

24-
operator-framework/operator-sdk v0.15.1
24+
operator-framework/operator-sdk v0.18.2
2525
https://github.com/operator-framework/operator-sdk
2626

2727
k8s.io/api

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The [Kubernetes Operator SDK](https://github.com/operator-framework/operator-sdk
3434
must also be installed to build this project.
3535

3636
```
37-
git clone -b v0.15.1 https://github.com/operator-framework/operator-sdk
37+
git clone -b v0.18.2 https://github.com/operator-framework/operator-sdk
3838
cd operator-sdk
3939
make tidy
4040
make install

build/Dockerfile.builder

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ RUN ln -s /usr/bin/microdnf /usr/bin/dnf \
2626

2727
USER root
2828

29-
ENV OPERATOR_SDK_VERSION 0.15.1
29+
ENV OPERATOR_SDK_VERSION 0.18.2
3030
ENV OPERATOR_SDK_URL https://github.com/operator-framework/operator-sdk/releases/download/v${OPERATOR_SDK_VERSION}/operator-sdk-v${OPERATOR_SDK_VERSION}-x86_64-linux-gnu
3131
ENV DOCKER_CLI_URL https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-cli-19.03.5-3.el7.x86_64.rpm
3232

build/make_bundle.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ for v in $OLD_VERSIONS; do
2323
name: $v
2424
served: true
2525
storage: false
26+
schema:
27+
openAPIV3Schema:
28+
type: object
29+
properties:
30+
apiVersion:
31+
type: string
2632
EOF
2733
done
2834

@@ -126,7 +132,7 @@ cat << EOF >$YAML_SCRIPT_FILE
126132
EOF
127133

128134
echo Updating $OLM_CATALOG
129-
operator-sdk generate csv --csv-version $VERSION --operator-name splunk --update-crds --verbose
135+
operator-sdk generate csv --csv-version $VERSION --operator-name splunk --update-crds --make-manifests=false --verbose
130136
yq w -i -s $YAML_SCRIPT_FILE $OLM_CATALOG/splunk/$VERSION/splunk.v${VERSION}.clusterserviceversion.yaml
131137
rm -f $YAML_SCRIPT_FILE
132138

cmd/manager/main.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func main() {
133133
}
134134

135135
// Add the Metrics Service
136-
addMetrics(ctx, cfg, namespace)
136+
addMetrics(ctx, cfg)
137137

138138
log.Info("Starting the Manager.")
139139

@@ -146,12 +146,17 @@ func main() {
146146

147147
// addMetrics will create the Services and Service Monitors to allow the operator export the metrics by using
148148
// the Prometheus operator
149-
func addMetrics(ctx context.Context, cfg *rest.Config, namespace string) {
150-
if err := serveCRMetrics(cfg); err != nil {
149+
func addMetrics(ctx context.Context, cfg *rest.Config) {
150+
// Get the namespace the operator is currently deployed in.
151+
operatorNs, err := k8sutil.GetOperatorNamespace()
152+
if err != nil {
151153
if errors.Is(err, k8sutil.ErrRunLocal) {
152154
log.Info("Skipping CR metrics server creation; not running in a cluster.")
153155
return
154156
}
157+
}
158+
159+
if err := serveCRMetrics(cfg, operatorNs); err != nil {
155160
log.Info("Could not generate and serve custom resource metrics", "error", err.Error())
156161
}
157162

@@ -170,7 +175,9 @@ func addMetrics(ctx context.Context, cfg *rest.Config, namespace string) {
170175
// CreateServiceMonitors will automatically create the prometheus-operator ServiceMonitor resources
171176
// necessary to configure Prometheus to scrape metrics from this operator.
172177
services := []*v1.Service{service}
173-
_, err = metrics.CreateServiceMonitors(cfg, namespace, services)
178+
179+
// The ServiceMonitor is created in the same namespace where the operator is deployed
180+
_, err = metrics.CreateServiceMonitors(cfg, operatorNs, services)
174181
if err != nil {
175182
log.Info("Could not create ServiceMonitor object", "error", err.Error())
176183
// If this operator is deployed to a cluster without the prometheus-operator running, it will return
@@ -183,20 +190,22 @@ func addMetrics(ctx context.Context, cfg *rest.Config, namespace string) {
183190

184191
// serveCRMetrics gets the Operator/CustomResource GVKs and generates metrics based on those types.
185192
// It serves those metrics on "http://metricsHost:operatorMetricsPort".
186-
func serveCRMetrics(cfg *rest.Config) error {
187-
// Below function returns filtered operator/CustomResource specific GVKs.
188-
// For more control override the below GVK list with your own custom logic.
193+
func serveCRMetrics(cfg *rest.Config, operatorNs string) error {
194+
// The function below returns a list of filtered operator/CR specific GVKs. For more control, override the GVK list below
195+
// with your own custom logic. Note that if you are adding third party API schemas, probably you will need to
196+
// customize this implementation to avoid permissions issues.
189197
filteredGVK, err := k8sutil.GetGVKsFromAddToScheme(apis.AddToScheme)
190198
if err != nil {
191199
return err
192200
}
193-
// Get the namespace the operator is currently deployed in.
194-
operatorNs, err := k8sutil.GetOperatorNamespace()
201+
202+
// The metrics will be generated from the namespaces which are returned here.
203+
// NOTE that passing nil or an empty list of namespaces in GenerateAndServeCRMetrics will result in an error.
204+
ns, err := kubemetrics.GetNamespacesForMetrics(operatorNs)
195205
if err != nil {
196206
return err
197207
}
198-
// To generate metrics in other namespaces, add the values below.
199-
ns := []string{operatorNs}
208+
200209
// Generate and serve custom resource specific metrics.
201210
err = kubemetrics.GenerateAndServeCRMetrics(cfg, ns, filteredGVK, metricsHost, operatorMetricsPort)
202211
if err != nil {

0 commit comments

Comments
 (0)