Skip to content

Commit 542e28e

Browse files
committed
fix(charts,e2e): enable local Kind e2e and runner-pool demand validation
1 parent d4d338c commit 542e28e

7 files changed

Lines changed: 339 additions & 4 deletions

File tree

Dockerfile.operator

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# syntax=docker/dockerfile:1
2-
FROM golang:1.23-alpine AS builder
2+
FROM golang:1.25-alpine AS builder
33
WORKDIR /workspace
44

55
COPY go.mod go.sum ./
@@ -9,7 +9,7 @@ COPY api/ api/
99
COPY cmd/operator/ cmd/operator/
1010
COPY internal/ internal/
1111

12-
RUN CGO_ENABLED=0 GOOS=linux go build -a -o operator ./cmd/operator
12+
RUN CGO_ENABLED=0 GOOS=linux go build -o operator ./cmd/operator
1313

1414
FROM gcr.io/distroless/static:nonroot
1515
WORKDIR /
Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
"helm.sh/resource-policy": keep
7+
controller-gen.kubebuilder.io/version: v0.20.1
8+
name: impvmrunnerpools.imp.dev
9+
spec:
10+
group: imp.dev
11+
names:
12+
categories:
13+
- imp
14+
kind: ImpVMRunnerPool
15+
listKind: ImpVMRunnerPoolList
16+
plural: impvmrunnerpools
17+
shortNames:
18+
- imprp
19+
singular: impvmrunnerpool
20+
scope: Namespaced
21+
versions:
22+
- additionalPrinterColumns:
23+
- jsonPath: .spec.platform.type
24+
name: Platform
25+
type: string
26+
- jsonPath: .spec.templateName
27+
name: Template
28+
type: string
29+
- jsonPath: .status.idleCount
30+
name: Idle
31+
type: integer
32+
- jsonPath: .status.activeCount
33+
name: Active
34+
type: integer
35+
- jsonPath: .metadata.creationTimestamp
36+
name: Age
37+
type: date
38+
name: v1alpha1
39+
schema:
40+
openAPIV3Schema:
41+
description: |-
42+
ImpVMRunnerPool provisions ephemeral CI runner VMs that register with a CI
43+
platform, execute exactly one job, and then terminate.
44+
properties:
45+
apiVersion:
46+
description: |-
47+
APIVersion defines the versioned schema of this representation of an object.
48+
Servers should convert recognized schemas to the latest internal value, and
49+
may reject unrecognized values.
50+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
51+
type: string
52+
kind:
53+
description: |-
54+
Kind is a string value representing the REST resource this object represents.
55+
Servers may infer this from the endpoint the client submits requests to.
56+
Cannot be updated.
57+
In CamelCase.
58+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
59+
type: string
60+
metadata:
61+
type: object
62+
spec:
63+
description: ImpVMRunnerPoolSpec defines a pool of ephemeral CI runner
64+
VMs.
65+
properties:
66+
jobDetection:
67+
description: JobDetection configures how the operator discovers queued
68+
jobs.
69+
properties:
70+
polling:
71+
description: Polling enables periodic API polling as a fallback.
72+
properties:
73+
enabled:
74+
description: Enabled turns on polling-based job detection.
75+
type: boolean
76+
intervalSeconds:
77+
default: 30
78+
description: IntervalSeconds is how often the operator polls
79+
the platform API.
80+
format: int32
81+
minimum: 10
82+
type: integer
83+
type: object
84+
webhook:
85+
description: Webhook enables platform-push job events.
86+
properties:
87+
enabled:
88+
description: Enabled turns on webhook-based job detection.
89+
type: boolean
90+
secretRef:
91+
description: SecretRef names a Secret containing the HMAC
92+
webhook secret.
93+
type: string
94+
type: object
95+
type: object
96+
labels:
97+
description: Labels are applied to runner registrations on the CI
98+
platform.
99+
items:
100+
type: string
101+
type: array
102+
platform:
103+
description: Platform configures the CI platform integration.
104+
properties:
105+
credentialsSecret:
106+
description: CredentialsSecret names a Secret containing the registration
107+
token or PAT.
108+
type: string
109+
scope:
110+
description: Scope configures the registration scope (org or repo).
111+
properties:
112+
org:
113+
description: Org registers a runner for the entire organisation.
114+
type: string
115+
repo:
116+
description: Repo registers a runner for a single repository
117+
("owner/repo").
118+
type: string
119+
type: object
120+
x-kubernetes-validations:
121+
- message: set exactly one of org or repo
122+
rule: (size(self.org) > 0) != (size(self.repo) > 0)
123+
serverURL:
124+
description: ServerURL is required for GitLab and Forgejo. Leave
125+
empty for github.com.
126+
type: string
127+
type:
128+
description: Type selects the CI platform driver.
129+
enum:
130+
- github-actions
131+
- gitlab
132+
- forgejo
133+
type: string
134+
required:
135+
- credentialsSecret
136+
- type
137+
type: object
138+
runnerLayer:
139+
description: |-
140+
RunnerLayer is the OCI image containing the runner binary.
141+
When set, it is composited on top of the template image at boot time.
142+
Omit if the runner binary is already baked into the template image.
143+
type: string
144+
scaling:
145+
description: Scaling controls how many runner VMs are maintained.
146+
properties:
147+
maxConcurrent:
148+
default: 10
149+
description: MaxConcurrent is the hard cap on simultaneous runner
150+
VMs.
151+
format: int32
152+
maximum: 100
153+
minimum: 1
154+
type: integer
155+
minIdle:
156+
default: 0
157+
description: |-
158+
MinIdle is the number of pre-registered idle runner VMs to keep available.
159+
0 means pure on-demand — no idle VMs sit waiting.
160+
format: int32
161+
maximum: 3
162+
minimum: 0
163+
type: integer
164+
type: object
165+
templateName:
166+
description: TemplateName references an ImpVMTemplate in the same
167+
namespace.
168+
type: string
169+
required:
170+
- platform
171+
- templateName
172+
type: object
173+
status:
174+
description: ImpVMRunnerPoolStatus reflects the observed pool state.
175+
properties:
176+
activeCount:
177+
description: ActiveCount is the number of runner VMs currently executing
178+
a job.
179+
format: int32
180+
type: integer
181+
conditions:
182+
description: Conditions follow the standard k8s condition convention.
183+
items:
184+
description: Condition contains details for one aspect of the current
185+
state of this API Resource.
186+
properties:
187+
lastTransitionTime:
188+
description: |-
189+
lastTransitionTime is the last time the condition transitioned from one status to another.
190+
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
191+
format: date-time
192+
type: string
193+
message:
194+
description: |-
195+
message is a human readable message indicating details about the transition.
196+
This may be an empty string.
197+
maxLength: 32768
198+
type: string
199+
observedGeneration:
200+
description: |-
201+
observedGeneration represents the .metadata.generation that the condition was set based upon.
202+
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
203+
with respect to the current state of the instance.
204+
format: int64
205+
minimum: 0
206+
type: integer
207+
reason:
208+
description: |-
209+
reason contains a programmatic identifier indicating the reason for the condition's last transition.
210+
Producers of specific condition types may define expected values and meanings for this field,
211+
and whether the values are considered a guaranteed API.
212+
The value should be a CamelCase string.
213+
This field may not be empty.
214+
maxLength: 1024
215+
minLength: 1
216+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
217+
type: string
218+
status:
219+
description: status of the condition, one of True, False, Unknown.
220+
enum:
221+
- "True"
222+
- "False"
223+
- Unknown
224+
type: string
225+
type:
226+
description: type of condition in CamelCase or in foo.example.com/CamelCase.
227+
maxLength: 316
228+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
229+
type: string
230+
required:
231+
- lastTransitionTime
232+
- message
233+
- reason
234+
- status
235+
- type
236+
type: object
237+
type: array
238+
x-kubernetes-list-map-keys:
239+
- type
240+
x-kubernetes-list-type: map
241+
idleCount:
242+
description: IdleCount is the number of runner VMs currently registered
243+
and waiting for a job.
244+
format: int32
245+
type: integer
246+
type: object
247+
type: object
248+
served: true
249+
storage: true
250+
subresources:
251+
status: {}

