Reputation: 3167
What order does kubectl execute if I just run kubectl -f test/
which has all the files and folders below? Would it determine that mysite-db-namespace.yml
to run first and then other services.yml
etc?
Or should I be naming the files with numbers so it it executes exactly how I want?
test/
├── database
│ ├── database-clusterip-service.yml
│ ├── database-deployment.yml
│ ├── persistent-Volume-Claim.yml
│ ├── storage-class.yml
│ └── mysite-db-namespace.yml
├── httpd
│ ├── httpd-clusterip-service.yml
│ ├── httpd-deployment.yml
│ ├── ingress-rules.yml.orig
│ ├── nginx-ingress-controller.yml.orig
│ └── nginx-ingress-lb-service.yml.orig
└── tomcat
├── tomcat-clusterip-service.yml
├── tomcat-deployment.yml
└── mysite-web-namespace.yml
Upvotes: 1
Views: 1661
Reputation: 1
If you decide to execute it manually here is the hierarchy or order you should follow to execute any Kubernetes files:
1 Namespace
2 RBAC (Roles, RoleBindings, ServiceAccounts)
3 Persistent Storage (StorageClass, PV, PVC)
4 ConfigMaps & Secrets
5 Networking (Ingress, NetworkPolicies)
6 Services
7 Workloads (Deployments, StatefulSets, etc.)
8 HPA (Horizontal Pod Autoscaler)
Upvotes: 0
Reputation: 991
You can use helm hooks to order your yamls. Other than that kubectl will load your yamls in same folder based on alphabetic order. This is not guarenteed to always work though, there can be race-condition issues where you apply the yaml first but it being in effect relies on the kubernetes side.
Upvotes: 1