Skip to content

Commit 42b8d8d

Browse files
committed
Introduce new preview auto-scaling mode for ARC.
1 parent 3e88ae2 commit 42b8d8d

File tree

105 files changed

+41261
-333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+41261
-333
lines changed

.github/workflows/publish-chart.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ on:
1010
- 'charts/**'
1111
- '.github/workflows/publish-chart.yaml'
1212
- '!charts/actions-runner-controller/docs/**'
13+
- '!charts/actions-runner-controller-2/**'
14+
- '!charts/auto-scaling-runner-set/**'
1315
- '!**.md'
1416
workflow_dispatch:
1517

.github/workflows/validate-chart.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
- 'charts/**'
77
- '.github/workflows/validate-chart.yaml'
88
- '!charts/actions-runner-controller/docs/**'
9+
- '!charts/actions-runner-controller-2/**'
10+
- '!charts/auto-scaling-runner-set/**'
911
- '!**.md'
1012
workflow_dispatch:
1113
env:

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ RUN --mount=target=. \
3737
--mount=type=cache,mode=0777,target=${GOCACHE} \
3838
export GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${TARGETVARIANT#v} && \
3939
go build -trimpath -ldflags="-s -w -X 'github.com/actions/actions-runner-controller/build.Version=${VERSION}'" -o /out/manager main.go && \
40+
go build -trimpath -ldflags="-s -w" -o /out/github-runnerscaleset-listener ./cmd/githubrunnerscalesetlistener && \
4041
go build -trimpath -ldflags="-s -w" -o /out/github-webhook-server ./cmd/githubwebhookserver && \
4142
go build -trimpath -ldflags="-s -w" -o /out/actions-metrics-server ./cmd/actionsmetricsserver
4243

@@ -49,6 +50,7 @@ WORKDIR /
4950
COPY --from=builder /out/manager .
5051
COPY --from=builder /out/github-webhook-server .
5152
COPY --from=builder /out/actions-metrics-server .
53+
COPY --from=builder /out/github-runnerscaleset-listener .
5254

5355
USER 65532:65532
5456

Makefile

+9
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ test-with-deps: kube-apiserver etcd kubectl
8686
# Build manager binary
8787
manager: generate fmt vet
8888
go build -o bin/manager main.go
89+
go build -o bin/github-runnerscaleset-listener ./cmd/githubrunnerscalesetlistener
8990

9091
# Run against the configured Kubernetes cluster in ~/.kube/config
9192
run: generate fmt vet manifests
@@ -115,6 +116,14 @@ manifests-gen-crds: controller-gen yq
115116

116117
chart-crds:
117118
cp config/crd/bases/*.yaml charts/actions-runner-controller/crds/
119+
cp config/crd/bases/actions.github.com_autoscalingrunnersets.yaml charts/actions-runner-controller-2/crds/
120+
cp config/crd/bases/actions.github.com_autoscalinglisteners.yaml charts/actions-runner-controller-2/crds/
121+
cp config/crd/bases/actions.github.com_ephemeralrunnersets.yaml charts/actions-runner-controller-2/crds/
122+
cp config/crd/bases/actions.github.com_ephemeralrunners.yaml charts/actions-runner-controller-2/crds/
123+
rm charts/actions-runner-controller/crds/actions.github.com_autoscalingrunnersets.yaml
124+
rm charts/actions-runner-controller/crds/actions.github.com_autoscalinglisteners.yaml
125+
rm charts/actions-runner-controller/crds/actions.github.com_ephemeralrunnersets.yaml
126+
rm charts/actions-runner-controller/crds/actions.github.com_ephemeralrunners.yaml
118127

119128
# Run go fmt against code
120129
fmt:

PROJECT

+12
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,16 @@ resources:
1010
- group: actions
1111
kind: RunnerDeployment
1212
version: v1alpha1
13+
- group: actions
14+
kind: AutoscalingRunnerSet
15+
version: v1alpha1
16+
- group: actions
17+
kind: EphemeralRunnerSet
18+
version: v1alpha1
19+
- group: actions
20+
kind: EphemeralRunner
21+
version: v1alpha1
22+
- group: actions
23+
kind: AutoscalingListener
24+
version: v1alpha1
1325
version: "2"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
Copyright 2020 The actions-runner-controller authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
corev1 "k8s.io/api/core/v1"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
// AutoscalingListenerSpec defines the desired state of AutoscalingListener
25+
type AutoscalingListenerSpec struct {
26+
// Required
27+
GitHubConfigUrl string `json:"githubConfigUrl,omitempty"`
28+
29+
// Required
30+
GitHubConfigSecret string `json:"githubConfigSecret,omitempty"`
31+
32+
// Required
33+
RunnerScaleSetId int `json:"runnerScaleSetId,omitempty"`
34+
35+
// Required
36+
AutoscalingRunnerSetNamespace string `json:"autoscalingRunnerSetNamespace,omitempty"`
37+
38+
// Required
39+
AutoscalingRunnerSetName string `json:"autoscalingRunnerSetName,omitempty"`
40+
41+
// Required
42+
EphemeralRunnerSetName string `json:"ephemeralRunnerSetName,omitempty"`
43+
44+
// Required
45+
// +kubebuilder:validation:Minimum:=0
46+
MaxRunners int `json:"maxRunners,omitempty"`
47+
48+
// Required
49+
// +kubebuilder:validation:Minimum:=0
50+
MinRunners int `json:"minRunners,omitempty"`
51+
52+
// Required
53+
Image string `json:"image,omitempty"`
54+
55+
// Required
56+
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
57+
}
58+
59+
// AutoscalingListenerStatus defines the observed state of AutoscalingListener
60+
type AutoscalingListenerStatus struct {
61+
}
62+
63+
//+kubebuilder:object:root=true
64+
//+kubebuilder:subresource:status
65+
//+kubebuilder:printcolumn:JSONPath=".spec.githubConfigUrl",name=GitHub Configure URL,type=string
66+
//+kubebuilder:printcolumn:JSONPath=".spec.autoscalingRunnerSetNamespace",name=AutoscalingRunnerSet Namespace,type=string
67+
//+kubebuilder:printcolumn:JSONPath=".spec.autoscalingRunnerSetName",name=AutoscalingRunnerSet Name,type=string
68+
69+
// AutoscalingListener is the Schema for the autoscalinglisteners API
70+
type AutoscalingListener struct {
71+
metav1.TypeMeta `json:",inline"`
72+
metav1.ObjectMeta `json:"metadata,omitempty"`
73+
74+
Spec AutoscalingListenerSpec `json:"spec,omitempty"`
75+
Status AutoscalingListenerStatus `json:"status,omitempty"`
76+
}
77+
78+
//+kubebuilder:object:root=true
79+
80+
// AutoscalingListenerList contains a list of AutoscalingListener
81+
type AutoscalingListenerList struct {
82+
metav1.TypeMeta `json:",inline"`
83+
metav1.ListMeta `json:"metadata,omitempty"`
84+
Items []AutoscalingListener `json:"items"`
85+
}
86+
87+
func init() {
88+
SchemeBuilder.Register(&AutoscalingListener{}, &AutoscalingListenerList{})
89+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
Copyright 2020 The actions-runner-controller authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
"github.com/actions/actions-runner-controller/hash"
21+
corev1 "k8s.io/api/core/v1"
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
)
24+
25+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
26+
27+
//+kubebuilder:object:root=true
28+
//+kubebuilder:subresource:status
29+
//+kubebuilder:printcolumn:JSONPath=".spec.minRunners",name=Minimum Runners,type=number
30+
//+kubebuilder:printcolumn:JSONPath=".spec.maxRunners",name=Maximum Runners,type=number
31+
//+kubebuilder:printcolumn:JSONPath=".status.currentRunners",name=Current Runners,type=number
32+
//+kubebuilder:printcolumn:JSONPath=".status.state",name=State,type=string
33+
34+
// AutoscalingRunnerSet is the Schema for the autoscalingrunnersets API
35+
type AutoscalingRunnerSet struct {
36+
metav1.TypeMeta `json:",inline"`
37+
metav1.ObjectMeta `json:"metadata,omitempty"`
38+
39+
Spec AutoscalingRunnerSetSpec `json:"spec,omitempty"`
40+
Status AutoscalingRunnerSetStatus `json:"status,omitempty"`
41+
}
42+
43+
// AutoscalingRunnerSetSpec defines the desired state of AutoscalingRunnerSet
44+
type AutoscalingRunnerSetSpec struct {
45+
// Required
46+
GitHubConfigUrl string `json:"githubConfigUrl,omitempty"`
47+
48+
// Required
49+
GitHubConfigSecret string `json:"githubConfigSecret,omitempty"`
50+
51+
// +optional
52+
RunnerGroup string `json:"runnerGroup,omitempty"`
53+
54+
// +optional
55+
Proxy *ProxyConfig `json:"proxy,omitempty"`
56+
57+
// +optional
58+
GitHubServerTLS *GitHubServerTLSConfig `json:"githubServerTLS,omitempty"`
59+
60+
// Required
61+
Template corev1.PodTemplateSpec `json:"template,omitempty"`
62+
63+
// +optional
64+
// +kubebuilder:validation:Minimum:=0
65+
MaxRunners *int `json:"maxRunners,omitempty"`
66+
67+
// +optional
68+
// +kubebuilder:validation:Minimum:=0
69+
MinRunners *int `json:"minRunners,omitempty"`
70+
}
71+
72+
type GitHubServerTLSConfig struct {
73+
// Required
74+
RootCAsConfigMapRef string `json:"certConfigMapRef,omitempty"`
75+
}
76+
77+
type ProxyConfig struct {
78+
// +optional
79+
HTTP *ProxyServerConfig `json:"http,omitempty"`
80+
81+
// +optional
82+
HTTPS *ProxyServerConfig `json:"https,omitempty"`
83+
}
84+
85+
type ProxyServerConfig struct {
86+
// Required
87+
Url string `json:"url,omitempty"`
88+
89+
// +optional
90+
CredentialSecretRef string `json:"credentialSecretRef,omitempty"`
91+
92+
// +optional
93+
NoProxy []string `json:"noProxy,omitempty"`
94+
}
95+
96+
// AutoscalingRunnerSetStatus defines the observed state of AutoscalingRunnerSet
97+
type AutoscalingRunnerSetStatus struct {
98+
// +optional
99+
CurrentRunners int `json:"currentRunners,omitempty"`
100+
101+
// +optional
102+
State string `json:"state,omitempty"`
103+
}
104+
105+
func (ars *AutoscalingRunnerSet) ListenerSpecHash() string {
106+
type listenerSpec = AutoscalingRunnerSetSpec
107+
arsSpec := ars.Spec.DeepCopy()
108+
spec := arsSpec
109+
return hash.ComputeTemplateHash(&spec)
110+
}
111+
112+
func (ars *AutoscalingRunnerSet) RunnerSetSpecHash() string {
113+
type runnerSetSpec struct {
114+
GitHubConfigUrl string
115+
GitHubConfigSecret string
116+
RunnerGroup string
117+
Proxy *ProxyConfig
118+
GitHubServerTLS *GitHubServerTLSConfig
119+
Template corev1.PodTemplateSpec
120+
}
121+
spec := &runnerSetSpec{
122+
GitHubConfigUrl: ars.Spec.GitHubConfigUrl,
123+
GitHubConfigSecret: ars.Spec.GitHubConfigSecret,
124+
RunnerGroup: ars.Spec.RunnerGroup,
125+
Proxy: ars.Spec.Proxy,
126+
GitHubServerTLS: ars.Spec.GitHubServerTLS,
127+
Template: ars.Spec.Template,
128+
}
129+
return hash.ComputeTemplateHash(&spec)
130+
}
131+
132+
//+kubebuilder:object:root=true
133+
134+
// AutoscalingRunnerSetList contains a list of AutoscalingRunnerSet
135+
type AutoscalingRunnerSetList struct {
136+
metav1.TypeMeta `json:",inline"`
137+
metav1.ListMeta `json:"metadata,omitempty"`
138+
Items []AutoscalingRunnerSet `json:"items"`
139+
}
140+
141+
func init() {
142+
SchemeBuilder.Register(&AutoscalingRunnerSet{}, &AutoscalingRunnerSetList{})
143+
}

0 commit comments

Comments
 (0)