Google Deployment Manager ordering of resources using references for kubernetes cluster

3/7/2018

I am trying to use the api exposed by a k8 cluster in other resources.

I want the k8 cluster to be up first and later other resources make use of the api exposed by this k8 cluster. I tried to use the references to lay out an implicit order on the resource creation, but I see that even before the k8 cluster is fully up, another resource is trying to access an API exposed by the k8 cluster.

More details: https://gist.github.com/VarunkumarManohar/508454c42afa481771e2c600120ca7ac

-- Varunkumar Manohar
google-deployment-manager
kubernetes

1 Answer

3/8/2018

This is not how kubernetes works.

Kubernetes uses a process called reconciliation, where specs/resource definitions that describe an end state get created without any explicit or implicit expectation around ordering. Individual resources/applications/controllers try and retry and retry again to reconcile themselves with that desired end state.

All cross-application references/dependencies have to be explicitly and literally specified prior to submitting the specs/resources. There is no variable interpolation or substitution or anything like that in k8s, unlike some application configuration management systems.

Part of the spec for individual services involves what to do when they fail- should they retry, how many times, for how long, etc. When you have layers of dependent services, the services that have no dependencies may come up and get to a state of readiness right away, whereas other services that have dependencies may try to locate those dependencies, fail, and then get restarted/retried by kubernetes.

Eventually all the parts, sometimes after many individual restarts, are up and ready and therefore reconciled with the desired end state.

-- Jonah Benton
Source: StackOverflow