From the documentation for the MongoDB resource, which is deployed by the operator, I’ve successfully added annotations that apply across each service created for each replica in my cluster.
For integration with the external-dns operator (to create DNS names for each LoadBalancer service’s IP), is there a way to specify that each service created by the operator should have an annotation containing the DNS name for that specific instance? I’ve reviewed the docs at length and it seems I can only apply annotations that have a shared value across each generated service.
For example I have something like the following in the MongoDB resource spec:
apiVersion: mongodb.com/v1
kind: MongoDB
metadata:
name: mymongodb
spec:
...
connectivity:
replicaSetHorizons:
- "external": "mydb-db-0.my-domain.com:27017"
- "external": "mydb-db-1.my-domain.com:27017"
- "external": "mydb-db-2.my-domain.com:27017"
externalAccess:
externalService:
annotations:
service.beta.kubernetes.io/azure-load-balancer-internal-subnet: mysubnet
In the above scenario, the annotation is added equally to each generated service.
I want in the MongoDB resource spec to be able to define an annotation with a distinct value for each service. For example I want generated service “mydb-db-0-svc-external” to have annotation:
external-dns.alpha.kubernetes.io/hostname: mydb-db-0.my-domain.com
Whereas service “mydb-db-1-svc-external” would have annotation:
external-dns.alpha.kubernetes.io/hostname: mydb-db-1.my-domain.com
etc.