github.com/alibaba/ilogtail/pkg@v0.0.0-20250526110833-c53b480d046c/helper/k8smeta/k8s_meta_const.go (about)

     1  package k8smeta
     2  
     3  import (
     4  	app "k8s.io/api/apps/v1"
     5  	batch "k8s.io/api/batch/v1"
     6  	v1 "k8s.io/api/core/v1"
     7  	networking "k8s.io/api/networking/v1"
     8  )
     9  
    10  const (
    11  	// entity type
    12  	POD                   = "pod"
    13  	SERVICE               = "service"
    14  	DEPLOYMENT            = "deployment"
    15  	REPLICASET            = "replicaset"
    16  	STATEFULSET           = "statefulset"
    17  	DAEMONSET             = "daemonset"
    18  	CRONJOB               = "cronjob"
    19  	JOB                   = "job"
    20  	NODE                  = "node"
    21  	NAMESPACE             = "namespace"
    22  	CONFIGMAP             = "configmap"
    23  	PERSISTENTVOLUME      = "persistentvolume"
    24  	PERSISTENTVOLUMECLAIM = "persistentvolumeclaim"
    25  	STORAGECLASS          = "storageclass"
    26  	INGRESS               = "ingress"
    27  	CONTAINER             = "container"
    28  	// entity link type, the direction is from resource which will be trigger to linked resource
    29  	//revive:disable:var-naming
    30  	LINK_SPLIT_CHARACTER     = "->"
    31  	POD_NODE                 = "pod->node"
    32  	POD_DEPLOYMENT           = "pod->deployment"
    33  	POD_REPLICASET           = "pod->replicaset"
    34  	REPLICASET_DEPLOYMENT    = "replicaset->deployment"
    35  	POD_STATEFULSET          = "pod->statefulset"
    36  	POD_DAEMONSET            = "pod->daemonset"
    37  	JOB_CRONJOB              = "job->cronjob"
    38  	POD_JOB                  = "pod->job"
    39  	POD_PERSISENTVOLUMECLAIN = "pod->persistentvolumeclaim"
    40  	POD_CONFIGMAP            = "pod->configmap"
    41  	POD_SERVICE              = "pod->service"
    42  	POD_CONTAINER            = "pod->container"
    43  	INGRESS_SERVICE          = "ingress->service"
    44  	//revive:enable:var-naming
    45  
    46  	// add namespace link
    47  	//revive:disable:var-naming
    48  	POD_NAMESPACE                   = "pod->namesapce"
    49  	SERVICE_NAMESPACE               = "service->namesapce"
    50  	DEPLOYMENT_NAMESPACE            = "deployment->namesapce"
    51  	DAEMONSET_NAMESPACE             = "daemonset->namesapce"
    52  	STATEFULSET_NAMESPACE           = "statefulset->namesapce"
    53  	CONFIGMAP_NAMESPACE             = "configmap->namesapce"
    54  	JOB_NAMESPACE                   = "job->namesapce"
    55  	CRONJOB_NAMESPACE               = "cronjob->namesapce"
    56  	PERSISTENTVOLUMECLAIM_NAMESPACE = "persistentvolumeclaim->namesapce"
    57  	INGRESS_NAMESPACE               = "ingress->namesapce"
    58  	//revive:disable:var-naming
    59  )
    60  
    61  var AllResources = []string{
    62  	POD,
    63  	SERVICE,
    64  	DEPLOYMENT,
    65  	REPLICASET,
    66  	STATEFULSET,
    67  	DAEMONSET,
    68  	CRONJOB,
    69  	JOB,
    70  	NODE,
    71  	NAMESPACE,
    72  	CONFIGMAP,
    73  	PERSISTENTVOLUME,
    74  	PERSISTENTVOLUMECLAIM,
    75  	STORAGECLASS,
    76  	INGRESS,
    77  }
    78  
    79  type PodNode struct {
    80  	Pod  *v1.Pod
    81  	Node *v1.Node
    82  }
    83  
    84  type PodDeployment struct {
    85  	Pod        *v1.Pod
    86  	Deployment *app.Deployment
    87  }
    88  
    89  type ReplicaSetDeployment struct {
    90  	Deployment *app.Deployment
    91  	ReplicaSet *app.ReplicaSet
    92  }
    93  
    94  type PodReplicaSet struct {
    95  	ReplicaSet *app.ReplicaSet
    96  	Pod        *v1.Pod
    97  }
    98  
    99  type PodStatefulSet struct {
   100  	StatefulSet *app.StatefulSet
   101  	Pod         *v1.Pod
   102  }
   103  
   104  type PodDaemonSet struct {
   105  	DaemonSet *app.DaemonSet
   106  	Pod       *v1.Pod
   107  }
   108  
   109  type JobCronJob struct {
   110  	CronJob *batch.CronJob
   111  	Job     *batch.Job
   112  }
   113  
   114  type PodJob struct {
   115  	Job *batch.Job
   116  	Pod *v1.Pod
   117  }
   118  
   119  type PodPersistentVolumeClaim struct {
   120  	Pod                   *v1.Pod
   121  	PersistentVolumeClaim *v1.PersistentVolumeClaim
   122  }
   123  
   124  type PodConfigMap struct {
   125  	Pod       *v1.Pod
   126  	ConfigMap *v1.ConfigMap
   127  }
   128  
   129  type PodService struct {
   130  	Service *v1.Service
   131  	Pod     *v1.Pod
   132  }
   133  
   134  type IngressService struct {
   135  	Ingress *networking.Ingress
   136  	Service *v1.Service
   137  }
   138  
   139  type PodContainer struct {
   140  	Pod       *v1.Pod
   141  	Container *v1.Container
   142  }
   143  
   144  type PodNamespace struct {
   145  	Pod       *v1.Pod
   146  	Namespace *v1.Namespace
   147  }
   148  
   149  type ServiceNamespace struct {
   150  	Service   *v1.Service
   151  	Namespace *v1.Namespace
   152  }
   153  
   154  type DeploymentNamespace struct {
   155  	Deployment *app.Deployment
   156  	Namespace  *v1.Namespace
   157  }
   158  
   159  type DaemonSetNamespace struct {
   160  	DaemonSet *app.DaemonSet
   161  	Namespace *v1.Namespace
   162  }
   163  
   164  type StatefulSetNamespace struct {
   165  	StatefulSet *app.StatefulSet
   166  	Namespace   *v1.Namespace
   167  }
   168  
   169  type ConfigMapNamespace struct {
   170  	ConfigMap *v1.ConfigMap
   171  	Namespace *v1.Namespace
   172  }
   173  
   174  type JobNamespace struct {
   175  	Job       *batch.Job
   176  	Namespace *v1.Namespace
   177  }
   178  
   179  type CronJobNamespace struct {
   180  	CronJob   *batch.CronJob
   181  	Namespace *v1.Namespace
   182  }
   183  
   184  type PersistentVolumeClaimNamespace struct {
   185  	PersistentVolumeClaim *v1.PersistentVolumeClaim
   186  	Namespace             *v1.Namespace
   187  }
   188  
   189  type IngressNamespace struct {
   190  	Ingress   *networking.Ingress
   191  	Namespace *v1.Namespace
   192  }
   193  
   194  const (
   195  	EventTypeAdd            = "add"
   196  	EventTypeUpdate         = "update"
   197  	EventTypeDelete         = "delete"
   198  	EventTypeDeferredDelete = "deferredDelete"
   199  	EventTypeTimer          = "timer"
   200  )
   201  
   202  type PodMetadata struct {
   203  	PodName      string            `json:"podName"`
   204  	StartTime    int64             `json:"startTime"`
   205  	Namespace    string            `json:"namespace"`
   206  	WorkloadName string            `json:"workloadName"`
   207  	WorkloadKind string            `json:"workloadKind"`
   208  	Labels       map[string]string `json:"labels"`
   209  	Envs         map[string]string `json:"envs"`
   210  	Images       map[string]string `json:"images"`
   211  
   212  	ServiceName  string   `json:"serviceName,omitempty"`
   213  	ContainerIDs []string `json:"containerIDs,omitempty"`
   214  	PodIP        string   `json:"podIP,omitempty"`
   215  	IsDeleted    bool     `json:"-"`
   216  }