Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Adding missing operator metrics service #186

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ endif
##@ Development

manifests: controller-gen kustomize authorino-manifests ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=authorino-operator-manager webhook paths="./..." output:crd:artifacts:config=config/crd/bases && $(KUSTOMIZE) build config/install > $(OPERATOR_MANIFESTS)
$(CONTROLLER_GEN) -h $(CRD_OPTIONS) rbac:roleName=authorino-operator-manager webhook paths="./..." output:crd:artifacts:config=config/crd/bases && $(KUSTOMIZE) build config/install > $(OPERATOR_MANIFESTS)
$(MAKE) deploy-manifest OPERATOR_IMAGE=$(OPERATOR_IMAGE)

.PHONY: authorino-manifests
Expand All @@ -154,7 +154,7 @@ authorino-manifests: ## Update authorino manifests.
> config/authorino/kustomization.yaml

generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
$(CONTROLLER_GEN) -h object:headerFile="hack/boilerplate.go.txt" paths="./..."

fmt: ## Run go fmt against code.
go fmt ./...
Expand Down
16 changes: 14 additions & 2 deletions controllers/authorino_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,9 @@ func (r *AuthorinoReconciler) createAuthorinoServices(authorino *api.Authorino)

authorinoInstanceName := authorino.Name
authorinoInstanceNamespace := authorino.Namespace
authorinoOperatorLabels := map[string]string{
"app": "authorino-operator",
}

var desiredServices []*k8score.Service
var grpcPort, httpPort int32
Expand Down Expand Up @@ -657,13 +660,22 @@ func (r *AuthorinoReconciler) createAuthorinoServices(authorino *api.Authorino)
authorino.Labels,
))

// metrics service
if p := authorino.Spec.Metrics.Port; p != nil {
httpPort = *p
} else {
httpPort = defaultMetricsServicePort
}
desiredServices = append(desiredServices, authorinoResources.NewMetricsService(

// operator metrics service
desiredServices = append(desiredServices, authorinoResources.NewOperatorMetricsService(
authorinoInstanceName,
authorinoInstanceNamespace,
httpPort,
authorinoOperatorLabels,
))
Comment on lines +670 to +675
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confused about this. This will create a metrics service for the operator after each Authorino CR, which is meant to deploy the operand. I don't think that's what we want.


// operand metrics service
desiredServices = append(desiredServices, authorinoResources.NewOperandMetricsService(
authorinoInstanceName,
authorinoInstanceNamespace,
httpPort,
Expand Down
3 changes: 2 additions & 1 deletion controllers/authorino_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ var _ = Describe("Authorino controller", func() {
It("Should create authorino required services", func() {
desiredServices := []*k8score.Service{
authorinoResources.NewOIDCService(authorinoInstance.Name, authorinoInstance.Namespace, defaultOIDCServicePort, authorinoInstance.Labels),
authorinoResources.NewMetricsService(authorinoInstance.Name, authorinoInstance.Namespace, defaultMetricsServicePort, authorinoInstance.Labels),
authorinoResources.NewOperandMetricsService(authorinoInstance.Name, authorinoInstance.Namespace, defaultMetricsServicePort, authorinoInstance.Labels),
authorinoResources.NewOperatorMetricsService(authorinoInstance.Name, authorinoInstance.Namespace, defaultMetricsServicePort, authorinoInstance.Labels),
authorinoResources.NewAuthService(authorinoInstance.Name, authorinoInstance.Namespace, defaultAuthGRPCServicePort, defaultAuthHTTPServicePort, authorinoInstance.Labels),
}

Expand Down
13 changes: 11 additions & 2 deletions pkg/resources/k8s_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,21 @@ func NewOIDCService(authorinoName, authorinoNamespace string, port int32, labels
return newService("authorino-oidc", authorinoNamespace, authorinoName, labels, ports...)
}

func NewMetricsService(authorinoName, serviceNamespace string, port int32, labels map[string]string) *k8score.Service {
func NewOperandMetricsService(authorinoName, serviceNamespace string, port int32, labels map[string]string) *k8score.Service {
var ports []k8score.ServicePort
if port != 0 {
ports = append(ports, newServicePort("http", port))
}
return newService("controller-metrics", serviceNamespace, authorinoName, labels, ports...)

return newService("metrics", serviceNamespace, authorinoName, labels, ports...)
}

func NewOperatorMetricsService(authorinoName, serviceNamespace string, port int32, labels map[string]string) *k8score.Service {
var ports []k8score.ServicePort
if port != 0 {
ports = append(ports, newServicePort("http", port))
}
return newService("operator-controller-manager-metrics-service", serviceNamespace, authorinoName, labels, ports...)
}

func EqualServices(s1, s2 *k8score.Service) bool {
Expand Down
Loading