1717package commonBean
1818
1919import (
20+ v1 "k8s.io/api/core/v1"
2021 "k8s.io/apimachinery/pkg/api/meta"
22+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2123 "k8s.io/apimachinery/pkg/runtime/schema"
2224)
2325
@@ -73,6 +75,17 @@ const (
7375 StatefulSetsResourceType = "statefulsets"
7476)
7577
78+ const (
79+ ContainersType = "Containers"
80+ ContainersNamesType = "ContainerNames"
81+ InitContainersNamesType = "InitContainerNames"
82+ EphemeralContainersInfoType = "EphemeralContainerInfo"
83+ EphemeralContainersStatusType = "EphemeralContainerStatuses"
84+ StatusReason = "Status Reason"
85+ Node = "Node"
86+ RestartCount = "Restart Count"
87+ )
88+
7689const (
7790 Group = "group"
7891 Version = "version"
@@ -103,6 +116,7 @@ const K8sClusterResourceNameKey = "name"
103116const K8sClusterResourcePriorityKey = "priority"
104117const K8sClusterResourceNamespaceKey = "namespace"
105118const K8sClusterResourceMetadataKey = "metadata"
119+ const K8sClusterResourceSpecKey = "spec"
106120const K8sClusterResourceMetadataNameKey = "name"
107121const K8sClusterResourceOwnerReferenceKey = "ownerReferences"
108122const K8sClusterResourceCreationTimestampKey = "creationTimestamp"
@@ -126,6 +140,9 @@ const V1VERSION = "v1"
126140const BatchGroup = "batch"
127141const AppsGroup = "apps"
128142
143+ const HelmHookAnnotation = "helm.sh/hook"
144+ const HibernateReplicaAnnotation = "hibernator.devtron.ai/replicas"
145+
129146const (
130147 K8sResourceColumnDefinitionName = "Name"
131148 K8sResourceColumnDefinitionSyncStatus = "Sync Status"
@@ -200,3 +217,131 @@ type GvrAndScope struct {
200217func GetGvkVsChildGvrAndScope () map [schema.GroupVersionKind ][]* GvrAndScope {
201218 return gvkVsChildGvrAndScope
202219}
220+
221+ // ResourceNode contains information about live resource and its children
222+ type ResourceNode struct {
223+ * ResourceRef `json:",inline" protobuf:"bytes,1,opt,name=resourceRef"`
224+ ParentRefs []* ResourceRef `json:"parentRefs,omitempty" protobuf:"bytes,2,opt,name=parentRefs"`
225+ NetworkingInfo * ResourceNetworkingInfo `json:"networkingInfo,omitempty" protobuf:"bytes,4,opt,name=networkingInfo"`
226+ ResourceVersion string `json:"resourceVersion,omitempty" protobuf:"bytes,5,opt,name=resourceVersion"`
227+ Health * HealthStatus `json:"health,omitempty" protobuf:"bytes,7,opt,name=health"`
228+ IsHibernated bool `json:"isHibernated"`
229+ CanBeHibernated bool `json:"canBeHibernated"`
230+ Info []InfoItem `json:"info,omitempty"`
231+ Port []int64 `json:"port,omitempty"`
232+ CreatedAt string `json:"createdAt,omitempty"`
233+ IsHook bool `json:"isHook,omitempty"`
234+ HookType string `json:"hookType,omitempty"`
235+ // UpdateRevision is used when a pod's owner is a StatefulSet for identifying if the pod is new or old
236+ UpdateRevision string `json:"updateRevision,omitempty"`
237+ // DeploymentPodHash is the podHash in deployment manifest and is used to compare replicaSet's podHash for identifying new vs old pod
238+ DeploymentPodHash string `json:"deploymentPodHash,omitempty"`
239+ DeploymentCollisionCount * int32 `json:"deploymentCollisionCount,omitempty"`
240+ // RolloutCurrentPodHash is the podHash in rollout manifest and is used to compare replicaSet's podHash for identifying new vs old pod
241+ RolloutCurrentPodHash string `json:"rolloutCurrentPodHash,omitempty"`
242+ }
243+
244+ // ResourceRef includes fields which unique identify resource
245+ type ResourceRef struct {
246+ Group string `json:"group,omitempty" protobuf:"bytes,1,opt,name=group"`
247+ Version string `json:"version,omitempty" protobuf:"bytes,2,opt,name=version"`
248+ Kind string `json:"kind,omitempty" protobuf:"bytes,3,opt,name=kind"`
249+ Namespace string `json:"namespace,omitempty" protobuf:"bytes,4,opt,name=namespace"`
250+ Name string `json:"name,omitempty" protobuf:"bytes,5,opt,name=name"`
251+ UID string `json:"uid,omitempty" protobuf:"bytes,6,opt,name=uid"`
252+ Manifest unstructured.Unstructured `json:"-"`
253+ }
254+
255+ func (r * ResourceRef ) GetGvk () schema.GroupVersionKind {
256+ if r == nil {
257+ return schema.GroupVersionKind {}
258+ }
259+ return schema.GroupVersionKind {
260+ Group : r .Group ,
261+ Version : r .Version ,
262+ Kind : r .Kind ,
263+ }
264+ }
265+
266+ // ResourceNetworkingInfo holds networking resource related information
267+ type ResourceNetworkingInfo struct {
268+ Labels map [string ]string `json:"labels,omitempty" protobuf:"bytes,3,opt,name=labels"`
269+ }
270+
271+ type HealthStatus struct {
272+ Status HealthStatusCode `json:"status,omitempty" protobuf:"bytes,1,opt,name=status"`
273+ Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
274+ }
275+
276+ type HealthStatusCode = string
277+
278+ const (
279+ HealthStatusUnknown HealthStatusCode = "Unknown"
280+ HealthStatusProgressing HealthStatusCode = "Progressing"
281+ HealthStatusHealthy HealthStatusCode = "Healthy"
282+ HealthStatusSuspended HealthStatusCode = "Suspended"
283+ HealthStatusDegraded HealthStatusCode = "Degraded"
284+ HealthStatusMissing HealthStatusCode = "Missing"
285+ HealthStatusHibernated HealthStatusCode = "Hibernated"
286+ HealthStatusPartiallyHibernated HealthStatusCode = "Partially Hibernated"
287+ )
288+
289+ type ResourceTreeResponse struct {
290+ Nodes []* ResourceNode `json:"nodes,omitempty"`
291+ PodMetadata []* PodMetadata `json:"podMetadata,omitempty"`
292+ }
293+
294+ type PodMetadata struct {
295+ Name string `json:"name"`
296+ UID string `json:"uid"`
297+ Containers []string `json:"containers"`
298+ InitContainers []string `json:"initContainers"`
299+ IsNew bool `json:"isNew"`
300+ EphemeralContainers []* EphemeralContainerData `json:"ephemeralContainers"`
301+ }
302+
303+ // use value field as generic type
304+ // InfoItem contains arbitrary, human readable information about an application
305+ type InfoItem struct {
306+ // Name is a human readable title for this piece of information.
307+ Name string `json:"name,omitempty"`
308+ // Value is human readable content.
309+ Value interface {} `json:"value,omitempty"`
310+ }
311+
312+ type EphemeralContainerData struct {
313+ Name string `json:"name"`
314+ IsExternal bool `json:"isExternal"`
315+ }
316+
317+ type EphemeralContainerStatusesInfo struct {
318+ Name string
319+ State v1.ContainerState
320+ }
321+
322+ type EphemeralContainerInfo struct {
323+ Name string
324+ Command []string
325+ }
326+ type ExtraNodeInfo struct {
327+ // UpdateRevision is only used for StatefulSets, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence
328+ UpdateRevision string
329+ ResourceNetworkingInfo * ResourceNetworkingInfo
330+ RolloutCurrentPodHash string
331+ }
332+
333+ const (
334+ DEFAULT_CLUSTER = "default_cluster"
335+ DEVTRON_SERVICE_NAME = "devtron-service"
336+ DefaultClusterUrl = "https://kubernetes.default.svc"
337+ BearerToken = "bearer_token"
338+ CertificateAuthorityData = "cert_auth_data"
339+ CertData = "cert_data"
340+ TlsKey = "tls_key"
341+ LiveZ = "/livez"
342+ Running = "Running"
343+ RestartingNotSupported = "restarting not supported"
344+ DEVTRON_APP_LABEL_KEY = "app"
345+ DEVTRON_APP_LABEL_VALUE1 = "devtron"
346+ DEVTRON_APP_LABEL_VALUE2 = "orchestrator"
347+ )
0 commit comments