Adding a default docker registry mirror (#689)

* Adding a default docker registry mirror

This change allows the controller to start with a specified default
docker registry mirror and avoid having to specify it in all the runner*
objects.

The change is backward compatible, if a runner has a docker registry
mirror specified, it will supersede the default one.
This commit is contained in:
Sebastien Le Digabel
2021-07-14 22:20:08 +01:00
committed by GitHub
parent b27b6ea2a8
commit 7f2795b5d6
6 changed files with 46 additions and 27 deletions

38
main.go
View File

@@ -69,10 +69,11 @@ func main() {
gitHubAPICacheDuration time.Duration
runnerImage string
dockerImage string
namespace string
logLevel string
runnerImage string
dockerImage string
dockerRegistryMirror string
namespace string
logLevel string
commonRunnerLabels commaSeparatedStringSlice
)
@@ -88,6 +89,7 @@ func main() {
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")
flag.StringVar(&runnerImage, "runner-image", defaultRunnerImage, "The image name of self-hosted runner container.")
flag.StringVar(&dockerImage, "docker-image", defaultDockerImage, "The image name of docker sidecar container.")
flag.StringVar(&dockerRegistryMirror, "docker-registry-mirror", "", "The default Docker Registry Mirror used by runners.")
flag.StringVar(&c.Token, "github-token", c.Token, "The personal access token of GitHub.")
flag.Int64Var(&c.AppID, "github-app-id", c.AppID, "The application ID of GitHub App.")
flag.Int64Var(&c.AppInstallationID, "github-app-installation-id", c.AppInstallationID, "The installation ID of GitHub App.")
@@ -138,12 +140,13 @@ func main() {
}
runnerReconciler := &controllers.RunnerReconciler{
Client: mgr.GetClient(),
Log: log.WithName("runner"),
Scheme: mgr.GetScheme(),
GitHubClient: ghClient,
RunnerImage: runnerImage,
DockerImage: dockerImage,
Client: mgr.GetClient(),
Log: log.WithName("runner"),
Scheme: mgr.GetScheme(),
GitHubClient: ghClient,
RunnerImage: runnerImage,
DockerImage: dockerImage,
DockerRegistryMirror: dockerRegistryMirror,
}
if err = runnerReconciler.SetupWithManager(mgr); err != nil {
@@ -176,13 +179,14 @@ func main() {
}
runnerSetReconciler := &controllers.RunnerSetReconciler{
Client: mgr.GetClient(),
Log: log.WithName("runnerset"),
Scheme: mgr.GetScheme(),
CommonRunnerLabels: commonRunnerLabels,
RunnerImage: runnerImage,
DockerImage: dockerImage,
GitHubBaseURL: ghClient.GithubBaseURL,
Client: mgr.GetClient(),
Log: log.WithName("runnerset"),
Scheme: mgr.GetScheme(),
CommonRunnerLabels: commonRunnerLabels,
RunnerImage: runnerImage,
DockerImage: dockerImage,
DockerRegistryMirror: dockerRegistryMirror,
GitHubBaseURL: ghClient.GithubBaseURL,
}
if err = runnerSetReconciler.SetupWithManager(mgr); err != nil {