Make manifest file from imperative command

3/5/2019

I am reading on k8s it has 2 method to use it. Both of them are complement of each other.

Today I tried one feature to get a declarative (manifest file).

Suppose I create namespace instance

$ kubectl create namespace cert-manager
namespace/cert-manager created

Then I export the manifest file for using declarative method next time

kubectl get namespace cert-manager -o yaml --export > cert-manager.yaml

cert-manager.yaml

apiVersion: v1
kind: Namespace
metadata:
  creationTimestamp: null
  name: cert-manager
  selfLink: /api/v1/namespaces/cert-manager
spec:
  finalizers:
  - kubernetes
status:
  phase: Active

Compare with other example

apiVersion: v1
kind: Namespace
metadata:
  name: nginx-ingress

Question

Is 2nd shorter manifest file correctly done?

-- Sarit
declaration
export
imperative
kubernetes
manifest

1 Answer

3/5/2019

Yes, your 2nd manifest file is correct.

The spec describes your desired state for the object–the characteristics that you want the object to have. The status describes the actual state of the object, and is supplied and updated by the Kubernetes system.

Namespace object has only one optional field finalizers, which allows observables to purge resources whenever the namespace is deleted.

So, the simplest namespace manifest file is the following:

apiVersion: v1
kind: Namespace
metadata:
  name: <namespace-name>
-- nickgryg
Source: StackOverflow