charts/imp/templates/operator/clusterrole.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ rules:
1313
- impnetworks
1414
- clusterimpconfigs
1515
- clusterimpnodeprofiles
16-
verbs: [get, list, watch, update, patch]
16+
- impvmrunnerpools
17+
verbs: [get, list, watch, create, update, patch, delete]
1718
- apiGroups: ["imp.dev"]
1819
resources:
1920
- impvms/status
2021
- impnetworks/status
22+
- impvmrunnerpools/status
2123
verbs: [get, update, patch]
2224
- apiGroups: ["imp.dev"]
2325
resources:
@@ -30,6 +32,9 @@ rules:
3032
- apiGroups: [""]
3133
resources: [events]
3234
verbs: [create, patch]
35+
- apiGroups: [""]
36+
resources: [secrets]
37+
verbs: [get]
3338
- apiGroups: ["apiextensions.k8s.io"]
3439
resources: [customresourcedefinitions]
3540
verbs: [get, list]

charts/imp/templates/webhook/mutatingwebhook.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ webhooks:
1414
service:
1515
name: {{ include "imp.fullname" . }}-operator
1616
namespace: {{ .Release.Namespace }}
17+
port: 9443
1718
path: /mutate-imp-dev-v1alpha1-impvm
1819
rules:
1920
- apiGroups: ["imp.dev"]

