kro creates the resources of an RGD in the order of their dependencies. If one object references a second through an expression and the second references the first, there is no order – the RGD stays Inactive.
Symptom
kubectl apply -f zyklus.yaml
kubectl get rgd notesapp-zyklus \
-o jsonpath='{.status.state}: {.status.conditions[?(@.type=="GraphAccepted")].message}{"\n"}'
resourcegraphdefinition.kro.run/notesapp-zyklus created
Inactive: failed to build dependency graph: graph contains a cycle: service ->
deployment -> service
The message shows the cycle object by object.
Diagnosis
In the course it was an extra environment variable in the Deployment that reads the Service's name.
env:
- name: NOTES_SVC
value: ${service.metadata.name}
- name: NOTES_API_KEY
Causes
service ↔ deploymentTwo objects reference each other
The Service needs the Deployment's selector, the Deployment needs the Service's name. There is no order in which kro could create them.
Fix
kubectl delete -f zyklus.yaml
Don't: Routing the reference through an external ConfigMap to trick the check. The cycle remains, just hidden.
kro hands-on, day 4: the NotesApp from Secret, Deployment and Service, dependencies and a cycle.
Go to day 4 →
FAQ
Where do I see the order kro built?
kubectl get rgd -o wide shows TOPOLOGICALORDER, for example ["secret","deployment","service"].
Isn't the Service's name simply known?
Yes – that is why it is enough to build it from the schema instead of from the Service object.