Skip to content

Commit

Permalink
Added service monitor for metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Juansasa committed Mar 5, 2025
1 parent 85d4147 commit d88fbc8
Show file tree
Hide file tree
Showing 22 changed files with 307 additions and 403 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)

## Tool Versions
KUSTOMIZE_VERSION ?= v5.3.0
CONTROLLER_TOOLS_VERSION ?= v0.14.0
CONTROLLER_TOOLS_VERSION ?= v0.17.2
ENVTEST_VERSION ?= release-0.17
GOLANGCI_LINT_VERSION ?= v1.64.2

Expand Down
4 changes: 2 additions & 2 deletions catalog/channels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ schema: olm.channel
package: rhbk-operator
name: preview
entries:
- name: rhbk-operator.v0.0.5
skipRange: ">=0.0.1 <0.0.5"
- name: rhbk-operator.v0.0.6
skipRange: ">=0.0.1 <0.0.6"
5 changes: 5 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"os"
"strconv"

monitoring "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"

route "github.com/openshift/api/route/v1"
"github.com/stakater/rhbk-operator/internal/constants"
v12 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -54,9 +56,12 @@ var (
)

func init() {
utilruntime.Must(v12.AddToScheme(scheme))
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(route.AddToScheme(scheme))
utilruntime.Must(ssov1alpha1.AddToScheme(scheme))
utilruntime.Must(ssov1alpha1.AddToScheme(scheme))
utilruntime.Must(monitoring.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}

Expand Down
23 changes: 4 additions & 19 deletions config/crd/bases/sso.stakater.com_keycloakimports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.17.2
name: keycloakimports.sso.stakater.com
spec:
group: sso.stakater.com
Expand Down Expand Up @@ -76,9 +76,7 @@ spec:
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret or its key must
Expand All @@ -102,16 +100,8 @@ spec:
properties:
conditions:
items:
description: "Condition contains details for one aspect of the current
state of this API Resource.\n---\nThis struct is intended for
direct use as an array at the field path .status.conditions. For
example,\n\n\n\ttype FooStatus struct{\n\t // Represents the
observations of a foo's current state.\n\t // Known .status.conditions.type
are: \"Available\", \"Progressing\", and \"Degraded\"\n\t //
+patchMergeKey=type\n\t // +patchStrategy=merge\n\t // +listType=map\n\t
\ // +listMapKey=type\n\t Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`\n\n\n\t
\ // other fields\n\t}"
description: Condition contains details for one aspect of the current
state of this API Resource.
properties:
lastTransitionTime:
description: |-
Expand Down Expand Up @@ -152,12 +142,7 @@ spec:
- Unknown
type: string
type:
description: |-
type of condition in CamelCase or in foo.example.com/CamelCase.
---
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be
useful (see .node.status.conditions), the ability to deconflict is important.
The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
description: type of condition in CamelCase or in foo.example.com/CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
Expand Down
39 changes: 4 additions & 35 deletions config/crd/bases/sso.stakater.com_keycloaks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.17.2
name: keycloaks.sso.stakater.com
spec:
group: sso.stakater.com
Expand Down Expand Up @@ -59,9 +59,7 @@ spec:
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret or its key must
Expand Down Expand Up @@ -96,9 +94,7 @@ spec:
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret or its key must
Expand Down Expand Up @@ -127,9 +123,7 @@ spec:
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret or its key must
Expand Down Expand Up @@ -162,9 +156,7 @@ spec:
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret or its key must
Expand Down Expand Up @@ -193,9 +185,7 @@ spec:
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret or its key must
Expand Down Expand Up @@ -224,9 +214,7 @@ spec:
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret or its key must
Expand Down Expand Up @@ -255,9 +243,7 @@ spec:
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret or its key must
Expand Down Expand Up @@ -314,9 +300,7 @@ spec:
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
optional:
description: Specify whether the Secret or its key must
Expand Down Expand Up @@ -344,9 +328,7 @@ spec:
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
TODO: Add other useful fields. apiVersion, kind, uid?
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
type: string
type: object
x-kubernetes-map-type: atomic
Expand All @@ -359,16 +341,8 @@ spec:
properties:
conditions:
items:
description: "Condition contains details for one aspect of the current
state of this API Resource.\n---\nThis struct is intended for
direct use as an array at the field path .status.conditions. For
example,\n\n\n\ttype FooStatus struct{\n\t // Represents the
observations of a foo's current state.\n\t // Known .status.conditions.type
are: \"Available\", \"Progressing\", and \"Degraded\"\n\t //
+patchMergeKey=type\n\t // +patchStrategy=merge\n\t // +listType=map\n\t
\ // +listMapKey=type\n\t Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`\n\n\n\t
\ // other fields\n\t}"
description: Condition contains details for one aspect of the current
state of this API Resource.
properties:
lastTransitionTime:
description: |-
Expand Down Expand Up @@ -409,12 +383,7 @@ spec:
- Unknown
type: string
type:
description: |-
type of condition in CamelCase or in foo.example.com/CamelCase.
---
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be
useful (see .node.status.conditions), the ability to deconflict is important.
The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
description: type of condition in CamelCase or in foo.example.com/CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
Expand Down
45 changes: 12 additions & 33 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,43 @@ metadata:
name: manager-role
rules:
- apiGroups:
- apps
- ""
resources:
- statefulsets
- secrets
- services
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- batch
- apps
resources:
- jobs
- statefulsets
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- ""
- batch
resources:
- secrets
- jobs
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- ""
- monitoring.coreos.com
resources:
- services
- servicemonitors
verbs:
- create
- delete
- get
- list
- update
Expand All @@ -58,31 +60,6 @@ rules:
- sso.stakater.com
resources:
- keycloakimports
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- sso.stakater.com
resources:
- keycloakimports/finalizers
verbs:
- update
- apiGroups:
- sso.stakater.com
resources:
- keycloakimports/status
verbs:
- get
- patch
- update
- apiGroups:
- sso.stakater.com
resources:
- keycloaks
verbs:
- create
Expand All @@ -95,12 +72,14 @@ rules:
- apiGroups:
- sso.stakater.com
resources:
- keycloakimports/finalizers
- keycloaks/finalizers
verbs:
- update
- apiGroups:
- sso.stakater.com
resources:
- keycloakimports/status
- keycloaks/status
verbs:
- get
Expand Down
12 changes: 6 additions & 6 deletions config/samples/sso_v1alpha1_keycloak.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ spec:
secret:
name: rhbk-pguser-rhbk
key: password
trustedCABundles:
name: openshift-service-ca.crt
providers:
- name: custom-spi.jar
url:
value: "https://github.com/example/custom-spi.jar"
# trustedCABundles:
# name: openshift-service-ca.crt
# providers:
# - name: custom-spi.jar
# url:
# value: "https://github.com/example/custom-spi.jar"
Loading

0 comments on commit d88fbc8

Please sign in to comment.