Sort resources to apply into dependency order
Kubernetes resource kinds have a partial order relation of (loosely)
"may refer to": a Deployment may mount a ConfigMap as a volume; most
resources are scoped to a namespace; a RoleBinding refers to a Role or
ClusterRole; and so on.
Usually, you want the referenced resources to be created or changed
before the referring resources. In general, Kubernetes is designed so
that it will sort itself out eventually, but things go more smoothly
if things are present before they are needed.
Here I've boiled the ordering down to a small number of ranks, with
each rank containing kinds that refer only to kinds in the ranks
before. When applying resources, they are sorted by rank, so that
resources that depend on other resources will get updated or created
after those others.