charts/imp/templates/webhook/validatingwebhook.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ webhooks:
1414
service:
1515
name: {{ include "imp.fullname" . }}-operator
1616
namespace: {{ .Release.Namespace }}
17+
port: 9443
1718
path: /validate-imp-dev-v1alpha1-impvm
1819
rules:
1920
- apiGroups: ["imp.dev"]
@@ -31,6 +32,7 @@ webhooks:
3132
service:
3233
name: {{ include "imp.fullname" . }}-operator
3334
namespace: {{ .Release.Namespace }}
35+
port: 9443
3436
path: /validate-imp-dev-v1alpha1-impvmclass
3537
rules:
3638
- apiGroups: ["imp.dev"]
@@ -48,6 +50,7 @@ webhooks:
4850
service:
4951
name: {{ include "imp.fullname" . }}-operator
5052
namespace: {{ .Release.Namespace }}
53+
port: 9443
5154
path: /validate-imp-dev-v1alpha1-impvmtemplate
5255
rules:
5356
- apiGroups: ["imp.dev"]

test/e2e/e2e_suite_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,15 @@ var _ = BeforeSuite(func() {
5959
By("installing imp chart")
6060
impCmd := exec.Command("helm", "install", helmRelease, "charts/imp",
6161
"--namespace", namespace,
62+
"--set", "operator.image.repository=local/imp-operator",
63+
"--set", "operator.image.tag=e2e",
64+
"--set", "agent.image.repository=local/imp-agent",
65+
"--set", "agent.image.tag=e2e",
66+
"--set", "agent.env.kernelPath=/var/lib/imp/vmlinux",
67+
"--set-string", "agent.nodeSelector.imp\\.dev/no-agent=true",
6268
"--set", "metrics.serviceMonitor.enabled=false",
6369
"--set", "metrics.podMonitor.enabled=false",
64-
"--wait", "--timeout", "2m")
70+
"--wait", "--timeout", "10m")
6571
_, err = utils.Run(impCmd)
6672
Expect(err).NotTo(HaveOccurred(), "helm install imp failed")
6773
})

0 commit comments

Comments
 (0)