10

KCAD Prep Part 1 - Kubernetes API Primitives - briansdevblog

 3 years ago
source link: https://www.briansdevblog.com/2021/04/kcad-prep-kubernetes-api-primitives/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Kubernetes API PrimitivesSkip to content

Search for:
Home/Kubernetes/KCAD Prep Part 1 – Kubernetes API Primitives

I’ve been working with Kubernetes for a while now and and I’m really enjoying it. I feel I’ve learned quite a bit but its difficult to know how much without some kind of measuring stick. With that in mind I’ve decided to start studying for the Kubernetes Certified Application Developer (KCAD) exam.

When studying for certs in the past I’ve usually scribbled notes privately in Evernote. This time though I’m going to share them here in a series of posts. It seems a waste to put time and effort into notes and not share them. Putting the notes in the public domain will hopefully help other folks studying for the KCAD and help keep me motivated to get through the material quickly.

Ok, enough chit chat….lets get started.

Kubernetes API Primitives

Kubernetes API primitives are data objects that represent the state of the cluster. They’re often referred to as Kubernetes Objects. Examples are

  • Replica Set
  • Service

To see a full list of Kubernetes Objects available run

kubectl api-resources
kubectl api-resources.

Every Kubernetes Object has a Spec and a

Status
Status.
  • Spec – defines the desired state of the object running in the cluster. Usually defined in a yaml file and applied to the cluster using
    kubectl
    kubectl
  • Status – Current state of the object in the cluster. This can be retrieved from the cluster using
    kubectl
    kubectl

Viewing Kubernetes Objects

To view a list of Kubernetes objects of a certain type use the

kubectl get
kubectl get command. For example to view all Nodes run
kubectl get nodes
kubectl get nodes.

k_get_pods.png

I’m running minikube locally so I only have 1 node, but if I were connected to a cluster with multiple nodes, they’d all be listed here.

To see detailed metadata associated with an object you can run

kubectl get node minikube -o yaml
kubectl get node minikube -o yaml. The yaml output contains lots of information regarding the Object including its Spec and
Status
Status.k_get_minus_o.png

Another way to view detailed metadata for an object is the 

kubectl describe
kubectl describe command. For example, to view detail for the
minikube
minikube node run 
kubectl describe node minikube
kubectl describe node minikube.

k_describe_node.png


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK