What’s Your Naming Convention for YAML Files and Resources in Kubernetes?

0
20
Asked By CuriousCoder93 On

Hey everyone! I started documenting my new Kubernetes cluster and noticed that the names of the .yaml files for existing services like kubernetes-dashboard and ArgoCD are all over the place. I'm curious how others approach naming their YAML files, resources, and namespaces.

Here are my thoughts so far on file naming:
- RoleBinding: role-binding-.yaml
- ClusterRole: cluster-role-.yaml
- ServiceAccount: sa-.yaml
- Deployment: deploy-.yaml

For namespaces, I'm thinking of using:
- --

I'm also considering organizing the YAML files into folders in the git repository, like this:
- main-folder/application-name/deployments/.yaml
- main-folder/application-name/rbac/role-bindings/-.yaml
- main-folder/application-name/rbac/cluster-role/.yaml

I'm feeling a bit lost with this, so any tips or insights would be greatly appreciated! Am I overcomplicating things, or is there a better way to go about it?

5 Answers

Answered By NamespaceNinja On

I believe namespaces should be separate from the service definitions, so I don't include them in the filenames. This allows me to deploy testing copies of services to different namespaces when needed.

SkepticalDev22 -

That’s a good point, but watch out for helm-releases that might delete the targetNamespace along with everything inside that isn’t part of the helm chart.

Answered By PragmaticDeployer On

Honestly, it doesn't matter that much. For my small lab environment, I organize things by namespace. I'll put namespace-wide YAMLs in their own directory and application YAMLs in the respective application directory. You could even just dump everything in a single directory and be fine, depending on your setup.

Answered By AppWhisperer On

We do it a bit differently—our format is -.yaml. It puts everything related to the same application close together in the filesystem, which I find helpful.

Answered By StructuringPro42 On

For naming conventions, I stick with using a structure like ..yaml. Everything is organized in a folder system sorted by clusters, environments, and applications. Although it’s not strictly DRY, this makes navigation much easier and allows for clear scaling due to the organized conventions.

FolderFanatic77 -

Nice tidy setup! What's typically in each layer of your structure? How do you classify things like External Secrets or Prometheus?

NewbieNerd89 -

I love that! Learning k8s with flux must be such an advantage!

Answered By ManifestMaster On

I use this structure: ///manifests/-.yaml. This way, everything is neatly categorized by where it applies.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.