From a277489003ea24b85e753f5063923ea27bc317e6 Mon Sep 17 00:00:00 2001 From: Jonathan Gonzalez V Date: Tue, 22 Jun 2021 04:27:26 -0400 Subject: [PATCH] Added support to enable and disable enableServiceLinks. (#628) This option expose internally some `KUBERNETES_*` environment variables that doesn't allow the runner to use KinD (Kubernetes in Docker) since it will try to connect to the Kubernetes cluster where the runner it's running. This option it's set by default to `true` in any Kubernetes deployment. Signed-off-by: Jonathan Gonzalez V --- api/v1alpha1/runner_types.go | 3 +++ api/v1alpha1/zz_generated.deepcopy.go | 5 +++++ .../crds/actions.summerwind.dev_runnerdeployments.yaml | 2 ++ .../crds/actions.summerwind.dev_runnerreplicasets.yaml | 2 ++ .../crds/actions.summerwind.dev_runners.yaml | 2 ++ .../crd/bases/actions.summerwind.dev_runnerdeployments.yaml | 2 ++ .../crd/bases/actions.summerwind.dev_runnerreplicasets.yaml | 2 ++ config/crd/bases/actions.summerwind.dev_runners.yaml | 2 ++ controllers/runner_controller.go | 1 + 9 files changed, 21 insertions(+) diff --git a/api/v1alpha1/runner_types.go b/api/v1alpha1/runner_types.go index a5c23c4673..ca77c5943b 100644 --- a/api/v1alpha1/runner_types.go +++ b/api/v1alpha1/runner_types.go @@ -100,6 +100,9 @@ type RunnerPodSpec struct { // +optional Volumes []corev1.Volume `json:"volumes,omitempty"` + // +optional + EnableServiceLinks *bool `json:"enableServiceLinks,omitempty"` + // +optional InitContainers []corev1.Container `json:"initContainers,omitempty"` diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 7fc89f1b5c..073485e375 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -624,6 +624,11 @@ func (in *RunnerPodSpec) DeepCopyInto(out *RunnerPodSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.EnableServiceLinks != nil { + in, out := &in.EnableServiceLinks, &out.EnableServiceLinks + *out = new(bool) + **out = **in + } if in.InitContainers != nil { in, out := &in.InitContainers, &out.InitContainers *out = make([]v1.Container, len(*in)) diff --git a/charts/actions-runner-controller/crds/actions.summerwind.dev_runnerdeployments.yaml b/charts/actions-runner-controller/crds/actions.summerwind.dev_runnerdeployments.yaml index c14d8c5fa3..317c11c8ae 100644 --- a/charts/actions-runner-controller/crds/actions.summerwind.dev_runnerdeployments.yaml +++ b/charts/actions-runner-controller/crds/actions.summerwind.dev_runnerdeployments.yaml @@ -632,6 +632,8 @@ spec: type: object dockerdWithinRunnerContainer: type: boolean + enableServiceLinks: + type: boolean enterprise: pattern: ^[^/]+$ type: string diff --git a/charts/actions-runner-controller/crds/actions.summerwind.dev_runnerreplicasets.yaml b/charts/actions-runner-controller/crds/actions.summerwind.dev_runnerreplicasets.yaml index 11b8b4a862..6c8feb7d22 100644 --- a/charts/actions-runner-controller/crds/actions.summerwind.dev_runnerreplicasets.yaml +++ b/charts/actions-runner-controller/crds/actions.summerwind.dev_runnerreplicasets.yaml @@ -629,6 +629,8 @@ spec: type: object dockerdWithinRunnerContainer: type: boolean + enableServiceLinks: + type: boolean enterprise: pattern: ^[^/]+$ type: string diff --git a/charts/actions-runner-controller/crds/actions.summerwind.dev_runners.yaml b/charts/actions-runner-controller/crds/actions.summerwind.dev_runners.yaml index fec0ee04d9..b23f930935 100644 --- a/charts/actions-runner-controller/crds/actions.summerwind.dev_runners.yaml +++ b/charts/actions-runner-controller/crds/actions.summerwind.dev_runners.yaml @@ -577,6 +577,8 @@ spec: type: object dockerdWithinRunnerContainer: type: boolean + enableServiceLinks: + type: boolean enterprise: pattern: ^[^/]+$ type: string diff --git a/config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml b/config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml index c14d8c5fa3..317c11c8ae 100644 --- a/config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml +++ b/config/crd/bases/actions.summerwind.dev_runnerdeployments.yaml @@ -632,6 +632,8 @@ spec: type: object dockerdWithinRunnerContainer: type: boolean + enableServiceLinks: + type: boolean enterprise: pattern: ^[^/]+$ type: string diff --git a/config/crd/bases/actions.summerwind.dev_runnerreplicasets.yaml b/config/crd/bases/actions.summerwind.dev_runnerreplicasets.yaml index 11b8b4a862..6c8feb7d22 100644 --- a/config/crd/bases/actions.summerwind.dev_runnerreplicasets.yaml +++ b/config/crd/bases/actions.summerwind.dev_runnerreplicasets.yaml @@ -629,6 +629,8 @@ spec: type: object dockerdWithinRunnerContainer: type: boolean + enableServiceLinks: + type: boolean enterprise: pattern: ^[^/]+$ type: string diff --git a/config/crd/bases/actions.summerwind.dev_runners.yaml b/config/crd/bases/actions.summerwind.dev_runners.yaml index fec0ee04d9..b23f930935 100644 --- a/config/crd/bases/actions.summerwind.dev_runners.yaml +++ b/config/crd/bases/actions.summerwind.dev_runners.yaml @@ -577,6 +577,8 @@ spec: type: object dockerdWithinRunnerContainer: type: boolean + enableServiceLinks: + type: boolean enterprise: pattern: ^[^/]+$ type: string diff --git a/controllers/runner_controller.go b/controllers/runner_controller.go index 0b0bcd4c3b..a14d9cdf44 100644 --- a/controllers/runner_controller.go +++ b/controllers/runner_controller.go @@ -622,6 +622,7 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) { } template.Spec.SecurityContext = runner.Spec.SecurityContext + template.Spec.EnableServiceLinks = runner.Spec.EnableServiceLinks registrationOnly := metav1.HasAnnotation(runner.ObjectMeta, annotationKeyRegistrationOnly)