Skip to content

Commit

Permalink
Merge pull request #4147 from typeid/HOSTEDCP-1689
Browse files Browse the repository at this point in the history
HOSTEDCP-1689: add PodMonitor for external-dns
  • Loading branch information
openshift-merge-bot[bot] authored Jun 7, 2024
2 parents abad36f + 08185a0 commit 5518314
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 5 deletions.
41 changes: 36 additions & 5 deletions cmd/install/assets/hypershift_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const (
externaDNSCredsSecretName = "external-dns-credentials"

HypershiftOperatorName = "operator"
ExternalDNSDeploymentName = "external-dns"
HyperShiftInstallCLIVersionAnnotation = "hypershift.openshift.io/install-cli-version"
)

Expand Down Expand Up @@ -191,22 +192,22 @@ func (o ExternalDNSDeployment) Build() *appsv1.Deployment {
APIVersion: appsv1.SchemeGroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "external-dns",
Name: ExternalDNSDeploymentName,
Namespace: o.Namespace.Name,
},
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"name": "external-dns",
"name": ExternalDNSDeploymentName,
},
},
Replicas: &replicas,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"name": "external-dns",
"app": "external-dns",
hyperv1.OperatorComponent: "external-dns",
"name": ExternalDNSDeploymentName,
"app": ExternalDNSDeploymentName,
hyperv1.OperatorComponent: ExternalDNSDeploymentName,
},
},
Spec: corev1.PodSpec{
Expand Down Expand Up @@ -864,6 +865,36 @@ func (o ExternalDNSClusterRoleBinding) Build() *rbacv1.ClusterRoleBinding {
return binding
}

type ExternalDNSPodMonitor struct {
Namespace *corev1.Namespace
}

func (o ExternalDNSPodMonitor) Build() *prometheusoperatorv1.PodMonitor {
return &prometheusoperatorv1.PodMonitor{
TypeMeta: metav1.TypeMeta{
Kind: "PodMonitor",
APIVersion: prometheusoperatorv1.SchemeGroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Namespace: o.Namespace.Name,
Name: ExternalDNSDeploymentName,
},
Spec: prometheusoperatorv1.PodMonitorSpec{
JobLabel: "component",
Selector: metav1.LabelSelector{
MatchLabels: map[string]string{
"name": ExternalDNSDeploymentName,
},
},
PodMetricsEndpoints: []prometheusoperatorv1.PodMetricsEndpoint{{
Port: "metrics",
Interval: "30s",
},
},
},
}
}

type HyperShiftOperatorServiceAccount struct {
Namespace *corev1.Namespace
}
Expand Down
5 changes: 5 additions & 0 deletions cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,11 @@ func hyperShiftOperatorManifests(opts Options) ([]crclient.Object, []crclient.Ob
TxtOwnerId: opts.ExternalDNSTxtOwnerId,
}.Build()
objects = append(objects, externalDNSDeployment)

podMonitor := assets.ExternalDNSPodMonitor{
Namespace: operatorNamespace,
}.Build()
objects = append(objects, podMonitor)
}

if opts.MonitoringDashboards {
Expand Down
17 changes: 17 additions & 0 deletions hack/app-sre/saas_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,23 @@ objects:
secret:
secretName: ${EXTERNAL_DNS_CREDS_SECRET}
status: {}
- apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
creationTimestamp: null
name: external-dns
namespace: ${NAMESPACE}
spec:
jobLabel: component
namespaceSelector: {}
podMetricsEndpoints:
- bearerTokenSecret:
key: ""
interval: 30s
port: metrics
selector:
matchLabels:
name: external-dns
- apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down

0 comments on commit 5518314

Please sign in to comment.