1

I was handed a Kubernetes cluster with no config files, and was not setup with helm. The author said they just created everything from the cmd line. It is a small/new cluster for a single API server with an nginx ingress controller. I know enough of Kubernetes to get around and was able to add a new web server, but now I need to get in deeper and update existing configs. Specifically, I want to enable prometheus metrics on the nginx controller, but I don't want to break anything.

Is there a standard way to retrieve the existing configurations (deployments, services, etc) from the cluster, make modifications, and apply them? Or is there a way to patch in updates to individual parts of the existing configuration without having to create a new yaml file?

I understand I can get the current config with something like this:

kubectl get services -n nginx -o yaml 

That output has additional fields like creationTimestamp, uid, etc, that I suppose I need to remove. Or can I just save the output exactly as is to a yaml file, make my modifications to enable prometheus, and then apply the config back to the controller? Will it ignore the kube-created fields? Is there a different approach I should be considering?

Secondly, should I store these configurations in a repository, or is this just how things are done?

1 Answer 1

1

Seems like you have almost anything you need; there are only some minor considerations:

  • kubectl -n <ns> get <CRD> -o yaml will give you the output with some read-only identificators, which you cannot redefine even if they will keep theis values, so these aren't suited to keep them as plain files.
  • use kubectl edit instead
  • as about should you keep these in any VCS you want, or should you just make modifications on the fly - it's entirely up to you to decide; any attempt to discuss this will probably start a flame.
1
  • Thank you very much, exactly what I was missing. I'm okay with taking an approach that 50% consider valid. I'm sure I will come to a conclusion on that myself as I get more insight and experience with Kube. Commented Sep 8, 2023 at 13:04

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.