How does Cilium get Pod info when creating a new Pod for setting up labels for endpoints?

30 views Asked by At

I am trying to understand endpoint creation for pods. In func (d *Daemon) createEndpoint(), d.fetchK8sMetadataForEndpoint() will fetch pod and its labels: `

func (d *Daemon) fetchK8sMetadataForEndpoint(nsName, podName string) (*slim_corev1.Pod, []slim_corev1.ContainerPort, labels.Labels, labels.Labels, map[string]string, error) {
        ns, p, err := d.endpointMetadataFetcher.Fetch(nsName, podName)
        if err != nil {
                return nil, nil, nil, nil, nil, err
        }

        containerPorts, lbls, annotations, err := k8s.GetPodMetadata(ns, p)
        if err != nil {
                return nil, nil, nil, nil, nil, err
        }

        k8sLbls := labels.Map2Labels(lbls, labels.LabelSourceK8s)
        identityLabels, infoLabels := labelsfilter.Filter(k8sLbls)
        return p, containerPorts, identityLabels, infoLabels, annotations, nil
}

How this function fetches pod in case of cached and uncached methods? It searches for pod from same node only or it can find pod from kubeapi server? any extra config (to cilium install) needed to fetch pod from kubeapi server?

I have traced down the code till cilium/pkg/k8s/watcher/pod.go. It seems to fetch pod details from local store?

0

There are 0 answers