which k8s data structure to represent basic objects?

5/10/2018

I would like to use a common data structure of kubernetes to represent objects including services, replication controller, deployments, statefulset, daemonsets, etc. Now kubernetes api already provides individual data structures for each of them and the data structure that i could find the closest to representing a common structure are

  • type ObjectMeta
  • type ObjectReference

reference : https://github.com/kubernetes/api/blob/master/core/v1/types.go

The reason I do not select one of the above two structures is because I need to use the status field of most objects so that I can check if

`replicas==readyreplicas==Availablereplicas`

or to check for most things

Desired==Current==Available
-- Yashgiri Goswami
kubernetes

1 Answer

5/10/2018

There is no common structure which can describe each object in Kubernetes, except using some dynamic one, but it will be hard to validate the structure of objects based on dynamic objects inside it.

Each type has a different set of objects inside. If you want to work with Kubernetes objects, just use proper structures from core.

-- Anton Kostenko
Source: StackOverflow