Allow custom graceful termination and loadBalancerSourceRanges for the githubwebhook service (#2305)

Co-authored-by: Dimitar Hristov <dimitar.hristov@skyscanner.net>
This commit is contained in:
Dimitar 2023-02-25 05:18:29 +00:00 committed by GitHub
parent 678eafcd67
commit 7d0918b6d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 2 deletions

View File

@ -39,7 +39,8 @@ RUN --mount=target=. \
go build -trimpath -ldflags="-s -w -X 'github.com/actions/actions-runner-controller/build.Version=${VERSION}'" -o /out/manager main.go && \ go build -trimpath -ldflags="-s -w -X 'github.com/actions/actions-runner-controller/build.Version=${VERSION}'" -o /out/manager main.go && \
go build -trimpath -ldflags="-s -w" -o /out/github-runnerscaleset-listener ./cmd/githubrunnerscalesetlistener && \ go build -trimpath -ldflags="-s -w" -o /out/github-runnerscaleset-listener ./cmd/githubrunnerscalesetlistener && \
go build -trimpath -ldflags="-s -w" -o /out/github-webhook-server ./cmd/githubwebhookserver && \ go build -trimpath -ldflags="-s -w" -o /out/github-webhook-server ./cmd/githubwebhookserver && \
go build -trimpath -ldflags="-s -w" -o /out/actions-metrics-server ./cmd/actionsmetricsserver go build -trimpath -ldflags="-s -w" -o /out/actions-metrics-server ./cmd/actionsmetricsserver && \
go build -trimpath -ldflags="-s -w" -o /out/sleep ./cmd/sleep
# Use distroless as minimal base image to package the manager binary # Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details # Refer to https://github.com/GoogleContainerTools/distroless for more details
@ -51,6 +52,7 @@ COPY --from=builder /out/manager .
COPY --from=builder /out/github-webhook-server . COPY --from=builder /out/github-webhook-server .
COPY --from=builder /out/actions-metrics-server . COPY --from=builder /out/actions-metrics-server .
COPY --from=builder /out/github-runnerscaleset-listener . COPY --from=builder /out/github-runnerscaleset-listener .
COPY --from=builder /out/sleep .
USER 65532:65532 USER 65532:65532

View File

@ -56,6 +56,12 @@ spec:
{{- end }} {{- end }}
command: command:
- "/github-webhook-server" - "/github-webhook-server"
{{- if .Values.githubWebhookServer.lifecycle }}
{{- with .Values.githubWebhookServer.lifecycle }}
lifecycle:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- end }}
env: env:
- name: GITHUB_WEBHOOK_SECRET_TOKEN - name: GITHUB_WEBHOOK_SECRET_TOKEN
valueFrom: valueFrom:
@ -148,7 +154,7 @@ spec:
securityContext: securityContext:
{{- toYaml .Values.securityContext | nindent 12 }} {{- toYaml .Values.securityContext | nindent 12 }}
{{- end }} {{- end }}
terminationGracePeriodSeconds: 10 terminationGracePeriodSeconds: {{ .Values.githubWebhookServer.terminationGracePeriodSeconds }}
{{- with .Values.githubWebhookServer.nodeSelector }} {{- with .Values.githubWebhookServer.nodeSelector }}
nodeSelector: nodeSelector:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}

View File

@ -23,4 +23,10 @@ spec:
{{- end }} {{- end }}
selector: selector:
{{- include "actions-runner-controller-github-webhook-server.selectorLabels" . | nindent 4 }} {{- include "actions-runner-controller-github-webhook-server.selectorLabels" . | nindent 4 }}
{{- if .Values.githubWebhookServer.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- range $ip := .Values.githubWebhookServer.service.loadBalancerSourceRanges }}
- {{ $ip -}}
{{- end }}
{{- end }}
{{- end }} {{- end }}

View File

@ -240,6 +240,7 @@ githubWebhookServer:
protocol: TCP protocol: TCP
name: http name: http
#nodePort: someFixedPortForUseWithTerraformCdkCfnEtc #nodePort: someFixedPortForUseWithTerraformCdkCfnEtc
loadBalancerSourceRanges: []
ingress: ingress:
enabled: false enabled: false
ingressClassName: "" ingressClassName: ""
@ -276,6 +277,8 @@ githubWebhookServer:
# minAvailable: 1 # minAvailable: 1
# maxUnavailable: 3 # maxUnavailable: 3
# queueLimit: 100 # queueLimit: 100
terminationGracePeriodSeconds: 10
lifecycle: {}
actionsMetrics: actionsMetrics:
serviceAnnotations: {} serviceAnnotations: {}

33
cmd/sleep/main.go Normal file
View File

@ -0,0 +1,33 @@
/*
Copyright 2021 The actions-runner-controller authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"flag"
"fmt"
"time"
)
var Seconds int
func main() {
fmt.Printf("sleeping for %d seconds\n", Seconds)
time.Sleep(time.Duration(Seconds) * time.Second)
fmt.Println("done sleeping")
}
func init() {
flag.IntVar(&Seconds, "seconds", 60, "Number of seconds to sleep")
flag.Parse()
}