Documentation ¶
Overview ¶
Package resources contains Kubernetes resources required by Jenkins
Index ¶
- Constants
- Variables
- func BuildResourceLabels(jenkins *v1alpha2.Jenkins) map[string]string
- func DefaultResourceRequirement() corev1.ResourceRequirements
- func GetBasePluginsVolumeNameConfigMapName(jenkins *v1alpha2.Jenkins) string
- func GetDestinationRepository(cr *jenkinsv1alpha2.JenkinsImage) string
- func GetDockerBuilderSecretName(namespace string, clientSet client.Client) (string, error)
- func GetDockerfileConfigMapName(cr *jenkinsv1alpha2.JenkinsImage) string
- func GetExtraRoleBindingName(jenkins *v1alpha2.Jenkins, roleRef rbacv1.RoleRef) string
- func GetInitConfigurationConfigMapName(jenkins *v1alpha2.Jenkins) string
- func GetJenkinsBackupPVCName(backupVolumeName string) string
- func GetJenkinsBackupPoolName(backupVolumeName string) string
- func GetJenkinsContainer(jenkins *v1alpha2.Jenkins, jenkinsContainer v1alpha2.Container, ...) corev1.Container
- func GetJenkinsDeploymentName(jenkins *v1alpha2.Jenkins) string
- func GetJenkinsHTTPServiceName(jenkins *v1alpha2.Jenkins) string
- func GetJenkinsJNLPServiceName(jenkins *v1alpha2.Jenkins) string
- func GetJenkinsMasterContainerBaseEnvs(jenkins *v1alpha2.Jenkins) []corev1.EnvVar
- func GetJenkinsMasterContainerBaseVolumeMounts(jenkins *v1alpha2.Jenkins, spec *v1alpha2.JenkinsSpec) []corev1.VolumeMount
- func GetJenkinsMasterPodBaseVolumes(jenkins *v1alpha2.Jenkins) []corev1.Volume
- func GetOperatorCredentialsSecretName(jenkins *v1alpha2.Jenkins) string
- func GetResourceList(cpu string, mem string) corev1.ResourceList
- func GetResourceName(jenkins *v1alpha2.Jenkins) string
- func GetResourceRequirements(cpuRequest string, memRequest string, cpuLimit string, memLimit string) corev1.ResourceRequirements
- func GetTCPContainerPort(portName string, portNumber int32) corev1.ContainerPort
- func IsImageRegistryAvailable(manager manager.Manager) bool
- func IsImageRegistryAvailableCached() bool
- func IsOpenshiftProxyAPIAvailable(clientSet *kubernetes.Clientset) bool
- func IsProxyOverridden(envVar []corev1.EnvVar) (overrides bool)
- func IsRouteAPIAvailable(clientSet *kubernetes.Clientset) bool
- func NewBasePluginConfigMap(meta metav1.ObjectMeta, jenkins *v1alpha2.Jenkins) (*corev1.ConfigMap, error)
- func NewBuilderPod(client client.Client, cr *jenkinsv1alpha2.JenkinsImage) *corev1.Pod
- func NewDefaultPolicyRules() []v1.PolicyRule
- func NewDockerfileConfigMap(cr *jenkinsv1alpha2.JenkinsImage) *corev1.ConfigMap
- func NewInitConfigurationConfigMap(meta metav1.ObjectMeta, jenkins *v1alpha2.Jenkins) (*corev1.ConfigMap, error)
- func NewJenkinsBackupContainer(jenkins *v1alpha2.Jenkins) corev1.Container
- func NewJenkinsBackupInitContainer(spec *v1alpha2.JenkinsSpec) corev1.Container
- func NewJenkinsConfigContainer(jenkins *v1alpha2.Jenkins) corev1.Container
- func NewJenkinsConfigInitContainer(spec *v1alpha2.JenkinsSpec) corev1.Container
- func NewJenkinsDeployment(objectMeta metav1.ObjectMeta, jenkins *v1alpha2.Jenkins, ...) *appsv1.Deployment
- func NewJenkinsMasterContainer(jenkins *v1alpha2.Jenkins) corev1.Container
- func NewJenkinsPluginsInitContainer(spec *v1alpha2.JenkinsSpec) corev1.Container
- func NewOperatorCredentialsSecret(meta metav1.ObjectMeta, jenkins *v1alpha2.Jenkins) *corev1.Secret
- func NewPolicyRule(apiGroup string, resource, resourceName string, verbs []string) v1.PolicyRule
- func NewProbe(uri string, port string, scheme corev1.URIScheme, ...) *corev1.Probe
- func NewResourceObjectMeta(jenkins *v1alpha2.Jenkins) metav1.ObjectMeta
- func NewResourceRequirements(cpuRequest, memoryRequest, cpuLimit, memoryLimit string) corev1.ResourceRequirements
- func NewRole(jenkins *v1alpha2.Jenkins) *v1.Role
- func NewRoleBinding(jenkins *v1alpha2.Jenkins, roleRef v1.RoleRef) *v1.RoleBinding
- func NewScriptsConfigMap(meta metav1.ObjectMeta, jenkins *v1alpha2.Jenkins) (*corev1.ConfigMap, error)
- func NewServiceAccount(meta metav1.ObjectMeta, annotations map[string]string) *v1.ServiceAccount
- func NewSimpleProbe(uri string, port string, scheme corev1.URIScheme, initialDelaySeconds int32) *corev1.Probe
- func QueryProxyConfig(manager manager.Manager) error
- func ToEnvVar(proxy *apiconfigv1.Proxy) []corev1.EnvVar
- func UpdateRoute(actual routev1.Route, jenkins *v1alpha2.Jenkins) routev1.Route
- func UpdateService(current corev1.Service, desired v1alpha2.Service) corev1.Service
- func WaitForPodIsCompleted(k8sClient client.Client, podName, namespace string) error
- func WaitForPodRunning(k8sClient client.Client, podName, namespace string, timeout time.Duration) error
Constants ¶
const ( NameWithSuffixFormat = "%s-%s" PluginDefinitionFormat = "%s:%s" BuilderDockerfileArg = "--dockerfile=/dockerfile/Dockerfile" BuilderContextDirArg = "--context=dir://workspace/" BuilderNoPushArg = "--no-push" BuilderDestinationArg = "--destination" BuilderDigestFileArg = "--digest-file=/dev/termination-log" BuilderReproducibleArg = "--reproducible" BuilderSuffix = "builder" DockerfileStorageSuffix = "dockerfile-storage" DockerSecretSuffix = "docker-secret" DockerfileNameSuffix = "dockerfile" JenkinsImageBuilderImage = "quay.io/redhat-developer/openshift-jenkins-image-builder:v1.3.0" JenkinsImageBuilderName = "jenkins-image-builder" JenkinsImageDefaultBaseImage = "jenkins/jenkins:lts" DefaultImageRegistry = "image-registry.openshift-image-registry.svc:5000" DefaultImageTag = "latest" DockerfileName = "Dockerfile" DockerfileTemplate = `` /* 184-byte string literal not displayed */ )
const ( // OperatorUserName defines username for Jenkins API calls OperatorUserName = "jenkins-operator" // OperatorCredentialsSecretUserNameKey defines key of username in operator credentials secret OperatorCredentialsSecretUserNameKey = "user" // OperatorCredentialsSecretPasswordKey defines key of password in operator credentials secret OperatorCredentialsSecretPasswordKey = "password" // OperatorCredentialsSecretTokenKey defines key of token in operator credentials secret OperatorCredentialsSecretTokenKey = "token" // OperatorCredentialsSecretTokenCreationKey defines key of token creation time in operator credentials secret OperatorCredentialsSecretTokenCreationKey = "tokenCreationTime" )
const ( JenkinsSideCarImageEnvVar = "JENKINS_SIDECAR_IMAGE" JenkinsBackupImageEnvVar = "JENKINS_BACKUP_IMAGE" JenkinsMasterContainerName = constants.DefaultJenkinsMasterContainerName // JenkinsHomeVolumeName is the Jenkins home volume name JenkinsHomeVolumeName = "jenkins-home" // JenkinsScriptsVolumePath is a path where are scripts used to configure Jenkins JenkinsScriptsVolumePath = jenkinsPath + "/scripts" // InitScriptName is the init script name which configures init.groovy.d, scripts and install plugins InitScriptName = "init.sh" // BasePluginsVolumePath is a path where the base-plugins file is generated BasePluginsVolumePath = jenkinsPath + "/" + basePluginsFileName ConfigurationAsCodeVolumeName = "casc-config" ConfigurationAsCodeVolumePath = jenkinsPath + "/configuration-as-code" ConfigurationAsCodeSecretVolumeName = "casc-secret" ConfigurationAsCodeSecretVolumePath = "/tmp" + "/configuration-as-code-secrets" // defaut configmap for jenkins configuration JenkinsDefaultConfigMapName = "jenkins-default-configuration" // Names of Sidecar and Init Containers ConfigSidecarName = "config" ConfigInitContainerName = "config-init" PluginsInitContainerName = "plugins-init" BackupSidecarName = "backup" BackupInitContainerName = "backup-init" // Config Sidecar related variables JenkinsSCConfigReqURL = "http://localhost:8080/reload-configuration-as-code/?casc-reload-token=$(POD_NAME)" JenkinsSCConfigReqMethod = "POST" JenkinsSCConfigReqRetry = "10" JenkinsSCConfigLabel = "type" JenkinsSCConfigLabelValue = "%s-jenkins-config" // Backup Sidecar related variables JenkinsBackupVolumeMountName = "backup-pool" JenkinsBackupVolumePath = "/jenkins-backups" // Helper scripts related variables ScriptsVolumeMountName = "helper-scripts" ScriptsVolumePath = "/jenkins-operator-scripts" QuietDownScriptPath = ScriptsVolumePath + "/quietdown.sh" CancelQuietDownScriptPath = ScriptsVolumePath + "/cancelquietdown.sh" RestartScriptPath = ScriptsVolumePath + "/restart.sh" SafeRestartScriptPath = ScriptsVolumePath + "/saferestart.sh" // Common attributes used for Sidecars SidecarCPULimit = "100m" SidecarMEMLimit = "100Mi" SidecarCPURequest = "50m" SidecarMEMRequest = "50Mi" )
const ( // EmptyAPIGroup short hand for the empty API group while defining policies EmptyAPIGroup = "" // ImageAPIGroup the openshift api group name for images ImageAPIGroup = "image.openshift.io" // BuildAPIGroup the openshift api group name for builds BuildAPIGroup = "build.openshift.io" // SecurityAPIGroup the openshift api group name for security SecurityAPIGroup = "security.openshift.io" )
const ( DefaultOpenShiftImageRegistryNamespace = "openshift-image-registry" DefaultOpenShiftImageRegistryServiceName = "image-registry" )
const ( DefaultCPURequest = "50m" DefaultMemoryRequest = "50Mi" DefaultCPULimit = "100m" DefaultMemoryLimit = "100Mi" )
const ( ServiceAccountNameAnnotation = "kubernetes.io/service-account.name" BuilderServiceAccountName = "builder" )
const JenkinsImageBuilderEnv = "JENKINS_BUILDER_IMAGE"
const RouteKind = "Route"
RouteKind the kind name for route
const ServiceKind = "Service"
ServiceKind the kind name for Service
Variables ¶
var ( ProxyAPIAvailable = false ProxyAPIChecked = false ProxyEnvVars = []corev1.EnvVar{} GlobalProxy = &apiconfigv1.Proxy{} )
var ( RouteAPIAvailable = false RouteAPIChecked = false )
var ( EmptyListOptions = metav1.ListOptions{} EmptyGetOptions = metav1.GetOptions{} )
Functions ¶
func BuildResourceLabels ¶
BuildResourceLabels returns labels for all Kubernetes resources created by operator
func DefaultResourceRequirement ¶
func DefaultResourceRequirement() corev1.ResourceRequirements
func GetBasePluginsVolumeNameConfigMapName ¶
GetBasePluginsVolumeNameConfigMapName returns name of Kubernetes config map used to init configuration
func GetDestinationRepository ¶
func GetDestinationRepository(cr *jenkinsv1alpha2.JenkinsImage) string
GetDestinationRepository returns the destination repository matching To.Repository/To.Name:To.Tag or default to openshift-image-registry if running on openshift or --no-push otherwise
func GetDockerBuilderSecretName ¶
GetDockerBuilderSecretName returns the *first* Docker secret used for pushing images into the openshift registry in the current namespace or empty string
func GetDockerfileConfigMapName ¶
func GetDockerfileConfigMapName(cr *jenkinsv1alpha2.JenkinsImage) string
func GetExtraRoleBindingName ¶
func GetInitConfigurationConfigMapName ¶
GetInitConfigurationConfigMapName returns name of Kubernetes config map used to init configuration
func GetJenkinsBackupPVCName ¶
func GetJenkinsBackupPoolName ¶
GetJenkinsDeploymentName returns Jenkins deployment name for given CR
func GetJenkinsContainer ¶
func GetJenkinsDeploymentName ¶
GetJenkinsDeploymentName returns Jenkins deployment name for given CR
func GetJenkinsHTTPServiceName ¶
GetJenkinsHTTPServiceName returns Kubernetes service name used for expose Jenkins HTTP endpoint
func GetJenkinsJNLPServiceName ¶
GetJenkinsJNLPServiceName returns Kubernetes service name used for expose Jenkins JNLP endpoint
func GetJenkinsMasterContainerBaseEnvs ¶
GetJenkinsMasterContainerBaseEnvs returns Jenkins master pod envs required by operator
func GetJenkinsMasterContainerBaseVolumeMounts ¶
func GetJenkinsMasterContainerBaseVolumeMounts(jenkins *v1alpha2.Jenkins, spec *v1alpha2.JenkinsSpec) []corev1.VolumeMount
GetJenkinsMasterContainerBaseVolumeMounts returns Jenkins master pod volume mounts required by operator
func GetJenkinsMasterPodBaseVolumes ¶
GetJenkinsMasterPodBaseVolumes returns Jenkins master pod volumes required by operator
func GetOperatorCredentialsSecretName ¶
GetOperatorCredentialsSecretName returns name of Kubernetes secret used to store jenkins operator credentials to allow calls to Jenkins API
func GetResourceList ¶
func GetResourceList(cpu string, mem string) corev1.ResourceList
func GetResourceName ¶
GetResourceName returns name of Kubernetes resource base on Jenkins CR
func GetResourceRequirements ¶
func GetTCPContainerPort ¶
func GetTCPContainerPort(portName string, portNumber int32) corev1.ContainerPort
func IsImageRegistryAvailable ¶
IsImageRegistryAvailable tells if the openshift image registry is installed and working
func IsImageRegistryAvailableCached ¶
func IsImageRegistryAvailableCached() bool
func IsOpenshiftProxyAPIAvailable ¶
func IsOpenshiftProxyAPIAvailable(clientSet *kubernetes.Clientset) bool
func IsProxyOverridden ¶
IsOverridden returns true if the given container overrides proxy env variable(s). We apply the following rule:
If a container already defines any of the proxy env variable then it overrides all of these.
func IsRouteAPIAvailable ¶
func IsRouteAPIAvailable(clientSet *kubernetes.Clientset) bool
IsRouteAPIAvailable tells if the Route API is installed and discoverable
func NewBasePluginConfigMap ¶
func NewBasePluginConfigMap(meta metav1.ObjectMeta, jenkins *v1alpha2.Jenkins) (*corev1.ConfigMap, error)
NewBasePluginConfigMap builds Kubernetes config map used for base plugins
func NewBuilderPod ¶
func NewBuilderPod(client client.Client, cr *jenkinsv1alpha2.JenkinsImage) *corev1.Pod
NewBuilderPod returns a busybox pod with the same name/namespace as the cr.
func NewDefaultPolicyRules ¶
func NewDefaultPolicyRules() []v1.PolicyRule
NewDefaultPolicyRules sets the default policy rules
func NewDockerfileConfigMap ¶
func NewDockerfileConfigMap(cr *jenkinsv1alpha2.JenkinsImage) *corev1.ConfigMap
NewDockerfileConfigMap returns a busybox pod with the same name/namespace as the cr.
func NewInitConfigurationConfigMap ¶
func NewInitConfigurationConfigMap(meta metav1.ObjectMeta, jenkins *v1alpha2.Jenkins) (*corev1.ConfigMap, error)
NewInitConfigurationConfigMap builds Kubernetes config map used to init configuration
func NewJenkinsBackupInitContainer ¶
func NewJenkinsBackupInitContainer(spec *v1alpha2.JenkinsSpec) corev1.Container
NewJenkinsConfigInitContainer returns Jenkins init container to copy configmap to make it writable
func NewJenkinsConfigContainer ¶
NewJenkinsConfigContainer returns Jenkins side container for config reloading
func NewJenkinsConfigInitContainer ¶
func NewJenkinsConfigInitContainer(spec *v1alpha2.JenkinsSpec) corev1.Container
NewJenkinsConfigInitContainer returns Jenkins init container to copy configmap to make it writable
func NewJenkinsDeployment ¶
func NewJenkinsDeployment(objectMeta metav1.ObjectMeta, jenkins *v1alpha2.Jenkins, jenkinsSpec *v1alpha2.JenkinsSpec) *appsv1.Deployment
NewJenkinsMasterPod builds Jenkins Master Kubernetes Pod resource.
func NewJenkinsMasterContainer ¶
NewJenkinsMasterContainer returns Jenkins master Kubernetes container
func NewJenkinsPluginsInitContainer ¶
func NewJenkinsPluginsInitContainer(spec *v1alpha2.JenkinsSpec) corev1.Container
NewJenkinsPluginsInitContainer returns Jenkins init container to install required based plugins
func NewOperatorCredentialsSecret ¶
NewOperatorCredentialsSecret builds the Kubernetes secret used to store jenkins operator credentials to allow calls to Jenkins API
func NewPolicyRule ¶
func NewPolicyRule(apiGroup string, resource, resourceName string, verbs []string) v1.PolicyRule
NewPolicyRule returns a policyRule allowing verbs on resources
func NewResourceObjectMeta ¶
func NewResourceObjectMeta(jenkins *v1alpha2.Jenkins) metav1.ObjectMeta
TODO Remove this meta object stuff and use Jenkins instead NewResourceObjectMeta builds ObjectMeta for all Kubernetes resources created by operator
func NewResourceRequirements ¶
func NewResourceRequirements(cpuRequest, memoryRequest, cpuLimit, memoryLimit string) corev1.ResourceRequirements
func NewRoleBinding ¶
NewRoleBinding returns rbac role binding for jenkins master
func NewScriptsConfigMap ¶
func NewScriptsConfigMap(meta metav1.ObjectMeta, jenkins *v1alpha2.Jenkins) (*corev1.ConfigMap, error)
NewScriptsConfigMap builds Kubernetes config map used to store scripts
func NewServiceAccount ¶
func NewServiceAccount(meta metav1.ObjectMeta, annotations map[string]string) *v1.ServiceAccount
NewServiceAccount return Kubernetes service account
func NewSimpleProbe ¶
func QueryProxyConfig ¶
func UpdateRoute ¶
UpdateRoute returns new route matching the service
func UpdateService ¶
UpdateService returns new service with override fields from config
func WaitForPodIsCompleted ¶
Poll up to timeout seconds for pod to enter running state. Returns an error if the pod never enters the running state.
Types ¶
This section is empty.