Skip to content

Commit

Permalink
expose instance type as label on Central pod (#882)
Browse files Browse the repository at this point in the history
The label will be scraped by Prometheus as a source for dashboards.
  • Loading branch information
stehessel authored Mar 14, 2023
1 parent 5d5ecf3 commit c5581c1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
7 changes: 5 additions & 2 deletions fleetshard/pkg/central/reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
envAnnotationKey = "rhacs.redhat.com/environment"
clusterNameAnnotationKey = "rhacs.redhat.com/cluster-name"
orgNameAnnotationKey = "rhacs.redhat.com/org-name"
instanceTypeLabelKey = "rhacs.redhat.com/instance-type"
orgIDLabelKey = "rhacs.redhat.com/org-id"
tenantIDLabelKey = "rhacs.redhat.com/tenant"

Expand Down Expand Up @@ -139,6 +140,7 @@ func (r *CentralReconciler) Reconcile(ctx context.Context, remoteCentral private
Labels: map[string]string{
k8s.ManagedByLabelKey: k8s.ManagedByFleetshardValue,
tenantIDLabelKey: remoteCentral.Id,
instanceTypeLabelKey: remoteCentral.Spec.Central.InstanceType,
},
Annotations: map[string]string{managedServicesAnnotation: "true"},
},
Expand Down Expand Up @@ -185,8 +187,9 @@ func (r *CentralReconciler) Reconcile(ctx context.Context, remoteCentral private
orgNameAnnotationKey: remoteCentral.Spec.Auth.OwnerOrgName,
},
Labels: map[string]string{
orgIDLabelKey: remoteCentral.Spec.Auth.OwnerOrgId,
tenantIDLabelKey: remoteCentral.Id,
orgIDLabelKey: remoteCentral.Spec.Auth.OwnerOrgId,
tenantIDLabelKey: remoteCentral.Id,
instanceTypeLabelKey: remoteCentral.Spec.Central.InstanceType,
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions fleetshard/pkg/central/reconciler/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ var simpleManagedCentral = private.ManagedCentral{
DataEndpoint: private.ManagedCentralAllOfSpecDataEndpoint{
Host: fmt.Sprintf("acs-data-%s.acs.rhcloud.test", centralID),
},
Central: private.ManagedCentralAllOfSpecCentral{
InstanceType: "standard",
},
},
}

Expand Down Expand Up @@ -108,6 +111,7 @@ func TestReconcileCreate(t *testing.T) {
assert.Equal(t, clusterName, central.Spec.Customize.Annotations[clusterNameAnnotationKey])
assert.Equal(t, simpleManagedCentral.Spec.Auth.OwnerOrgName, central.Spec.Customize.Annotations[orgNameAnnotationKey])
assert.Equal(t, simpleManagedCentral.Spec.Auth.OwnerOrgId, central.Spec.Customize.Labels[orgIDLabelKey])
assert.Equal(t, simpleManagedCentral.Spec.Central.InstanceType, central.Spec.Customize.Labels[instanceTypeLabelKey])
assert.Equal(t, "1", central.GetAnnotations()[util.RevisionAnnotationKey])
assert.Equal(t, "true", central.GetAnnotations()[managedServicesAnnotation])
assert.Equal(t, true, *central.Spec.Central.Exposure.Route.Enabled)
Expand Down
5 changes: 5 additions & 0 deletions internal/dinosaur/pkg/api/private/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,11 @@ components:
type: string
ManagedCentral_allOf_spec_central:
properties:
instanceType:
enum:
- eval
- standard
type: string
resources:
$ref: '#/components/schemas/ResourceRequirements'
ManagedCentral_allOf_spec_scanner_analyzer_scaling:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/dinosaur/pkg/presenters/managedcentral.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func (c *ManagedCentralPresenter) PresentManagedCentral(from *dbapi.CentralReque
CentralOperator: from.DesiredCentralOperatorVersion,
},
Central: private.ManagedCentralAllOfSpecCentral{
InstanceType: from.InstanceType,
Resources: private.ResourceRequirements{
Requests: map[string]string{
corev1.ResourceCPU.String(): orDefaultQty(central.Resources.Requests[corev1.ResourceCPU], defaults.Central.CPURequest).String(),
Expand Down
3 changes: 3 additions & 0 deletions openapi/fleet-manager-private.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ components:
central:
type: object
properties:
instanceType:
type: string
enum: [eval, standard]
resources:
$ref: "#/components/schemas/ResourceRequirements"
scanner:
Expand Down

0 comments on commit c5581c1

Please sign in to comment.