func (c *Controller) reconcilePodmonitors(ctx context.Context, controlPlane *v1alpha1.ControlPlane) error {
	// create pod monitor for API server and etcd pods
	for _, spec := range []monitoringv1.PodMonitorSpec{
		apiServerPodMonitorFor(controlPlane),
		etcdPodMonitorFor(controlPlane),
	} {
		if err := c.kubeClient.EnsureCreate(ctx, object.WithOwner(controlPlane, &monitoringv1.PodMonitor{
			ObjectMeta: metav1.ObjectMeta{
				Name:      spec.JobLabel,
				Namespace: controlPlane.Namespace,
				Labels:    map[string]string{"release": "kube-prometheus-stack"},
			},
			Spec: spec,
		})); err != nil {
			return fmt.Errorf("ensuring podmonitor for %s, %w", spec.JobLabel, err)
		}
	}
	return nil
}
// reconcilePodmonitors patches the required cert volumes by Prometheus to scrape guest cluster metrics
reconcilePodmonitors patches the required cert volumes by Prometheus to scrape guest cluster metrics
// reconcilePodmonitors patches the required cert volumes by Prometheus to scrape guest cluster metrics
func (c *Controller) reconcilePodmonitors(ctx context.Context, controlPlane *v1alpha1.ControlPlane) error {
	for _, spec := range []monitoringv1.PodMonitorSpec{
		apiServerPodMonitorFor(controlPlane),
		etcdPodMonitorFor(controlPlane),
	} {
		if err := c.kubeClient.EnsureCreate(ctx, object.WithOwner(controlPlane, &monitoringv1.PodMonitor{
			ObjectMeta: metav1.ObjectMeta{
				Name:      spec.JobLabel,
				Namespace: controlPlane.Namespace,
				Labels:    map[string]string{"release": "kube-prometheus-stack"},
			},
			Spec: spec,
		})); err != nil {
			return fmt.Errorf("ensuring podmonitor for %s, %w", spec.JobLabel, err)
		}
	}
	return nil
}
func ( c * Controller ) reconcilePodmonitors ( ctx context . Context , controlPlane * v1alpha1 . ControlPlane ) error { for _ , spec := range [ ] monitoringv1 . PodMonitorSpec { apiServerPodMonitorFor ( controlPlane ) , etcdPodMonitorFor ( controlPlane ) , } { if err := c . kubeClient . EnsureCreate ( ctx , object . WithOwner ( controlPlane , & monitoringv1 . PodMonitor { ObjectMeta : metav1 . ObjectMeta { Name : spec . JobLabel , Namespace : controlPlane . Namespace , Labels : map [ string ] string { " " : " " } , } , Spec : spec , } ) ) ; err != nil { return fmt . Errorf ( " " , spec . JobLabel , err ) } } return nil }
reconcilePodmonitors patches the required cert volumes by Prometheus to scrape guest cluster metrics
reconcilePodmonitors patches the required cert volumes by Prometheus to scrape guest cluster metrics
// create pod monitor for API server and etcd pods