apiVersion - what follows this keyword?

I've noticed that various components from the exercises/labs, use various info for the apiVersion. 

Is the apiVersion value a fixed value that we must understand for each "KIND" of deployment? 

apiVersion: apps/v1beta2 

apiVersion: v1

etc, ...

  • post-author-pic
    Terrence C

    The apiVersion tells Kubernetes what features and syntax is supported in the configuration files for the services you are working with. There are multiple supported versions, not everything is backward compatible, so by specifying the version, you can decide what and how to implement your cluster services. It is mainly for backward compatibility as Kubernetes versions move forward quickly.

  • post-author-pic
    Rajesh P

    How do we know what value to be used while writing yaml files? I am confused regarding the version to use while writing the yaml. kubectl explain ...  describes what fields are available. 

    For example, the following uses different apiVersion for each resource type which is expected. I am bit worried as to know how to get the value to used during the exam if they were asked to write yaml for that.  Please advise.
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    name: test-network-policy
    namespace: default
    apiVersion: apps/v1
    kind: Deployment
    name: nginx-deployment
    app: nginx

  • post-author-pic

    For the exam, I would say, to use the k8s to quickly lookup the propery syntax or use the --generator.  in the real world, I think we would all be using existing templates but for the exam, --generator is the way to go.  

Looking For Team Training?

Learn More