Open amisevsk opened 3 years ago
The reason the service is duplicated is because OLM generates APIServices and Webhooks in a very similar way - by providing a port on the CSV OLM generates a service. There's no clear way to change this behavior since other operator CSV's rely on OLM creating a service for their Webhooks and APIServices.
That being said the SDK <-> OLM behavior around webhooks should be consistent, should triage this further.
To further add to the confusion caused by this behaviour -- to avoid a duplicate service, I changed the name we use to match what's expected by OLM (i.e. devworkspace-controller-manager-service
), but I also added another port to support metrics (rather than have two services that point at the same deployment). In this case, OLM overwrites the perfectly acceptable service's ports, removing my metrics port:
The file in bundle/manifests
apiVersion: v1
kind: Service
spec:
ports:
- name: https
port: 443
protocol: TCP
targetPort: conversion
- name: metrics
port: 8443
targetPort: metrics
The service created when installing the operator
apiVersion: v1
kind: Service
spec:
ports:
- name: https
port: 443
protocol: TCP
targetPort: conversion
Bug Report
What did you do? Deploy an operator with
What did you expect to see? OLM uses the existing service in the bundle to configure conversion webhooks on CRDs.
What did you see instead? Under which circumstances? OLM creates a duplicate service with the same configuration as the provided service to match the controller deployment name. E.g. in my case, I end up with
devworkspace-controller-manager
devworkspace-controller-service
devworkspace-controller-manager-service
, with the same exposed ports as the service above.Environment
Not sure how to get this info; whatever ships with OpenShift 4.7.2
Additional context This is mostly a point of friction between Operator SDK and OLM. To generate a CSV with webhookDefinitions, the Operator SDK requires:
.spec.conversion
sectionThis gets converted to a CSV whose
webhookDefinitions
reference the deployment by name directly, skipping the deployment. When the CSV is processed, it results in a separate service being created, with name<deploymentName>-service
, even if the service used by Operator SDK has a different name.The only way to avoid a duplicate service is to look at what OLM does, and then name your service accordingly.