From 31c8368c552a7ea3733dfa6a472a0c8128c8bcd4 Mon Sep 17 00:00:00 2001 From: Mateusz Korus Date: Fri, 24 Sep 2021 15:00:14 +0200 Subject: [PATCH] Add HostAliases to schema (#656) Add HostAliases to schema and propagate them to pods so the user can add entries to /etc/hosts --- api/v1alpha2/jenkins_types.go | 4 ++++ pkg/configuration/base/resources/deployment.go | 1 + pkg/configuration/base/resources/pod.go | 1 + pkg/configuration/user/seedjobs/seedjobs.go | 1 + 4 files changed, 7 insertions(+) diff --git a/api/v1alpha2/jenkins_types.go b/api/v1alpha2/jenkins_types.go index bd4e6607..1f73d8ea 100644 --- a/api/v1alpha2/jenkins_types.go +++ b/api/v1alpha2/jenkins_types.go @@ -372,6 +372,10 @@ type JenkinsMaster struct { // PriorityClassName for Jenkins master pod // +optional PriorityClassName string `json:"priorityClassName,omitempty"` + + // HostAliases for Jenkins master pod and SeedJob agent + // +optional + HostAliases []corev1.HostAlias `json:"hostAliases,omitempty"` } // Service defines Kubernetes service attributes diff --git a/pkg/configuration/base/resources/deployment.go b/pkg/configuration/base/resources/deployment.go index 8c8d2a44..c5f7481d 100644 --- a/pkg/configuration/base/resources/deployment.go +++ b/pkg/configuration/base/resources/deployment.go @@ -37,6 +37,7 @@ func NewJenkinsDeployment(objectMeta metav1.ObjectMeta, jenkins *v1alpha2.Jenkin ImagePullSecrets: jenkins.Spec.Master.ImagePullSecrets, Tolerations: jenkins.Spec.Master.Tolerations, PriorityClassName: jenkins.Spec.Master.PriorityClassName, + HostAliases: jenkins.Spec.Master.HostAliases, }, }, Selector: selector, diff --git a/pkg/configuration/base/resources/pod.go b/pkg/configuration/base/resources/pod.go index 26f202ed..c832667d 100644 --- a/pkg/configuration/base/resources/pod.go +++ b/pkg/configuration/base/resources/pod.go @@ -380,6 +380,7 @@ func NewJenkinsMasterPod(objectMeta metav1.ObjectMeta, jenkins *v1alpha2.Jenkins ImagePullSecrets: jenkins.Spec.Master.ImagePullSecrets, Tolerations: jenkins.Spec.Master.Tolerations, PriorityClassName: jenkins.Spec.Master.PriorityClassName, + HostAliases: jenkins.Spec.Master.HostAliases, }, } } diff --git a/pkg/configuration/user/seedjobs/seedjobs.go b/pkg/configuration/user/seedjobs/seedjobs.go index 96d1df75..dadc3e97 100644 --- a/pkg/configuration/user/seedjobs/seedjobs.go +++ b/pkg/configuration/user/seedjobs/seedjobs.go @@ -439,6 +439,7 @@ func agentDeployment(jenkins *v1alpha2.Jenkins, namespace string, agentName stri NodeSelector: jenkins.Spec.Master.NodeSelector, Tolerations: jenkins.Spec.Master.Tolerations, ImagePullSecrets: jenkins.Spec.Master.ImagePullSecrets, + HostAliases: jenkins.Spec.Master.HostAliases, Containers: []corev1.Container{ { Name: "jnlp",