diff --git a/apis/actions.summerwind.net/v1alpha1/runnerdeployment_types.go b/apis/actions.summerwind.net/v1alpha1/runnerdeployment_types.go index eabd2bb4..7f5925bf 100644 --- a/apis/actions.summerwind.net/v1alpha1/runnerdeployment_types.go +++ b/apis/actions.summerwind.net/v1alpha1/runnerdeployment_types.go @@ -72,11 +72,16 @@ type RunnerDeploymentStatus struct { // Replicas is the total number of replicas // +optional Replicas *int `json:"replicas"` + + // Selector is the string form of the pod selector + // +optional + Selector string `json:"selector"` } // +kubebuilder:object:root=true // +kubebuilder:resource:shortName=rdeploy // +kubebuilder:subresource:status +// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector // +kubebuilder:printcolumn:JSONPath=".spec.template.spec.enterprise",name=Enterprise,type=string // +kubebuilder:printcolumn:JSONPath=".spec.template.spec.organization",name=Organization,type=string // +kubebuilder:printcolumn:JSONPath=".spec.template.spec.repository",name=Repository,type=string diff --git a/apis/actions.summerwind.net/v1alpha1/runnerset_types.go b/apis/actions.summerwind.net/v1alpha1/runnerset_types.go index 58ef755e..09beacec 100644 --- a/apis/actions.summerwind.net/v1alpha1/runnerset_types.go +++ b/apis/actions.summerwind.net/v1alpha1/runnerset_types.go @@ -69,10 +69,15 @@ type RunnerSetStatus struct { // Replicas is the total number of replicas // +optional Replicas *int `json:"replicas"` + + // Selector is the string form of the pod selector + // +optional + Selector string `json:"selector"` } // +kubebuilder:object:root=true // +kubebuilder:subresource:status +// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector // +kubebuilder:printcolumn:JSONPath=".spec.replicas",name=Desired,type=number // +kubebuilder:printcolumn:JSONPath=".status.replicas",name=Current,type=number // +kubebuilder:printcolumn:JSONPath=".status.updatedReplicas",name=Up-To-Date,type=number diff --git a/charts/actions-runner-controller/crds/actions.summerwind.dev_runnerdeployments.yaml b/charts/actions-runner-controller/crds/actions.summerwind.dev_runnerdeployments.yaml index 0b525430..07564987 100644 --- a/charts/actions-runner-controller/crds/actions.summerwind.dev_runnerdeployments.yaml +++ b/charts/actions-runner-controller/crds/actions.summerwind.dev_runnerdeployments.yaml @@ -5526,6 +5526,9 @@ spec: replicas: description: Replicas is the total number of replicas type: integer + selector: + description: Selector is the string form of the pod selector + type: string updatedReplicas: description: ReadyReplicas is the total number of available runners which have been successfully registered to GitHub and still running. This corresponds to status.replicas of the runner replica set that has the desired template hash. type: integer @@ -5534,5 +5537,9 @@ spec: served: true storage: true subresources: + scale: + labelSelectorPath: .status.selector + specReplicasPath: .spec.replicas + statusReplicasPath: .status.replicas status: {} preserveUnknownFields: false diff --git a/charts/actions-runner-controller/crds/actions.summerwind.dev_runnersets.yaml b/charts/actions-runner-controller/crds/actions.summerwind.dev_runnersets.yaml index 250e21e7..2257443a 100644 --- a/charts/actions-runner-controller/crds/actions.summerwind.dev_runnersets.yaml +++ b/charts/actions-runner-controller/crds/actions.summerwind.dev_runnersets.yaml @@ -4785,6 +4785,9 @@ spec: replicas: description: Replicas is the total number of replicas type: integer + selector: + description: Selector is the string form of the pod selector + type: string updatedReplicas: description: ReadyReplicas is the total number of available runners which have been successfully registered to GitHub and still running. This corresponds to status.replicas of the runner replica set that has the desired template hash. type: integer @@ -4793,5 +4796,9 @@ spec: served: true storage: true subresources: + scale: + labelSelectorPath: .status.selector + specReplicasPath: .spec.replicas + statusReplicasPath: .status.replicas status: {} preserveUnknownFields: false diff --git a/config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml b/config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml index 0b525430..07564987 100644 --- a/config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml +++ b/config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml @@ -5526,6 +5526,9 @@ spec: replicas: description: Replicas is the total number of replicas type: integer + selector: + description: Selector is the string form of the pod selector + type: string updatedReplicas: description: ReadyReplicas is the total number of available runners which have been successfully registered to GitHub and still running. This corresponds to status.replicas of the runner replica set that has the desired template hash. type: integer @@ -5534,5 +5537,9 @@ spec: served: true storage: true subresources: + scale: + labelSelectorPath: .status.selector + specReplicasPath: .spec.replicas + statusReplicasPath: .status.replicas status: {} preserveUnknownFields: false diff --git a/config/crd/bases/actions.summerwind.dev_runnersets.yaml b/config/crd/bases/actions.summerwind.dev_runnersets.yaml index 250e21e7..2257443a 100644 --- a/config/crd/bases/actions.summerwind.dev_runnersets.yaml +++ b/config/crd/bases/actions.summerwind.dev_runnersets.yaml @@ -4785,6 +4785,9 @@ spec: replicas: description: Replicas is the total number of replicas type: integer + selector: + description: Selector is the string form of the pod selector + type: string updatedReplicas: description: ReadyReplicas is the total number of available runners which have been successfully registered to GitHub and still running. This corresponds to status.replicas of the runner replica set that has the desired template hash. type: integer @@ -4793,5 +4796,9 @@ spec: served: true storage: true subresources: + scale: + labelSelectorPath: .status.selector + specReplicasPath: .spec.replicas + statusReplicasPath: .status.replicas status: {} preserveUnknownFields: false diff --git a/controllers/actions.summerwind.net/runnerdeployment_controller.go b/controllers/actions.summerwind.net/runnerdeployment_controller.go index 7753b640..c3ca29ae 100644 --- a/controllers/actions.summerwind.net/runnerdeployment_controller.go +++ b/controllers/actions.summerwind.net/runnerdeployment_controller.go @@ -313,6 +313,13 @@ func (r *RunnerDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req status.DesiredReplicas = &newDesiredReplicas status.Replicas = &totalCurrentReplicas status.UpdatedReplicas = &updatedReplicas + selector, err := metav1.LabelSelectorAsSelector(rd.Spec.Selector) + if err != nil { + log.Error(err, "Failed to retrieve pod labels") + + return ctrl.Result{}, err + } + status.Selector = selector.String() if !reflect.DeepEqual(rd.Status, status) { updated := rd.DeepCopy() diff --git a/controllers/actions.summerwind.net/runnerset_controller.go b/controllers/actions.summerwind.net/runnerset_controller.go index 5fd825a2..347efc49 100644 --- a/controllers/actions.summerwind.net/runnerset_controller.go +++ b/controllers/actions.summerwind.net/runnerset_controller.go @@ -157,6 +157,13 @@ func (r *RunnerSetReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( status.DesiredReplicas = &newDesiredReplicas status.Replicas = &statusReplicas status.UpdatedReplicas = &updatedReplicas + selector, err := metav1.LabelSelectorAsSelector(runnerSet.Spec.Selector) + if err != nil { + log.Error(err, "Failed to retrieve pod labels") + + return ctrl.Result{}, err + } + status.Selector = selector.String() if !reflect.DeepEqual(runnerSet.Status, status) { updated := runnerSet.DeepCopy()