mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-14 13:46:45 +00:00
support runner labels
This commit is contained in:
@@ -31,6 +31,9 @@ type RunnerSpec struct {
|
|||||||
// +kubebuilder:validation:Pattern=`^[^/]*$`
|
// +kubebuilder:validation:Pattern=`^[^/]*$`
|
||||||
Repository string `json:"repository,omitempty"`
|
Repository string `json:"repository,omitempty"`
|
||||||
|
|
||||||
|
// +optional
|
||||||
|
Labels []string `json:"labels,omitempty"`
|
||||||
|
|
||||||
// +optional
|
// +optional
|
||||||
Containers []corev1.Container `json:"containers,omitempty"`
|
Containers []corev1.Container `json:"containers,omitempty"`
|
||||||
// +optional
|
// +optional
|
||||||
@@ -84,6 +87,7 @@ type RunnerStatus struct {
|
|||||||
type RunnerStatusRegistration struct {
|
type RunnerStatusRegistration struct {
|
||||||
Organization string `json:"organization"`
|
Organization string `json:"organization"`
|
||||||
Repository string `json:"repository,omitempty"`
|
Repository string `json:"repository,omitempty"`
|
||||||
|
Labels []string `json:"labels,omitempty"`
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
ExpiresAt metav1.Time `json:"expiresAt"`
|
ExpiresAt metav1.Time `json:"expiresAt"`
|
||||||
}
|
}
|
||||||
@@ -92,6 +96,7 @@ type RunnerStatusRegistration struct {
|
|||||||
// +kubebuilder:subresource:status
|
// +kubebuilder:subresource:status
|
||||||
// +kubebuilder:printcolumn:JSONPath=".spec.organization",name=Organization,type=string
|
// +kubebuilder:printcolumn:JSONPath=".spec.organization",name=Organization,type=string
|
||||||
// +kubebuilder:printcolumn:JSONPath=".spec.repository",name=Repository,type=string
|
// +kubebuilder:printcolumn:JSONPath=".spec.repository",name=Repository,type=string
|
||||||
|
// +kubebuilder:printcolumn:JSONPath=".spec.labels",name=Labels,type=string
|
||||||
// +kubebuilder:printcolumn:JSONPath=".status.phase",name=Status,type=string
|
// +kubebuilder:printcolumn:JSONPath=".status.phase",name=Status,type=string
|
||||||
|
|
||||||
// Runner is the Schema for the runners API
|
// Runner is the Schema for the runners API
|
||||||
|
|||||||
@@ -277,6 +277,11 @@ func (in *RunnerReplicaSetStatus) DeepCopy() *RunnerReplicaSetStatus {
|
|||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *RunnerSpec) DeepCopyInto(out *RunnerSpec) {
|
func (in *RunnerSpec) DeepCopyInto(out *RunnerSpec) {
|
||||||
*out = *in
|
*out = *in
|
||||||
|
if in.Labels != nil {
|
||||||
|
in, out := &in.Labels, &out.Labels
|
||||||
|
*out = make([]string, len(*in))
|
||||||
|
copy(*out, *in)
|
||||||
|
}
|
||||||
if in.Containers != nil {
|
if in.Containers != nil {
|
||||||
in, out := &in.Containers, &out.Containers
|
in, out := &in.Containers, &out.Containers
|
||||||
*out = make([]v1.Container, len(*in))
|
*out = make([]v1.Container, len(*in))
|
||||||
@@ -404,6 +409,11 @@ func (in *RunnerStatus) DeepCopy() *RunnerStatus {
|
|||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *RunnerStatusRegistration) DeepCopyInto(out *RunnerStatusRegistration) {
|
func (in *RunnerStatusRegistration) DeepCopyInto(out *RunnerStatusRegistration) {
|
||||||
*out = *in
|
*out = *in
|
||||||
|
if in.Labels != nil {
|
||||||
|
in, out := &in.Labels, &out.Labels
|
||||||
|
*out = make([]string, len(*in))
|
||||||
|
copy(*out, *in)
|
||||||
|
}
|
||||||
in.ExpiresAt.DeepCopyInto(&out.ExpiresAt)
|
in.ExpiresAt.DeepCopyInto(&out.ExpiresAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4111,6 +4111,10 @@ spec:
|
|||||||
- name
|
- name
|
||||||
type: object
|
type: object
|
||||||
type: array
|
type: array
|
||||||
|
labels:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: string
|
type: string
|
||||||
|
|||||||
@@ -4111,6 +4111,10 @@ spec:
|
|||||||
- name
|
- name
|
||||||
type: object
|
type: object
|
||||||
type: array
|
type: array
|
||||||
|
labels:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: string
|
type: string
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ spec:
|
|||||||
- JSONPath: .spec.repository
|
- JSONPath: .spec.repository
|
||||||
name: Repository
|
name: Repository
|
||||||
type: string
|
type: string
|
||||||
|
- JSONPath: .spec.labels
|
||||||
|
name: Labels
|
||||||
|
type: string
|
||||||
- JSONPath: .status.phase
|
- JSONPath: .status.phase
|
||||||
name: Status
|
name: Status
|
||||||
type: string
|
type: string
|
||||||
@@ -3857,6 +3860,10 @@ spec:
|
|||||||
- name
|
- name
|
||||||
type: object
|
type: object
|
||||||
type: array
|
type: array
|
||||||
|
labels:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: string
|
type: string
|
||||||
@@ -6316,6 +6323,10 @@ spec:
|
|||||||
expiresAt:
|
expiresAt:
|
||||||
format: date-time
|
format: date-time
|
||||||
type: string
|
type: string
|
||||||
|
labels:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
organization:
|
organization:
|
||||||
type: string
|
type: string
|
||||||
repository:
|
repository:
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/go-logr/logr"
|
"github.com/go-logr/logr"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
@@ -119,6 +120,7 @@ func (r *RunnerReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
|
|||||||
updated.Status.Registration = v1alpha1.RunnerStatusRegistration{
|
updated.Status.Registration = v1alpha1.RunnerStatusRegistration{
|
||||||
Organization: runner.Spec.Organization,
|
Organization: runner.Spec.Organization,
|
||||||
Repository: runner.Spec.Repository,
|
Repository: runner.Spec.Repository,
|
||||||
|
Labels: runner.Spec.Labels,
|
||||||
Token: rt.GetToken(),
|
Token: rt.GetToken(),
|
||||||
ExpiresAt: metav1.NewTime(rt.GetExpiresAt().Time),
|
ExpiresAt: metav1.NewTime(rt.GetExpiresAt().Time),
|
||||||
}
|
}
|
||||||
@@ -262,6 +264,10 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) {
|
|||||||
Name: "RUNNER_REPO",
|
Name: "RUNNER_REPO",
|
||||||
Value: runner.Spec.Repository,
|
Value: runner.Spec.Repository,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "RUNNER_LABELS",
|
||||||
|
Value: strings.Join(runner.Spec.Labels, ","),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "RUNNER_TOKEN",
|
Name: "RUNNER_TOKEN",
|
||||||
Value: runner.Status.Registration.Token,
|
Value: runner.Status.Registration.Token,
|
||||||
|
|||||||
@@ -16,13 +16,17 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${RUNNER_LABELS}" ]; then
|
||||||
|
LABEL_ARG="--labels ${RUNNER_LABELS}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "${RUNNER_TOKEN}" ]; then
|
if [ -z "${RUNNER_TOKEN}" ]; then
|
||||||
echo "RUNNER_TOKEN must be set" 1>&2
|
echo "RUNNER_TOKEN must be set" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd /runner
|
cd /runner
|
||||||
./config.sh --unattended --replace --name "${RUNNER_NAME}" --url "https://github.com/${ATTACH}" --token "${RUNNER_TOKEN}"
|
./config.sh --unattended --replace --name "${RUNNER_NAME}" --url "https://github.com/${ATTACH}" --token "${RUNNER_TOKEN}" ${LABEL_ARG}
|
||||||
|
|
||||||
unset RUNNER_NAME RUNNER_REPO RUNNER_TOKEN
|
unset RUNNER_NAME RUNNER_REPO RUNNER_TOKEN
|
||||||
exec ./run.sh --once
|
exec ./run.sh --once
|
||||||
|
|||||||
Reference in New Issue
Block a user