github.com/cilium/cilium@v1.16.2/pkg/hubble/parser/getters/getters.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Hubble 3 4 package getters 5 6 import ( 7 "net/netip" 8 9 flowpb "github.com/cilium/cilium/api/v1/flow" 10 cgroupManager "github.com/cilium/cilium/pkg/cgroups/manager" 11 "github.com/cilium/cilium/pkg/identity" 12 "github.com/cilium/cilium/pkg/ipcache" 13 slim_corev1 "github.com/cilium/cilium/pkg/k8s/slim/k8s/api/core/v1" 14 "github.com/cilium/cilium/pkg/labels" 15 policyTypes "github.com/cilium/cilium/pkg/policy/types" 16 ) 17 18 // DNSGetter ... 19 type DNSGetter interface { 20 // GetNamesOf fetches FQDNs of a given IP from the perspective of 21 // the endpoint with ID sourceEpID. The returned names must not have 22 // trailing dots. 23 GetNamesOf(sourceEpID uint32, ip netip.Addr) (names []string) 24 } 25 26 // EndpointGetter ... 27 type EndpointGetter interface { 28 // GetEndpointInfo looks up endpoint by IP address. 29 GetEndpointInfo(ip netip.Addr) (endpoint EndpointInfo, ok bool) 30 // GetEndpointInfo looks up endpoint by id 31 GetEndpointInfoByID(id uint16) (endpoint EndpointInfo, ok bool) 32 } 33 34 // IdentityGetter ... 35 type IdentityGetter interface { 36 // GetIdentity fetches a full identity object given a numeric security id. 37 GetIdentity(id uint32) (*identity.Identity, error) 38 } 39 40 // IPGetter fetches per-IP metadata 41 type IPGetter interface { 42 // GetK8sMetadata returns Kubernetes metadata for the given IP address. 43 GetK8sMetadata(ip netip.Addr) *ipcache.K8sMetadata 44 // LookupSecIDByIP returns the corresponding security identity that 45 // the specified IP maps to as well as if the corresponding entry exists. 46 LookupSecIDByIP(ip netip.Addr) (ipcache.Identity, bool) 47 } 48 49 // ServiceGetter fetches service metadata. 50 type ServiceGetter interface { 51 GetServiceByAddr(ip netip.Addr, port uint16) *flowpb.Service 52 } 53 54 // LinkGetter fetches local link information. 55 type LinkGetter interface { 56 // GetIfNameCached returns the name of an interface (if it exists) by 57 // looking it up in a regularly updated cache 58 GetIfNameCached(ifIndex int) (string, bool) 59 60 // Name returns the name of an interface, or returns a string 61 // containing the ifindex if the link name cannot be determined. 62 Name(ifIndex uint32) string 63 } 64 65 // PodMetadataGetter returns pod metadata based on identifiers received from 66 // datapath trace events. 67 type PodMetadataGetter interface { 68 // GetPodMetadataForContainer returns the pod metadata for the given container 69 // cgroup id. 70 GetPodMetadataForContainer(cgroupId uint64) *cgroupManager.PodMetadata 71 } 72 73 // EndpointInfo defines readable fields of a Cilium endpoint. 74 type EndpointInfo interface { 75 GetID() uint64 76 GetIdentity() identity.NumericIdentity 77 GetK8sPodName() string 78 GetK8sNamespace() string 79 GetLabels() []string 80 GetPod() *slim_corev1.Pod 81 GetRealizedPolicyRuleLabelsForKey(key policyTypes.Key) (derivedFrom labels.LabelArrayList, revision uint64, ok bool) 82 }