From e73720cd952e46a4d2b4a791903c19a70d6d93e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20S=C4=99k?= Date: Thu, 21 Nov 2019 11:29:32 +0100 Subject: [PATCH 01/12] Update olm-catalog deployment manifests --- .../0.2.2/jenkins-operator.v0.2.2.clusterserviceversion.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/olm-catalog/jenkins-operator/0.2.2/jenkins-operator.v0.2.2.clusterserviceversion.yaml b/deploy/olm-catalog/jenkins-operator/0.2.2/jenkins-operator.v0.2.2.clusterserviceversion.yaml index 90a5b3a9..6cfc6845 100644 --- a/deploy/olm-catalog/jenkins-operator/0.2.2/jenkins-operator.v0.2.2.clusterserviceversion.yaml +++ b/deploy/olm-catalog/jenkins-operator/0.2.2/jenkins-operator.v0.2.2.clusterserviceversion.yaml @@ -235,7 +235,7 @@ spec: serviceAccountName: jenkins-operator strategy: deployment installModes: - - supported: true + - supported: false type: OwnNamespace - supported: true type: SingleNamespace From a612939f338b42dec1a60b01a93134a1f937610d Mon Sep 17 00:00:00 2001 From: Jakub Al-Khalili Date: Fri, 22 Nov 2019 11:52:19 +0100 Subject: [PATCH 02/12] Add support for local development kubernetes cluster software (#207) #203 Add support for local development kubernetes cluster --- Makefile | 15 +++-- cmd/manager/main.go | 14 ++++- config.env => config.base.env | 4 -- config.minikube.env | 10 ++++ pkg/controller/jenkins/client/jenkins.go | 56 ++++++++++--------- .../jenkins/configuration/base/reconcile.go | 34 ++++++----- .../configuration/base/reconcile_test.go | 6 +- .../configuration/base/validate_test.go | 55 +++++++++--------- pkg/controller/jenkins/jenkins_controller.go | 43 ++++++-------- test/e2e/configuration_test.go | 6 +- test/e2e/jenkins.go | 26 +++++++-- test/e2e/main_test.go | 10 ++++ test/e2e/restart_test.go | 2 +- test/e2e/restorebackup_test.go | 9 ++- test/e2e/seedjobs_test.go | 2 +- 15 files changed, 171 insertions(+), 121 deletions(-) rename config.env => config.base.env (75%) create mode 100644 config.minikube.env diff --git a/Makefile b/Makefile index 9bb0c038..fd280500 100644 --- a/Makefile +++ b/Makefile @@ -15,9 +15,11 @@ else endif endif +include config.base.env + # Import config # You can change the default config with `make config="config_special.env" build` -config ?= config.env +config ?= config.minikube.env include $(config) # Set an output prefix, which is the local directory if not specified @@ -154,6 +156,7 @@ test: ## Runs the go tests .PHONY: e2e CURRENT_DIRECTORY := $(shell pwd) +JENKINS_API_HOSTNAME := $(shell $(JENKINS_API_HOSTNAME_COMMAND)) e2e: docker-build ## Runs e2e tests, you can use EXTRA_ARGS @echo "+ $@" @echo "Docker image: $(DOCKER_REGISTRY):$(GITCOMMIT)" @@ -164,22 +167,22 @@ e2e: docker-build ## Runs e2e tests, you can use EXTRA_ARGS cat deploy/operator.yaml >> deploy/namespace-init.yaml ifeq ($(OSFLAG), LINUX) sed -i 's|\(image:\).*|\1 $(DOCKER_REGISTRY):$(GITCOMMIT)|g' deploy/namespace-init.yaml -ifeq ($(KUBECTL_CONTEXT),minikube) +ifeq ($(KUBERNETES_PROVIDER),minikube) sed -i 's|\(imagePullPolicy\): IfNotPresent|\1: Never|g' deploy/namespace-init.yaml - sed -i 's|\(args:\).*|\1\ ["--minikube"\]|' deploy/namespace-init.yaml endif endif ifeq ($(OSFLAG), OSX) sed -i '' 's|\(image:\).*|\1 $(DOCKER_REGISTRY):$(GITCOMMIT)|g' deploy/namespace-init.yaml -ifeq ($(KUBECTL_CONTEXT),minikube) +ifeq ($(KUBERNETES_PROVIDER),minikube) sed -i '' 's|\(imagePullPolicy\): IfNotPresent|\1: Never|g' deploy/namespace-init.yaml - sed -i '' 's|\(args:\).*|\1\ ["--minikube"\]|' deploy/namespace-init.yaml endif endif @RUNNING_TESTS=1 go test -parallel=1 "./test/e2e/" -tags "$(BUILDTAGS) cgo" -v -timeout 45m -run "$(E2E_TEST_SELECTOR)" \ - -root=$(CURRENT_DIRECTORY) -kubeconfig=$(HOME)/.kube/config -globalMan deploy/crds/jenkins_$(API_VERSION)_jenkins_crd.yaml -namespacedMan deploy/namespace-init.yaml $(EXTRA_ARGS) + -root=$(CURRENT_DIRECTORY) -kubeconfig=$(HOME)/.kube/config -globalMan deploy/crds/jenkins_$(API_VERSION)_jenkins_crd.yaml \ + -jenkins-api-hostname=$(JENKINS_API_HOSTNAME) -jenkins-api-port=$(JENKINS_API_PORT) -jenkins-api-use-nodeport=$(JENKINS_API_USE_NODEPORT) \ + -namespacedMan deploy/namespace-init.yaml $(EXTRA_ARGS) .PHONY: vet vet: ## Verifies `go vet` passes diff --git a/cmd/manager/main.go b/cmd/manager/main.go index 6831f396..be6082df 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -12,6 +12,7 @@ import ( "github.com/jenkinsci/kubernetes-operator/pkg/apis" "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins" + "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/client" "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/constants" "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/notifications" e "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/notifications/event" @@ -64,8 +65,9 @@ func main() { // controller-runtime) pflag.CommandLine.AddGoFlagSet(flag.CommandLine) - minikube := pflag.Bool("minikube", false, "Use minikube as a Kubernetes platform") - local := pflag.Bool("local", false, "Run operator locally") + hostname := pflag.String("jenkins-api-hostname", "", "Hostname or IP of Jenkins API. It can be service name, node IP or localhost.") + port := pflag.Int("jenkins-api-port", 0, "The port on which Jenkins API is running. Note: If you want to use nodePort don't set this setting and --jenkins-api-use-nodeport must be true.") + useNodePort := pflag.Bool("jenkins-api-use-nodeport", false, "Connect to Jenkins API using the service nodePort instead of service port. If you want to set this as true - don't set --jenkins-api-port.") debug := pflag.Bool("debug", false, "Set log level to debug") pflag.Parse() @@ -123,8 +125,14 @@ func main() { c := make(chan e.Event) go notifications.Listen(c, events, mgr.GetClient()) + // validate jenkins API connection + jenkinsAPIConnectionSettings := client.JenkinsAPIConnectionSettings{Hostname: *hostname, Port: *port, UseNodePort: *useNodePort} + if err := jenkinsAPIConnectionSettings.Validate(); err != nil { + fatal(errors.Wrap(err, "invalid command line parameters"), *debug) + } + // setup Jenkins controller - if err := jenkins.Add(mgr, *local, *minikube, *clientSet, *cfg, &c); err != nil { + if err := jenkins.Add(mgr, jenkinsAPIConnectionSettings, *clientSet, *cfg, &c); err != nil { fatal(errors.Wrap(err, "failed to setup controllers"), *debug) } diff --git a/config.env b/config.base.env similarity index 75% rename from config.env rename to config.base.env index 53037d69..bfb2aab8 100644 --- a/config.env +++ b/config.base.env @@ -7,9 +7,5 @@ DOCKER_ORGANIZATION=virtuslab DOCKER_REGISTRY=jenkins-operator NAMESPACE=default API_VERSION=v1alpha2 -MINIKUBE_KUBERNETES_VERSION=v1.16.0 -MINIKUBE_DRIVER=virtualbox -MINIKUBE_VERSION=1.4.0 -KUBECTL_CONTEXT=minikube ALL_IN_ONE_DEPLOY_FILE_PREFIX=all-in-one GEN_CRD_API=gen-crd-api-reference-docs diff --git a/config.minikube.env b/config.minikube.env new file mode 100644 index 00000000..6c6ff315 --- /dev/null +++ b/config.minikube.env @@ -0,0 +1,10 @@ +KUBERNETES_PROVIDER=minikube + +MINIKUBE_KUBERNETES_VERSION=v1.16.0 +MINIKUBE_DRIVER=virtualbox +MINIKUBE_VERSION=1.4.0 +KUBECTL_CONTEXT=minikube + +JENKINS_API_HOSTNAME_COMMAND=minikube ip +JENKINS_API_PORT=-1 +JENKINS_API_USE_NODEPORT=true \ No newline at end of file diff --git a/pkg/controller/jenkins/client/jenkins.go b/pkg/controller/jenkins/client/jenkins.go index e757073b..802850d8 100644 --- a/pkg/controller/jenkins/client/jenkins.go +++ b/pkg/controller/jenkins/client/jenkins.go @@ -1,10 +1,8 @@ package client import ( - "bytes" "fmt" "net/http" - "os/exec" "regexp" "strings" @@ -63,6 +61,13 @@ type jenkins struct { gojenkins.Jenkins } +// JenkinsAPIConnectionSettings is struct that handle information about Jenkins API connection +type JenkinsAPIConnectionSettings struct { + Hostname string + Port int + UseNodePort bool +} + // CreateOrUpdateJob creates or updates a job from config func (jenkins *jenkins) CreateOrUpdateJob(config, jobName string) (job *gojenkins.Job, created bool, err error) { // create or update @@ -80,34 +85,33 @@ func (jenkins *jenkins) CreateOrUpdateJob(config, jobName string) (job *gojenkin } // BuildJenkinsAPIUrl returns Jenkins API URL -func BuildJenkinsAPIUrl(namespace, serviceName string, portNumber int32, local, minikube bool) (string, error) { - // Get Jenkins URL from minikube command - if local && minikube { - cmd := exec.Command("minikube", "service", "--url", "-n", namespace, serviceName) - var out bytes.Buffer - cmd.Stdout = &out - err := cmd.Run() - if err != nil { - return "", errors.WithStack(err) - } - lines := strings.Split(out.String(), "\n") - // First is for http, the second one is for Jenkins slaves communication - // see pkg/controller/jenkins/configuration/base/resources/service.go - url := lines[0] - if strings.HasPrefix(url, "* ") { - return url[2:], nil - } - - return url, nil +func (j JenkinsAPIConnectionSettings) BuildJenkinsAPIUrl(serviceName string, serviceNamespace string, servicePort int32, serviceNodePort int32) string { + if j.Hostname == "" && j.Port == 0 { + return fmt.Sprintf("http://%s.%s:%d", serviceName, serviceNamespace, servicePort) } - if local { - // When run locally make port-forward to jenkins pod ('kubectl -n default port-forward jenkins-operator-example 8080') - return fmt.Sprintf("http://localhost:%d", portNumber), nil + if j.Hostname != "" && j.UseNodePort { + return fmt.Sprintf("http://%s:%d", j.Hostname, serviceNodePort) } - // Connect through Kubernetes service, operator has to be run inside cluster - return fmt.Sprintf("http://%s.%s:%d", serviceName, namespace, portNumber), nil + return fmt.Sprintf("http://%s:%d", j.Hostname, j.Port) +} + +// Validate validates jenkins API connection settings +func (j JenkinsAPIConnectionSettings) Validate() error { + if j.Port >= 0 && j.UseNodePort { + return errors.New("can't use service port and nodePort both. Please use port or nodePort") + } + + if j.Port < 0 { + return errors.New("service port cannot be lower than 0") + } + + if (j.Hostname == "" && j.Port > 0) || (j.Hostname == "" && j.UseNodePort) { + return errors.New("empty hostname is now allowed. Please provide hostname") + } + + return nil } // New creates Jenkins API client diff --git a/pkg/controller/jenkins/configuration/base/reconcile.go b/pkg/controller/jenkins/configuration/base/reconcile.go index 77f6ba7b..42b17b54 100644 --- a/pkg/controller/jenkins/configuration/base/reconcile.go +++ b/pkg/controller/jenkins/configuration/base/reconcile.go @@ -41,19 +41,18 @@ const ( // ReconcileJenkinsBaseConfiguration defines values required for Jenkins base configuration type ReconcileJenkinsBaseConfiguration struct { configuration.Configuration - logger logr.Logger - local, minikube bool - config *rest.Config + logger logr.Logger + jenkinsAPIConnectionSettings jenkinsclient.JenkinsAPIConnectionSettings + config *rest.Config } // New create structure which takes care of base configuration -func New(config configuration.Configuration, logger logr.Logger, local, minikube bool, restConfig *rest.Config) *ReconcileJenkinsBaseConfiguration { +func New(config configuration.Configuration, logger logr.Logger, jenkinsAPIConnectionSettings jenkinsclient.JenkinsAPIConnectionSettings, restConfig *rest.Config) *ReconcileJenkinsBaseConfiguration { return &ReconcileJenkinsBaseConfiguration{ - Configuration: config, - logger: logger, - local: local, - minikube: minikube, - config: restConfig, + Configuration: config, + logger: logger, + jenkinsAPIConnectionSettings: jenkinsAPIConnectionSettings, + config: restConfig, } } @@ -800,16 +799,23 @@ func (r *ReconcileJenkinsBaseConfiguration) waitForJenkins() (reconcile.Result, } func (r *ReconcileJenkinsBaseConfiguration) ensureJenkinsClient() (jenkinsclient.Jenkins, error) { - jenkinsURL, err := jenkinsclient.BuildJenkinsAPIUrl( - r.Configuration.Jenkins.ObjectMeta.Namespace, resources.GetJenkinsHTTPServiceName(r.Configuration.Jenkins), r.Configuration.Jenkins.Spec.Service.Port, r.local, r.minikube) + var service corev1.Service + + err := r.Client.Get(context.TODO(), types.NamespacedName{ + Namespace: r.Configuration.Jenkins.ObjectMeta.Namespace, + Name: resources.GetJenkinsHTTPServiceName(r.Configuration.Jenkins), + }, &service) + + if err != nil { + return nil, err + } + + jenkinsURL := r.jenkinsAPIConnectionSettings.BuildJenkinsAPIUrl(service.Name, service.Namespace, service.Spec.Ports[0].Port, service.Spec.Ports[0].NodePort) if prefix, ok := GetJenkinsOpts(*r.Configuration.Jenkins)["prefix"]; ok { jenkinsURL = jenkinsURL + prefix } - if err != nil { - return nil, err - } r.logger.V(log.VDebug).Info(fmt.Sprintf("Jenkins API URL '%s'", jenkinsURL)) credentialsSecret := &corev1.Secret{} diff --git a/pkg/controller/jenkins/configuration/base/reconcile_test.go b/pkg/controller/jenkins/configuration/base/reconcile_test.go index 67088a71..2b6a073a 100644 --- a/pkg/controller/jenkins/configuration/base/reconcile_test.go +++ b/pkg/controller/jenkins/configuration/base/reconcile_test.go @@ -234,7 +234,7 @@ func TestCompareVolumes(t *testing.T) { Volumes: resources.GetJenkinsMasterPodBaseVolumes(jenkins), }, } - reconciler := New(configuration.Configuration{Jenkins: jenkins}, nil, false, false, nil) + reconciler := New(configuration.Configuration{Jenkins: jenkins}, nil, client.JenkinsAPIConnectionSettings{}, nil) got := reconciler.compareVolumes(pod) @@ -258,7 +258,7 @@ func TestCompareVolumes(t *testing.T) { Volumes: resources.GetJenkinsMasterPodBaseVolumes(jenkins), }, } - reconciler := New(configuration.Configuration{Jenkins: jenkins}, nil, false, false, nil) + reconciler := New(configuration.Configuration{Jenkins: jenkins}, nil, client.JenkinsAPIConnectionSettings{}, nil) got := reconciler.compareVolumes(pod) @@ -282,7 +282,7 @@ func TestCompareVolumes(t *testing.T) { Volumes: append(resources.GetJenkinsMasterPodBaseVolumes(jenkins), corev1.Volume{Name: "added"}), }, } - reconciler := New(configuration.Configuration{Jenkins: jenkins}, nil, false, false, nil) + reconciler := New(configuration.Configuration{Jenkins: jenkins}, nil, client.JenkinsAPIConnectionSettings{}, nil) got := reconciler.compareVolumes(pod) diff --git a/pkg/controller/jenkins/configuration/base/validate_test.go b/pkg/controller/jenkins/configuration/base/validate_test.go index fff7101f..b6d4415e 100644 --- a/pkg/controller/jenkins/configuration/base/validate_test.go +++ b/pkg/controller/jenkins/configuration/base/validate_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2" + "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/client" "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/configuration" "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/configuration/base/resources" "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/constants" @@ -23,7 +24,7 @@ import ( func TestValidatePlugins(t *testing.T) { log.SetupLogger(true) - baseReconcileLoop := New(configuration.Configuration{}, log.Log, false, false, nil) + baseReconcileLoop := New(configuration.Configuration{}, log.Log, client.JenkinsAPIConnectionSettings{}, nil) t.Run("empty", func(t *testing.T) { var requiredBasePlugins []plugins.Plugin var basePlugins []v1alpha2.Plugin @@ -166,7 +167,7 @@ func TestReconcileJenkinsBaseConfiguration_validateImagePullSecrets(t *testing.T baseReconcileLoop := New(configuration.Configuration{ Client: fakeClient, Jenkins: &jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got, err := baseReconcileLoop.validateImagePullSecrets() fmt.Println(got) @@ -190,7 +191,7 @@ func TestReconcileJenkinsBaseConfiguration_validateImagePullSecrets(t *testing.T baseReconcileLoop := New(configuration.Configuration{ Client: fakeClient, Jenkins: &jenkins, - }, nil, false, false, nil) + }, nil, client.JenkinsAPIConnectionSettings{}, nil) got, _ := baseReconcileLoop.validateImagePullSecrets() @@ -226,7 +227,7 @@ func TestReconcileJenkinsBaseConfiguration_validateImagePullSecrets(t *testing.T baseReconcileLoop := New(configuration.Configuration{ Client: fakeClient, Jenkins: &jenkins, - }, nil, false, false, nil) + }, nil, client.JenkinsAPIConnectionSettings{}, nil) got, _ := baseReconcileLoop.validateImagePullSecrets() @@ -262,7 +263,7 @@ func TestReconcileJenkinsBaseConfiguration_validateImagePullSecrets(t *testing.T baseReconcileLoop := New(configuration.Configuration{ Client: fakeClient, Jenkins: &jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got, _ := baseReconcileLoop.validateImagePullSecrets() @@ -298,7 +299,7 @@ func TestReconcileJenkinsBaseConfiguration_validateImagePullSecrets(t *testing.T baseReconcileLoop := New(configuration.Configuration{ Client: fakeClient, Jenkins: &jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got, _ := baseReconcileLoop.validateImagePullSecrets() @@ -334,7 +335,7 @@ func TestReconcileJenkinsBaseConfiguration_validateImagePullSecrets(t *testing.T baseReconcileLoop := New(configuration.Configuration{ Client: fakeClient, Jenkins: &jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got, _ := baseReconcileLoop.validateImagePullSecrets() @@ -367,7 +368,7 @@ func TestValidateJenkinsMasterPodEnvs(t *testing.T) { } baseReconcileLoop := New(configuration.Configuration{ Jenkins: &jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got := baseReconcileLoop.validateJenkinsMasterPodEnvs() assert.Nil(t, got) }) @@ -390,7 +391,7 @@ func TestValidateJenkinsMasterPodEnvs(t *testing.T) { } baseReconcileLoop := New(configuration.Configuration{ Jenkins: &jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got := baseReconcileLoop.validateJenkinsMasterPodEnvs() assert.Equal(t, got, []string{"Jenkins Master container env 'JAVA_OPTS' doesn't have required flag '-Djava.awt.headless=true'"}) @@ -414,7 +415,7 @@ func TestValidateJenkinsMasterPodEnvs(t *testing.T) { } baseReconcileLoop := New(configuration.Configuration{ Jenkins: &jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got := baseReconcileLoop.validateJenkinsMasterPodEnvs() assert.Equal(t, got, []string{"Jenkins Master container env 'JAVA_OPTS' doesn't have required flag '-Djenkins.install.runSetupWizard=false'"}) @@ -436,7 +437,7 @@ func TestValidateReservedVolumes(t *testing.T) { } baseReconcileLoop := New(configuration.Configuration{ Jenkins: &jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got := baseReconcileLoop.validateReservedVolumes() assert.Nil(t, got) }) @@ -454,7 +455,7 @@ func TestValidateReservedVolumes(t *testing.T) { } baseReconcileLoop := New(configuration.Configuration{ Jenkins: &jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got := baseReconcileLoop.validateReservedVolumes() assert.Equal(t, got, []string{"Jenkins Master pod volume 'jenkins-home' is reserved please choose different one"}) @@ -470,7 +471,7 @@ func TestValidateContainerVolumeMounts(t *testing.T) { } baseReconcileLoop := New(configuration.Configuration{ Jenkins: &jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got := baseReconcileLoop.validateContainerVolumeMounts(v1alpha2.Container{}) assert.Nil(t, got) }) @@ -498,7 +499,7 @@ func TestValidateContainerVolumeMounts(t *testing.T) { } baseReconcileLoop := New(configuration.Configuration{ Jenkins: &jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got := baseReconcileLoop.validateContainerVolumeMounts(jenkins.Spec.Master.Containers[0]) assert.Nil(t, got) }) @@ -526,7 +527,7 @@ func TestValidateContainerVolumeMounts(t *testing.T) { } baseReconcileLoop := New(configuration.Configuration{ Jenkins: &jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got := baseReconcileLoop.validateContainerVolumeMounts(jenkins.Spec.Master.Containers[0]) assert.Equal(t, got, []string{"mountPath not set for 'example' volume mount in container ''"}) }) @@ -549,7 +550,7 @@ func TestValidateContainerVolumeMounts(t *testing.T) { } baseReconcileLoop := New(configuration.Configuration{ Jenkins: &jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got := baseReconcileLoop.validateContainerVolumeMounts(jenkins.Spec.Master.Containers[0]) assert.Equal(t, got, []string{"Not found volume for 'missing-volume' volume mount in container ''"}) @@ -571,7 +572,7 @@ func TestValidateConfigMapVolume(t *testing.T) { fakeClient := fake.NewFakeClient() baseReconcileLoop := New(configuration.Configuration{ Client: fakeClient, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got, err := baseReconcileLoop.validateConfigMapVolume(volume) @@ -599,7 +600,7 @@ func TestValidateConfigMapVolume(t *testing.T) { baseReconcileLoop := New(configuration.Configuration{ Client: fakeClient, Jenkins: jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got, err := baseReconcileLoop.validateConfigMapVolume(volume) @@ -625,7 +626,7 @@ func TestValidateConfigMapVolume(t *testing.T) { baseReconcileLoop := New(configuration.Configuration{ Client: fakeClient, Jenkins: jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got, err := baseReconcileLoop.validateConfigMapVolume(volume) @@ -650,7 +651,7 @@ func TestValidateSecretVolume(t *testing.T) { fakeClient := fake.NewFakeClient() baseReconcileLoop := New(configuration.Configuration{ Client: fakeClient, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got, err := baseReconcileLoop.validateSecretVolume(volume) @@ -676,7 +677,7 @@ func TestValidateSecretVolume(t *testing.T) { baseReconcileLoop := New(configuration.Configuration{ Client: fakeClient, Jenkins: jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got, err := baseReconcileLoop.validateSecretVolume(volume) @@ -700,7 +701,7 @@ func TestValidateSecretVolume(t *testing.T) { baseReconcileLoop := New(configuration.Configuration{ Client: fakeClient, Jenkins: jenkins, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got, err := baseReconcileLoop.validateSecretVolume(volume) assert.NoError(t, err) @@ -724,7 +725,7 @@ func TestValidateCustomization(t *testing.T) { baseReconcileLoop := New(configuration.Configuration{ Jenkins: jenkins, Client: fakeClient, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) got, err := baseReconcileLoop.validateCustomization(customization, "spec.groovyScripts") @@ -746,7 +747,7 @@ func TestValidateCustomization(t *testing.T) { baseReconcileLoop := New(configuration.Configuration{ Jenkins: jenkins, Client: fakeClient, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) err := fakeClient.Create(context.TODO(), secret) require.NoError(t, err) @@ -777,7 +778,7 @@ func TestValidateCustomization(t *testing.T) { baseReconcileLoop := New(configuration.Configuration{ Jenkins: jenkins, Client: fakeClient, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) err := fakeClient.Create(context.TODO(), secret) require.NoError(t, err) err = fakeClient.Create(context.TODO(), configMap) @@ -804,7 +805,7 @@ func TestValidateCustomization(t *testing.T) { baseReconcileLoop := New(configuration.Configuration{ Jenkins: jenkins, Client: fakeClient, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) err := fakeClient.Create(context.TODO(), configMap) require.NoError(t, err) @@ -829,7 +830,7 @@ func TestValidateCustomization(t *testing.T) { baseReconcileLoop := New(configuration.Configuration{ Jenkins: jenkins, Client: fakeClient, - }, logf.ZapLogger(false), false, false, nil) + }, logf.ZapLogger(false), client.JenkinsAPIConnectionSettings{}, nil) err := fakeClient.Create(context.TODO(), secret) require.NoError(t, err) diff --git a/pkg/controller/jenkins/jenkins_controller.go b/pkg/controller/jenkins/jenkins_controller.go index f0885dd0..79607a44 100644 --- a/pkg/controller/jenkins/jenkins_controller.go +++ b/pkg/controller/jenkins/jenkins_controller.go @@ -47,20 +47,19 @@ var reconcileErrors = map[string]reconcileError{} // Add creates a new Jenkins Controller and adds it to the Manager. The Manager will set fields on the Controller // and Start it when the Manager is Started. -func Add(mgr manager.Manager, local, minikube bool, clientSet kubernetes.Clientset, config rest.Config, notificationEvents *chan event.Event) error { - return add(mgr, newReconciler(mgr, local, minikube, clientSet, config, notificationEvents)) +func Add(mgr manager.Manager, jenkinsAPIConnectionSettings jenkinsclient.JenkinsAPIConnectionSettings, clientSet kubernetes.Clientset, config rest.Config, notificationEvents *chan event.Event) error { + return add(mgr, newReconciler(mgr, jenkinsAPIConnectionSettings, clientSet, config, notificationEvents)) } // newReconciler returns a new reconcile.Reconciler -func newReconciler(mgr manager.Manager, local, minikube bool, clientSet kubernetes.Clientset, config rest.Config, notificationEvents *chan event.Event) reconcile.Reconciler { +func newReconciler(mgr manager.Manager, jenkinsAPIConnectionSettings jenkinsclient.JenkinsAPIConnectionSettings, clientSet kubernetes.Clientset, config rest.Config, notificationEvents *chan event.Event) reconcile.Reconciler { return &ReconcileJenkins{ - client: mgr.GetClient(), - scheme: mgr.GetScheme(), - local: local, - minikube: minikube, - clientSet: clientSet, - config: config, - notificationEvents: notificationEvents, + client: mgr.GetClient(), + scheme: mgr.GetScheme(), + jenkinsAPIConnectionSettings: jenkinsAPIConnectionSettings, + clientSet: clientSet, + config: config, + notificationEvents: notificationEvents, } } @@ -114,12 +113,12 @@ var _ reconcile.Reconciler = &ReconcileJenkins{} // ReconcileJenkins reconciles a Jenkins object type ReconcileJenkins struct { - client client.Client - scheme *runtime.Scheme - local, minikube bool - clientSet kubernetes.Clientset - config rest.Config - notificationEvents *chan event.Event + client client.Client + scheme *runtime.Scheme + jenkinsAPIConnectionSettings jenkinsclient.JenkinsAPIConnectionSettings + clientSet kubernetes.Clientset + config rest.Config + notificationEvents *chan event.Event } // Reconcile it's a main reconciliation loop which maintain desired state based on Jenkins.Spec @@ -236,7 +235,7 @@ func (r *ReconcileJenkins) reconcile(request reconcile.Request, logger logr.Logg } // Reconcile base configuration - baseConfiguration := base.New(config, logger, r.local, r.minikube, &r.config) + baseConfiguration := base.New(config, logger, r.jenkinsAPIConnectionSettings, &r.config) var baseMessages []string baseMessages, err = baseConfiguration.Validate(jenkins) @@ -446,16 +445,8 @@ func (r *ReconcileJenkins) setDefaults(jenkins *v1alpha2.Jenkins, logger logr.Lo if reflect.DeepEqual(jenkins.Spec.Service, v1alpha2.Service{}) { logger.Info("Setting default Jenkins master service") changed = true - var serviceType corev1.ServiceType - if r.minikube { - // When running locally with minikube cluster Jenkins Service have to be exposed via node port - // to allow communication operator -> Jenkins API - serviceType = corev1.ServiceTypeNodePort - } else { - serviceType = corev1.ServiceTypeClusterIP - } jenkins.Spec.Service = v1alpha2.Service{ - Type: serviceType, + Type: corev1.ServiceTypeClusterIP, Port: constants.DefaultHTTPPortInt32, } } diff --git a/test/e2e/configuration_test.go b/test/e2e/configuration_test.go index b21fe118..a8f1b319 100644 --- a/test/e2e/configuration_test.go +++ b/test/e2e/configuration_test.go @@ -89,7 +89,7 @@ func TestConfiguration(t *testing.T) { createKubernetesCredentialsProviderSecret(t, namespace, mySeedJob) waitForJenkinsBaseConfigurationToComplete(t, jenkins) verifyJenkinsMasterPodAttributes(t, jenkins) - client := verifyJenkinsAPIConnection(t, jenkins) + client := verifyJenkinsAPIConnection(t, jenkins, *hostname, *port, *useNodePort) verifyPlugins(t, client, jenkins) // user @@ -121,7 +121,7 @@ func TestPlugins(t *testing.T) { jenkins := createJenkinsCR(t, "k8s-e2e", namespace, seedJobs, v1alpha2.GroovyScripts{}, v1alpha2.ConfigurationAsCode{}) waitForJenkinsUserConfigurationToComplete(t, jenkins) - jenkinsClient := verifyJenkinsAPIConnection(t, jenkins) + jenkinsClient := verifyJenkinsAPIConnection(t, jenkins, *hostname, *port, *useNodePort) waitForJob(t, jenkinsClient, jobID) job, err := jenkinsClient.GetJob(jobID) @@ -267,7 +267,7 @@ func verifyJenkinsMasterPodAttributes(t *testing.T, jenkins *v1alpha2.Jenkins) { func verifyContainer(t *testing.T, expected corev1.Container, actual corev1.Container) { assert.Equal(t, expected.Args, actual.Args, expected.Name, expected.Name) assert.Equal(t, expected.Command, actual.Command, expected.Name) - assert.Equal(t, expected.Env, actual.Env, expected.Name) + assert.ElementsMatch(t, expected.Env, actual.Env, expected.Name) assert.Equal(t, expected.EnvFrom, actual.EnvFrom, expected.Name) assert.Equal(t, expected.Image, actual.Image, expected.Name) assert.Equal(t, expected.ImagePullPolicy, actual.ImagePullPolicy, expected.Name) diff --git a/test/e2e/jenkins.go b/test/e2e/jenkins.go index e842e9f1..df1b5784 100644 --- a/test/e2e/jenkins.go +++ b/test/e2e/jenkins.go @@ -7,7 +7,7 @@ import ( "github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2" jenkinsclient "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/client" "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/configuration/base/resources" - + "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/constants" framework "github.com/operator-framework/operator-sdk/pkg/test" "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1" @@ -46,18 +46,30 @@ func getJenkinsMasterPod(t *testing.T, jenkins *v1alpha2.Jenkins) *v1.Pod { return &podList.Items[0] } -func createJenkinsAPIClient(jenkins *v1alpha2.Jenkins) (jenkinsclient.Jenkins, error) { +func createJenkinsAPIClient(jenkins *v1alpha2.Jenkins, hostname string, port int, useNodePort bool) (jenkinsclient.Jenkins, error) { adminSecret := &v1.Secret{} namespaceName := types.NamespacedName{Namespace: jenkins.Namespace, Name: resources.GetOperatorCredentialsSecretName(jenkins)} if err := framework.Global.Client.Get(context.TODO(), namespaceName, adminSecret); err != nil { return nil, err } - jenkinsAPIURL, err := jenkinsclient.BuildJenkinsAPIUrl(jenkins.ObjectMeta.Namespace, resources.GetJenkinsHTTPServiceName(jenkins), resources.HTTPPortInt, true, true) + var service corev1.Service + + err := framework.Global.Client.Get(context.TODO(), types.NamespacedName{ + Namespace: jenkins.Namespace, + Name: resources.GetJenkinsHTTPServiceName(jenkins), + }, &service) + if err != nil { return nil, err } + jenkinsAPIURL := jenkinsclient.JenkinsAPIConnectionSettings{ + Hostname: hostname, + Port: port, + UseNodePort: useNodePort, + }.BuildJenkinsAPIUrl(service.Name, service.Namespace, service.Spec.Ports[0].Port, service.Spec.Ports[0].NodePort) + return jenkinsclient.New( jenkinsAPIURL, string(adminSecret.Data[resources.OperatorCredentialsSecretUserNameKey]), @@ -129,6 +141,10 @@ func createJenkinsCR(t *testing.T, name, namespace string, seedJob *[]v1alpha2.S NodeSelector: map[string]string{"kubernetes.io/hostname": "minikube"}, }, SeedJobs: seedJobs, + Service: v1alpha2.Service{ + Type: corev1.ServiceTypeNodePort, + Port: constants.DefaultHTTPPortInt32, + }, }, } @@ -140,8 +156,8 @@ func createJenkinsCR(t *testing.T, name, namespace string, seedJob *[]v1alpha2.S return jenkins } -func verifyJenkinsAPIConnection(t *testing.T, jenkins *v1alpha2.Jenkins) jenkinsclient.Jenkins { - client, err := createJenkinsAPIClient(jenkins) +func verifyJenkinsAPIConnection(t *testing.T, jenkins *v1alpha2.Jenkins, hostname string, port int, useNodePort bool) jenkinsclient.Jenkins { + client, err := createJenkinsAPIClient(jenkins, hostname, port, useNodePort) if err != nil { t.Fatal(err) } diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index 154a6894..d0764078 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -17,14 +17,24 @@ import ( const ( jenkinsOperatorDeploymentName = constants.OperatorName seedJobConfigurationParameterName = "seed-job-config" + hostnameParameterName = "jenkins-api-hostname" + portParameterName = "jenkins-api-port" + nodePortParameterName = "jenkins-api-use-nodeport" ) var ( seedJobConfigurationFile *string + hostname *string + port *int + useNodePort *bool ) func TestMain(m *testing.M) { seedJobConfigurationFile = flag.String(seedJobConfigurationParameterName, "", "path to seed job config") + hostname = flag.String(hostnameParameterName, "", "Hostname or IP of Jenkins API. It can be service name, node IP or localhost.") + port = flag.Int(portParameterName, -1, "The port on which Jenkins API is working. Note: If you want to use nodePort don't set this setting and --jenkins-api-use-nodeport must be false.") + useNodePort = flag.Bool(nodePortParameterName, false, "Connect to Jenkins API using the nodePort instead of service port. If you want to set this as true - don't set --jenkins-api-port.") + f.MainEntry(m) } diff --git a/test/e2e/restart_test.go b/test/e2e/restart_test.go index 5f4896df..66e1f606 100644 --- a/test/e2e/restart_test.go +++ b/test/e2e/restart_test.go @@ -48,7 +48,7 @@ func TestSafeRestart(t *testing.T) { jenkins := createJenkinsCR(t, jenkinsCRName, namespace, nil, groovyScriptsConfig, v1alpha2.ConfigurationAsCode{}) waitForJenkinsBaseConfigurationToComplete(t, jenkins) waitForJenkinsUserConfigurationToComplete(t, jenkins) - jenkinsClient := verifyJenkinsAPIConnection(t, jenkins) + jenkinsClient := verifyJenkinsAPIConnection(t, jenkins, *hostname, *port, *useNodePort) checkIfAuthorizationStrategyUnsecuredIsSet(t, jenkinsClient) err := jenkinsClient.SafeRestart() diff --git a/test/e2e/restorebackup_test.go b/test/e2e/restorebackup_test.go index 07ab5f9f..0dd41f9d 100644 --- a/test/e2e/restorebackup_test.go +++ b/test/e2e/restorebackup_test.go @@ -9,6 +9,7 @@ import ( "github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2" "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/client" "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/configuration/base/resources" + "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/constants" framework "github.com/operator-framework/operator-sdk/pkg/test" "github.com/stretchr/testify/assert" @@ -31,7 +32,7 @@ func TestBackupAndRestore(t *testing.T) { jenkins := createJenkinsWithBackupAndRestoreConfigured(t, "e2e", namespace) waitForJenkinsUserConfigurationToComplete(t, jenkins) - jenkinsClient := verifyJenkinsAPIConnection(t, jenkins) + jenkinsClient := verifyJenkinsAPIConnection(t, jenkins, *hostname, *port, *useNodePort) waitForJob(t, jenkinsClient, jobID) job, err := jenkinsClient.GetJob(jobID) require.NoError(t, err, job) @@ -43,7 +44,7 @@ func TestBackupAndRestore(t *testing.T) { restartJenkinsMasterPod(t, jenkins) waitForRecreateJenkinsMasterPod(t, jenkins) waitForJenkinsUserConfigurationToComplete(t, jenkins) - jenkinsClient = verifyJenkinsAPIConnection(t, jenkins) + jenkinsClient = verifyJenkinsAPIConnection(t, jenkins, *hostname, *port, *useNodePort) waitForJob(t, jenkinsClient, jobID) verifyJobBuildsAfterRestoreBackup(t, jenkinsClient, jobID) } @@ -162,6 +163,10 @@ func createJenkinsWithBackupAndRestoreConfigured(t *testing.T, name, namespace s RepositoryURL: "https://github.com/jenkinsci/kubernetes-operator.git", }, }, + Service: v1alpha2.Service{ + Type: corev1.ServiceTypeNodePort, + Port: constants.DefaultHTTPPortInt32, + }, }, } diff --git a/test/e2e/seedjobs_test.go b/test/e2e/seedjobs_test.go index 428a38df..adc73416 100644 --- a/test/e2e/seedjobs_test.go +++ b/test/e2e/seedjobs_test.go @@ -58,7 +58,7 @@ func TestSeedJobs(t *testing.T) { waitForJenkinsBaseConfigurationToComplete(t, jenkins) verifyJenkinsMasterPodAttributes(t, jenkins) - client := verifyJenkinsAPIConnection(t, jenkins) + client := verifyJenkinsAPIConnection(t, jenkins, *hostname, *port, *useNodePort) verifyPlugins(t, client, jenkins) // user From b75e8de59669eaec0f17caf77186447014528d8b Mon Sep 17 00:00:00 2001 From: Jakub Al-Khalili Date: Fri, 22 Nov 2019 15:40:00 +0100 Subject: [PATCH 03/12] Quick fix ports in jenkins.go This bug makes it impossible to use NodePort instead of port. --- pkg/controller/jenkins/client/jenkins.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controller/jenkins/client/jenkins.go b/pkg/controller/jenkins/client/jenkins.go index 802850d8..c8ae39d1 100644 --- a/pkg/controller/jenkins/client/jenkins.go +++ b/pkg/controller/jenkins/client/jenkins.go @@ -99,7 +99,7 @@ func (j JenkinsAPIConnectionSettings) BuildJenkinsAPIUrl(serviceName string, ser // Validate validates jenkins API connection settings func (j JenkinsAPIConnectionSettings) Validate() error { - if j.Port >= 0 && j.UseNodePort { + if j.Port > 0 && j.UseNodePort { return errors.New("can't use service port and nodePort both. Please use port or nodePort") } From eea28a42a364d966cdf17782e45ed04d52d8f332 Mon Sep 17 00:00:00 2001 From: Jakub Al-Khalili Date: Thu, 28 Nov 2019 16:26:40 +0100 Subject: [PATCH 04/12] Add support for podman & fix crc e2e tests (#214) #203 Add support for podman - container runtime --- Makefile | 97 +++++++++++++++++++++++++++++---------------- config.base.env | 1 + config.crc.env | 7 ++++ config.minikube.env | 2 +- 4 files changed, 72 insertions(+), 35 deletions(-) create mode 100644 config.crc.env diff --git a/Makefile b/Makefile index fd280500..5a30d4d4 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,9 @@ BUILD_TAG := $(GITBRANCH)-$(GITCOMMIT) BUILD_PATH := ./cmd/manager +# CONTAINER_RUNTIME_COMMAND is Container Runtime - it could be docker or podman +CONTAINER_RUNTIME_COMMAND := docker + # Set any default go build tags BUILDTAGS := @@ -62,12 +65,13 @@ PACKAGES_FOR_UNIT_TESTS = $(shell go list -f '{{.ImportPath}}/' ./... | grep -v # Run all the e2e tests by default E2E_TEST_SELECTOR ?= .* -ARGS ?= /usr/bin/jenkins-operator --local --namespace=$(NAMESPACE) $(EXTRA_ARGS) +JENKINS_API_HOSTNAME := $(shell $(JENKINS_API_HOSTNAME_COMMAND)) +OPERATOR_ARGS ?= --jenkins-api-hostname=$(JENKINS_API_HOSTNAME) --jenkins-api-port=$(JENKINS_API_PORT) --jenkins-api-use-nodeport=$(JENKINS_API_USE_NODEPORT) --namespace=$(NAMESPACE) $(OPERATOR_EXTRA_ARGS) .DEFAULT_GOAL := help .PHONY: all -all: status checkmake clean build verify install docker-build docker-images ## Build the image +all: status checkmake clean build verify install container-runtime-build container-runtime-images ## Build the image @echo "+ $@" .PHONY: check-env @@ -156,24 +160,38 @@ test: ## Runs the go tests .PHONY: e2e CURRENT_DIRECTORY := $(shell pwd) -JENKINS_API_HOSTNAME := $(shell $(JENKINS_API_HOSTNAME_COMMAND)) -e2e: docker-build ## Runs e2e tests, you can use EXTRA_ARGS +e2e: container-runtime-build ## Runs e2e tests, you can use EXTRA_ARGS @echo "+ $@" @echo "Docker image: $(DOCKER_REGISTRY):$(GITCOMMIT)" +ifeq ($(KUBERNETES_PROVIDER),minikube) kubectl config use-context $(KUBECTL_CONTEXT) +endif +ifeq ($(KUBERNETES_PROVIDER),crc) + oc project $(CRC_OC_PROJECT) +endif cp deploy/service_account.yaml deploy/namespace-init.yaml cat deploy/role.yaml >> deploy/namespace-init.yaml cat deploy/role_binding.yaml >> deploy/namespace-init.yaml cat deploy/operator.yaml >> deploy/namespace-init.yaml ifeq ($(OSFLAG), LINUX) +ifeq ($(IMAGE_PULL_MODE), remote) + sed -i 's|\(image:\).*|\1 $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(GITCOMMIT)|g' deploy/namespace-init.yaml + sed -i 's|\(imagePullPolicy\): IfNotPresent|\1: Always|g' deploy/namespace-init.yaml +else sed -i 's|\(image:\).*|\1 $(DOCKER_REGISTRY):$(GITCOMMIT)|g' deploy/namespace-init.yaml +endif ifeq ($(KUBERNETES_PROVIDER),minikube) sed -i 's|\(imagePullPolicy\): IfNotPresent|\1: Never|g' deploy/namespace-init.yaml endif endif ifeq ($(OSFLAG), OSX) +ifeq ($(IMAGE_PULL_MODE), remote) + sed -i '' 's|\(image:\).*|\1 $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(GITCOMMIT)|g' deploy/namespace-init.yaml + sed -i '' 's|\(imagePullPolicy\): IfNotPresent|\1: Always|g' deploy/namespace-init.yaml +else sed -i '' 's|\(image:\).*|\1 $(DOCKER_REGISTRY):$(GITCOMMIT)|g' deploy/namespace-init.yaml +endif ifeq ($(KUBERNETES_PROVIDER),minikube) sed -i '' 's|\(imagePullPolicy\): IfNotPresent|\1: Never|g' deploy/namespace-init.yaml endif @@ -182,7 +200,7 @@ endif @RUNNING_TESTS=1 go test -parallel=1 "./test/e2e/" -tags "$(BUILDTAGS) cgo" -v -timeout 45m -run "$(E2E_TEST_SELECTOR)" \ -root=$(CURRENT_DIRECTORY) -kubeconfig=$(HOME)/.kube/config -globalMan deploy/crds/jenkins_$(API_VERSION)_jenkins_crd.yaml \ -jenkins-api-hostname=$(JENKINS_API_HOSTNAME) -jenkins-api-port=$(JENKINS_API_PORT) -jenkins-api-use-nodeport=$(JENKINS_API_USE_NODEPORT) \ - -namespacedMan deploy/namespace-init.yaml $(EXTRA_ARGS) + -namespacedMan deploy/namespace-init.yaml $(TEST_ARGS) .PHONY: vet vet: ## Verifies `go vet` passes @@ -227,10 +245,15 @@ run: export WATCH_NAMESPACE = $(NAMESPACE) run: export OPERATOR_NAME = $(NAME) run: build ## Run the executable, you can use EXTRA_ARGS @echo "+ $@" +ifeq ($(KUBERNETES_PROVIDER),minikube) kubectl config use-context $(KUBECTL_CONTEXT) +endif +ifeq ($(KUBERNETES_PROVIDER),crc) + oc project $(CRC_OC_PROJECT) +endif kubectl apply -f deploy/crds/jenkins_$(API_VERSION)_jenkins_crd.yaml @echo "Watching '$(WATCH_NAMESPACE)' namespace" - build/_output/bin/jenkins-operator --local $(EXTRA_ARGS) + build/_output/bin/jenkins-operator $(OPERATOR_ARGS) .PHONY: clean clean: ## Cleanup any build binaries or packages @@ -281,44 +304,50 @@ ifndef HAS_CHECKMAKE endif @checkmake Makefile -.PHONY: docker-login -docker-login: ## Log in into the Docker repository +.PHONY: container-runtime-login +container-runtime-login: ## Log in into the Docker repository @echo "+ $@" -.PHONY: docker-build -docker-build: check-env ## Build the container +.PHONY: container-runtime-build +container-runtime-build: check-env ## Build the container @echo "+ $@" - docker build \ + $(CONTAINER_RUNTIME_COMMAND) build \ --build-arg GO_VERSION=$(GO_VERSION) \ --build-arg OPERATOR_SDK_VERSION=$(OPERATOR_SDK_VERSION) \ -t $(DOCKER_REGISTRY):$(GITCOMMIT) . \ - --file build/Dockerfile + --file build/Dockerfile $(CONTAINER_RUNTIME_EXTRA_ARGS) -.PHONY: docker-images -docker-images: ## List all local containers +.PHONY: container-runtime-images +container-runtime-images: ## List all local containers @echo "+ $@" - docker images + $(CONTAINER_RUNTIME_COMMAND) images $(CONTAINER_RUNTIME_EXTRA_ARGS) -.PHONY: docker-push -docker-push: ## Push the container +.PHONY: container-runtime-push +container-runtime-push: ## Push the container @echo "+ $@" - docker tag $(DOCKER_REGISTRY):$(GITCOMMIT) $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(BUILD_TAG) - docker push $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(BUILD_TAG) + $(CONTAINER_RUNTIME_COMMAND) tag $(DOCKER_REGISTRY):$(GITCOMMIT) $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(BUILD_TAG) $(CONTAINER_RUNTIME_EXTRA_ARGS) + $(CONTAINER_RUNTIME_COMMAND) push $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(BUILD_TAG) $(CONTAINER_RUNTIME_EXTRA_ARGS) -.PHONY: docker-release-version -docker-release-version: ## Release image with version tag (in addition to build tag) +.PHONY: container-runtime-snapshot-push +container-runtime-snapshot-push: @echo "+ $@" - docker tag $(DOCKER_REGISTRY):$(GITCOMMIT) $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(VERSION_TAG) - docker push $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(VERSION_TAG) + $(CONTAINER_RUNTIME_COMMAND) tag $(DOCKER_REGISTRY):$(GITCOMMIT) $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(GITCOMMIT) $(CONTAINER_RUNTIME_EXTRA_ARGS) + $(CONTAINER_RUNTIME_COMMAND) push $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(GITCOMMIT) $(CONTAINER_RUNTIME_EXTRA_ARGS) -.PHONY: docker-release-latest -docker-release-latest: ## Release image with latest tags (in addition to build tag) +.PHONY: container-runtime-release-version +container-runtime-release-version: ## Release image with version tag (in addition to build tag) @echo "+ $@" - docker tag $(DOCKER_REGISTRY):$(GITCOMMIT) $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(LATEST_TAG) - docker push $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(LATEST_TAG) + $(CONTAINER_RUNTIME_COMMAND) tag $(DOCKER_REGISTRY):$(GITCOMMIT) $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(VERSION_TAG) $(CONTAINER_RUNTIME_EXTRA_ARGS) + $(CONTAINER_RUNTIME_COMMAND) push $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(VERSION_TAG) $(CONTAINER_RUNTIME_EXTRA_ARGS) -.PHONY: docker-release -docker-release: docker-build docker-release-version docker-release-latest ## Release image with version and latest tags (in addition to build tag) +.PHONY: container-runtime-release-latest +container-runtime-release-latest: ## Release image with latest tags (in addition to build tag) + @echo "+ $@" + $(CONTAINER_RUNTIME_COMMAND) tag $(DOCKER_REGISTRY):$(GITCOMMIT) $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(LATEST_TAG) $(CONTAINER_RUNTIME_EXTRA_ARGS) + $(CONTAINER_RUNTIME_COMMAND) push $(DOCKER_ORGANIZATION)/$(DOCKER_REGISTRY):$(LATEST_TAG) $(CONTAINER_RUNTIME_EXTRA_ARGS) + +.PHONY: container-runtime-release +container-runtime-release: container-runtime-build container-runtime-release-version container-runtime-release-latest ## Release image with version and latest tags (in addition to build tag) @echo "+ $@" # if this session isn't interactive, then we don't want to allocate a @@ -329,12 +358,12 @@ ifeq ($(INTERACTIVE), 1) DOCKER_FLAGS += -t endif -.PHONY: docker-run -docker-run: ## Run the container in docker, you can use EXTRA_ARGS +.PHONY: container-runtime-run +container-runtime-run: ## Run the container in docker, you can use EXTRA_ARGS @echo "+ $@" - docker run --rm -i $(DOCKER_FLAGS) \ + $(CONTAINER_RUNTIME_COMMAND) run $(CONTAINER_RUNTIME_EXTRA_ARGS) --rm -i $(DOCKER_FLAGS) \ --volume $(HOME)/.kube/config:/home/jenkins-operator/.kube/config \ - $(DOCKER_REGISTRY):$(GITCOMMIT) $(ARGS) + $(DOCKER_REGISTRY):$(GITCOMMIT) /usr/bin/jenkins-operator $(OPERATOR_ARGS) .PHONY: minikube-run minikube-run: export WATCH_NAMESPACE = $(NAMESPACE) @@ -344,7 +373,7 @@ minikube-run: minikube-start ## Run the operator locally and use minikube as Kub kubectl config use-context minikube kubectl apply -f deploy/crds/jenkins_$(API_VERSION)_jenkins_crd.yaml @echo "Watching '$(WATCH_NAMESPACE)' namespace" - build/_output/bin/jenkins-operator $(EXTRA_ARGS) + build/_output/bin/jenkins-operator $(OPERATOR_ARGS) .PHONY: deepcopy-gen deepcopy-gen: ## Generate deepcopy golang code diff --git a/config.base.env b/config.base.env index bfb2aab8..8eddce01 100644 --- a/config.base.env +++ b/config.base.env @@ -9,3 +9,4 @@ NAMESPACE=default API_VERSION=v1alpha2 ALL_IN_ONE_DEPLOY_FILE_PREFIX=all-in-one GEN_CRD_API=gen-crd-api-reference-docs +IMAGE_PULL_MODE=local \ No newline at end of file diff --git a/config.crc.env b/config.crc.env new file mode 100644 index 00000000..8bead977 --- /dev/null +++ b/config.crc.env @@ -0,0 +1,7 @@ +KUBERNETES_PROVIDER=crc + +JENKINS_API_HOSTNAME_COMMAND=crc ip +JENKINS_API_PORT=0 +JENKINS_API_USE_NODEPORT=true + +CRC_OC_PROJECT=default \ No newline at end of file diff --git a/config.minikube.env b/config.minikube.env index 6c6ff315..0e0d230f 100644 --- a/config.minikube.env +++ b/config.minikube.env @@ -6,5 +6,5 @@ MINIKUBE_VERSION=1.4.0 KUBECTL_CONTEXT=minikube JENKINS_API_HOSTNAME_COMMAND=minikube ip -JENKINS_API_PORT=-1 +JENKINS_API_PORT=0 JENKINS_API_USE_NODEPORT=true \ No newline at end of file From ab24e2c8fd599ab085ba0c65f1dfdc631e2803dd Mon Sep 17 00:00:00 2001 From: Jakub Al-Khalili Date: Wed, 27 Nov 2019 10:53:45 +0100 Subject: [PATCH 05/12] Add 0.3.x docs, add instruction how to run e2e tests on crc --- .../content/en/docs/Developer Guide/tools.md | 57 - .../en/docs/Getting Started/future/_index.md | 18 + .../en/docs/Getting Started/future/aks.md | 24 + .../Getting Started/future/configuration.md | 325 +++ .../future/configure-backup-and-restore.md | 86 + .../future/custom-backup-and-restore.md | 184 ++ .../Getting Started/future/customization.md | 186 ++ .../Getting Started/future/deploy-jenkins.md | 89 + .../Getting Started/future/developer-guide.md | 224 ++ .../Getting Started/future/diagnostics.md | 42 + .../en/docs/Getting Started/future/schema.md | 1979 +++++++++++++++++ .../latest/developer-guide.md} | 47 + .../Getting Started/v0.1.x/developer-guide.md | 198 ++ 13 files changed, 3402 insertions(+), 57 deletions(-) delete mode 100644 website/content/en/docs/Developer Guide/tools.md create mode 100644 website/content/en/docs/Getting Started/future/_index.md create mode 100644 website/content/en/docs/Getting Started/future/aks.md create mode 100644 website/content/en/docs/Getting Started/future/configuration.md create mode 100644 website/content/en/docs/Getting Started/future/configure-backup-and-restore.md create mode 100644 website/content/en/docs/Getting Started/future/custom-backup-and-restore.md create mode 100644 website/content/en/docs/Getting Started/future/customization.md create mode 100644 website/content/en/docs/Getting Started/future/deploy-jenkins.md create mode 100644 website/content/en/docs/Getting Started/future/developer-guide.md create mode 100644 website/content/en/docs/Getting Started/future/diagnostics.md create mode 100644 website/content/en/docs/Getting Started/future/schema.md rename website/content/en/docs/{Developer Guide/_index.md => Getting Started/latest/developer-guide.md} (82%) create mode 100644 website/content/en/docs/Getting Started/v0.1.x/developer-guide.md diff --git a/website/content/en/docs/Developer Guide/tools.md b/website/content/en/docs/Developer Guide/tools.md deleted file mode 100644 index 95285d80..00000000 --- a/website/content/en/docs/Developer Guide/tools.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: "Tools" -linkTitle: "Tools" -weight: 30 -date: 2019-08-05 -description: > - Required tools for building and running Jenkins Operator ---- - -{{% pageinfo %}} -This document explains how to install the Go tools used by the development process. -{{% /pageinfo %}} - -## Configure environment variables - -```bash -export GOPATH=/home/go # example value -export GOROOT=/usr/lib/go-1.12 # example value -export PATH=$GOPATH/bin:$PATH -``` - -## goimports - -``` -go get golang.org/x/tools/cmd/goimports -cd $GOPATH/src/golang.org/x/tools/cmd/goimports -go build -go install -``` - -## golint - -``` -go get -u golang.org/x/lint/golint -cd $GOPATH/src/golang.org/x/lint/golint -go build -go install -``` - -## checkmake -``` -go get github.com/mrtazz/checkmake -cd $GOPATH/src/github.com/mrtazz/checkmake -go build -go install -``` - -## staticcheck - -``` -mkdir -p $GOPATH/src/github.com/dominikh/ -cd $GOPATH/src/github.com/dominikh/ -git clone https://github.com/dominikh/go-tools.git -cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck -go build -go install -``` diff --git a/website/content/en/docs/Getting Started/future/_index.md b/website/content/en/docs/Getting Started/future/_index.md new file mode 100644 index 00000000..4cddd338 --- /dev/null +++ b/website/content/en/docs/Getting Started/future/_index.md @@ -0,0 +1,18 @@ +--- +title: "Future (v0.3.x)" +linkTitle: "Future (v0.3.x)" +weight: 10 +date: 2019-08-05 +description: > + How to work with jenkins-operator latest version +--- + +{{% pageinfo %}} +This document describes a getting started guide for **Jenkins Operator** `v0.3.x` and an additional configuration. +{{% /pageinfo %}} + +## First Steps + +Prepare your Kubernetes cluster and set up your `kubectl` access. + +Once you have running Kubernetes cluster you can focus on installing **Jenkins Operator** according to the [Installation](/docs/installation/) guide. diff --git a/website/content/en/docs/Getting Started/future/aks.md b/website/content/en/docs/Getting Started/future/aks.md new file mode 100644 index 00000000..7eab9a40 --- /dev/null +++ b/website/content/en/docs/Getting Started/future/aks.md @@ -0,0 +1,24 @@ +--- +title: "AKS" +linkTitle: "AKS" +weight: 10 +date: 2019-08-05 +description: > + Additional configuration for Azure Kubernetes Service +--- + +Azure AKS managed Kubernetes service adds to every pod the following environment variables: + +```yaml +- name: KUBERNETES_PORT_443_TCP_ADDR + value: +- name: KUBERNETES_PORT + value: tcp:// +- name: KUBERNETES_PORT_443_TCP + value: tcp:// +- name: KUBERNETES_SERVICE_HOST + value: +``` + +The operator is aware of it and omits these environment variables when checking if a Jenkins pod environment has been changed. It prevents the +restart of a Jenkins pod over and over again. \ No newline at end of file diff --git a/website/content/en/docs/Getting Started/future/configuration.md b/website/content/en/docs/Getting Started/future/configuration.md new file mode 100644 index 00000000..ef8086b1 --- /dev/null +++ b/website/content/en/docs/Getting Started/future/configuration.md @@ -0,0 +1,325 @@ +--- +title: "Configuration" +linkTitle: "Configuration" +weight: 2 +date: 2019-08-05 +description: > + How to configure Jenkins with Operator +--- + +## Configure Seed Jobs and Pipelines + +Jenkins operator uses [job-dsl][job-dsl] and [kubernetes-credentials-provider][kubernetes-credentials-provider] plugins for configuring jobs +and deploy keys. + +## Prepare job definitions and pipelines + +First you have to prepare pipelines and job definition in your GitHub repository using the following structure: + +``` +cicd/ +├── jobs +│   └── build.jenkins +└── pipelines + └── build.jenkins +``` + +**`cicd/jobs/build.jenkins`** is a job definition: + +``` +#!/usr/bin/env groovy + +pipelineJob('build-jenkins-operator') { + displayName('Build jenkins-operator') + + definition { + cpsScm { + scm { + git { + remote { + url('https://github.com/jenkinsci/kubernetes-operator.git') + credentials('jenkins-operator') + } + branches('*/master') + } + } + scriptPath('cicd/pipelines/build.jenkins') + } + } +} +``` + +**`cicd/pipelines/build.jenkins`** is an actual Jenkins pipeline: + +``` +#!/usr/bin/env groovy + +def label = "build-jenkins-operator-${UUID.randomUUID().toString()}" +def home = "/home/jenkins" +def workspace = "${home}/workspace/build-jenkins-operator" +def workdir = "${workspace}/src/github.com/jenkinsci/kubernetes-operator/" + +podTemplate(label: label, + containers: [ + containerTemplate(name: 'jnlp', image: 'jenkins/jnlp-slave:alpine'), + containerTemplate(name: 'go', image: 'golang:1-alpine', command: 'cat', ttyEnabled: true), + ], + envVars: [ + envVar(key: 'GOPATH', value: workspace), + ], + ) { + + node(label) { + dir(workdir) { + stage('Init') { + timeout(time: 3, unit: 'MINUTES') { + checkout scm + } + container('go') { + sh 'apk --no-cache --update add make git gcc libc-dev' + } + } + + stage('Dep') { + container('go') { + sh 'make dep' + } + } + + stage('Test') { + container('go') { + sh 'make test' + } + } + + stage('Build') { + container('go') { + sh 'make build' + } + } + } + } +} +``` + +## Configure Seed Jobs + +Jenkins Seed Jobs are configured using `Jenkins.spec.seedJobs` section from your custom resource manifest: + +``` +apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + seedJobs: + - id: jenkins-operator + targets: "cicd/jobs/*.jenkins" + description: "Jenkins Operator repository" + repositoryBranch: master + repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git +``` + +**Jenkins Operator** will automatically discover and configure all the seed jobs. + +You can verify if deploy keys were successfully configured in the Jenkins **Credentials** tab. + +![jenkins](/kubernetes-operator/img/jenkins-credentials.png) + +You can verify if your pipelines were successfully configured in the Jenkins Seed Job console output. + +![jenkins](/kubernetes-operator/img/jenkins-seed.png) + +If your GitHub repository is **private** you have to configure SSH or username/password authentication. + +### SSH authentication + +#### Generate SSH Keys + +There are two methods of SSH private key generation: + +```bash +$ openssl genrsa -out 2048 +``` + +or + +```bash +$ ssh-keygen -t rsa -b 2048 +$ ssh-keygen -p -f -m pem +``` + +Then copy content from generated file. + +#### Public key + +If you want to upload your public key to your Git server you need to extract it. + +If key was generated by `openssl` then you need to type this to extract public key: + +```bash +$ openssl rsa -in -pubout > .pub +``` + +If key was generated by `ssh-keygen` the public key content is located in .pub and there is no need to extract public key + +#### Configure SSH authentication + +Configure a seed job like this: + +``` +apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + seedJobs: + - id: jenkins-operator-ssh + credentialType: basicSSHUserPrivateKey + credentialID: k8s-ssh + targets: "cicd/jobs/*.jenkins" + description: "Jenkins Operator repository" + repositoryBranch: master + repositoryUrl: git@github.com:jenkinsci/kubernetes-operator.git +``` + +and create a Kubernetes Secret (name of secret should be the same from `credentialID` field): + +``` +apiVersion: v1 +kind: Secret +metadata: + name: k8s-ssh +stringData: + privateKey: | + -----BEGIN RSA PRIVATE KEY----- + MIIJKAIBAAKCAgEAxxDpleJjMCN5nusfW/AtBAZhx8UVVlhhhIKXvQ+dFODQIdzO + oDXybs1zVHWOj31zqbbJnsfsVZ9Uf3p9k6xpJ3WFY9b85WasqTDN1xmSd6swD4N8 + ... + username: github_user_name +``` + +### Username & password authentication + +Configure the seed job like: + +``` +apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + seedJobs: + - id: jenkins-operator-user-pass + credentialType: usernamePassword + credentialID: k8s-user-pass + targets: "cicd/jobs/*.jenkins" + description: "Jenkins Operator repository" + repositoryBranch: master + repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git +``` + +and create a Kubernetes Secret (name of secret should be the same from `credentialID` field): + +``` +apiVersion: v1 +kind: Secret +metadata: + name: k8s-user-pass +stringData: + username: github_user_name + password: password_or_token +``` + +## HTTP Proxy for downloading plugins + +To use forwarding proxy with an operator to download plugins you need to add the following environment variable to Jenkins Custom Resource (CR), e.g.: + +```yaml +spec: + master: + containers: + - name: jenkins-master + env: + - name: CURL_OPTIONS + value: -L -x +``` + +In `CURL_OPTIONS` var you can set additional arguments to `curl` command. + +## Pulling Docker images from private repositories + +To pull a Docker Image from private repository you can use `imagePullSecrets`. + +Please follow the instructions on [creating a secret with a docker config](https://kubernetes.io/docs/concepts/containers/images/?origin_team=T42NTAGHM#creating-a-secret-with-a-docker-config). + +### Docker Hub Configuration +To use Docker Hub additional steps are required. + +Edit the previously created secret: +```bash +kubectl -n edit secret +``` + +The `.dockerconfigjson` key's value needs to be replaced with a modified version. + +After modifications, it needs to be encoded as a Base64 value before setting the `.dockerconfigjson` key. + +Example config file to modify and use: +``` +{ + "auths":{ + "https://index.docker.io/v1/":{ + "username":"user", + "password":"password", + "email":"yourdockeremail@gmail.com", + "auth":"base64 of string user:password" + }, + "auth.docker.io":{ + "username":"user", + "password":"password", + "email":"yourdockeremail@gmail.com", + "auth":"base64 of string user:password" + }, + "registry.docker.io":{ + "username":"user", + "password":"password", + "email":"yourdockeremail@gmail.com", + "auth":"base64 of string user:password" + }, + "docker.io":{ + "username":"user", + "password":"password", + "email":"yourdockeremail@gmail.com", + "auth":"base64 of string user:password" + }, + "https://registry-1.docker.io/v2/": { + "username":"user", + "password":"password", + "email":"yourdockeremail@gmail.com", + "auth":"base64 of string user:password" + }, + "registry-1.docker.io/v2/": { + "username":"user", + "password":"password", + "email":"yourdockeremail@gmail.com", + "auth":"base64 of string user:password" + }, + "registry-1.docker.io": { + "username":"user", + "password":"password", + "email":"yourdockeremail@gmail.com", + "auth":"base64 of string user:password" + }, + "https://registry-1.docker.io": { + "username":"user", + "password":"password", + "email":"yourdockeremail@gmail.com", + "auth":"base64 of string user:password" + } + } +} +``` + +[job-dsl]:https://github.com/jenkinsci/job-dsl-plugin +[kubernetes-credentials-provider]:https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/ diff --git a/website/content/en/docs/Getting Started/future/configure-backup-and-restore.md b/website/content/en/docs/Getting Started/future/configure-backup-and-restore.md new file mode 100644 index 00000000..c8987e0e --- /dev/null +++ b/website/content/en/docs/Getting Started/future/configure-backup-and-restore.md @@ -0,0 +1,86 @@ +--- +title: "Configure backup and restore" +linkTitle: "Configure backup and restore" +weight: 10 +date: 2019-08-05 +description: > + Prevent loss of job history +--- + +Backup and restore is done by a container sidecar. + +### PVC + +#### Create PVC + +Save to the file named pvc.yaml: +```yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: + namespace: +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 500Gi +``` + +Run the following command: +```bash +$ kubectl -n create -f pvc.yaml +``` + +#### Configure Jenkins CR + +```yaml +apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: + namespace: +spec: + master: + securityContext: + runAsUser: 1000 + fsGroup: 1000 + containers: + - name: jenkins-master + image: jenkins/jenkins:lts + - name: backup # container responsible for the backup and restore + env: + - name: BACKUP_DIR + value: /backup + - name: JENKINS_HOME + value: /jenkins-home + - name: BACKUP_COUNT + value: "3" # keep only the 2 most recent backups + image: virtuslab/jenkins-operator-backup-pvc:v0.0.7 # look at backup/pvc directory + imagePullPolicy: IfNotPresent + volumeMounts: + - mountPath: /jenkins-home # Jenkins home volume + name: jenkins-home + - mountPath: /backup # backup volume + name: backup + volumes: + - name: backup # PVC volume where backups will be stored + persistentVolumeClaim: + claimName: + backup: + containerName: backup # container name is responsible for backup + action: + exec: + command: + - /home/user/bin/backup.sh # this command is invoked on "backup" container to make backup, for example /home/user/bin/backup.sh , is passed by operator + interval: 30 # how often make backup in seconds + makeBackupBeforePodDeletion: true # make a backup before pod deletion + restore: + containerName: backup # container name is responsible for restore backup + action: + exec: + command: + - /home/user/bin/restore.sh # this command is invoked on "backup" container to make restore backup, for example /home/user/bin/restore.sh , is passed by operator + #recoveryOnce: # if want to restore specific backup configure this field and then Jenkins will be restarted and desired backup will be restored +``` diff --git a/website/content/en/docs/Getting Started/future/custom-backup-and-restore.md b/website/content/en/docs/Getting Started/future/custom-backup-and-restore.md new file mode 100644 index 00000000..cc927599 --- /dev/null +++ b/website/content/en/docs/Getting Started/future/custom-backup-and-restore.md @@ -0,0 +1,184 @@ +--- +title: "Custom Backup and Restore Providers" +linkTitle: "Custom Backup and Restore Providers" +weight: 10 +date: 2019-08-05 +description: > + Custom backup and restore provider +--- + +With enough effort one can create a custom backup and restore provider +for the Jenkins Operator. + +## Requirements + +Two commands (e.g. scripts) are required: + +- a backup command, e.g. `backup.sh` that takes one argument, a **backup number** +- a restore command, e.g. `backup.sh` that takes one argument, a **backup number** + +Both scripts need to return an exit code of `0` on success and `1` or greater for failure. + +One of those scripts (or the entry point of the container) needs to be responsible +for backup cleanup or rotation if required, or an external system. + +## How it works + +The mechanism relies on basic Kubernetes and UNIX functionalities. + +The backup (and restore) container runs as a sidecar in the same +Kubernetes pod as the Jenkins master. + +Name of the backup and restore containers can be set as necessary using +`spec.backup.containerName` and `spec.restore.containerName`. +In most cases it will be the same container, but we allow for less common use cases. + +The operator will call a backup or restore commands inside a sidecar container when necessary: + +- backup command (defined in `spec.backup.action.exec.command`) + will be called every `N` seconds configurable in: `spec.backup.interval` + and on pod shutdown (if enabled in `spec.backup.makeBackupBeforePodDeletion`) + with an integer representing the current backup number as first and only argument +- restore command (defined in `spec.restore.action.exec.command`) + will be called at Jenkins startup + with an integer representing the backup number to restore as first and only argument + (can be overridden using `spec.restore.recoveryOnce`) + +## Example AWS S3 backup using the CLI + +This example shows abbreviated version of a simple AWS S3 backup implementation +using: `aws-cli`, `bash` and `kube2iam`. + +In addition to your normal `Jenkins` `CustomResource` some additional settings +for backup and restore are required, e.g.: + +```yaml +kind: Jenkins +apiVersion: jenkins.io/v1alpha1 +metadata: + name: example + namespace: jenkins +spec: + master: + masterAnnotations: + iam.amazonaws.com/role: "my-example-backup-role" # tell kube2iam where the AWS IAM role is + containers: + - name: jenkins-master + ... + - name: backup # container responsible for backup and restore + image: quay.io/virtuslab/aws-cli:1.16.263-2 + workingDir: /home/user/bin/ + command: # our container entry point + - sleep + - infinity + env: + - name: BACKUP_BUCKET + value: my-example-bucket # the S3 bucket name to use + - name: BACKUP_PATH + value: my-backup-path # the S3 bucket path prefix to use + - name: JENKINS_HOME + value: /jenkins-home # the path to mount jenkins home dir in the backup container + volumeMounts: + - mountPath: /jenkins-home # Jenkins home volume + name: jenkins-home + - mountPath: /home/user/bin/backup.sh + name: backup-scripts + subPath: backup.sh + readOnly: true + - mountPath: /home/user/bin/restore.sh + name: backup-scripts + subPath: restore.sh + readOnly: true + volumes: + - name: backup-scripts + configMap: + defaultMode: 0754 + name: jenkins-operator-backup-s3 + securityContext: # make sure both containers use the same UID and GUID + runAsUser: 1000 + fsGroup: 1000 + ... + backup: + containerName: backup # container name responsible for backup + interval: 3600 # how often make a backup in seconds + makeBackupBeforePodDeletion: true # trigger backup just before deleting the pod + action: + exec: + command: + # this command is invoked on "backup" container to create a backup, + # is passed by operator, + # for example /home/user/bin/backup.sh + - /home/user/bin/backup.sh + restore: + containerName: backup # container name is responsible for restore backup + action: + exec: + command: + # this command is invoked on "backup" container to restore a backup, + # is passed by operator + # for example /home/user/bin/restore.sh + - /home/user/bin/restore.sh +# recoveryOnce: # if want to restore specific backup configure this field and then Jenkins will be restarted and desired backup will be restored +``` + +The actual backup and restore scripts will be provided in a `ConfigMap`: + +```yaml +kind: ConfigMap +apiVersion: v1 +metadata: + name: jenkins-operator-backup-s3 + namespace: jenkins + labels: + app: jenkins-operator +data: + backup.sh: |- + #!/bin/bash -xeu + [[ ! $# -eq 1 ]] && echo "Usage: $0 backup_number" && exit 1; + [[ -z "${BACKUP_BUCKET}" ]] && echo "Required 'BACKUP_BUCKET' env not set" && exit 1; + [[ -z "${BACKUP_PATH}" ]] && echo "Required 'BACKUP_PATH' env not set" && exit 1; + [[ -z "${JENKINS_HOME}" ]] && echo "Required 'JENKINS_HOME' env not set" && exit 1; + + backup_number=$1 + echo "Running backup #${backup_number}" + + BACKUP_TMP_DIR=$(mktemp -d) + tar -C ${JENKINS_HOME} -czf "${BACKUP_TMP_DIR}/${backup_number}.tar.gz" --exclude jobs/*/workspace* -c jobs && \ + + aws s3 cp ${BACKUP_TMP_DIR}/${backup_number}.tar.gz s3://${BACKUP_BUCKET}/${BACKUP_PATH}/${backup_number}.tar.gz + echo Done + + restore.sh: |- + #!/bin/bash -xeu + [[ ! $# -eq 1 ]] && echo "Usage: $0 backup_number" && exit 1 + [[ -z "${BACKUP_BUCKET}" ]] && echo "Required 'BACKUP_BUCKET' env not set" && exit 1; + [[ -z "${BACKUP_PATH}" ]] && echo "Required 'BACKUP_PATH' env not set" && exit 1; + [[ -z "${JENKINS_HOME}" ]] && echo "Required 'JENKINS_HOME' env not set" && exit 1; + + backup_number=$1 + echo "Running restore #${backup_number}" + + BACKUP_TMP_DIR=$(mktemp -d) + aws s3 cp s3://${BACKUP_BUCKET}/${BACKUP_PATH}/${backup_number}.tar.gz ${BACKUP_TMP_DIR}/${backup_number}.tar.gz + + tar -C ${JENKINS_HOME} -zxf "${BACKUP_TMP_DIR}/${backup_number}.tar.gz" + echo Done +``` + +In our example we will use S3 bucket lifecycle policy to keep +the number of backups under control, e.g. Cloud Formation fragment: +```yaml + Type: AWS::S3::Bucket + Properties: + BucketName: my-example-bucket + ... + LifecycleConfiguration: + Rules: + - Id: BackupCleanup + Status: Enabled + Prefix: my-backup-path + ExpirationInDays: 7 + NoncurrentVersionExpirationInDays: 14 + AbortIncompleteMultipartUpload: + DaysAfterInitiation: 3 +``` diff --git a/website/content/en/docs/Getting Started/future/customization.md b/website/content/en/docs/Getting Started/future/customization.md new file mode 100644 index 00000000..7d953c71 --- /dev/null +++ b/website/content/en/docs/Getting Started/future/customization.md @@ -0,0 +1,186 @@ +--- +title: "Customization" +linkTitle: "Customization" +weight: 3 +date: 2019-08-05 +description: > + How to customize Jenkins +--- + +Jenkins can be customized using groovy scripts or the [configuration as code plugin](https://github.com/jenkinsci/configuration-as-code-plugin). +By using a [ConfigMap](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/) you can create your own **Jenkins** customized configuration. +Then you must reference the **`ConfigMap`** in the **Jenkins** pod customization file in `spec.groovyScripts` or `spec.configurationAsCode` + +For example create a **`ConfigMap`** with name `jenkins-operator-user-configuration`. Then, modify the **Jenkins** manifest to look like this: + +```yaml +apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + configurationAsCode: + configurations: + - name: jenkins-operator-user-configuration + groovyScripts: + configurations: + - name: jenkins-operator-user-configuration +``` + +Here is an example of `jenkins-operator-user-configuration`: +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: jenkins-operator-user-configuration +data: + 1-configure-theme.groovy: | + import jenkins.* + import jenkins.model.* + import hudson.* + import hudson.model.* + import org.jenkinsci.plugins.simpletheme.ThemeElement + import org.jenkinsci.plugins.simpletheme.CssTextThemeElement + import org.jenkinsci.plugins.simpletheme.CssUrlThemeElement + + Jenkins jenkins = Jenkins.getInstance() + + def decorator = Jenkins.instance.getDescriptorByType(org.codefirst.SimpleThemeDecorator.class) + + List configElements = new ArrayList<>(); + configElements.add(new CssTextThemeElement("DEFAULT")); + configElements.add(new CssUrlThemeElement("https://cdn.rawgit.com/afonsof/jenkins-material-theme/gh-pages/dist/material-light-green.css")); + decorator.setElements(configElements); + decorator.save(); + + jenkins.save() + 1-system-message.yaml: | + jenkins: + systemMessage: "Configuration as Code integration works!!!" +``` + +* `*.groovy` is Groovy script configuration +* `*.yaml is` configuration as code + +If you want to correct your configuration you can edit it while the **Jenkins Operator** is running. +Jenkins will reconcile and apply the new configuration. + +### Using secrets from a Groovy script + +If you configured `spec.groovyScripts.secret.name`, then this secret is available to use from map Groovy scripts. +The secrets are loaded to `secrets` map. + +Create a [secret](https://kubernetes.io/docs/concepts/configuration/secret/) with for example the name `jenkins-conf-secrets`. + +```yaml +kind: Secret +apiVersion: v1 +type: Opaque +metadata: + name: jenkins-conf-secrets + namespace: default +data: + SYSTEM_MESSAGE: SGVsbG8gd29ybGQ= +``` + +Then modify the **Jenkins** pod manifest by changing `spec.groovyScripts.secret.name` to `jenkins-conf-secrets`. + +```yaml +apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + configurationAsCode: + configurations: + - name: jenkins-operator-user-configuration + secret: + name: jenkins-conf-secrets + groovyScripts: + configurations: + - name: jenkins-operator-user-configuration + secret: + name: jenkins-conf-secrets +``` + +Now you can test that the secret is mounted by applying this `ConfigMap` for Groovy script: + +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: jenkins-operator-user-configuration +data: + 1-system-message.groovy: | + import jenkins.* + import jenkins.model.* + import hudson.* + import hudson.model.* + Jenkins jenkins = Jenkins.getInstance() + + jenkins.setSystemMessage(secrets["SYSTEM_MESSAGE"]) + jenkins.save() +``` + +Or by applying this configuration as code: +```yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: jenkins-operator-user-configuration +data: + 1-system-message.yaml: | + jenkins: + systemMessage: ${SYSTEM_MESSAGE} +``` + + +After this, you should see the `Hello world` system message from the **Jenkins** homepage. + +## Install Plugins + +Edit Custom Resource under `spec.master.plugins`: + +``` +apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + master: + plugins: + - name: simple-theme-plugin + version: 0.5.1 +``` + +Under `spec.master.basePlugins` you can find plugins for a valid **Jenkins Operator**: + +```yaml +apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + master: + basePlugins: + - name: kubernetes + version: 1.18.3 + - name: workflow-job + version: "2.34" + - name: workflow-aggregator + version: "2.6" + - name: git + version: 3.12.0 + - name: job-dsl + version: "1.76" + - name: configuration-as-code + version: "1.29" + - name: configuration-as-code-support + version: "1.19" + - name: kubernetes-credentials-provider + version: 0.12.1 +``` + +You can change their versions. + +The **Jenkins Operator** will then automatically install plugins after the Jenkins master pod restarts. diff --git a/website/content/en/docs/Getting Started/future/deploy-jenkins.md b/website/content/en/docs/Getting Started/future/deploy-jenkins.md new file mode 100644 index 00000000..4f7b5a96 --- /dev/null +++ b/website/content/en/docs/Getting Started/future/deploy-jenkins.md @@ -0,0 +1,89 @@ +--- +title: "Deploy Jenkins" +linkTitle: "Deploy Jenkins" +weight: 1 +date: 2019-08-05 +description: > + Deploy production ready Jenkins Operator manifest +--- + +Once Jenkins Operator is up and running let's deploy actual Jenkins instance. +Create manifest e.g. **`jenkins_instance.yaml`** with following data and save it on drive. + +```bash +apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + master: + containers: + - name: jenkins-master + image: jenkins/jenkins:lts + imagePullPolicy: Always + livenessProbe: + failureThreshold: 12 + httpGet: + path: /login + port: http + scheme: HTTP + initialDelaySeconds: 80 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + readinessProbe: + failureThreshold: 3 + httpGet: + path: /login + port: http + scheme: HTTP + initialDelaySeconds: 30 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + resources: + limits: + cpu: 1500m + memory: 3Gi + requests: + cpu: "1" + memory: 500Mi + seedJobs: + - id: jenkins-operator + targets: "cicd/jobs/*.jenkins" + description: "Jenkins Operator repository" + repositoryBranch: master + repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git +``` + +Deploy a Jenkins to Kubernetes: + +```bash +kubectl create -f jenkins_instance.yaml +``` +Watch the Jenkins instance being created: + +```bash +kubectl get pods -w +``` + +Get the Jenkins credentials: + +```bash +kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.user}' | base64 -d +kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.password}' | base64 -d +``` + +Connect to the Jenkins instance (minikube): + +```bash +minikube service jenkins-operator-http- --url +``` + +Connect to the Jenkins instance (actual Kubernetes cluster): + +```bash +kubectl port-forward jenkins- 8080:8080 +``` +Then open browser with address `http://localhost:8080`. +![jenkins](/img/jenkins.png) diff --git a/website/content/en/docs/Getting Started/future/developer-guide.md b/website/content/en/docs/Getting Started/future/developer-guide.md new file mode 100644 index 00000000..93435098 --- /dev/null +++ b/website/content/en/docs/Getting Started/future/developer-guide.md @@ -0,0 +1,224 @@ +--- +title: "Developer Guide" +linkTitle: "Developer Guide" +weight: 60 +date: 2019-08-05 +description: > + Jenkins Operator for developers +--- + +{{% pageinfo %}} +This document explains how to setup your development environment. +{{% /pageinfo %}} + +## Prerequisites + +- [operator_sdk][operator_sdk] version v0.8.1 +- [git][git_tool] +- [go][go_tool] version v1.12+ +- [goimports, golint, checkmake and staticcheck][install_dev_tools] +- [minikube][minikube] version v1.1.0+ (preferred Hypervisor - [virtualbox][virtualbox]) +- [docker][docker_tool] version 17.03+ + +## Clone repository and download dependencies + +```bash +mkdir -p $GOPATH/src/github.com/jenkinsci +cd $GOPATH/src/github.com/jenkinsci/ +git clone git@github.com:jenkinsci/kubernetes-operator.git +cd kubernetes-operator +make go-dependencies +``` + +## Build and run with a minikube + +Build and run **Jenkins Operator** locally: + +```bash +make build minikube-run EXTRA_ARGS='--jenkins-api-hostname=$(eval minikube ip) --jenkins-api-use-nodeport=true' +``` + +Once minikube and **Jenkins Operator** are up and running, apply Jenkins custom resource: + +```bash +kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl get jenkins -o yaml +kubectl get po +``` + +## Build and run with a remote Kubernetes cluster + +You can also run the controller locally and make it listen to a remote Kubernetes server. + +```bash +make run NAMESPACE=default KUBECTL_CONTEXT=remote-k8s EXTRA_ARGS='--kubeconfig ~/.kube/config' +``` + +Once minikube and **Jenkins Operator** are up and running, apply Jenkins custom resource: + +```bash +kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl --context remote-k8s --namespace default get jenkins -o yaml +kubectl --context remote-k8s --namespace default get po +``` + +## Testing + +Run unit tests: + +```bash +make test +``` + +### Running E2E tests on Linux + +Run e2e tests with minikube: + +```bash +make minikube-start +eval $(minikube docker-env) +make build e2e config=config.minikube.env CR=podman +``` + +`config.minikube.env` is the E2E test profile which provides all connection info to operator to run on minikube. + +Run the specific e2e test: + +```bash +make build e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.minikube.env CR=podman +``` + +If you want to run E2E tests on CRC (Code Ready Containers by OpenShift), you should use `config.crc.env` profile instead of `config.minikube.env`. + +### Running E2E tests on macOS + +At first, you need to start minikube: +```bash +$ make minikube-start +$ eval $(minikube docker-env) +``` + +Build a Docker image inside the provided Linux container by: +```bash +$ make indocker +``` + +Build **Jenkins Operator** inside a container using: + + +```bash +$ make build +``` + +Then exit the container and run: +``` +make e2e CONFIG=config.minikube.env +``` + +or with CRC: +``` +make e2e CONFIG=config.crc.env +``` + +### Use Docker image instead of podman (Code Ready Containers) + +If you have trouble to build image with `podman`, you can set additional flag `USE_ORGANIZATION` to pull image from organization. + +At first, edit you `config.base.env` and change `DOCKER_ORGANIZATION` to your account/organization name from [hub](https://hub.docker.com/). +Next, you need to pull image to your repository: + +```bash +$ make cr-build cr-snapshot-push +``` + +When image will be uploaded to repository, you can now write this command to run E2E tests: + +```bash +$ make e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.crc.env USE_ORGANIZATION=true +``` + +## Tips & Tricks + +### Building docker image on minikube (for e2e tests) + +To be able to work with the docker daemon on `minikube` machine run the following command before building an image: + +```bash +eval $(minikube docker-env) +``` + +### When `pkg/apis/jenkinsio/*/jenkins_types.go` has changed + +Run: + +```bash +make deepcopy-gen +``` + +### Getting the Jenkins URL and basic credentials + +```bash +minikube service jenkins-operator-http- --url +kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.user}' | base64 -d +kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.password}' | base64 -d +``` + +# Tools + +## Configure environment variables + +```bash +export GOPATH=/home/go # example value +export GOROOT=/usr/lib/go-1.12 # example value +export PATH=$GOPATH/bin:$PATH +``` + +## goimports + +``` +go get golang.org/x/tools/cmd/goimports +cd $GOPATH/src/golang.org/x/tools/cmd/goimports +go build +go install +``` + +## golint + +``` +go get -u golang.org/x/lint/golint +cd $GOPATH/src/golang.org/x/lint/golint +go build +go install +``` + +## checkmake +``` +go get github.com/mrtazz/checkmake +cd $GOPATH/src/github.com/mrtazz/checkmake +go build +go install +``` + +## staticcheck + +``` +mkdir -p $GOPATH/src/github.com/dominikh/ +cd $GOPATH/src/github.com/dominikh/ +git clone https://github.com/dominikh/go-tools.git +cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck +go build +go install +``` + + +[dep_tool]:https://golang.github.io/dep/docs/installation.html +[git_tool]:https://git-scm.com/downloads +[go_tool]:https://golang.org/dl/ +[operator_sdk]:https://github.com/operator-framework/operator-sdk +[fork_guide]:https://help.github.com/articles/fork-a-repo/ +[docker_tool]:https://docs.docker.com/install/ +[kubectl_tool]:https://kubernetes.io/docs/tasks/tools/install-kubectl/ +[minikube]:https://kubernetes.io/docs/tasks/tools/install-minikube/ +[virtualbox]:https://www.virtualbox.org/wiki/Downloads +[jenkins-operator]:../README.md +[install_dev_tools]:install_dev_tools.md diff --git a/website/content/en/docs/Getting Started/future/diagnostics.md b/website/content/en/docs/Getting Started/future/diagnostics.md new file mode 100644 index 00000000..87286adb --- /dev/null +++ b/website/content/en/docs/Getting Started/future/diagnostics.md @@ -0,0 +1,42 @@ +--- +title: "Diagnostics" +linkTitle: "Diagnostics" +weight: 40 +date: 2019-08-05 +description: > + How to deal with Jenkins Operator problems +--- + + +Turn on debug in **Jenkins Operator** deployment: + +```bash +sed -i 's|\(args:\).*|\1\ ["--debug"\]|' deploy/operator.yaml +kubectl apply -f deploy/operator.yaml +``` + +Watch Kubernetes events: + +```bash +kubectl get events --sort-by='{.lastTimestamp}' +``` + +Verify Jenkins master logs: + +```bash +kubectl logs -f jenkins- +``` + +Verify the `jenkins-operator` logs: + +```bash +kubectl logs deployment/jenkins-operator +``` + +## Troubleshooting + +Delete the Jenkins master pod and wait for the new one to come up: + +```bash +kubectl delete pod jenkins- +``` diff --git a/website/content/en/docs/Getting Started/future/schema.md b/website/content/en/docs/Getting Started/future/schema.md new file mode 100644 index 00000000..008414be --- /dev/null +++ b/website/content/en/docs/Getting Started/future/schema.md @@ -0,0 +1,1979 @@ +--- +title: "Schema" +linkTitle: "Schema" +weight: 40 +date: 2019-08-05 +description: > + API Schema definitions for Jenkins CRD +--- + +{{% pageinfo %}} +This document contains API scheme for `jenkins-operator` Custom Resource Definition manifest +{{% /pageinfo %}} + +

Packages:

+ +

jenkins.io

+

+

Package v1alpha2 contains the API Schema definitions for the jenkins.io v1alpha2 API group

+

+Resource Types: + +

Jenkins +

+

+

Jenkins is the Schema for the jenkins API

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+apiVersion
+string
+ +jenkins.io/v1alpha2 + +
+kind
+string +
Jenkins
+metadata
+ + +Kubernetes meta/v1.ObjectMeta + + +
+Refer to the Kubernetes API documentation for the fields of the +metadata field. +
+spec
+ + +JenkinsSpec + + +
+

Spec defines the desired state of the Jenkins

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+master
+ + +JenkinsMaster + + +
+

Master represents Jenkins master pod properties and Jenkins plugins. +Every single change here requires a pod restart.

+
+seedJobs
+ + +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob + + +
+(Optional) +

SeedJobs defines a list of Jenkins Seed Job configurations +More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines

+
+service
+ + +Service + + +
+(Optional) +

Service is the Kubernetes service of the Jenkins master HTTP pod +Defaults to : +port: 8080 +type: ClusterIP

+
+slaveService
+ + +Service + + +
+(Optional) +

Service is the Kubernetes service of the Jenkins slave pods +Defaults to : +port: 50000 +type: ClusterIP

+
+backup
+ + +Backup + + +
+(Optional) +

Backup defines the configuration of a Jenkins backup +More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

+
+restore
+ + +Restore + + +
+(Optional) +

Backup defines the configuration of a Jenkins backup restore +More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

+
+groovyScripts
+ + +GroovyScripts + + +
+(Optional) +

GroovyScripts defines the configuration of Jenkins customization via groovy scripts

+
+configurationAsCode
+ + +ConfigurationAsCode + + +
+(Optional) +

ConfigurationAsCode defines the configuration of Jenkins customization via the Configuration as Code Jenkins plugin

+
+
+status
+ + +JenkinsStatus + + +
+

Status defines the observed state of Jenkins

+
+

AppliedGroovyScript +

+

+(Appears on: +JenkinsStatus) +

+

+

AppliedGroovyScript is the applied groovy script in Jenkins by the operator

+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+configurationType
+ +string + +
+

ConfigurationType is the name of the configuration type(base-groovy, user-groovy, user-casc)

+
+source
+ +string + +
+

Source is the name of source where is located groovy script

+
+name
+ +string + +
+

Name is the name of the groovy script

+
+Hash
+ +string + +
+

Hash is the hash of the groovy script and secrets which it uses

+
+

Backup +

+

+(Appears on: +JenkinsSpec) +

+

+

Backup defines the configuration of a Jenkins backup

+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+containerName
+ +string + +
+

ContainerName is the container name responsible for backup operation

+
+action
+ + +Handler + + +
+

Action defines the action which performs the backup in the backup container sidecar

+
+interval
+ +uint64 + +
+

Interval tells you how often the backup is made in seconds +Defaults to 30.

+
+makeBackupBeforePodDeletion
+ +bool + +
+

MakeBackupBeforePodDeletion tells the operator to make a backup before Jenkins master pod deletion

+
+

ConfigMapRef +

+

+(Appears on: +Customization) +

+

+

ConfigMapRef is the reference to Kubernetes ConfigMap

+

+ + + + + + + + + + + + + +
FieldDescription
+name
+ +string + +
+
+

ConfigurationAsCode +

+

+(Appears on: +JenkinsSpec) +

+

+

ConfigurationAsCode defines configuration of Jenkins customization via the Configuration as Code Jenkins plugin

+

+ + + + + + + + + + + + + +
FieldDescription
+Customization
+ + +Customization + + +
+
+

Container +

+

+(Appears on: +JenkinsMaster) +

+

+

Container defines the Kubernetes container attributes

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+name
+ +string + +
+

Name of the container specified as a DNS_LABEL. +Each container in a pod must have a unique name (DNS_LABEL).

+
+image
+ +string + +
+

Docker image name. +More info: https://kubernetes.io/docs/concepts/containers/images

+
+imagePullPolicy
+ + +Kubernetes core/v1.PullPolicy + + +
+

Image pull policy. +One of Always, Never, IfNotPresent. +Defaults to Always.

+
+resources
+ + +Kubernetes core/v1.ResourceRequirements + + +
+

Compute Resources required by this container. +More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/

+
+command
+ +[]string + +
+(Optional) +

Entrypoint array. Not executed within a shell. +The docker image’s ENTRYPOINT is used if this is not provided. +Variable references $(VAR_NAME) are expanded using the container’s environment. If a variable +cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax +can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, +regardless of whether the variable exists or not. +More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell

+
+args
+ +[]string + +
+(Optional) +

Arguments to the entrypoint. +The docker image’s CMD is used if this is not provided. +Variable references $(VAR_NAME) are expanded using the container’s environment. If a variable +cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax +can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, +regardless of whether the variable exists or not. +More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell

+
+workingDir
+ +string + +
+(Optional) +

Container’s working directory. +If not specified, the container runtime’s default will be used, which +might be configured in the container image.

+
+ports
+ + +[]Kubernetes core/v1.ContainerPort + + +
+(Optional) +

List of ports to expose from the container. Exposing a port here gives +the system additional information about the network connections a +container uses, but is primarily informational. Not specifying a port here +DOES NOT prevent that port from being exposed. Any port which is +listening on the default “0.0.0.0” address inside a container will be +accessible from the network.

+
+envFrom
+ + +[]Kubernetes core/v1.EnvFromSource + + +
+(Optional) +

List of sources to populate environment variables in the container. +The keys defined within a source must be a C_IDENTIFIER. All invalid keys +will be reported as an event when the container is starting. When a key exists in multiple +sources, the value associated with the last source will take precedence. +Values defined by an Env with a duplicate key will take precedence.

+
+env
+ + +[]Kubernetes core/v1.EnvVar + + +
+(Optional) +

List of environment variables to set in the container.

+
+volumeMounts
+ + +[]Kubernetes core/v1.VolumeMount + + +
+(Optional) +

Pod volumes to mount into the container’s filesystem.

+
+livenessProbe
+ + +Kubernetes core/v1.Probe + + +
+(Optional) +

Periodic probe of container liveness. +Container will be restarted if the probe fails.

+
+readinessProbe
+ + +Kubernetes core/v1.Probe + + +
+(Optional) +

Periodic probe of container service readiness. +Container will be removed from service endpoints if the probe fails.

+
+lifecycle
+ + +Kubernetes core/v1.Lifecycle + + +
+(Optional) +

Actions that the management system should take in response to container lifecycle events.

+
+securityContext
+ + +Kubernetes core/v1.SecurityContext + + +
+(Optional) +

Security options the pod should run with. +More info: https://kubernetes.io/docs/concepts/policy/security-context/ +More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/

+
+

Customization +

+

+(Appears on: +ConfigurationAsCode, +GroovyScripts) +

+

+

Customization defines configuration of Jenkins customization

+

+ + + + + + + + + + + + + + + + + +
FieldDescription
+secret
+ + +SecretRef + + +
+
+configurations
+ + +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigMapRef + + +
+
+

GroovyScripts +

+

+(Appears on: +JenkinsSpec) +

+

+

GroovyScripts defines configuration of Jenkins customization via groovy scripts

+

+ + + + + + + + + + + + + +
FieldDescription
+Customization
+ + +Customization + + +
+
+

Handler +

+

+(Appears on: +Backup, +Restore) +

+

+

Handler defines a specific action that should be taken

+

+ + + + + + + + + + + + + +
FieldDescription
+exec
+ + +Kubernetes core/v1.ExecAction + + +
+

Exec specifies the action to take.

+
+

JenkinsCredentialType +(string alias)

+

+(Appears on: +SeedJob) +

+

+

JenkinsCredentialType defines the type of Jenkins credential used in the seed job mechanism

+

+

JenkinsMaster +

+

+(Appears on: +JenkinsSpec) +

+

+

JenkinsMaster defines the Jenkins master pod attributes and plugins, +every single change requires a Jenkins master pod restart

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+masterAnnotations
+ +map[string]string + +
+(Optional) +

Annotations is an unstructured key value map stored with a resource that may be +set by external tools to store and retrieve arbitrary metadata. They are not +queryable and should be preserved when modifying objects. +More info: http://kubernetes.io/docs/user-guide/annotations

+
+nodeSelector
+ +map[string]string + +
+(Optional) +

NodeSelector is a selector which must be true for the pod to fit on a node. +Selector which must match a node’s labels for the pod to be scheduled on that node. +More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/

+
+securityContext
+ + +Kubernetes core/v1.PodSecurityContext + + +
+(Optional) +

SecurityContext that applies to all the containers of the Jenkins +Master. As per kubernetes specification, it can be overridden +for each container individually. +Defaults to: +runAsUser: 1000 +fsGroup: 1000

+
+containers
+ + +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Container + + +
+

List of containers belonging to the pod. +Containers cannot currently be added or removed. +There must be at least one container in a Pod. +Defaults to: +- image: jenkins/jenkins:lts +imagePullPolicy: Always +livenessProbe: +failureThreshold: 12 +httpGet: +path: /login +port: http +scheme: HTTP +initialDelaySeconds: 80 +periodSeconds: 10 +successThreshold: 1 +timeoutSeconds: 5 +name: jenkins-master +readinessProbe: +failureThreshold: 3 +httpGet: +path: /login +port: http +scheme: HTTP +initialDelaySeconds: 30 +periodSeconds: 10 +successThreshold: 1 +timeoutSeconds: 1 +resources: +limits: +cpu: 1500m +memory: 3Gi +requests: +cpu: “1” +memory: 600Mi

+
+imagePullSecrets
+ + +[]Kubernetes core/v1.LocalObjectReference + + +
+(Optional) +

ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. +If specified, these secrets will be passed to individual puller implementations for them to use. For example, +in the case of docker, only DockerConfig type secrets are honored. +More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod

+
+volumes
+ + +[]Kubernetes core/v1.Volume + + +
+(Optional) +

List of volumes that can be mounted by containers belonging to the pod. +More info: https://kubernetes.io/docs/concepts/storage/volumes

+
+basePlugins
+ + +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin + + +
+

BasePlugins contains plugins required by operator +Defaults to : +- name: kubernetes +version: 1.15.7 +- name: workflow-job +version: “2.32” +- name: workflow-aggregator +version: “2.6” +- name: git +version: 3.10.0 +- name: job-dsl +version: “1.74” +- name: configuration-as-code +version: “1.19” +- name: configuration-as-code-support +version: “1.19” +- name: kubernetes-credentials-provider +version: 0.12.1

+
+plugins
+ + +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin + + +
+(Optional) +

Plugins contains plugins required by user

+
+

JenkinsSpec +

+

+(Appears on: +Jenkins) +

+

+

JenkinsSpec defines the desired state of the Jenkins

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+master
+ + +JenkinsMaster + + +
+

Master represents Jenkins master pod properties and Jenkins plugins. +Every single change here requires a pod restart.

+
+seedJobs
+ + +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob + + +
+(Optional) +

SeedJobs defines list of Jenkins Seed Job configurations +More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines

+
+service
+ + +Service + + +
+(Optional) +

Service is Kubernetes service of Jenkins master HTTP pod +Defaults to : +port: 8080 +type: ClusterIP

+
+slaveService
+ + +Service + + +
+(Optional) +

Service is Kubernetes service of Jenkins slave pods +Defaults to : +port: 50000 +type: ClusterIP

+
+backup
+ + +Backup + + +
+(Optional) +

Backup defines configuration of Jenkins backup +More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

+
+restore
+ + +Restore + + +
+(Optional) +

Backup defines configuration of Jenkins backup restore +More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

+
+groovyScripts
+ + +GroovyScripts + + +
+(Optional) +

GroovyScripts defines configuration of Jenkins customization via groovy scripts

+
+configurationAsCode
+ + +ConfigurationAsCode + + +
+(Optional) +

ConfigurationAsCode defines configuration of Jenkins customization via Configuration as Code Jenkins plugin

+
+

JenkinsStatus +

+

+(Appears on: +Jenkins) +

+

+

JenkinsStatus defines the observed state of Jenkins

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+operatorVersion
+ +string + +
+(Optional) +

OperatorVersion is the operator version which manages this CR

+
+provisionStartTime
+ + +Kubernetes meta/v1.Time + + +
+(Optional) +

ProvisionStartTime is a time when Jenkins master pod has been created

+
+baseConfigurationCompletedTime
+ + +Kubernetes meta/v1.Time + + +
+(Optional) +

BaseConfigurationCompletedTime is a time when Jenkins base configuration phase has been completed

+
+userConfigurationCompletedTime
+ + +Kubernetes meta/v1.Time + + +
+(Optional) +

UserConfigurationCompletedTime is a time when Jenkins user configuration phase has been completed

+
+restoredBackup
+ +uint64 + +
+(Optional) +

RestoredBackup is the restored backup number after Jenkins master pod restart

+
+lastBackup
+ +uint64 + +
+(Optional) +

LastBackup is the latest backup number

+
+pendingBackup
+ +uint64 + +
+(Optional) +

PendingBackup is the pending backup number

+
+backupDoneBeforePodDeletion
+ +bool + +
+(Optional) +

BackupDoneBeforePodDeletion tells if backup before pod deletion has been made

+
+userAndPasswordHash
+ +string + +
+(Optional) +

UserAndPasswordHash is a SHA256 hash made from the username and password

+
+createdSeedJobs
+ +[]string + +
+(Optional) +

CreatedSeedJobs contains list of seed job ids already created in Jenkins

+
+appliedGroovyScripts
+ + +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.AppliedGroovyScript + + +
+(Optional) +

AppliedGroovyScripts is a list with all applied groovy scripts in Jenkins by the operator

+
+

Mailgun +

+

+(Appears on: +Notification) +

+

+

Mailgun is handler for Mailgun email service notification channel

+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+domain
+ +string + +
+
+apiKeySecretKeySelector
+ + +SecretKeySelector + + +
+
+recipient
+ +string + +
+
+from
+ +string + +
+
+

MicrosoftTeams +

+

+(Appears on: +Notification) +

+

+

MicrosoftTeams is handler for Microsoft MicrosoftTeams notification channel

+

+ + + + + + + + + + + + + +
FieldDescription
+webHookURLSecretKeySelector
+ + +SecretKeySelector + + +
+

The web hook URL to MicrosoftTeams App

+
+

Notification +

+

+

Notification is a service configuration used to send notifications about Jenkins status

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+loggingLevel
+ + +NotificationLogLevel + + +
+
+verbose
+ +bool + +
+
+name
+ +string + +
+
+slack
+ + +github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Slack + + +
+
+teams
+ + +github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.MicrosoftTeams + + +
+
+mailgun
+ + +github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Mailgun + + +
+
+

NotificationLogLevel +(string alias)

+

+(Appears on: +Notification) +

+

+

NotificationLogLevel defines logging level of Notification

+

+

Plugin +

+

+(Appears on: +JenkinsMaster) +

+

+

Plugin defines Jenkins plugin

+

+ + + + + + + + + + + + + + + + + +
FieldDescription
+name
+ +string + +
+

Name is the name of Jenkins plugin

+
+version
+ +string + +
+

Version is the version of Jenkins plugin

+
+

Restore +

+

+(Appears on: +JenkinsSpec) +

+

+

Restore defines configuration of Jenkins backup restore operation

+

+ + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+containerName
+ +string + +
+

ContainerName is the container name responsible for restore backup operation

+
+action
+ + +Handler + + +
+

Action defines action which performs restore backup in restore container sidecar

+
+recoveryOnce
+ +uint64 + +
+(Optional) +

RecoveryOnce if want to restore specific backup set this field and then Jenkins will be restarted and desired backup will be restored

+
+

SecretKeySelector +

+

+(Appears on: +Mailgun, +MicrosoftTeams, +Slack) +

+

+

SecretKeySelector selects a key of a Secret.

+

+ + + + + + + + + + + + + + + + + +
FieldDescription
+secret
+ + +Kubernetes core/v1.LocalObjectReference + + +
+

The name of the secret in the pod’s namespace to select from.

+
+key
+ +string + +
+

The key of the secret to select from. Must be a valid secret key.

+
+

SecretRef +

+

+(Appears on: +Customization) +

+

+

SecretRef is reference to Kubernetes secret

+

+ + + + + + + + + + + + + +
FieldDescription
+name
+ +string + +
+
+

SeedJob +

+

+(Appears on: +JenkinsSpec) +

+

+

SeedJob defines configuration for seed job +More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+id
+ +string + +
+

ID is the unique seed job name

+
+credentialID
+ +string + +
+

CredentialID is the Kubernetes secret name which stores repository access credentials

+
+description
+ +string + +
+(Optional) +

Description is the description of the seed job

+
+targets
+ +string + +
+

Targets is the repository path where the seed job definitions are

+
+repositoryBranch
+ +string + +
+

RepositoryBranch is the repository branch where the seed job definitions are

+
+repositoryUrl
+ +string + +
+

RepositoryURL is the repository access URL. Can be SSH or HTTPS.

+
+credentialType
+ + +JenkinsCredentialType + + +
+(Optional) +

JenkinsCredentialType is the https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/ credential type

+
+githubPushTrigger
+ +bool + +
+(Optional) +

GitHubPushTrigger is used for GitHub web hooks

+
+buildPeriodically
+ +string + +
+(Optional) +

BuildPeriodically is setting for scheduled trigger

+
+pollSCM
+ +string + +
+(Optional) +

PollSCM is setting for polling changes in SCM

+
+ignoreMissingFiles
+ +bool + +
+(Optional) +

IgnoreMissingFiles is setting for Job DSL API plugin to ignore files that miss

+
+additionalClasspath
+ +string + +
+(Optional) +

AdditionalClasspath is setting for Job DSL API plugin to set Additional Classpath

+
+failOnMissingPlugin
+ +bool + +
+(Optional) +

FailOnMissingPlugin is setting for Job DSL API plugin that fails job if required plugin is missing

+
+unstableOnDeprecation
+ +bool + +
+(Optional) +

UnstableOnDeprecation is setting for Job DSL API plugin that sets build status as unstable if build using deprecated features

+
+

Service +

+

+(Appears on: +JenkinsSpec) +

+

+

Service defines Kubernetes service attributes

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+annotations
+ +map[string]string + +
+(Optional) +

Annotations is an unstructured key value map stored with a resource that may be +set by external tools to store and retrieve arbitrary metadata. They are not +queryable and should be preserved when modifying objects. +More info: http://kubernetes.io/docs/user-guide/annotations

+
+labels
+ +map[string]string + +
+

Route service traffic to pods with label keys and values matching this +selector. If empty or not present, the service is assumed to have an +external process managing its endpoints, which Kubernetes will not +modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. +Ignored if type is ExternalName. +More info: https://kubernetes.io/docs/concepts/services-networking/service/

+
+type
+ + +Kubernetes core/v1.ServiceType + + +
+(Optional) +

Type determines how the Service is exposed. Defaults to ClusterIP. Valid +options are ExternalName, ClusterIP, NodePort, and LoadBalancer. +“ExternalName” maps to the specified externalName. +“ClusterIP” allocates a cluster-internal IP address for load-balancing to +endpoints. Endpoints are determined by the selector or if that is not +specified, by manual construction of an Endpoints object. If clusterIP is +“None”, no virtual IP is allocated and the endpoints are published as a +set of endpoints rather than a stable IP. +“NodePort” builds on ClusterIP and allocates a port on every node which +routes to the clusterIP. +“LoadBalancer” builds on NodePort and creates an +external load-balancer (if supported in the current cloud) which routes +to the clusterIP. +More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services—service-types

+
+port
+ +int32 + +
+

The port that is exposed by this service. +More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies

+
+nodePort
+ +int32 + +
+(Optional) +

The port on each node on which this service is exposed when type=NodePort or LoadBalancer. +Usually assigned by the system. If specified, it will be allocated to the service +if unused, or else creation of the service will fail. +Default is to auto-allocate a port if the ServiceType of this Service requires one. +More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport

+
+loadBalancerSourceRanges
+ +[]string + +
+(Optional) +

If specified and supported by the platform, this will restrict traffic through the cloud-provider +the load-balancer will be restricted to the specified client IPs. This field will be ignored if the +cloud-provider does not support the feature.” +More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/

+
+loadBalancerIP
+ +string + +
+(Optional) +

Only applies to Service Type: LoadBalancer +LoadBalancer will get created with the IP specified in this field. +This feature depends on whether the underlying cloud-provider supports specifying +the loadBalancerIP when a load balancer is created. +This field will be ignored if the cloud-provider does not support the feature.

+
+

Slack +

+

+(Appears on: +Notification) +

+

+

Slack is handler for Slack notification channel

+

+ + + + + + + + + + + + + +
FieldDescription
+webHookURLSecretKeySelector
+ + +SecretKeySelector + + +
+

The web hook URL to Slack App

+
+
+

+Generated with gen-crd-api-reference-docs +on git commit f4c4235. +

diff --git a/website/content/en/docs/Developer Guide/_index.md b/website/content/en/docs/Getting Started/latest/developer-guide.md similarity index 82% rename from website/content/en/docs/Developer Guide/_index.md rename to website/content/en/docs/Getting Started/latest/developer-guide.md index 8b831b97..056f54ac 100644 --- a/website/content/en/docs/Developer Guide/_index.md +++ b/website/content/en/docs/Getting Started/latest/developer-guide.md @@ -137,6 +137,53 @@ kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.us kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.password}' | base64 -d ``` +# Tools + +## Configure environment variables + +```bash +export GOPATH=/home/go # example value +export GOROOT=/usr/lib/go-1.12 # example value +export PATH=$GOPATH/bin:$PATH +``` + +## goimports + +``` +go get golang.org/x/tools/cmd/goimports +cd $GOPATH/src/golang.org/x/tools/cmd/goimports +go build +go install +``` + +## golint + +``` +go get -u golang.org/x/lint/golint +cd $GOPATH/src/golang.org/x/lint/golint +go build +go install +``` + +## checkmake +``` +go get github.com/mrtazz/checkmake +cd $GOPATH/src/github.com/mrtazz/checkmake +go build +go install +``` + +## staticcheck + +``` +mkdir -p $GOPATH/src/github.com/dominikh/ +cd $GOPATH/src/github.com/dominikh/ +git clone https://github.com/dominikh/go-tools.git +cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck +go build +go install +``` + [dep_tool]:https://golang.github.io/dep/docs/installation.html [git_tool]:https://git-scm.com/downloads diff --git a/website/content/en/docs/Getting Started/v0.1.x/developer-guide.md b/website/content/en/docs/Getting Started/v0.1.x/developer-guide.md new file mode 100644 index 00000000..056f54ac --- /dev/null +++ b/website/content/en/docs/Getting Started/v0.1.x/developer-guide.md @@ -0,0 +1,198 @@ +--- +title: "Developer Guide" +linkTitle: "Developer Guide" +weight: 60 +date: 2019-08-05 +description: > + Jenkins Operator for developers +--- + +{{% pageinfo %}} +This document explains how to setup your development environment. +{{% /pageinfo %}} + +## Prerequisites + +- [operator_sdk][operator_sdk] version v0.8.1 +- [git][git_tool] +- [go][go_tool] version v1.12+ +- [goimports, golint, checkmake and staticcheck][install_dev_tools] +- [minikube][minikube] version v1.1.0+ (preferred Hypervisor - [virtualbox][virtualbox]) +- [docker][docker_tool] version 17.03+ + +## Clone repository and download dependencies + +```bash +mkdir -p $GOPATH/src/github.com/jenkinsci +cd $GOPATH/src/github.com/jenkinsci/ +git clone git@github.com:jenkinsci/kubernetes-operator.git +cd kubernetes-operator +make go-dependencies +``` + +## Build and run with a minikube + +Build and run **Jenkins Operator** locally: + +```bash +make build minikube-run EXTRA_ARGS='--minikube --local' +``` + +Once minikube and **Jenkins Operator** are up and running, apply Jenkins custom resource: + +```bash +kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl get jenkins -o yaml +kubectl get po +``` + +## Build and run with a remote Kubernetes cluster + +You can also run the controller locally and make it listen to a remote Kubernetes server. + +```bash +make run NAMESPACE=default KUBECTL_CONTEXT=remote-k8s EXTRA_ARGS='--kubeconfig ~/.kube/config' +``` + +Once minikube and **Jenkins Operator** are up and running, apply Jenkins custom resource: + +```bash +kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl --context remote-k8s --namespace default get jenkins -o yaml +kubectl --context remote-k8s --namespace default get po +``` + +## Testing + +Run unit tests: + +```bash +make test +``` + +### Running E2E tests on Linux + +Run e2e tests with minikube: + +```bash +make minikube-start +eval $(minikube docker-env) +make build e2e +``` + +Run the specific e2e test: + +```bash +make build e2e E2E_TEST_SELECTOR='^TestConfiguration$' +``` + +### Running E2E tests on macOS + +At first, you need to start minikube: +```bash +$ make minikube-start +$ eval $(minikube docker-env) +``` + +Build a Docker image inside the provided Linux container by: +```bash +$ make indocker +``` + +Build **Jenkins Operator** inside a container using: + + +```bash +$ make build +``` + +Then exit the container and run: +``` +make e2e +``` + +## Tips & Tricks + +### Building docker image on minikube (for e2e tests) + +To be able to work with the docker daemon on `minikube` machine run the following command before building an image: + +```bash +eval $(minikube docker-env) +``` + +### When `pkg/apis/jenkinsio/*/jenkins_types.go` has changed + +Run: + +```bash +make deepcopy-gen +``` + +### Getting the Jenkins URL and basic credentials + +```bash +minikube service jenkins-operator-http- --url +kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.user}' | base64 -d +kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.password}' | base64 -d +``` + +# Tools + +## Configure environment variables + +```bash +export GOPATH=/home/go # example value +export GOROOT=/usr/lib/go-1.12 # example value +export PATH=$GOPATH/bin:$PATH +``` + +## goimports + +``` +go get golang.org/x/tools/cmd/goimports +cd $GOPATH/src/golang.org/x/tools/cmd/goimports +go build +go install +``` + +## golint + +``` +go get -u golang.org/x/lint/golint +cd $GOPATH/src/golang.org/x/lint/golint +go build +go install +``` + +## checkmake +``` +go get github.com/mrtazz/checkmake +cd $GOPATH/src/github.com/mrtazz/checkmake +go build +go install +``` + +## staticcheck + +``` +mkdir -p $GOPATH/src/github.com/dominikh/ +cd $GOPATH/src/github.com/dominikh/ +git clone https://github.com/dominikh/go-tools.git +cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck +go build +go install +``` + + +[dep_tool]:https://golang.github.io/dep/docs/installation.html +[git_tool]:https://git-scm.com/downloads +[go_tool]:https://golang.org/dl/ +[operator_sdk]:https://github.com/operator-framework/operator-sdk +[fork_guide]:https://help.github.com/articles/fork-a-repo/ +[docker_tool]:https://docs.docker.com/install/ +[kubectl_tool]:https://kubernetes.io/docs/tasks/tools/install-kubectl/ +[minikube]:https://kubernetes.io/docs/tasks/tools/install-minikube/ +[virtualbox]:https://www.virtualbox.org/wiki/Downloads +[jenkins-operator]:../README.md +[install_dev_tools]:install_dev_tools.md From 698401191cb88c31557932c27e0e9d2de5e9db0c Mon Sep 17 00:00:00 2001 From: Jakub Al-Khalili Date: Wed, 27 Nov 2019 13:10:28 +0100 Subject: [PATCH 06/12] Update CRC & IMAGE_PULL_MODE docs --- .../content/en/docs/Getting Started/future/developer-guide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/content/en/docs/Getting Started/future/developer-guide.md b/website/content/en/docs/Getting Started/future/developer-guide.md index 93435098..dcbbb926 100644 --- a/website/content/en/docs/Getting Started/future/developer-guide.md +++ b/website/content/en/docs/Getting Started/future/developer-guide.md @@ -122,7 +122,7 @@ make e2e CONFIG=config.crc.env ### Use Docker image instead of podman (Code Ready Containers) -If you have trouble to build image with `podman`, you can set additional flag `USE_ORGANIZATION` to pull image from organization. +If you have trouble to build image with `podman`, you can set additional flag `IMAGE_PULL_MODE` to pull image from organization. At first, edit you `config.base.env` and change `DOCKER_ORGANIZATION` to your account/organization name from [hub](https://hub.docker.com/). Next, you need to pull image to your repository: @@ -134,7 +134,7 @@ $ make cr-build cr-snapshot-push When image will be uploaded to repository, you can now write this command to run E2E tests: ```bash -$ make e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.crc.env USE_ORGANIZATION=true +$ make e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.crc.env IMAGE_PULL_MODE=remote ``` ## Tips & Tricks From 15401ddc54857223b9255dae674384f4ca2777ef Mon Sep 17 00:00:00 2001 From: Jakub Al-Khalili Date: Thu, 28 Nov 2019 10:04:03 +0100 Subject: [PATCH 07/12] Update docs - change CR to CONTAINER_RUNTIME, IMAGE_PULL_MODE in .env notice --- .../content/en/docs/Getting Started/future/developer-guide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/content/en/docs/Getting Started/future/developer-guide.md b/website/content/en/docs/Getting Started/future/developer-guide.md index dcbbb926..65f20919 100644 --- a/website/content/en/docs/Getting Started/future/developer-guide.md +++ b/website/content/en/docs/Getting Started/future/developer-guide.md @@ -77,7 +77,7 @@ Run e2e tests with minikube: ```bash make minikube-start eval $(minikube docker-env) -make build e2e config=config.minikube.env CR=podman +make build e2e config=config.minikube.env CONTAINER_RUNTIME=podman ``` `config.minikube.env` is the E2E test profile which provides all connection info to operator to run on minikube. @@ -85,7 +85,7 @@ make build e2e config=config.minikube.env CR=podman Run the specific e2e test: ```bash -make build e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.minikube.env CR=podman +make build e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.minikube.env CONTAINER_RUNTIME=podman ``` If you want to run E2E tests on CRC (Code Ready Containers by OpenShift), you should use `config.crc.env` profile instead of `config.minikube.env`. From ef38cb7da13cf13562bd0493bc05c357acb6942b Mon Sep 17 00:00:00 2001 From: Jakub Al-Khalili Date: Fri, 29 Nov 2019 09:27:08 +0100 Subject: [PATCH 08/12] Update docs --- .../Getting Started/future/developer-guide.md | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/website/content/en/docs/Getting Started/future/developer-guide.md b/website/content/en/docs/Getting Started/future/developer-guide.md index 65f20919..9d5c402c 100644 --- a/website/content/en/docs/Getting Started/future/developer-guide.md +++ b/website/content/en/docs/Getting Started/future/developer-guide.md @@ -35,7 +35,7 @@ make go-dependencies Build and run **Jenkins Operator** locally: ```bash -make build minikube-run EXTRA_ARGS='--jenkins-api-hostname=$(eval minikube ip) --jenkins-api-use-nodeport=true' +make build minikube-run OPERATOR_EXTRA_ARGS='--jenkins-api-hostname=$(eval minikube ip) --jenkins-api-use-nodeport=true' ``` Once minikube and **Jenkins Operator** are up and running, apply Jenkins custom resource: @@ -51,7 +51,7 @@ kubectl get po You can also run the controller locally and make it listen to a remote Kubernetes server. ```bash -make run NAMESPACE=default KUBECTL_CONTEXT=remote-k8s EXTRA_ARGS='--kubeconfig ~/.kube/config' +make run NAMESPACE=default KUBECTL_CONTEXT=remote-k8s OPERATOR_EXTRA_ARGS='--kubeconfig ~/.kube/config' ``` Once minikube and **Jenkins Operator** are up and running, apply Jenkins custom resource: @@ -89,6 +89,8 @@ make build e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.minikube.en ``` If you want to run E2E tests on CRC (Code Ready Containers by OpenShift), you should use `config.crc.env` profile instead of `config.minikube.env`. +If you have some trouble with `podman` (for example building) then check [how to use docker instead of podman](#using-docker-instead-of-podman). + ### Running E2E tests on macOS @@ -112,29 +114,30 @@ $ make build Then exit the container and run: ``` -make e2e CONFIG=config.minikube.env +make e2e config=config.minikube.env ``` -or with CRC: +or using `crc` as cluster software: ``` -make e2e CONFIG=config.crc.env +make e2e config=config.crc.env ``` -### Use Docker image instead of podman (Code Ready Containers) +### Using Docker instead of podman -If you have trouble to build image with `podman`, you can set additional flag `IMAGE_PULL_MODE` to pull image from organization. +If you have trouble with building image using the `podman`, you can set additional flag `IMAGE_PULL_MODE` to pull image from the organization. -At first, edit you `config.base.env` and change `DOCKER_ORGANIZATION` to your account/organization name from [hub](https://hub.docker.com/). -Next, you need to pull image to your repository: +At first, you need to edit `config.base.env` and change the `DOCKER_ORGANIZATION` to your [Docker Hub](https://hub.docker.com/) account/organization. +After this change the `IMAGE_PULL_MODE` to `remote`. It will setup the `Makefile` goal to pull Docker image from registry. +Then you need to pull image from your repository: ```bash -$ make cr-build cr-snapshot-push +$ make container-runtime-build container-runtime-snapshot-push ``` When image will be uploaded to repository, you can now write this command to run E2E tests: ```bash -$ make e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.crc.env IMAGE_PULL_MODE=remote +$ make e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.crc.env ``` ## Tips & Tricks From 7ded21993bce7a9510942dac3b50a7e85f6ad7eb Mon Sep 17 00:00:00 2001 From: Jakub Al-Khalili Date: Fri, 29 Nov 2019 15:08:29 +0100 Subject: [PATCH 09/12] Regenerate docs --- docs/docs/developer-guide/index.xml | 83 - .../getting-started/future/aks/index.html | 606 +++ .../future/configuration/index.html | 911 +++++ .../configure-backup-and-restore/index.html | 682 ++++ .../custom-backup-and-restore/index.html | 778 ++++ .../future/customization/index.html | 763 ++++ .../future/deploy-jenkins/index.html | 653 ++++ .../future/developer-guide/index.html | 771 ++++ .../future/diagnostics}/index.html | 232 +- docs/docs/getting-started/future/index.html | 752 ++++ docs/docs/getting-started/future/index.xml | 3020 +++++++++++++++ .../getting-started/future/schema/index.html | 2569 +++++++++++++ docs/docs/getting-started/index.html | 146 +- .../getting-started/latest/aks/index.html | 118 +- .../latest/configuration/index.html | 118 +- .../configure-backup-and-restore/index.html | 118 +- .../custom-backup-and-restore/index.html | 118 +- .../latest/customization/index.html | 118 +- .../latest/deploy-jenkins/index.html | 118 +- .../latest/developer-guide/index.html | 750 ++++ .../latest/diagnostics/index.html | 118 +- docs/docs/getting-started/latest/index.html | 146 +- docs/docs/getting-started/latest/index.xml | 135 + .../latest/migration/index.html | 118 +- .../getting-started/latest/schema/index.html | 118 +- .../getting-started/v0.1.x/aks/index.html | 118 +- .../v0.1.x/configuration/index.html | 118 +- .../configure-backup-and-restore/index.html | 118 +- .../v0.1.x/customization/index.html | 118 +- .../v0.1.x/deploy-jenkins/index.html | 118 +- .../v0.1.x}/developer-guide/index.html | 290 +- .../v0.1.x/diagnostics/index.html | 118 +- docs/docs/getting-started/v0.1.x/index.html | 146 +- docs/docs/getting-started/v0.1.x/index.xml | 135 + .../index.html | 118 +- .../getting-started/v0.1.x/scheme/index.html | 118 +- .../architecture-and-design/index.html | 118 +- docs/docs/how-it-works/index.html | 138 +- .../jenkins-docker-images/index.html | 118 +- docs/docs/index.html | 144 +- docs/docs/index.xml | 3303 ++++++++++++++++- docs/docs/installation/index.html | 138 +- docs/docs/security/index.html | 138 +- docs/sitemap.xml | 54 +- 44 files changed, 18613 insertions(+), 1112 deletions(-) delete mode 100644 docs/docs/developer-guide/index.xml create mode 100644 docs/docs/getting-started/future/aks/index.html create mode 100644 docs/docs/getting-started/future/configuration/index.html create mode 100644 docs/docs/getting-started/future/configure-backup-and-restore/index.html create mode 100644 docs/docs/getting-started/future/custom-backup-and-restore/index.html create mode 100644 docs/docs/getting-started/future/customization/index.html create mode 100644 docs/docs/getting-started/future/deploy-jenkins/index.html create mode 100644 docs/docs/getting-started/future/developer-guide/index.html rename docs/docs/{developer-guide/tools => getting-started/future/diagnostics}/index.html (71%) create mode 100644 docs/docs/getting-started/future/index.html create mode 100644 docs/docs/getting-started/future/index.xml create mode 100644 docs/docs/getting-started/future/schema/index.html create mode 100644 docs/docs/getting-started/latest/developer-guide/index.html rename docs/docs/{ => getting-started/v0.1.x}/developer-guide/index.html (78%) diff --git a/docs/docs/developer-guide/index.xml b/docs/docs/developer-guide/index.xml deleted file mode 100644 index cabc8bcd..00000000 --- a/docs/docs/developer-guide/index.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - Jenkins Operator – Developer Guide - https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/ - Recent Hugo news from gohugo.io - Hugo -- gohugo.io - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/img/hugo.png - GoHugo.io - https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/ - - - - - - - - - - - - Docs: Tools - https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/tools/ - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/tools/ - - - - - - - -<div class="pageinfo pageinfo-primary"> -<p>This document explains how to install the Go tools used by the development process.</p> - -</div> - - -<h2 id="configure-environment-variables">Configure environment variables</h2> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">export</span> <span style="color:#000">GOPATH</span><span style="color:#ce5c00;font-weight:bold">=</span>/home/go <span style="color:#8f5902;font-style:italic"># example value</span> -<span style="color:#204a87">export</span> <span style="color:#000">GOROOT</span><span style="color:#ce5c00;font-weight:bold">=</span>/usr/lib/go-1.12 <span style="color:#8f5902;font-style:italic"># example value</span> -<span style="color:#204a87">export</span> <span style="color:#000">PATH</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#000">$GOPATH</span>/bin:<span style="color:#000">$PATH</span></code></pre></div> -<h2 id="goimports">goimports</h2> - -<pre><code>go get golang.org/x/tools/cmd/goimports -cd $GOPATH/src/golang.org/x/tools/cmd/goimports -go build -go install -</code></pre> - -<h2 id="golint">golint</h2> - -<pre><code>go get -u golang.org/x/lint/golint -cd $GOPATH/src/golang.org/x/lint/golint -go build -go install -</code></pre> - -<h2 id="checkmake">checkmake</h2> - -<pre><code>go get github.com/mrtazz/checkmake -cd $GOPATH/src/github.com/mrtazz/checkmake -go build -go install -</code></pre> - -<h2 id="staticcheck">staticcheck</h2> - -<pre><code>mkdir -p $GOPATH/src/github.com/dominikh/ -cd $GOPATH/src/github.com/dominikh/ -git clone https://github.com/dominikh/go-tools.git -cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck -go build -go install -</code></pre> - - - - - - \ No newline at end of file diff --git a/docs/docs/getting-started/future/aks/index.html b/docs/docs/getting-started/future/aks/index.html new file mode 100644 index 00000000..c69d4c7a --- /dev/null +++ b/docs/docs/getting-started/future/aks/index.html @@ -0,0 +1,606 @@ + + + + + + + + + + + + + + + + + + + + + + +AKS | Jenkins Operator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AKS | Jenkins Operator + + +
+ + + +
+
+
+
+
+ + + + + +
+ + + + +
+ + + + +
+
+ + + + + + + + + + + +
+
+ + + +
+

AKS

+
Additional configuration for Azure Kubernetes Service
+

Azure AKS managed Kubernetes service adds to every pod the following environment variables:

+
- name: KUBERNETES_PORT_443_TCP_ADDR
+  value:
+- name: KUBERNETES_PORT
+  value: tcp://
+- name: KUBERNETES_PORT_443_TCP
+  value: tcp://
+- name: KUBERNETES_SERVICE_HOST
+  value:
+

The operator is aware of it and omits these environment variables when checking if a Jenkins pod environment has been changed. It prevents the +restart of a Jenkins pod over and over again.

+ + + +
Last modified August 5, 2019 +
+
+ + +
+
+
+ + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/docs/getting-started/future/configuration/index.html b/docs/docs/getting-started/future/configuration/index.html new file mode 100644 index 00000000..f848febc --- /dev/null +++ b/docs/docs/getting-started/future/configuration/index.html @@ -0,0 +1,911 @@ + + + + + + + + + + + + + + + + + + + + + + +Configuration | Jenkins Operator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Configuration | Jenkins Operator + + +
+ + + +
+
+
+
+
+ + + + + +
+ + + + +
+ + + + +
+ +
+ + + +
+

Configuration

+
How to configure Jenkins with Operator
+ + +

Configure Seed Jobs and Pipelines

+ +

Jenkins operator uses job-dsl and kubernetes-credentials-provider plugins for configuring jobs +and deploy keys.

+ +

Prepare job definitions and pipelines

+ +

First you have to prepare pipelines and job definition in your GitHub repository using the following structure:

+ +
cicd/
+├── jobs
+│   └── build.jenkins
+└── pipelines
+    └── build.jenkins
+
+ +

cicd/jobs/build.jenkins is a job definition:

+ +
#!/usr/bin/env groovy
+
+pipelineJob('build-jenkins-operator') {
+    displayName('Build jenkins-operator')
+
+    definition {
+        cpsScm {
+            scm {
+                git {
+                    remote {
+                        url('https://github.com/jenkinsci/kubernetes-operator.git')
+                        credentials('jenkins-operator')
+                    }
+                    branches('*/master')
+                }
+            }
+            scriptPath('cicd/pipelines/build.jenkins')
+        }
+    }
+}
+
+ +

cicd/pipelines/build.jenkins is an actual Jenkins pipeline:

+ +
#!/usr/bin/env groovy
+
+def label = "build-jenkins-operator-${UUID.randomUUID().toString()}"
+def home = "/home/jenkins"
+def workspace = "${home}/workspace/build-jenkins-operator"
+def workdir = "${workspace}/src/github.com/jenkinsci/kubernetes-operator/"
+
+podTemplate(label: label,
+        containers: [
+                containerTemplate(name: 'jnlp', image: 'jenkins/jnlp-slave:alpine'),
+                containerTemplate(name: 'go', image: 'golang:1-alpine', command: 'cat', ttyEnabled: true),
+        ],
+        envVars: [
+                envVar(key: 'GOPATH', value: workspace),
+        ],
+        ) {
+
+    node(label) {
+        dir(workdir) {
+            stage('Init') {
+                timeout(time: 3, unit: 'MINUTES') {
+                    checkout scm
+                }
+                container('go') {
+                    sh 'apk --no-cache --update add make git gcc libc-dev'
+                }
+            }
+
+            stage('Dep') {
+                container('go') {
+                    sh 'make dep'
+                }
+            }
+
+            stage('Test') {
+                container('go') {
+                    sh 'make test'
+                }
+            }
+
+            stage('Build') {
+                container('go') {
+                    sh 'make build'
+                }
+            }
+        }
+    }
+}
+
+ +

Configure Seed Jobs

+ +

Jenkins Seed Jobs are configured using Jenkins.spec.seedJobs section from your custom resource manifest:

+ +
apiVersion: jenkins.io/v1alpha2
+kind: Jenkins
+metadata:
+  name: example
+spec:
+  seedJobs:
+  - id: jenkins-operator
+    targets: "cicd/jobs/*.jenkins"
+    description: "Jenkins Operator repository"
+    repositoryBranch: master
+    repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git
+
+ +

Jenkins Operator will automatically discover and configure all the seed jobs.

+ +

You can verify if deploy keys were successfully configured in the Jenkins Credentials tab.

+ +

jenkins

+ +

You can verify if your pipelines were successfully configured in the Jenkins Seed Job console output.

+ +

jenkins

+ +

If your GitHub repository is private you have to configure SSH or username/password authentication.

+ +

SSH authentication

+ +

Generate SSH Keys

+ +

There are two methods of SSH private key generation:

+
$ openssl genrsa -out <filename> 2048
+

or

+
$ ssh-keygen -t rsa -b 2048
+$ ssh-keygen -p -f <filename> -m pem
+

Then copy content from generated file.

+ +

Public key

+ +

If you want to upload your public key to your Git server you need to extract it.

+ +

If key was generated by openssl then you need to type this to extract public key:

+
$ openssl rsa -in <filename> -pubout > <filename>.pub
+

If key was generated by ssh-keygen the public key content is located in .pub and there is no need to extract public key

+ +

Configure SSH authentication

+ +

Configure a seed job like this:

+ +
apiVersion: jenkins.io/v1alpha2
+kind: Jenkins
+metadata:
+  name: example
+spec:
+  seedJobs:
+  - id: jenkins-operator-ssh
+    credentialType: basicSSHUserPrivateKey
+    credentialID: k8s-ssh
+    targets: "cicd/jobs/*.jenkins"
+    description: "Jenkins Operator repository"
+    repositoryBranch: master
+    repositoryUrl: git@github.com:jenkinsci/kubernetes-operator.git
+
+ +

and create a Kubernetes Secret (name of secret should be the same from credentialID field):

+ +
apiVersion: v1
+kind: Secret
+metadata:
+  name: k8s-ssh
+stringData:
+  privateKey: |
+    -----BEGIN RSA PRIVATE KEY-----
+    MIIJKAIBAAKCAgEAxxDpleJjMCN5nusfW/AtBAZhx8UVVlhhhIKXvQ+dFODQIdzO
+    oDXybs1zVHWOj31zqbbJnsfsVZ9Uf3p9k6xpJ3WFY9b85WasqTDN1xmSd6swD4N8
+    ...
+  username: github_user_name
+
+ +

Username & password authentication

+ +

Configure the seed job like:

+ +
apiVersion: jenkins.io/v1alpha2
+kind: Jenkins
+metadata:
+  name: example
+spec:
+  seedJobs:
+  - id: jenkins-operator-user-pass
+    credentialType: usernamePassword
+    credentialID: k8s-user-pass
+    targets: "cicd/jobs/*.jenkins"
+    description: "Jenkins Operator repository"
+    repositoryBranch: master
+    repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git
+
+ +

and create a Kubernetes Secret (name of secret should be the same from credentialID field):

+ +
apiVersion: v1
+kind: Secret
+metadata:
+  name: k8s-user-pass
+stringData:
+  username: github_user_name
+  password: password_or_token
+
+ +

HTTP Proxy for downloading plugins

+ +

To use forwarding proxy with an operator to download plugins you need to add the following environment variable to Jenkins Custom Resource (CR), e.g.:

+
spec:
+  master:
+    containers:
+      - name: jenkins-master
+        env:
+          - name: CURL_OPTIONS
+            value: -L -x <proxy_url>
+

In CURL_OPTIONS var you can set additional arguments to curl command.

+ +

Pulling Docker images from private repositories

+ +

To pull a Docker Image from private repository you can use imagePullSecrets.

+ +

Please follow the instructions on creating a secret with a docker config.

+ +

Docker Hub Configuration

+ +

To use Docker Hub additional steps are required.

+ +

Edit the previously created secret:

+
kubectl -n <namespace> edit secret <name>
+

The .dockerconfigjson key’s value needs to be replaced with a modified version.

+ +

After modifications, it needs to be encoded as a Base64 value before setting the .dockerconfigjson key.

+ +

Example config file to modify and use:

+ +
{
+    "auths":{
+        "https://index.docker.io/v1/":{
+            "username":"user",
+            "password":"password",
+            "email":"yourdockeremail@gmail.com",
+            "auth":"base64 of string user:password"
+        },
+        "auth.docker.io":{
+            "username":"user",
+            "password":"password",
+            "email":"yourdockeremail@gmail.com",
+            "auth":"base64 of string user:password"
+        },
+        "registry.docker.io":{
+            "username":"user",
+            "password":"password",
+            "email":"yourdockeremail@gmail.com",
+            "auth":"base64 of string user:password"
+        },
+        "docker.io":{
+            "username":"user",
+            "password":"password",
+            "email":"yourdockeremail@gmail.com",
+            "auth":"base64 of string user:password"
+        },
+        "https://registry-1.docker.io/v2/": {
+            "username":"user",
+            "password":"password",
+            "email":"yourdockeremail@gmail.com",
+            "auth":"base64 of string user:password"
+        },
+        "registry-1.docker.io/v2/": {
+            "username":"user",
+            "password":"password",
+            "email":"yourdockeremail@gmail.com",
+            "auth":"base64 of string user:password"
+        },
+        "registry-1.docker.io": {
+            "username":"user",
+            "password":"password",
+            "email":"yourdockeremail@gmail.com",
+            "auth":"base64 of string user:password"
+        },
+        "https://registry-1.docker.io": {
+            "username":"user",
+            "password":"password",
+            "email":"yourdockeremail@gmail.com",
+            "auth":"base64 of string user:password"
+        }
+    }
+}
+
+ + + +
Last modified August 5, 2019 +
+
+ + +
+
+
+ + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/docs/getting-started/future/configure-backup-and-restore/index.html b/docs/docs/getting-started/future/configure-backup-and-restore/index.html new file mode 100644 index 00000000..5dabd514 --- /dev/null +++ b/docs/docs/getting-started/future/configure-backup-and-restore/index.html @@ -0,0 +1,682 @@ + + + + + + + + + + + + + + + + + + + + + + +Configure backup and restore | Jenkins Operator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Configure backup and restore | Jenkins Operator + + +
+ + + +
+
+
+
+
+ + + + + +
+ + + + +
+ + + + +
+
+ + + + + + + + + + + + + + + +
+
+ + + +
+

Configure backup and restore

+
Prevent loss of job history
+ + +

Backup and restore is done by a container sidecar.

+ +

PVC

+ +

Create PVC

+ +

Save to the file named pvc.yaml:

+
apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: <pvc_name>
+  namespace: <namespace>
+spec:
+  accessModes:
+  - ReadWriteOnce
+  resources:
+    requests:
+      storage: 500Gi
+

Run the following command:

+
$ kubectl -n <namespace> create -f pvc.yaml
+

Configure Jenkins CR

+
apiVersion: jenkins.io/v1alpha2
+kind: Jenkins
+metadata:
+  name: <cr_name>
+  namespace: <namespace>
+spec:
+  master:
+    securityContext:
+      runAsUser: 1000
+      fsGroup: 1000
+    containers:
+    - name: jenkins-master
+      image: jenkins/jenkins:lts
+    - name: backup # container responsible for the backup and restore
+      env:
+      - name: BACKUP_DIR
+        value: /backup
+      - name: JENKINS_HOME
+        value: /jenkins-home
+      - name: BACKUP_COUNT
+        value: "3" # keep only the 2 most recent backups
+      image: virtuslab/jenkins-operator-backup-pvc:v0.0.7 # look at backup/pvc directory
+      imagePullPolicy: IfNotPresent
+      volumeMounts:
+      - mountPath: /jenkins-home # Jenkins home volume
+        name: jenkins-home
+      - mountPath: /backup # backup volume
+        name: backup
+    volumes:
+    - name: backup # PVC volume where backups will be stored
+      persistentVolumeClaim:
+        claimName: <pvc_name>
+  backup:
+    containerName: backup # container name is responsible for backup
+    action:
+      exec:
+        command:
+        - /home/user/bin/backup.sh # this command is invoked on "backup" container to make backup, for example /home/user/bin/backup.sh <backup_number>, <backup_number> is passed by operator
+    interval: 30 # how often make backup in seconds
+    makeBackupBeforePodDeletion: true # make a backup before pod deletion
+  restore:
+    containerName: backup # container name is responsible for restore backup
+    action:
+      exec:
+        command:
+        - /home/user/bin/restore.sh # this command is invoked on "backup" container to make restore backup, for example /home/user/bin/restore.sh <backup_number>, <backup_number> is passed by operator
+    #recoveryOnce: <backup_number> # if want to restore specific backup configure this field and then Jenkins will be restarted and desired backup will be restored
+ + +
Last modified August 5, 2019 +
+
+ + +
+
+
+ + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/docs/getting-started/future/custom-backup-and-restore/index.html b/docs/docs/getting-started/future/custom-backup-and-restore/index.html new file mode 100644 index 00000000..7791cafc --- /dev/null +++ b/docs/docs/getting-started/future/custom-backup-and-restore/index.html @@ -0,0 +1,778 @@ + + + + + + + + + + + + + + + + + + + + + + +Custom Backup and Restore Providers | Jenkins Operator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Custom Backup and Restore Providers | Jenkins Operator + + +
+ + + +
+
+
+
+
+ + + + + +
+ + + + +
+ + + + +
+ +
+ + + +
+

Custom Backup and Restore Providers

+
Custom backup and restore provider
+ + +

With enough effort one can create a custom backup and restore provider +for the Jenkins Operator.

+ +

Requirements

+ +

Two commands (e.g. scripts) are required:

+ +
    +
  • a backup command, e.g. backup.sh that takes one argument, a backup number
  • +
  • a restore command, e.g. backup.sh that takes one argument, a backup number
  • +
+ +

Both scripts need to return an exit code of 0 on success and 1 or greater for failure.

+ +

One of those scripts (or the entry point of the container) needs to be responsible +for backup cleanup or rotation if required, or an external system.

+ +

How it works

+ +

The mechanism relies on basic Kubernetes and UNIX functionalities.

+ +

The backup (and restore) container runs as a sidecar in the same +Kubernetes pod as the Jenkins master.

+ +

Name of the backup and restore containers can be set as necessary using +spec.backup.containerName and spec.restore.containerName. +In most cases it will be the same container, but we allow for less common use cases.

+ +

The operator will call a backup or restore commands inside a sidecar container when necessary:

+ +
    +
  • backup command (defined in spec.backup.action.exec.command) +will be called every N seconds configurable in: spec.backup.interval +and on pod shutdown (if enabled in spec.backup.makeBackupBeforePodDeletion) +with an integer representing the current backup number as first and only argument
  • +
  • restore command (defined in spec.restore.action.exec.command) +will be called at Jenkins startup +with an integer representing the backup number to restore as first and only argument +(can be overridden using spec.restore.recoveryOnce)
  • +
+ +

Example AWS S3 backup using the CLI

+ +

This example shows abbreviated version of a simple AWS S3 backup implementation +using: aws-cli, bash and kube2iam.

+ +

In addition to your normal Jenkins CustomResource some additional settings +for backup and restore are required, e.g.:

+
kind: Jenkins
+apiVersion: jenkins.io/v1alpha1
+metadata:
+  name: example
+  namespace: jenkins
+spec:
+  master:
+    masterAnnotations:
+      iam.amazonaws.com/role: "my-example-backup-role" # tell kube2iam where the AWS IAM role is
+    containers:
+      - name: jenkins-master
+        ...
+      - name: backup # container responsible for backup and restore
+        image: quay.io/virtuslab/aws-cli:1.16.263-2
+        workingDir: /home/user/bin/
+        command: # our container entry point
+          - sleep
+          - infinity
+        env:
+          - name: BACKUP_BUCKET
+            value: my-example-bucket # the S3 bucket name to use
+          - name: BACKUP_PATH
+            value: my-backup-path # the S3 bucket path prefix to use
+          - name: JENKINS_HOME
+            value: /jenkins-home # the path to mount jenkins home dir in the backup container
+        volumeMounts:
+          - mountPath: /jenkins-home # Jenkins home volume
+            name: jenkins-home
+          - mountPath: /home/user/bin/backup.sh
+            name: backup-scripts
+            subPath: backup.sh
+            readOnly: true
+          - mountPath: /home/user/bin/restore.sh
+            name: backup-scripts
+            subPath: restore.sh
+            readOnly: true
+    volumes:
+      - name: backup-scripts
+        configMap:
+          defaultMode: 0754
+          name: jenkins-operator-backup-s3
+    securityContext: # make sure both containers use the same UID and GUID
+      runAsUser: 1000
+      fsGroup: 1000
+  ...
+  backup:
+    containerName: backup # container name responsible for backup
+    interval: 3600 # how often make a backup in seconds
+    makeBackupBeforePodDeletion: true # trigger backup just before deleting the pod
+    action:
+      exec:
+        command:
+          # this command is invoked on "backup" container to create a backup,
+          # <backup_number> is passed by operator,
+          # for example /home/user/bin/backup.sh <backup_number>
+          - /home/user/bin/backup.sh
+  restore:
+    containerName: backup # container name is responsible for restore backup
+    action:
+      exec:
+        command:
+          # this command is invoked on "backup" container to restore a backup,
+          # <backup_number> is passed by operator
+          # for example /home/user/bin/restore.sh <backup_number>
+          - /home/user/bin/restore.sh
+#    recoveryOnce: <backup_number> # if want to restore specific backup configure this field and then Jenkins will be restarted and desired backup will be restored
+

The actual backup and restore scripts will be provided in a ConfigMap:

+
kind: ConfigMap
+apiVersion: v1
+metadata:
+  name: jenkins-operator-backup-s3
+  namespace: jenkins
+  labels:
+    app: jenkins-operator
+data:
+  backup.sh: |-
+    #!/bin/bash -xeu
+    [[ ! $# -eq 1 ]] && echo "Usage: $0 backup_number" && exit 1;
+    [[ -z "${BACKUP_BUCKET}" ]] && echo "Required 'BACKUP_BUCKET' env not set" && exit 1;
+    [[ -z "${BACKUP_PATH}" ]] && echo "Required 'BACKUP_PATH' env not set" && exit 1;
+    [[ -z "${JENKINS_HOME}" ]] && echo "Required 'JENKINS_HOME' env not set" && exit 1;
+
+    backup_number=$1
+    echo "Running backup #${backup_number}"
+
+    BACKUP_TMP_DIR=$(mktemp -d)
+    tar -C ${JENKINS_HOME} -czf "${BACKUP_TMP_DIR}/${backup_number}.tar.gz" --exclude jobs/*/workspace* -c jobs && \
+
+    aws s3 cp ${BACKUP_TMP_DIR}/${backup_number}.tar.gz s3://${BACKUP_BUCKET}/${BACKUP_PATH}/${backup_number}.tar.gz
+    echo Done
+
+  restore.sh: |-
+    #!/bin/bash -xeu
+    [[ ! $# -eq 1 ]] && echo "Usage: $0 backup_number" && exit 1
+    [[ -z "${BACKUP_BUCKET}" ]] && echo "Required 'BACKUP_BUCKET' env not set" && exit 1;
+    [[ -z "${BACKUP_PATH}" ]] && echo "Required 'BACKUP_PATH' env not set" && exit 1;
+    [[ -z "${JENKINS_HOME}" ]] && echo "Required 'JENKINS_HOME' env not set" && exit 1;
+
+    backup_number=$1
+    echo "Running restore #${backup_number}"
+
+    BACKUP_TMP_DIR=$(mktemp -d)
+    aws s3 cp s3://${BACKUP_BUCKET}/${BACKUP_PATH}/${backup_number}.tar.gz ${BACKUP_TMP_DIR}/${backup_number}.tar.gz
+
+    tar -C ${JENKINS_HOME} -zxf "${BACKUP_TMP_DIR}/${backup_number}.tar.gz"
+    echo Done
+

In our example we will use S3 bucket lifecycle policy to keep +the number of backups under control, e.g. Cloud Formation fragment:

+
    Type: AWS::S3::Bucket
+    Properties:
+      BucketName: my-example-bucket
+      ...
+      LifecycleConfiguration:
+        Rules:
+          - Id: BackupCleanup
+            Status: Enabled
+            Prefix: my-backup-path
+            ExpirationInDays: 7
+            NoncurrentVersionExpirationInDays: 14
+            AbortIncompleteMultipartUpload:
+              DaysAfterInitiation: 3
+ + +
Last modified August 5, 2019 +
+
+ + +
+
+
+ + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/docs/getting-started/future/customization/index.html b/docs/docs/getting-started/future/customization/index.html new file mode 100644 index 00000000..4f74c278 --- /dev/null +++ b/docs/docs/getting-started/future/customization/index.html @@ -0,0 +1,763 @@ + + + + + + + + + + + + + + + + + + + + + + +Customization | Jenkins Operator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Customization | Jenkins Operator + + +
+ + + +
+
+
+
+
+ + + + + +
+ + + + +
+ + + + +
+
+ + + + + + + + + + + + + + + +
+
+ + + +
+

Customization

+
How to customize Jenkins
+ + +

Jenkins can be customized using groovy scripts or the configuration as code plugin. +By using a ConfigMap you can create your own Jenkins customized configuration. +Then you must reference the ConfigMap in the Jenkins pod customization file in spec.groovyScripts or spec.configurationAsCode

+ +

For example create a ConfigMap with name jenkins-operator-user-configuration. Then, modify the Jenkins manifest to look like this:

+
apiVersion: jenkins.io/v1alpha2
+kind: Jenkins
+metadata:
+  name: example
+spec:
+  configurationAsCode:
+    configurations: 
+    - name: jenkins-operator-user-configuration
+  groovyScripts:
+    configurations:
+    - name: jenkins-operator-user-configuration
+

Here is an example of jenkins-operator-user-configuration:

+
apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: jenkins-operator-user-configuration
+data:
+  1-configure-theme.groovy: | 
+    import jenkins.*
+    import jenkins.model.*
+    import hudson.*
+    import hudson.model.*
+    import org.jenkinsci.plugins.simpletheme.ThemeElement
+    import org.jenkinsci.plugins.simpletheme.CssTextThemeElement
+    import org.jenkinsci.plugins.simpletheme.CssUrlThemeElement
+
+    Jenkins jenkins = Jenkins.getInstance()
+
+    def decorator = Jenkins.instance.getDescriptorByType(org.codefirst.SimpleThemeDecorator.class)
+
+    List<ThemeElement> configElements = new ArrayList<>();
+    configElements.add(new CssTextThemeElement("DEFAULT"));
+    configElements.add(new CssUrlThemeElement("https://cdn.rawgit.com/afonsof/jenkins-material-theme/gh-pages/dist/material-light-green.css"));
+    decorator.setElements(configElements);
+    decorator.save();
+
+    jenkins.save()
+  1-system-message.yaml: |
+    jenkins:
+      systemMessage: "Configuration as Code integration works!!!"
+
    +
  • *.groovy is Groovy script configuration
  • +
  • *.yaml is configuration as code
  • +
+ +

If you want to correct your configuration you can edit it while the Jenkins Operator is running. +Jenkins will reconcile and apply the new configuration.

+ +

Using secrets from a Groovy script

+ +

If you configured spec.groovyScripts.secret.name, then this secret is available to use from map Groovy scripts. +The secrets are loaded to secrets map.

+ +

Create a secret with for example the name jenkins-conf-secrets.

+
kind: Secret
+apiVersion: v1
+type: Opaque
+metadata:
+  name: jenkins-conf-secrets
+  namespace: default
+data:
+  SYSTEM_MESSAGE: SGVsbG8gd29ybGQ=
+

Then modify the Jenkins pod manifest by changing spec.groovyScripts.secret.name to jenkins-conf-secrets.

+
apiVersion: jenkins.io/v1alpha2
+kind: Jenkins
+metadata:
+  name: example
+spec:
+  configurationAsCode:
+    configurations: 
+    - name: jenkins-operator-user-configuration
+    secret:
+      name: jenkins-conf-secrets
+  groovyScripts:
+    configurations:
+    - name: jenkins-operator-user-configuration
+    secret:
+      name: jenkins-conf-secrets
+

Now you can test that the secret is mounted by applying this ConfigMap for Groovy script:

+
apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: jenkins-operator-user-configuration
+data:
+  1-system-message.groovy: | 
+    import jenkins.*
+    import jenkins.model.*
+    import hudson.*
+    import hudson.model.*
+    Jenkins jenkins = Jenkins.getInstance()
+    
+    jenkins.setSystemMessage(secrets["SYSTEM_MESSAGE"])
+    jenkins.save()
+

Or by applying this configuration as code:

+
apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: jenkins-operator-user-configuration
+data:
+  1-system-message.yaml: |
+    jenkins:
+      systemMessage: ${SYSTEM_MESSAGE}
+

After this, you should see the Hello world system message from the Jenkins homepage.

+ +

Install Plugins

+ +

Edit Custom Resource under spec.master.plugins:

+ +
apiVersion: jenkins.io/v1alpha2
+kind: Jenkins
+metadata:
+  name: example
+spec:
+  master:
+   plugins:
+   - name: simple-theme-plugin
+     version: 0.5.1
+
+ +

Under spec.master.basePlugins you can find plugins for a valid Jenkins Operator:

+
apiVersion: jenkins.io/v1alpha2
+kind: Jenkins
+metadata:
+  name: example
+spec:
+  master:
+    basePlugins:
+    - name: kubernetes
+      version: 1.18.3
+    - name: workflow-job
+      version: "2.34"
+    - name: workflow-aggregator
+      version: "2.6"
+    - name: git
+      version: 3.12.0
+    - name: job-dsl
+      version: "1.76"
+    - name: configuration-as-code
+      version: "1.29"
+    - name: configuration-as-code-support
+      version: "1.19"
+    - name: kubernetes-credentials-provider
+      version: 0.12.1
+

You can change their versions.

+ +

The Jenkins Operator will then automatically install plugins after the Jenkins master pod restarts.

+ + + +
Last modified August 5, 2019 +
+
+ + +
+
+
+ + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/docs/getting-started/future/deploy-jenkins/index.html b/docs/docs/getting-started/future/deploy-jenkins/index.html new file mode 100644 index 00000000..391e6fe6 --- /dev/null +++ b/docs/docs/getting-started/future/deploy-jenkins/index.html @@ -0,0 +1,653 @@ + + + + + + + + + + + + + + + + + + + + + + +Deploy Jenkins | Jenkins Operator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Deploy Jenkins | Jenkins Operator + + +
+ + + +
+
+
+
+
+ + + + + +
+ + + + +
+ + + + +
+
+ + + + + + + + + + + +
+
+ + + +
+

Deploy Jenkins

+
Deploy production ready Jenkins Operator manifest
+

Once Jenkins Operator is up and running let’s deploy actual Jenkins instance. +Create manifest e.g. jenkins_instance.yaml with following data and save it on drive.

+
apiVersion: jenkins.io/v1alpha2
+kind: Jenkins
+metadata:
+  name: example
+spec:
+  master:
+    containers:
+    - name: jenkins-master
+      image: jenkins/jenkins:lts
+      imagePullPolicy: Always
+      livenessProbe:
+        failureThreshold: 12
+        httpGet:
+          path: /login
+          port: http
+          scheme: HTTP
+        initialDelaySeconds: 80
+        periodSeconds: 10
+        successThreshold: 1
+        timeoutSeconds: 5
+      readinessProbe:
+        failureThreshold: 3
+        httpGet:
+          path: /login
+          port: http
+          scheme: HTTP
+        initialDelaySeconds: 30
+        periodSeconds: 10
+        successThreshold: 1
+        timeoutSeconds: 1
+      resources:
+        limits:
+          cpu: 1500m
+          memory: 3Gi
+        requests:
+          cpu: "1"
+          memory: 500Mi
+  seedJobs:
+  - id: jenkins-operator
+    targets: "cicd/jobs/*.jenkins"
+    description: "Jenkins Operator repository"
+    repositoryBranch: master
+    repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git
+

Deploy a Jenkins to Kubernetes:

+
kubectl create -f jenkins_instance.yaml
+

Watch the Jenkins instance being created:

+
kubectl get pods -w
+

Get the Jenkins credentials:

+
kubectl get secret jenkins-operator-credentials-<cr_name> -o 'jsonpath={.data.user}' | base64 -d
+kubectl get secret jenkins-operator-credentials-<cr_name> -o 'jsonpath={.data.password}' | base64 -d
+

Connect to the Jenkins instance (minikube):

+
minikube service jenkins-operator-http-<cr_name> --url
+

Connect to the Jenkins instance (actual Kubernetes cluster):

+
kubectl port-forward jenkins-<cr_name> 8080:8080
+

Then open browser with address http://localhost:8080. +jenkins

+ + + +
Last modified August 5, 2019 +
+
+ + +
+
+
+ + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/docs/getting-started/future/developer-guide/index.html b/docs/docs/getting-started/future/developer-guide/index.html new file mode 100644 index 00000000..8c5b77cb --- /dev/null +++ b/docs/docs/getting-started/future/developer-guide/index.html @@ -0,0 +1,771 @@ + + + + + + + + + + + + + + + + + + + + + + +Developer Guide | Jenkins Operator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Developer Guide | Jenkins Operator + + +
+ + + +
+
+
+
+
+ + + + + +
+ + + + +
+ + + + +
+ +
+ + + +
+

Developer Guide

+
Jenkins Operator for developers
+ + + + +
+

This document explains how to setup your development environment.

+ +
+ + +

Prerequisites

+ + + +

Clone repository and download dependencies

+
mkdir -p $GOPATH/src/github.com/jenkinsci
+cd $GOPATH/src/github.com/jenkinsci/
+git clone git@github.com:jenkinsci/kubernetes-operator.git
+cd kubernetes-operator
+make go-dependencies
+

Build and run with a minikube

+ +

Build and run Jenkins Operator locally:

+
make build minikube-run OPERATOR_EXTRA_ARGS='--jenkins-api-hostname=$(eval minikube ip) --jenkins-api-use-nodeport=true'
+

Once minikube and Jenkins Operator are up and running, apply Jenkins custom resource:

+
kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml
+kubectl get jenkins -o yaml
+kubectl get po
+

Build and run with a remote Kubernetes cluster

+ +

You can also run the controller locally and make it listen to a remote Kubernetes server.

+
make run NAMESPACE=default KUBECTL_CONTEXT=remote-k8s OPERATOR_EXTRA_ARGS='--kubeconfig ~/.kube/config'
+

Once minikube and Jenkins Operator are up and running, apply Jenkins custom resource:

+
kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml
+kubectl --context remote-k8s --namespace default get jenkins -o yaml
+kubectl --context remote-k8s --namespace default get po
+

Testing

+ +

Run unit tests:

+
make test
+

Running E2E tests on Linux

+ +

Run e2e tests with minikube:

+
make minikube-start
+eval $(minikube docker-env)
+make build e2e config=config.minikube.env CONTAINER_RUNTIME=podman
+

config.minikube.env is the E2E test profile which provides all connection info to operator to run on minikube.

+ +

Run the specific e2e test:

+
make build e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.minikube.env CONTAINER_RUNTIME=podman
+

If you want to run E2E tests on CRC (Code Ready Containers by OpenShift), you should use config.crc.env profile instead of config.minikube.env. +If you have some trouble with podman (for example building) then check how to use docker instead of podman.

+ +

Running E2E tests on macOS

+ +

At first, you need to start minikube:

+
$ make minikube-start
+$ eval $(minikube docker-env) 
+

Build a Docker image inside the provided Linux container by:

+
$ make indocker
+

Build Jenkins Operator inside a container using:

+
$ make build
+

Then exit the container and run:

+ +
make e2e config=config.minikube.env
+
+ +

or using crc as cluster software:

+ +
make e2e config=config.crc.env
+
+ +

Using Docker instead of podman

+ +

If you have trouble with building image using the podman, you can set additional flag IMAGE_PULL_MODE to pull image from the organization.

+ +

At first, you need to edit config.base.env and change the DOCKER_ORGANIZATION to your Docker Hub account/organization. +After this change the IMAGE_PULL_MODE to remote. It will setup the Makefile goal to pull Docker image from registry. +Then you need to pull image from your repository:

+
$ make container-runtime-build container-runtime-snapshot-push
+

When image will be uploaded to repository, you can now write this command to run E2E tests:

+
$ make e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.crc.env
+

Tips & Tricks

+ +

Building docker image on minikube (for e2e tests)

+ +

To be able to work with the docker daemon on minikube machine run the following command before building an image:

+
eval $(minikube docker-env)
+

When pkg/apis/jenkinsio/*/jenkins_types.go has changed

+ +

Run:

+
make deepcopy-gen
+

Getting the Jenkins URL and basic credentials

+
minikube service jenkins-operator-http-<cr_name> --url
+kubectl get secret jenkins-operator-credentials-<cr_name> -o 'jsonpath={.data.user}' | base64 -d
+kubectl get secret jenkins-operator-credentials-<cr_name> -o 'jsonpath={.data.password}' | base64 -d
+

Tools

+ +

Configure environment variables

+
export GOPATH=/home/go # example value
+export GOROOT=/usr/lib/go-1.12 # example value
+export PATH=$GOPATH/bin:$PATH
+

goimports

+ +
go get golang.org/x/tools/cmd/goimports
+cd $GOPATH/src/golang.org/x/tools/cmd/goimports
+go build
+go install
+
+ +

golint

+ +
go get -u golang.org/x/lint/golint
+cd  $GOPATH/src/golang.org/x/lint/golint
+go build
+go install
+
+ +

checkmake

+ +
go get github.com/mrtazz/checkmake
+cd $GOPATH/src/github.com/mrtazz/checkmake
+go build
+go install
+
+ +

staticcheck

+ +
mkdir -p $GOPATH/src/github.com/dominikh/
+cd $GOPATH/src/github.com/dominikh/
+git clone https://github.com/dominikh/go-tools.git
+cd  $GOPATH/src/github.com/dominikh/go-tools/staticcheck
+go build
+go install
+
+ + + +
Last modified August 5, 2019 +
+
+ + +
+
+
+ + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/docs/developer-guide/tools/index.html b/docs/docs/getting-started/future/diagnostics/index.html similarity index 71% rename from docs/docs/developer-guide/tools/index.html rename to docs/docs/getting-started/future/diagnostics/index.html index 61681a1c..529e3f8f 100644 --- a/docs/docs/developer-guide/tools/index.html +++ b/docs/docs/getting-started/future/diagnostics/index.html @@ -20,29 +20,29 @@ -Tools | Jenkins Operator - + - + - - + - + - - + @@ -58,7 +58,7 @@ crossorigin="anonymous"> - Tools | Jenkins Operator + Diagnostics | Jenkins Operator
@@ -189,10 +189,10 @@ @@ -373,35 +462,6 @@ - - - - - - - - - - - - @@ -422,8 +482,8 @@ - Edit this page - Create documentation issue + Edit this page + Create documentation issue Create project issue @@ -435,19 +495,6 @@ - - @@ -465,6 +512,9 @@ + + + @@ -473,14 +523,21 @@ + + + + + @@ -488,56 +545,23 @@
-

Tools

-
Required tools for building and running Jenkins Operator
+

Diagnostics

+
How to deal with Jenkins Operator problems
+

Turn on debug in Jenkins Operator deployment:

+
sed -i 's|\(args:\).*|\1\ ["--debug"\]|' deploy/operator.yaml
+kubectl apply -f deploy/operator.yaml
+

Watch Kubernetes events:

+
kubectl get events --sort-by='{.lastTimestamp}'
+

Verify Jenkins master logs:

+
kubectl logs -f jenkins-<cr_name>
+

Verify the jenkins-operator logs:

+
kubectl logs deployment/jenkins-operator
+

Troubleshooting

- -
-

This document explains how to install the Go tools used by the development process.

- -
- - -

Configure environment variables

-
export GOPATH=/home/go # example value
-export GOROOT=/usr/lib/go-1.12 # example value
-export PATH=$GOPATH/bin:$PATH
-

goimports

- -
go get golang.org/x/tools/cmd/goimports
-cd $GOPATH/src/golang.org/x/tools/cmd/goimports
-go build
-go install
-
- -

golint

- -
go get -u golang.org/x/lint/golint
-cd  $GOPATH/src/golang.org/x/lint/golint
-go build
-go install
-
- -

checkmake

- -
go get github.com/mrtazz/checkmake
-cd $GOPATH/src/github.com/mrtazz/checkmake
-go build
-go install
-
- -

staticcheck

- -
mkdir -p $GOPATH/src/github.com/dominikh/
-cd $GOPATH/src/github.com/dominikh/
-git clone https://github.com/dominikh/go-tools.git
-cd  $GOPATH/src/github.com/dominikh/go-tools/staticcheck
-go build
-go install
-
- +

Delete the Jenkins master pod and wait for the new one to come up:

+
kubectl delete pod jenkins-<cr_name>
Last modified August 5, 2019 diff --git a/docs/docs/getting-started/future/index.html b/docs/docs/getting-started/future/index.html new file mode 100644 index 00000000..da8ab204 --- /dev/null +++ b/docs/docs/getting-started/future/index.html @@ -0,0 +1,752 @@ + + + + + + + + + + + + + + + + + + + + + + + +Future (v0.3.x) | Jenkins Operator + + + + + + + + + + + + + + + + + + + + + + + + Future (v0.3.x) | Jenkins Operator + + +
+ + + +
+
+
+
+
+ + + + + +
+ + + + +
+ + + + +
+
+ + + + + + + + + + + + + +
+
+ + + +
+

Future (v0.3.x)

+
How to work with jenkins-operator latest version
+ + + + +
+

This document describes a getting started guide for Jenkins Operator v0.3.x and an additional configuration.

+ +
+ + +

First Steps

+ +

Prepare your Kubernetes cluster and set up your kubectl access.

+ +

Once you have running Kubernetes cluster you can focus on installing Jenkins Operator according to the Installation guide.

+ +
+ + + + +
+ + + + +
+
+ Deploy Jenkins +
+

Deploy production ready Jenkins Operator manifest +

+
+ + + + + + + + + +
+
+ Configuration +
+

How to configure Jenkins with Operator +

+
+ + + + + + + +
+
+ Customization +
+

How to customize Jenkins +

+
+ + + + + + + + + +
+
+ AKS +
+

Additional configuration for Azure Kubernetes Service +

+
+ + + + + + + +
+
+ Configure backup and restore +
+

Prevent loss of job history +

+
+ + + + + + + +
+
+ Custom Backup and Restore Providers +
+

Custom backup and restore provider +

+
+ + + + + + + + + + + + + + + + + + + +
+
+ Diagnostics +
+

How to deal with Jenkins Operator problems +

+
+ + + + + + + +
+
+ Schema +
+

API Schema definitions for Jenkins CRD +

+
+ + + + + + + + + + + +
+
+ Developer Guide +
+

Jenkins Operator for developers +

+
+ + + + + + + +
+ + + +
Last modified August 5, 2019 +
+
+ +
+
+
+ + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/docs/getting-started/future/index.xml b/docs/docs/getting-started/future/index.xml new file mode 100644 index 00000000..9faa4556 --- /dev/null +++ b/docs/docs/getting-started/future/index.xml @@ -0,0 +1,3020 @@ + + + Jenkins Operator – Future (v0.3.x) + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/ + Recent Hugo news from gohugo.io + Hugo -- gohugo.io + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/img/hugo.png + GoHugo.io + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/ + + + + + + + + + + + + Docs: Deploy Jenkins + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/deploy-jenkins/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/deploy-jenkins/ + + + + <p>Once Jenkins Operator is up and running let&rsquo;s deploy actual Jenkins instance. +Create manifest e.g. <strong><code>jenkins_instance.yaml</code></strong> with following data and save it on drive.</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + master: + containers: + - name: jenkins-master + image: jenkins/jenkins:lts + imagePullPolicy: Always + livenessProbe: + failureThreshold: <span style="color:#0000cf;font-weight:bold">12</span> + httpGet: + path: /login + port: http + scheme: HTTP + initialDelaySeconds: <span style="color:#0000cf;font-weight:bold">80</span> + periodSeconds: <span style="color:#0000cf;font-weight:bold">10</span> + successThreshold: <span style="color:#0000cf;font-weight:bold">1</span> + timeoutSeconds: <span style="color:#0000cf;font-weight:bold">5</span> + readinessProbe: + failureThreshold: <span style="color:#0000cf;font-weight:bold">3</span> + httpGet: + path: /login + port: http + scheme: HTTP + initialDelaySeconds: <span style="color:#0000cf;font-weight:bold">30</span> + periodSeconds: <span style="color:#0000cf;font-weight:bold">10</span> + successThreshold: <span style="color:#0000cf;font-weight:bold">1</span> + timeoutSeconds: <span style="color:#0000cf;font-weight:bold">1</span> + resources: + limits: + cpu: 1500m + memory: 3Gi + requests: + cpu: <span style="color:#4e9a06">&#34;1&#34;</span> + memory: 500Mi + seedJobs: + - id: jenkins-operator + targets: <span style="color:#4e9a06">&#34;cicd/jobs/*.jenkins&#34;</span> + description: <span style="color:#4e9a06">&#34;Jenkins Operator repository&#34;</span> + repositoryBranch: master + repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git</code></pre></div> +<p>Deploy a Jenkins to Kubernetes:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl create -f jenkins_instance.yaml</code></pre></div> +<p>Watch the Jenkins instance being created:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl get pods -w</code></pre></div> +<p>Get the Jenkins credentials:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.user}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d +kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.password}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d</code></pre></div> +<p>Connect to the Jenkins instance (minikube):</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">minikube service jenkins-operator-http-&lt;cr_name&gt; --url</code></pre></div> +<p>Connect to the Jenkins instance (actual Kubernetes cluster):</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl port-forward jenkins-&lt;cr_name&gt; <span style="color:#0000cf;font-weight:bold">8080</span>:8080</code></pre></div> +<p>Then open browser with address <code>http://localhost:8080</code>. +<img src="https://jenkinsci.github.io/kubernetes-operator/img/jenkins.png" alt="jenkins" /></p> + + + + + + Docs: Configuration + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/configuration/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/configuration/ + + + + + +<h2 id="configure-seed-jobs-and-pipelines">Configure Seed Jobs and Pipelines</h2> + +<p>Jenkins operator uses <a href="https://github.com/jenkinsci/job-dsl-plugin" target="_blank">job-dsl</a> and <a href="https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/" target="_blank">kubernetes-credentials-provider</a> plugins for configuring jobs +and deploy keys.</p> + +<h2 id="prepare-job-definitions-and-pipelines">Prepare job definitions and pipelines</h2> + +<p>First you have to prepare pipelines and job definition in your GitHub repository using the following structure:</p> + +<pre><code>cicd/ +├── jobs +│   └── build.jenkins +└── pipelines + └── build.jenkins +</code></pre> + +<p><strong><code>cicd/jobs/build.jenkins</code></strong> is a job definition:</p> + +<pre><code>#!/usr/bin/env groovy + +pipelineJob('build-jenkins-operator') { + displayName('Build jenkins-operator') + + definition { + cpsScm { + scm { + git { + remote { + url('https://github.com/jenkinsci/kubernetes-operator.git') + credentials('jenkins-operator') + } + branches('*/master') + } + } + scriptPath('cicd/pipelines/build.jenkins') + } + } +} +</code></pre> + +<p><strong><code>cicd/pipelines/build.jenkins</code></strong> is an actual Jenkins pipeline:</p> + +<pre><code>#!/usr/bin/env groovy + +def label = &quot;build-jenkins-operator-${UUID.randomUUID().toString()}&quot; +def home = &quot;/home/jenkins&quot; +def workspace = &quot;${home}/workspace/build-jenkins-operator&quot; +def workdir = &quot;${workspace}/src/github.com/jenkinsci/kubernetes-operator/&quot; + +podTemplate(label: label, + containers: [ + containerTemplate(name: 'jnlp', image: 'jenkins/jnlp-slave:alpine'), + containerTemplate(name: 'go', image: 'golang:1-alpine', command: 'cat', ttyEnabled: true), + ], + envVars: [ + envVar(key: 'GOPATH', value: workspace), + ], + ) { + + node(label) { + dir(workdir) { + stage('Init') { + timeout(time: 3, unit: 'MINUTES') { + checkout scm + } + container('go') { + sh 'apk --no-cache --update add make git gcc libc-dev' + } + } + + stage('Dep') { + container('go') { + sh 'make dep' + } + } + + stage('Test') { + container('go') { + sh 'make test' + } + } + + stage('Build') { + container('go') { + sh 'make build' + } + } + } + } +} +</code></pre> + +<h2 id="configure-seed-jobs">Configure Seed Jobs</h2> + +<p>Jenkins Seed Jobs are configured using <code>Jenkins.spec.seedJobs</code> section from your custom resource manifest:</p> + +<pre><code>apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + seedJobs: + - id: jenkins-operator + targets: &quot;cicd/jobs/*.jenkins&quot; + description: &quot;Jenkins Operator repository&quot; + repositoryBranch: master + repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git +</code></pre> + +<p><strong>Jenkins Operator</strong> will automatically discover and configure all the seed jobs.</p> + +<p>You can verify if deploy keys were successfully configured in the Jenkins <strong>Credentials</strong> tab.</p> + +<p><img src="https://jenkinsci.github.io/kubernetes-operator/kubernetes-operator/img/jenkins-credentials.png" alt="jenkins" /></p> + +<p>You can verify if your pipelines were successfully configured in the Jenkins Seed Job console output.</p> + +<p><img src="https://jenkinsci.github.io/kubernetes-operator/kubernetes-operator/img/jenkins-seed.png" alt="jenkins" /></p> + +<p>If your GitHub repository is <strong>private</strong> you have to configure SSH or username/password authentication.</p> + +<h3 id="ssh-authentication">SSH authentication</h3> + +<h4 id="generate-ssh-keys">Generate SSH Keys</h4> + +<p>There are two methods of SSH private key generation:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ openssl genrsa -out &lt;filename&gt; <span style="color:#0000cf;font-weight:bold">2048</span></code></pre></div> +<p>or</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ ssh-keygen -t rsa -b <span style="color:#0000cf;font-weight:bold">2048</span> +$ ssh-keygen -p -f &lt;filename&gt; -m pem</code></pre></div> +<p>Then copy content from generated file.</p> + +<h4 id="public-key">Public key</h4> + +<p>If you want to upload your public key to your Git server you need to extract it.</p> + +<p>If key was generated by <code>openssl</code> then you need to type this to extract public key:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ openssl rsa -in &lt;filename&gt; -pubout &gt; &lt;filename&gt;.pub</code></pre></div> +<p>If key was generated by <code>ssh-keygen</code> the public key content is located in <filename>.pub and there is no need to extract public key</p> + +<h4 id="configure-ssh-authentication">Configure SSH authentication</h4> + +<p>Configure a seed job like this:</p> + +<pre><code>apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + seedJobs: + - id: jenkins-operator-ssh + credentialType: basicSSHUserPrivateKey + credentialID: k8s-ssh + targets: &quot;cicd/jobs/*.jenkins&quot; + description: &quot;Jenkins Operator repository&quot; + repositoryBranch: master + repositoryUrl: git@github.com:jenkinsci/kubernetes-operator.git +</code></pre> + +<p>and create a Kubernetes Secret (name of secret should be the same from <code>credentialID</code> field):</p> + +<pre><code>apiVersion: v1 +kind: Secret +metadata: + name: k8s-ssh +stringData: + privateKey: | + -----BEGIN RSA PRIVATE KEY----- + MIIJKAIBAAKCAgEAxxDpleJjMCN5nusfW/AtBAZhx8UVVlhhhIKXvQ+dFODQIdzO + oDXybs1zVHWOj31zqbbJnsfsVZ9Uf3p9k6xpJ3WFY9b85WasqTDN1xmSd6swD4N8 + ... + username: github_user_name +</code></pre> + +<h3 id="username-password-authentication">Username &amp; password authentication</h3> + +<p>Configure the seed job like:</p> + +<pre><code>apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + seedJobs: + - id: jenkins-operator-user-pass + credentialType: usernamePassword + credentialID: k8s-user-pass + targets: &quot;cicd/jobs/*.jenkins&quot; + description: &quot;Jenkins Operator repository&quot; + repositoryBranch: master + repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git +</code></pre> + +<p>and create a Kubernetes Secret (name of secret should be the same from <code>credentialID</code> field):</p> + +<pre><code>apiVersion: v1 +kind: Secret +metadata: + name: k8s-user-pass +stringData: + username: github_user_name + password: password_or_token +</code></pre> + +<h2 id="http-proxy-for-downloading-plugins">HTTP Proxy for downloading plugins</h2> + +<p>To use forwarding proxy with an operator to download plugins you need to add the following environment variable to Jenkins Custom Resource (CR), e.g.:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containers<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-master<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>env<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>CURL_OPTIONS<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-L<span style="color:#f8f8f8;text-decoration:underline"> </span>-x<span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;proxy_url&gt;</code></pre></div> +<p>In <code>CURL_OPTIONS</code> var you can set additional arguments to <code>curl</code> command.</p> + +<h2 id="pulling-docker-images-from-private-repositories">Pulling Docker images from private repositories</h2> + +<p>To pull a Docker Image from private repository you can use <code>imagePullSecrets</code>.</p> + +<p>Please follow the instructions on <a href="https://kubernetes.io/docs/concepts/containers/images/?origin_team=T42NTAGHM#creating-a-secret-with-a-docker-config" target="_blank">creating a secret with a docker config</a>.</p> + +<h3 id="docker-hub-configuration">Docker Hub Configuration</h3> + +<p>To use Docker Hub additional steps are required.</p> + +<p>Edit the previously created secret:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl -n &lt;namespace&gt; edit secret &lt;name&gt;</code></pre></div> +<p>The <code>.dockerconfigjson</code> key&rsquo;s value needs to be replaced with a modified version.</p> + +<p>After modifications, it needs to be encoded as a Base64 value before setting the <code>.dockerconfigjson</code> key.</p> + +<p>Example config file to modify and use:</p> + +<pre><code>{ + &quot;auths&quot;:{ + &quot;https://index.docker.io/v1/&quot;:{ + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + }, + &quot;auth.docker.io&quot;:{ + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + }, + &quot;registry.docker.io&quot;:{ + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + }, + &quot;docker.io&quot;:{ + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + }, + &quot;https://registry-1.docker.io/v2/&quot;: { + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + }, + &quot;registry-1.docker.io/v2/&quot;: { + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + }, + &quot;registry-1.docker.io&quot;: { + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + }, + &quot;https://registry-1.docker.io&quot;: { + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + } + } +} +</code></pre> + + + + + + Docs: Customization + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/customization/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/customization/ + + + + + +<p>Jenkins can be customized using groovy scripts or the <a href="https://github.com/jenkinsci/configuration-as-code-plugin" target="_blank">configuration as code plugin</a>. +By using a <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" target="_blank">ConfigMap</a> you can create your own <strong>Jenkins</strong> customized configuration. +Then you must reference the <strong><code>ConfigMap</code></strong> in the <strong>Jenkins</strong> pod customization file in <code>spec.groovyScripts</code> or <code>spec.configurationAsCode</code></p> + +<p>For example create a <strong><code>ConfigMap</code></strong> with name <code>jenkins-operator-user-configuration</code>. Then, modify the <strong>Jenkins</strong> manifest to look like this:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha2<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>example<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurationAsCode<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>groovyScripts<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration</code></pre></div> +<p>Here is an example of <code>jenkins-operator-user-configuration</code>:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ConfigMap<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>-configure-theme.groovy<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">| +</span><span style="color:#8f5902;font-style:italic"> import jenkins.*</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.model.*<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>hudson.*<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>hudson.model.*<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>org.jenkinsci.plugins.simpletheme.ThemeElement<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>org.jenkinsci.plugins.simpletheme.CssTextThemeElement<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>org.jenkinsci.plugins.simpletheme.CssUrlThemeElement<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins.getInstance()<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>def<span style="color:#f8f8f8;text-decoration:underline"> </span>decorator<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins.instance.getDescriptorByType(org.codefirst.SimpleThemeDecorator.class)<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>List&lt;ThemeElement&gt;<span style="color:#f8f8f8;text-decoration:underline"> </span>configElements<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>new<span style="color:#f8f8f8;text-decoration:underline"> </span>ArrayList&lt;&gt;();<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configElements.add(new<span style="color:#f8f8f8;text-decoration:underline"> </span>CssTextThemeElement(<span style="color:#4e9a06">&#34;DEFAULT&#34;</span>));<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configElements.add(new<span style="color:#f8f8f8;text-decoration:underline"> </span>CssUrlThemeElement(<span style="color:#4e9a06">&#34;https://cdn.rawgit.com/afonsof/jenkins-material-theme/gh-pages/dist/material-light-green.css&#34;</span>));<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>decorator.setElements(configElements);<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>decorator.save();<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.save()<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>-system-message.yaml<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">| +</span><span style="color:#8f5902;font-style:italic"> jenkins:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>systemMessage<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Configuration as Code integration works!!!&#34;</span></code></pre></div> +<ul> +<li><code>*.groovy</code> is Groovy script configuration</li> +<li><code>*.yaml is</code> configuration as code</li> +</ul> + +<p>If you want to correct your configuration you can edit it while the <strong>Jenkins Operator</strong> is running. +Jenkins will reconcile and apply the new configuration.</p> + +<h3 id="using-secrets-from-a-groovy-script">Using secrets from a Groovy script</h3> + +<p>If you configured <code>spec.groovyScripts.secret.name</code>, then this secret is available to use from map Groovy scripts. +The secrets are loaded to <code>secrets</code> map.</p> + +<p>Create a <a href="https://kubernetes.io/docs/concepts/configuration/secret/" target="_blank">secret</a> with for example the name <code>jenkins-conf-secrets</code>.</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Secret<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>type<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Opaque<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-conf-secrets<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>namespace<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>default<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>SYSTEM_MESSAGE<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>SGVsbG8gd29ybGQ=</code></pre></div> +<p>Then modify the <strong>Jenkins</strong> pod manifest by changing <code>spec.groovyScripts.secret.name</code> to <code>jenkins-conf-secrets</code>.</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha2<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>example<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurationAsCode<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>secret<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-conf-secrets<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>groovyScripts<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>secret<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-conf-secrets</code></pre></div> +<p>Now you can test that the secret is mounted by applying this <code>ConfigMap</code> for Groovy script:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ConfigMap<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>-system-message.groovy<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">| +</span><span style="color:#8f5902;font-style:italic"> import jenkins.*</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.model.*<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>hudson.*<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>hudson.model.*<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins.getInstance()<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.setSystemMessage(secrets<span style="color:#000;font-weight:bold">[</span><span style="color:#4e9a06">&#34;SYSTEM_MESSAGE&#34;</span><span style="color:#000;font-weight:bold">]</span>)<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.save()</code></pre></div> +<p>Or by applying this configuration as code:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ConfigMap<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>-system-message.yaml<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">| +</span><span style="color:#8f5902;font-style:italic"> jenkins:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>systemMessage<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>${SYSTEM_MESSAGE}</code></pre></div> +<p>After this, you should see the <code>Hello world</code> system message from the <strong>Jenkins</strong> homepage.</p> + +<h2 id="install-plugins">Install Plugins</h2> + +<p>Edit Custom Resource under <code>spec.master.plugins</code>:</p> + +<pre><code>apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + master: + plugins: + - name: simple-theme-plugin + version: 0.5.1 +</code></pre> + +<p>Under <code>spec.master.basePlugins</code> you can find plugins for a valid <strong>Jenkins Operator</strong>:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha2<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>example<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>basePlugins<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>kubernetes<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1.18</span>.<span style="color:#0000cf;font-weight:bold">3</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>workflow-job<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;2.34&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>workflow-aggregator<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;2.6&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>git<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">3.12</span>.<span style="color:#0000cf;font-weight:bold">0</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>job-dsl<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;1.76&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configuration-as-code<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;1.29&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configuration-as-code-support<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;1.19&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>kubernetes-credentials-provider<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">0.12</span>.<span style="color:#0000cf;font-weight:bold">1</span></code></pre></div> +<p>You can change their versions.</p> + +<p>The <strong>Jenkins Operator</strong> will then automatically install plugins after the Jenkins master pod restarts.</p> + + + + + + Docs: AKS + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/aks/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/aks/ + + + + <p>Azure AKS managed Kubernetes service adds to every pod the following environment variables:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KUBERNETES_PORT_443_TCP_ADDR<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KUBERNETES_PORT<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>tcp<span style="color:#000;font-weight:bold">:</span>//<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KUBERNETES_PORT_443_TCP<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>tcp<span style="color:#000;font-weight:bold">:</span>//<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KUBERNETES_SERVICE_HOST<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span></code></pre></div> +<p>The operator is aware of it and omits these environment variables when checking if a Jenkins pod environment has been changed. It prevents the +restart of a Jenkins pod over and over again.</p> + + + + + + Docs: Configure backup and restore + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/configure-backup-and-restore/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/configure-backup-and-restore/ + + + + + +<p>Backup and restore is done by a container sidecar.</p> + +<h3 id="pvc">PVC</h3> + +<h4 id="create-pvc">Create PVC</h4> + +<p>Save to the file named pvc.yaml:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>PersistentVolumeClaim<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;pvc_name<span style="color:#8f5902;font-style:italic">&gt; +</span><span style="color:#8f5902;font-style:italic"> namespace: &lt;namespace&gt;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>accessModes<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>ReadWriteOnce<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>resources<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>requests<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>storage<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>500Gi</code></pre></div> +<p>Run the following command:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ kubectl -n &lt;namespace&gt; create -f pvc.yaml</code></pre></div> +<h4 id="configure-jenkins-cr">Configure Jenkins CR</h4> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha2<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;cr_name<span style="color:#8f5902;font-style:italic">&gt; +</span><span style="color:#8f5902;font-style:italic"> namespace: &lt;namespace&gt;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>securityContext<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>runAsUser<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>fsGroup<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containers<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-master<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>image<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins/jenkins<span style="color:#000;font-weight:bold">:</span>lts<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container responsible for the backup and restore</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>env<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_DIR<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/backup<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>JENKINS_HOME<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_COUNT<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;3&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># keep only the 2 most recent backups</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>image<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>virtuslab/jenkins-operator-backup-pvc<span style="color:#000;font-weight:bold">:</span>v0.<span style="color:#0000cf;font-weight:bold">0.7</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># look at backup/pvc directory</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>imagePullPolicy<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IfNotPresent<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>volumeMounts<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># Jenkins home volume</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># backup volume</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>volumes<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># PVC volume where backups will be stored</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>persistentVolumeClaim<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>claimName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;pvc_name<span style="color:#8f5902;font-style:italic">&gt; +</span><span style="color:#8f5902;font-style:italic"> backup:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containerName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container name is responsible for backup</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>action<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/backup.sh<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># this command is invoked on &#34;backup&#34; container to make backup, for example /home/user/bin/backup.sh &lt;backup_number&gt;, &lt;backup_number&gt; is passed by operator</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>interval<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">30</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># how often make backup in seconds</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>makeBackupBeforePodDeletion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">true</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># make a backup before pod deletion</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>restore<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containerName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container name is responsible for restore backup</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>action<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/restore.sh<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># this command is invoked on &#34;backup&#34; container to make restore backup, for example /home/user/bin/restore.sh &lt;backup_number&gt;, &lt;backup_number&gt; is passed by operator</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">#recoveryOnce: &lt;backup_number&gt; # if want to restore specific backup configure this field and then Jenkins will be restarted and desired backup will be restored</span></code></pre></div> + + + + + Docs: Custom Backup and Restore Providers + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/custom-backup-and-restore/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/custom-backup-and-restore/ + + + + + +<p>With enough effort one can create a custom backup and restore provider +for the Jenkins Operator.</p> + +<h2 id="requirements">Requirements</h2> + +<p>Two commands (e.g. scripts) are required:</p> + +<ul> +<li>a backup command, e.g. <code>backup.sh</code> that takes one argument, a <strong>backup number</strong></li> +<li>a restore command, e.g. <code>backup.sh</code> that takes one argument, a <strong>backup number</strong></li> +</ul> + +<p>Both scripts need to return an exit code of <code>0</code> on success and <code>1</code> or greater for failure.</p> + +<p>One of those scripts (or the entry point of the container) needs to be responsible +for backup cleanup or rotation if required, or an external system.</p> + +<h2 id="how-it-works">How it works</h2> + +<p>The mechanism relies on basic Kubernetes and UNIX functionalities.</p> + +<p>The backup (and restore) container runs as a sidecar in the same +Kubernetes pod as the Jenkins master.</p> + +<p>Name of the backup and restore containers can be set as necessary using +<code>spec.backup.containerName</code> and <code>spec.restore.containerName</code>. +In most cases it will be the same container, but we allow for less common use cases.</p> + +<p>The operator will call a backup or restore commands inside a sidecar container when necessary:</p> + +<ul> +<li>backup command (defined in <code>spec.backup.action.exec.command</code>) +will be called every <code>N</code> seconds configurable in: <code>spec.backup.interval</code> +and on pod shutdown (if enabled in <code>spec.backup.makeBackupBeforePodDeletion</code>) +with an integer representing the current backup number as first and only argument</li> +<li>restore command (defined in <code>spec.restore.action.exec.command</code>) +will be called at Jenkins startup +with an integer representing the backup number to restore as first and only argument +(can be overridden using <code>spec.restore.recoveryOnce</code>)</li> +</ul> + +<h2 id="example-aws-s3-backup-using-the-cli">Example AWS S3 backup using the CLI</h2> + +<p>This example shows abbreviated version of a simple AWS S3 backup implementation +using: <code>aws-cli</code>, <code>bash</code> and <code>kube2iam</code>.</p> + +<p>In addition to your normal <code>Jenkins</code> <code>CustomResource</code> some additional settings +for backup and restore are required, e.g.:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>example<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>namespace<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>masterAnnotations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>iam.amazonaws.com/role<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;my-example-backup-role&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># tell kube2iam where the AWS IAM role is</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containers<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-master<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>...<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container responsible for backup and restore</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>image<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>quay.io/virtuslab/aws-cli<span style="color:#000;font-weight:bold">:</span><span style="color:#0000cf;font-weight:bold">1.16</span>.<span style="color:#0000cf;font-weight:bold">263</span>-<span style="color:#0000cf;font-weight:bold">2</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>workingDir<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># our container entry point</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>sleep<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>infinity<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>env<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_BUCKET<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>my-example-bucket<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># the S3 bucket name to use</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_PATH<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>my-backup-path<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># the S3 bucket path prefix to use</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>JENKINS_HOME<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># the path to mount jenkins home dir in the backup container</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>volumeMounts<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># Jenkins home volume</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/backup.sh<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup-scripts<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>subPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup.sh<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>readOnly<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">true</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/restore.sh<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup-scripts<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>subPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>restore.sh<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>readOnly<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">true</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>volumes<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup-scripts<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configMap<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>defaultMode<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">0754</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-backup-s3<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>securityContext<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># make sure both containers use the same UID and GUID</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>runAsUser<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>fsGroup<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>...<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containerName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container name responsible for backup</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>interval<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">3600</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># how often make a backup in seconds</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>makeBackupBeforePodDeletion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">true</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># trigger backup just before deleting the pod</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>action<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># this command is invoked on &#34;backup&#34; container to create a backup,</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># &lt;backup_number&gt; is passed by operator,</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># for example /home/user/bin/backup.sh &lt;backup_number&gt;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/backup.sh<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>restore<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containerName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container name is responsible for restore backup</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>action<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># this command is invoked on &#34;backup&#34; container to restore a backup,</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># &lt;backup_number&gt; is passed by operator</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># for example /home/user/bin/restore.sh &lt;backup_number&gt;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/restore.sh<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span><span style="color:#8f5902;font-style:italic"># recoveryOnce: &lt;backup_number&gt; # if want to restore specific backup configure this field and then Jenkins will be restarted and desired backup will be restored</span></code></pre></div> +<p>The actual backup and restore scripts will be provided in a <code>ConfigMap</code>:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ConfigMap<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-backup-s3<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>namespace<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>labels<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>app<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup.sh<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>|<span style="color:#8f5902;font-style:italic">- +</span><span style="color:#8f5902;font-style:italic"> #!/bin/bash -xeu</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>!<span style="color:#f8f8f8;text-decoration:underline"> </span>$<span style="color:#8f5902;font-style:italic"># -eq 1 ]] &amp;&amp; echo &#34;Usage: $0 backup_number&#34; &amp;&amp; exit 1;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_BUCKET}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;BACKUP_BUCKET&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_PATH}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;BACKUP_PATH&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${JENKINS_HOME}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;JENKINS_HOME&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup_number=$<span style="color:#0000cf;font-weight:bold">1</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Running backup #${backup_number}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_TMP_DIR=$(mktemp<span style="color:#f8f8f8;text-decoration:underline"> </span>-d)<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>tar<span style="color:#f8f8f8;text-decoration:underline"> </span>-C<span style="color:#f8f8f8;text-decoration:underline"> </span>${JENKINS_HOME}<span style="color:#f8f8f8;text-decoration:underline"> </span>-czf<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_TMP_DIR}/${backup_number}.tar.gz&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>--exclude<span style="color:#f8f8f8;text-decoration:underline"> </span>jobs/<span style="color:#8f5902;font-style:italic">*/workspace*</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-c<span style="color:#f8f8f8;text-decoration:underline"> </span>jobs<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>\<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>aws<span style="color:#f8f8f8;text-decoration:underline"> </span>s3<span style="color:#f8f8f8;text-decoration:underline"> </span>cp<span style="color:#f8f8f8;text-decoration:underline"> </span>${BACKUP_TMP_DIR}/${backup_number}.tar.gz<span style="color:#f8f8f8;text-decoration:underline"> </span>s3<span style="color:#000;font-weight:bold">:</span>//${BACKUP_BUCKET}/${BACKUP_PATH}/${backup_number}.tar.gz<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span>Done<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>restore.sh<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>|<span style="color:#8f5902;font-style:italic">- +</span><span style="color:#8f5902;font-style:italic"> #!/bin/bash -xeu</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>!<span style="color:#f8f8f8;text-decoration:underline"> </span>$<span style="color:#8f5902;font-style:italic"># -eq 1 ]] &amp;&amp; echo &#34;Usage: $0 backup_number&#34; &amp;&amp; exit 1</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_BUCKET}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;BACKUP_BUCKET&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_PATH}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;BACKUP_PATH&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${JENKINS_HOME}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;JENKINS_HOME&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup_number=$<span style="color:#0000cf;font-weight:bold">1</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Running restore #${backup_number}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_TMP_DIR=$(mktemp<span style="color:#f8f8f8;text-decoration:underline"> </span>-d)<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>aws<span style="color:#f8f8f8;text-decoration:underline"> </span>s3<span style="color:#f8f8f8;text-decoration:underline"> </span>cp<span style="color:#f8f8f8;text-decoration:underline"> </span>s3<span style="color:#000;font-weight:bold">:</span>//${BACKUP_BUCKET}/${BACKUP_PATH}/${backup_number}.tar.gz<span style="color:#f8f8f8;text-decoration:underline"> </span>${BACKUP_TMP_DIR}/${backup_number}.tar.gz<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>tar<span style="color:#f8f8f8;text-decoration:underline"> </span>-C<span style="color:#f8f8f8;text-decoration:underline"> </span>${JENKINS_HOME}<span style="color:#f8f8f8;text-decoration:underline"> </span>-zxf<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_TMP_DIR}/${backup_number}.tar.gz&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span>Done</code></pre></div> +<p>In our example we will use S3 bucket lifecycle policy to keep +the number of backups under control, e.g. Cloud Formation fragment:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml"><span style="color:#f8f8f8;text-decoration:underline"> </span>Type<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>AWS<span style="color:#000;font-weight:bold">::</span>S3<span style="color:#000;font-weight:bold">::</span>Bucket<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Properties<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BucketName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>my-example-bucket<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>...<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>LifecycleConfiguration<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Rules<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>Id<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BackupCleanup<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Status<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Enabled<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Prefix<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>my-backup-path<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ExpirationInDays<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">7</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>NoncurrentVersionExpirationInDays<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">14</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>AbortIncompleteMultipartUpload<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>DaysAfterInitiation<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">3</span></code></pre></div> + + + + + Docs: Diagnostics + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/diagnostics/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/diagnostics/ + + + + + +<p>Turn on debug in <strong>Jenkins Operator</strong> deployment:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">sed -i <span style="color:#4e9a06">&#39;s|\(args:\).*|\1\ [&#34;--debug&#34;\]|&#39;</span> deploy/operator.yaml +kubectl apply -f deploy/operator.yaml</code></pre></div> +<p>Watch Kubernetes events:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl get events --sort-by<span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;{.lastTimestamp}&#39;</span></code></pre></div> +<p>Verify Jenkins master logs:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl logs -f jenkins-&lt;cr_name&gt;</code></pre></div> +<p>Verify the <code>jenkins-operator</code> logs:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl logs deployment/jenkins-operator</code></pre></div> +<h2 id="troubleshooting">Troubleshooting</h2> + +<p>Delete the Jenkins master pod and wait for the new one to come up:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl delete pod jenkins-&lt;cr_name&gt;</code></pre></div> + + + + + Docs: Schema + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/schema/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/schema/ + + + + + +<div class="pageinfo pageinfo-primary"> +<p>This document contains API scheme for <code>jenkins-operator</code> Custom Resource Definition manifest</p> + +</div> + + +<p>Packages:</p> +<ul> +<li> +<a href="#jenkins.io">jenkins.io</a> +</li> +</ul> +<h2 id="jenkins.io">jenkins.io</h2> +<p> +<p>Package v1alpha2 contains the API Schema definitions for the jenkins.io v1alpha2 API group</p> +</p> +Resource Types: +<ul><li> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Jenkins">Jenkins</a> +</li></ul> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Jenkins">Jenkins +</h3> +<p> +<p>Jenkins is the Schema for the jenkins API</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>apiVersion</code></br> +string</td> +<td> +<code> +jenkins.io/v1alpha2 +</code> +</td> +</tr> +<tr> +<td> +<code>kind</code></br> +string +</td> +<td><code>Jenkins</code></td> +</tr> +<tr> +<td> +<code>metadata</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#objectmeta-v1-meta"> +Kubernetes meta/v1.ObjectMeta +</a> +</em> +</td> +<td> +Refer to the Kubernetes API documentation for the fields of the +<code>metadata</code> field. +</td> +</tr> +<tr> +<td> +<code>spec</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsSpec"> +JenkinsSpec +</a> +</em> +</td> +<td> +<p>Spec defines the desired state of the Jenkins</p> +<br/> +<br/> +<table> +<tr> +<td> +<code>master</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsMaster"> +JenkinsMaster +</a> +</em> +</td> +<td> +<p>Master represents Jenkins master pod properties and Jenkins plugins. +Every single change here requires a pod restart.</p> +</td> +</tr> +<tr> +<td> +<code>seedJobs</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>SeedJobs defines a list of Jenkins Seed Job configurations +More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines</a></p> +</td> +</tr> +<tr> +<td> +<code>service</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service"> +Service +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Service is the Kubernetes service of the Jenkins master HTTP pod +Defaults to : +port: 8080 +type: ClusterIP</p> +</td> +</tr> +<tr> +<td> +<code>slaveService</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service"> +Service +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Service is the Kubernetes service of the Jenkins slave pods +Defaults to : +port: 50000 +type: ClusterIP</p> +</td> +</tr> +<tr> +<td> +<code>backup</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Backup"> +Backup +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Backup defines the configuration of a Jenkins backup +More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore</a></p> +</td> +</tr> +<tr> +<td> +<code>restore</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Restore"> +Restore +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Backup defines the configuration of a Jenkins backup restore +More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore</a></p> +</td> +</tr> +<tr> +<td> +<code>groovyScripts</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.GroovyScripts"> +GroovyScripts +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>GroovyScripts defines the configuration of Jenkins customization via groovy scripts</p> +</td> +</tr> +<tr> +<td> +<code>configurationAsCode</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigurationAsCode"> +ConfigurationAsCode +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>ConfigurationAsCode defines the configuration of Jenkins customization via the Configuration as Code Jenkins plugin</p> +</td> +</tr> +</table> +</td> +</tr> +<tr> +<td> +<code>status</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsStatus"> +JenkinsStatus +</a> +</em> +</td> +<td> +<p>Status defines the observed state of Jenkins</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.AppliedGroovyScript">AppliedGroovyScript +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsStatus">JenkinsStatus</a>) +</p> +<p> +<p>AppliedGroovyScript is the applied groovy script in Jenkins by the operator</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>configurationType</code></br> +<em> +string +</em> +</td> +<td> +<p>ConfigurationType is the name of the configuration type(base-groovy, user-groovy, user-casc)</p> +</td> +</tr> +<tr> +<td> +<code>source</code></br> +<em> +string +</em> +</td> +<td> +<p>Source is the name of source where is located groovy script</p> +</td> +</tr> +<tr> +<td> +<code>name</code></br> +<em> +string +</em> +</td> +<td> +<p>Name is the name of the groovy script</p> +</td> +</tr> +<tr> +<td> +<code>Hash</code></br> +<em> +string +</em> +</td> +<td> +<p>Hash is the hash of the groovy script and secrets which it uses</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Backup">Backup +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> +<p>Backup defines the configuration of a Jenkins backup</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>containerName</code></br> +<em> +string +</em> +</td> +<td> +<p>ContainerName is the container name responsible for backup operation</p> +</td> +</tr> +<tr> +<td> +<code>action</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Handler"> +Handler +</a> +</em> +</td> +<td> +<p>Action defines the action which performs the backup in the backup container sidecar</p> +</td> +</tr> +<tr> +<td> +<code>interval</code></br> +<em> +uint64 +</em> +</td> +<td> +<p>Interval tells you how often the backup is made in seconds +Defaults to 30.</p> +</td> +</tr> +<tr> +<td> +<code>makeBackupBeforePodDeletion</code></br> +<em> +bool +</em> +</td> +<td> +<p>MakeBackupBeforePodDeletion tells the operator to make a backup before Jenkins master pod deletion</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigMapRef">ConfigMapRef +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Customization">Customization</a>) +</p> +<p> +<p>ConfigMapRef is the reference to Kubernetes ConfigMap</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>name</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigurationAsCode">ConfigurationAsCode +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> +<p>ConfigurationAsCode defines configuration of Jenkins customization via the Configuration as Code Jenkins plugin</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>Customization</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Customization"> +Customization +</a> +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Container">Container +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsMaster">JenkinsMaster</a>) +</p> +<p> +<p>Container defines the Kubernetes container attributes</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>name</code></br> +<em> +string +</em> +</td> +<td> +<p>Name of the container specified as a DNS_LABEL. +Each container in a pod must have a unique name (DNS_LABEL).</p> +</td> +</tr> +<tr> +<td> +<code>image</code></br> +<em> +string +</em> +</td> +<td> +<p>Docker image name. +More info: <a href="https://kubernetes.io/docs/concepts/containers/images">https://kubernetes.io/docs/concepts/containers/images</a></p> +</td> +</tr> +<tr> +<td> +<code>imagePullPolicy</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#pullpolicy-v1-core"> +Kubernetes core/v1.PullPolicy +</a> +</em> +</td> +<td> +<p>Image pull policy. +One of Always, Never, IfNotPresent. +Defaults to Always.</p> +</td> +</tr> +<tr> +<td> +<code>resources</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#resourcerequirements-v1-core"> +Kubernetes core/v1.ResourceRequirements +</a> +</em> +</td> +<td> +<p>Compute Resources required by this container. +More info: <a href="https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/">https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/</a></p> +</td> +</tr> +<tr> +<td> +<code>command</code></br> +<em> +[]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Entrypoint array. Not executed within a shell. +The docker image&rsquo;s ENTRYPOINT is used if this is not provided. +Variable references $(VAR_NAME) are expanded using the container&rsquo;s environment. If a variable +cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax +can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, +regardless of whether the variable exists or not. +More info: <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell">https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell</a></p> +</td> +</tr> +<tr> +<td> +<code>args</code></br> +<em> +[]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Arguments to the entrypoint. +The docker image&rsquo;s CMD is used if this is not provided. +Variable references $(VAR_NAME) are expanded using the container&rsquo;s environment. If a variable +cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax +can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, +regardless of whether the variable exists or not. +More info: <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell">https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell</a></p> +</td> +</tr> +<tr> +<td> +<code>workingDir</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Container&rsquo;s working directory. +If not specified, the container runtime&rsquo;s default will be used, which +might be configured in the container image.</p> +</td> +</tr> +<tr> +<td> +<code>ports</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#containerport-v1-core"> +[]Kubernetes core/v1.ContainerPort +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>List of ports to expose from the container. Exposing a port here gives +the system additional information about the network connections a +container uses, but is primarily informational. Not specifying a port here +DOES NOT prevent that port from being exposed. Any port which is +listening on the default &ldquo;0.0.0.0&rdquo; address inside a container will be +accessible from the network.</p> +</td> +</tr> +<tr> +<td> +<code>envFrom</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#envfromsource-v1-core"> +[]Kubernetes core/v1.EnvFromSource +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>List of sources to populate environment variables in the container. +The keys defined within a source must be a C_IDENTIFIER. All invalid keys +will be reported as an event when the container is starting. When a key exists in multiple +sources, the value associated with the last source will take precedence. +Values defined by an Env with a duplicate key will take precedence.</p> +</td> +</tr> +<tr> +<td> +<code>env</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#envvar-v1-core"> +[]Kubernetes core/v1.EnvVar +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>List of environment variables to set in the container.</p> +</td> +</tr> +<tr> +<td> +<code>volumeMounts</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#volumemount-v1-core"> +[]Kubernetes core/v1.VolumeMount +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Pod volumes to mount into the container&rsquo;s filesystem.</p> +</td> +</tr> +<tr> +<td> +<code>livenessProbe</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#probe-v1-core"> +Kubernetes core/v1.Probe +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Periodic probe of container liveness. +Container will be restarted if the probe fails.</p> +</td> +</tr> +<tr> +<td> +<code>readinessProbe</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#probe-v1-core"> +Kubernetes core/v1.Probe +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Periodic probe of container service readiness. +Container will be removed from service endpoints if the probe fails.</p> +</td> +</tr> +<tr> +<td> +<code>lifecycle</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#lifecycle-v1-core"> +Kubernetes core/v1.Lifecycle +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Actions that the management system should take in response to container lifecycle events.</p> +</td> +</tr> +<tr> +<td> +<code>securityContext</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#securitycontext-v1-core"> +Kubernetes core/v1.SecurityContext +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Security options the pod should run with. +More info: <a href="https://kubernetes.io/docs/concepts/policy/security-context/">https://kubernetes.io/docs/concepts/policy/security-context/</a> +More info: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/">https://kubernetes.io/docs/tasks/configure-pod-container/security-context/</a></p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Customization">Customization +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.ConfigurationAsCode">ConfigurationAsCode</a>, +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.GroovyScripts">GroovyScripts</a>) +</p> +<p> +<p>Customization defines configuration of Jenkins customization</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>secret</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretRef"> +SecretRef +</a> +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>configurations</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigMapRef"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigMapRef +</a> +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.GroovyScripts">GroovyScripts +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> +<p>GroovyScripts defines configuration of Jenkins customization via groovy scripts</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>Customization</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Customization"> +Customization +</a> +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Handler">Handler +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Backup">Backup</a>, +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Restore">Restore</a>) +</p> +<p> +<p>Handler defines a specific action that should be taken</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>exec</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#execaction-v1-core"> +Kubernetes core/v1.ExecAction +</a> +</em> +</td> +<td> +<p>Exec specifies the action to take.</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsCredentialType">JenkinsCredentialType +(<code>string</code> alias)</p></h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.SeedJob">SeedJob</a>) +</p> +<p> +<p>JenkinsCredentialType defines the type of Jenkins credential used in the seed job mechanism</p> +</p> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsMaster">JenkinsMaster +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> +<p>JenkinsMaster defines the Jenkins master pod attributes and plugins, +every single change requires a Jenkins master pod restart</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>masterAnnotations</code></br> +<em> +map[string]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Annotations is an unstructured key value map stored with a resource that may be +set by external tools to store and retrieve arbitrary metadata. They are not +queryable and should be preserved when modifying objects. +More info: <a href="http://kubernetes.io/docs/user-guide/annotations">http://kubernetes.io/docs/user-guide/annotations</a></p> +</td> +</tr> +<tr> +<td> +<code>nodeSelector</code></br> +<em> +map[string]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>NodeSelector is a selector which must be true for the pod to fit on a node. +Selector which must match a node&rsquo;s labels for the pod to be scheduled on that node. +More info: <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/">https://kubernetes.io/docs/concepts/configuration/assign-pod-node/</a></p> +</td> +</tr> +<tr> +<td> +<code>securityContext</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#podsecuritycontext-v1-core"> +Kubernetes core/v1.PodSecurityContext +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>SecurityContext that applies to all the containers of the Jenkins +Master. As per kubernetes specification, it can be overridden +for each container individually. +Defaults to: +runAsUser: 1000 +fsGroup: 1000</p> +</td> +</tr> +<tr> +<td> +<code>containers</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Container"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Container +</a> +</em> +</td> +<td> +<p>List of containers belonging to the pod. +Containers cannot currently be added or removed. +There must be at least one container in a Pod. +Defaults to: +- image: jenkins/jenkins:lts +imagePullPolicy: Always +livenessProbe: +failureThreshold: 12 +httpGet: +path: /login +port: http +scheme: HTTP +initialDelaySeconds: 80 +periodSeconds: 10 +successThreshold: 1 +timeoutSeconds: 5 +name: jenkins-master +readinessProbe: +failureThreshold: 3 +httpGet: +path: /login +port: http +scheme: HTTP +initialDelaySeconds: 30 +periodSeconds: 10 +successThreshold: 1 +timeoutSeconds: 1 +resources: +limits: +cpu: 1500m +memory: 3Gi +requests: +cpu: &ldquo;1&rdquo; +memory: 600Mi</p> +</td> +</tr> +<tr> +<td> +<code>imagePullSecrets</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#localobjectreference-v1-core"> +[]Kubernetes core/v1.LocalObjectReference +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. +If specified, these secrets will be passed to individual puller implementations for them to use. For example, +in the case of docker, only DockerConfig type secrets are honored. +More info: <a href="https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod">https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod</a></p> +</td> +</tr> +<tr> +<td> +<code>volumes</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#volume-v1-core"> +[]Kubernetes core/v1.Volume +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>List of volumes that can be mounted by containers belonging to the pod. +More info: <a href="https://kubernetes.io/docs/concepts/storage/volumes">https://kubernetes.io/docs/concepts/storage/volumes</a></p> +</td> +</tr> +<tr> +<td> +<code>basePlugins</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin +</a> +</em> +</td> +<td> +<p>BasePlugins contains plugins required by operator +Defaults to : +- name: kubernetes +version: 1.15.7 +- name: workflow-job +version: &ldquo;2.32&rdquo; +- name: workflow-aggregator +version: &ldquo;2.6&rdquo; +- name: git +version: 3.10.0 +- name: job-dsl +version: &ldquo;1.74&rdquo; +- name: configuration-as-code +version: &ldquo;1.19&rdquo; +- name: configuration-as-code-support +version: &ldquo;1.19&rdquo; +- name: kubernetes-credentials-provider +version: 0.12.1</p> +</td> +</tr> +<tr> +<td> +<code>plugins</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Plugins contains plugins required by user</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsSpec">JenkinsSpec +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Jenkins">Jenkins</a>) +</p> +<p> +<p>JenkinsSpec defines the desired state of the Jenkins</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>master</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsMaster"> +JenkinsMaster +</a> +</em> +</td> +<td> +<p>Master represents Jenkins master pod properties and Jenkins plugins. +Every single change here requires a pod restart.</p> +</td> +</tr> +<tr> +<td> +<code>seedJobs</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>SeedJobs defines list of Jenkins Seed Job configurations +More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines</a></p> +</td> +</tr> +<tr> +<td> +<code>service</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service"> +Service +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Service is Kubernetes service of Jenkins master HTTP pod +Defaults to : +port: 8080 +type: ClusterIP</p> +</td> +</tr> +<tr> +<td> +<code>slaveService</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service"> +Service +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Service is Kubernetes service of Jenkins slave pods +Defaults to : +port: 50000 +type: ClusterIP</p> +</td> +</tr> +<tr> +<td> +<code>backup</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Backup"> +Backup +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Backup defines configuration of Jenkins backup +More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore</a></p> +</td> +</tr> +<tr> +<td> +<code>restore</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Restore"> +Restore +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Backup defines configuration of Jenkins backup restore +More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore</a></p> +</td> +</tr> +<tr> +<td> +<code>groovyScripts</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.GroovyScripts"> +GroovyScripts +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>GroovyScripts defines configuration of Jenkins customization via groovy scripts</p> +</td> +</tr> +<tr> +<td> +<code>configurationAsCode</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigurationAsCode"> +ConfigurationAsCode +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>ConfigurationAsCode defines configuration of Jenkins customization via Configuration as Code Jenkins plugin</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsStatus">JenkinsStatus +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Jenkins">Jenkins</a>) +</p> +<p> +<p>JenkinsStatus defines the observed state of Jenkins</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>operatorVersion</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>OperatorVersion is the operator version which manages this CR</p> +</td> +</tr> +<tr> +<td> +<code>provisionStartTime</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#time-v1-meta"> +Kubernetes meta/v1.Time +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>ProvisionStartTime is a time when Jenkins master pod has been created</p> +</td> +</tr> +<tr> +<td> +<code>baseConfigurationCompletedTime</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#time-v1-meta"> +Kubernetes meta/v1.Time +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>BaseConfigurationCompletedTime is a time when Jenkins base configuration phase has been completed</p> +</td> +</tr> +<tr> +<td> +<code>userConfigurationCompletedTime</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#time-v1-meta"> +Kubernetes meta/v1.Time +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>UserConfigurationCompletedTime is a time when Jenkins user configuration phase has been completed</p> +</td> +</tr> +<tr> +<td> +<code>restoredBackup</code></br> +<em> +uint64 +</em> +</td> +<td> +<em>(Optional)</em> +<p>RestoredBackup is the restored backup number after Jenkins master pod restart</p> +</td> +</tr> +<tr> +<td> +<code>lastBackup</code></br> +<em> +uint64 +</em> +</td> +<td> +<em>(Optional)</em> +<p>LastBackup is the latest backup number</p> +</td> +</tr> +<tr> +<td> +<code>pendingBackup</code></br> +<em> +uint64 +</em> +</td> +<td> +<em>(Optional)</em> +<p>PendingBackup is the pending backup number</p> +</td> +</tr> +<tr> +<td> +<code>backupDoneBeforePodDeletion</code></br> +<em> +bool +</em> +</td> +<td> +<em>(Optional)</em> +<p>BackupDoneBeforePodDeletion tells if backup before pod deletion has been made</p> +</td> +</tr> +<tr> +<td> +<code>userAndPasswordHash</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>UserAndPasswordHash is a SHA256 hash made from the username and password</p> +</td> +</tr> +<tr> +<td> +<code>createdSeedJobs</code></br> +<em> +[]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>CreatedSeedJobs contains list of seed job ids already created in Jenkins</p> +</td> +</tr> +<tr> +<td> +<code>appliedGroovyScripts</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.AppliedGroovyScript"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.AppliedGroovyScript +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>AppliedGroovyScripts is a list with all applied groovy scripts in Jenkins by the operator</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Mailgun">Mailgun +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Notification">Notification</a>) +</p> +<p> +<p>Mailgun is handler for Mailgun email service notification channel</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>domain</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>apiKeySecretKeySelector</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector"> +SecretKeySelector +</a> +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>recipient</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>from</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.MicrosoftTeams">MicrosoftTeams +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Notification">Notification</a>) +</p> +<p> +<p>MicrosoftTeams is handler for Microsoft MicrosoftTeams notification channel</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>webHookURLSecretKeySelector</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector"> +SecretKeySelector +</a> +</em> +</td> +<td> +<p>The web hook URL to MicrosoftTeams App</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Notification">Notification +</h3> +<p> +<p>Notification is a service configuration used to send notifications about Jenkins status</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>loggingLevel</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.NotificationLogLevel"> +NotificationLogLevel +</a> +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>verbose</code></br> +<em> +bool +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>name</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>slack</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Slack"> +github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Slack +</a> +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>teams</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.MicrosoftTeams"> +github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.MicrosoftTeams +</a> +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>mailgun</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Mailgun"> +github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Mailgun +</a> +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.NotificationLogLevel">NotificationLogLevel +(<code>string</code> alias)</p></h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Notification">Notification</a>) +</p> +<p> +<p>NotificationLogLevel defines logging level of Notification</p> +</p> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin">Plugin +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsMaster">JenkinsMaster</a>) +</p> +<p> +<p>Plugin defines Jenkins plugin</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>name</code></br> +<em> +string +</em> +</td> +<td> +<p>Name is the name of Jenkins plugin</p> +</td> +</tr> +<tr> +<td> +<code>version</code></br> +<em> +string +</em> +</td> +<td> +<p>Version is the version of Jenkins plugin</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Restore">Restore +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> +<p>Restore defines configuration of Jenkins backup restore operation</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>containerName</code></br> +<em> +string +</em> +</td> +<td> +<p>ContainerName is the container name responsible for restore backup operation</p> +</td> +</tr> +<tr> +<td> +<code>action</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Handler"> +Handler +</a> +</em> +</td> +<td> +<p>Action defines action which performs restore backup in restore container sidecar</p> +</td> +</tr> +<tr> +<td> +<code>recoveryOnce</code></br> +<em> +uint64 +</em> +</td> +<td> +<em>(Optional)</em> +<p>RecoveryOnce if want to restore specific backup set this field and then Jenkins will be restarted and desired backup will be restored</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector">SecretKeySelector +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Mailgun">Mailgun</a>, +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.MicrosoftTeams">MicrosoftTeams</a>, +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Slack">Slack</a>) +</p> +<p> +<p>SecretKeySelector selects a key of a Secret.</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>secret</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#localobjectreference-v1-core"> +Kubernetes core/v1.LocalObjectReference +</a> +</em> +</td> +<td> +<p>The name of the secret in the pod&rsquo;s namespace to select from.</p> +</td> +</tr> +<tr> +<td> +<code>key</code></br> +<em> +string +</em> +</td> +<td> +<p>The key of the secret to select from. Must be a valid secret key.</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretRef">SecretRef +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Customization">Customization</a>) +</p> +<p> +<p>SecretRef is reference to Kubernetes secret</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>name</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob">SeedJob +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> +<p>SeedJob defines configuration for seed job +More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines</a></p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>id</code></br> +<em> +string +</em> +</td> +<td> +<p>ID is the unique seed job name</p> +</td> +</tr> +<tr> +<td> +<code>credentialID</code></br> +<em> +string +</em> +</td> +<td> +<p>CredentialID is the Kubernetes secret name which stores repository access credentials</p> +</td> +</tr> +<tr> +<td> +<code>description</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Description is the description of the seed job</p> +</td> +</tr> +<tr> +<td> +<code>targets</code></br> +<em> +string +</em> +</td> +<td> +<p>Targets is the repository path where the seed job definitions are</p> +</td> +</tr> +<tr> +<td> +<code>repositoryBranch</code></br> +<em> +string +</em> +</td> +<td> +<p>RepositoryBranch is the repository branch where the seed job definitions are</p> +</td> +</tr> +<tr> +<td> +<code>repositoryUrl</code></br> +<em> +string +</em> +</td> +<td> +<p>RepositoryURL is the repository access URL. Can be SSH or HTTPS.</p> +</td> +</tr> +<tr> +<td> +<code>credentialType</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsCredentialType"> +JenkinsCredentialType +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>JenkinsCredentialType is the <a href="https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/">https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/</a> credential type</p> +</td> +</tr> +<tr> +<td> +<code>githubPushTrigger</code></br> +<em> +bool +</em> +</td> +<td> +<em>(Optional)</em> +<p>GitHubPushTrigger is used for GitHub web hooks</p> +</td> +</tr> +<tr> +<td> +<code>buildPeriodically</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>BuildPeriodically is setting for scheduled trigger</p> +</td> +</tr> +<tr> +<td> +<code>pollSCM</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>PollSCM is setting for polling changes in SCM</p> +</td> +</tr> +<tr> +<td> +<code>ignoreMissingFiles</code></br> +<em> +bool +</em> +</td> +<td> +<em>(Optional)</em> +<p>IgnoreMissingFiles is setting for Job DSL API plugin to ignore files that miss</p> +</td> +</tr> +<tr> +<td> +<code>additionalClasspath</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>AdditionalClasspath is setting for Job DSL API plugin to set Additional Classpath</p> +</td> +</tr> +<tr> +<td> +<code>failOnMissingPlugin</code></br> +<em> +bool +</em> +</td> +<td> +<em>(Optional)</em> +<p>FailOnMissingPlugin is setting for Job DSL API plugin that fails job if required plugin is missing</p> +</td> +</tr> +<tr> +<td> +<code>unstableOnDeprecation</code></br> +<em> +bool +</em> +</td> +<td> +<em>(Optional)</em> +<p>UnstableOnDeprecation is setting for Job DSL API plugin that sets build status as unstable if build using deprecated features</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service">Service +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> +<p>Service defines Kubernetes service attributes</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>annotations</code></br> +<em> +map[string]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Annotations is an unstructured key value map stored with a resource that may be +set by external tools to store and retrieve arbitrary metadata. They are not +queryable and should be preserved when modifying objects. +More info: <a href="http://kubernetes.io/docs/user-guide/annotations">http://kubernetes.io/docs/user-guide/annotations</a></p> +</td> +</tr> +<tr> +<td> +<code>labels</code></br> +<em> +map[string]string +</em> +</td> +<td> +<p>Route service traffic to pods with label keys and values matching this +selector. If empty or not present, the service is assumed to have an +external process managing its endpoints, which Kubernetes will not +modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. +Ignored if type is ExternalName. +More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/">https://kubernetes.io/docs/concepts/services-networking/service/</a></p> +</td> +</tr> +<tr> +<td> +<code>type</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#servicetype-v1-core"> +Kubernetes core/v1.ServiceType +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Type determines how the Service is exposed. Defaults to ClusterIP. Valid +options are ExternalName, ClusterIP, NodePort, and LoadBalancer. +&ldquo;ExternalName&rdquo; maps to the specified externalName. +&ldquo;ClusterIP&rdquo; allocates a cluster-internal IP address for load-balancing to +endpoints. Endpoints are determined by the selector or if that is not +specified, by manual construction of an Endpoints object. If clusterIP is +&ldquo;None&rdquo;, no virtual IP is allocated and the endpoints are published as a +set of endpoints rather than a stable IP. +&ldquo;NodePort&rdquo; builds on ClusterIP and allocates a port on every node which +routes to the clusterIP. +&ldquo;LoadBalancer&rdquo; builds on NodePort and creates an +external load-balancer (if supported in the current cloud) which routes +to the clusterIP. +More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types">https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services&mdash;service-types</a></p> +</td> +</tr> +<tr> +<td> +<code>port</code></br> +<em> +int32 +</em> +</td> +<td> +<p>The port that is exposed by this service. +More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies">https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies</a></p> +</td> +</tr> +<tr> +<td> +<code>nodePort</code></br> +<em> +int32 +</em> +</td> +<td> +<em>(Optional)</em> +<p>The port on each node on which this service is exposed when type=NodePort or LoadBalancer. +Usually assigned by the system. If specified, it will be allocated to the service +if unused, or else creation of the service will fail. +Default is to auto-allocate a port if the ServiceType of this Service requires one. +More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport">https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport</a></p> +</td> +</tr> +<tr> +<td> +<code>loadBalancerSourceRanges</code></br> +<em> +[]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>If specified and supported by the platform, this will restrict traffic through the cloud-provider +the load-balancer will be restricted to the specified client IPs. This field will be ignored if the +cloud-provider does not support the feature.&rdquo; +More info: <a href="https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/">https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/</a></p> +</td> +</tr> +<tr> +<td> +<code>loadBalancerIP</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Only applies to Service Type: LoadBalancer +LoadBalancer will get created with the IP specified in this field. +This feature depends on whether the underlying cloud-provider supports specifying +the loadBalancerIP when a load balancer is created. +This field will be ignored if the cloud-provider does not support the feature.</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Slack">Slack +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Notification">Notification</a>) +</p> +<p> +<p>Slack is handler for Slack notification channel</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>webHookURLSecretKeySelector</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector"> +SecretKeySelector +</a> +</em> +</td> +<td> +<p>The web hook URL to Slack App</p> +</td> +</tr> +</tbody> +</table> +<hr/> +<p><em> +Generated with <code>gen-crd-api-reference-docs</code> +on git commit <code>f4c4235</code>. +</em></p> + + + + + + Docs: Developer Guide + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/developer-guide/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/developer-guide/ + + + + + + + +<div class="pageinfo pageinfo-primary"> +<p>This document explains how to setup your development environment.</p> + +</div> + + +<h2 id="prerequisites">Prerequisites</h2> + +<ul> +<li><a href="https://github.com/operator-framework/operator-sdk" target="_blank">operator_sdk</a> version v0.8.1</li> +<li><a href="https://git-scm.com/downloads" target="_blank">git</a></li> +<li><a href="https://golang.org/dl/" target="_blank">go</a> version v1.12+</li> +<li><a href="install_dev_tools.md" target="_blank">goimports, golint, checkmake and staticcheck</a></li> +<li><a href="https://kubernetes.io/docs/tasks/tools/install-minikube/" target="_blank">minikube</a> version v1.1.0+ (preferred Hypervisor - <a href="https://www.virtualbox.org/wiki/Downloads" target="_blank">virtualbox</a>)</li> +<li><a href="https://docs.docker.com/install/" target="_blank">docker</a> version 17.03+</li> +</ul> + +<h2 id="clone-repository-and-download-dependencies">Clone repository and download dependencies</h2> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">mkdir -p <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci +<span style="color:#204a87">cd</span> <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci/ +git clone git@github.com:jenkinsci/kubernetes-operator.git +<span style="color:#204a87">cd</span> kubernetes-operator +make go-dependencies</code></pre></div> +<h2 id="build-and-run-with-a-minikube">Build and run with a minikube</h2> + +<p>Build and run <strong>Jenkins Operator</strong> locally:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build minikube-run <span style="color:#000">OPERATOR_EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--jenkins-api-hostname=$(eval minikube ip) --jenkins-api-use-nodeport=true&#39;</span></code></pre></div> +<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl get jenkins -o yaml +kubectl get po</code></pre></div> +<h2 id="build-and-run-with-a-remote-kubernetes-cluster">Build and run with a remote Kubernetes cluster</h2> + +<p>You can also run the controller locally and make it listen to a remote Kubernetes server.</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make run <span style="color:#000">NAMESPACE</span><span style="color:#ce5c00;font-weight:bold">=</span>default <span style="color:#000">KUBECTL_CONTEXT</span><span style="color:#ce5c00;font-weight:bold">=</span>remote-k8s <span style="color:#000">OPERATOR_EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--kubeconfig ~/.kube/config&#39;</span></code></pre></div> +<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl --context remote-k8s --namespace default get jenkins -o yaml +kubectl --context remote-k8s --namespace default get po</code></pre></div> +<h2 id="testing">Testing</h2> + +<p>Run unit tests:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make test</code></pre></div> +<h3 id="running-e2e-tests-on-linux">Running E2E tests on Linux</h3> + +<p>Run e2e tests with minikube:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make minikube-start +<span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> +make build e2e <span style="color:#000">config</span><span style="color:#ce5c00;font-weight:bold">=</span>config.minikube.env <span style="color:#000">CONTAINER_RUNTIME</span><span style="color:#ce5c00;font-weight:bold">=</span>podman</code></pre></div> +<p><code>config.minikube.env</code> is the E2E test profile which provides all connection info to operator to run on minikube.</p> + +<p>Run the specific e2e test:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build e2e <span style="color:#000">E2E_TEST_SELECTOR</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;^TestConfiguration$&#39;</span> <span style="color:#000">config</span><span style="color:#ce5c00;font-weight:bold">=</span>config.minikube.env <span style="color:#000">CONTAINER_RUNTIME</span><span style="color:#ce5c00;font-weight:bold">=</span>podman</code></pre></div> +<p>If you want to run E2E tests on CRC (Code Ready Containers by OpenShift), you should use <code>config.crc.env</code> profile instead of <code>config.minikube.env</code>. +If you have some trouble with <code>podman</code> (for example building) then check <a href="#using-docker-instead-of-podman">how to use docker instead of podman</a>.</p> + +<h3 id="running-e2e-tests-on-macos">Running E2E tests on macOS</h3> + +<p>At first, you need to start minikube:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make minikube-start +$ <span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> </code></pre></div> +<p>Build a Docker image inside the provided Linux container by:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make indocker</code></pre></div> +<p>Build <strong>Jenkins Operator</strong> inside a container using:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make build</code></pre></div> +<p>Then exit the container and run:</p> + +<pre><code>make e2e config=config.minikube.env +</code></pre> + +<p>or using <code>crc</code> as cluster software:</p> + +<pre><code>make e2e config=config.crc.env +</code></pre> + +<h3 id="using-docker-instead-of-podman">Using Docker instead of podman</h3> + +<p>If you have trouble with building image using the <code>podman</code>, you can set additional flag <code>IMAGE_PULL_MODE</code> to pull image from the organization.</p> + +<p>At first, you need to edit <code>config.base.env</code> and change the <code>DOCKER_ORGANIZATION</code> to your <a href="https://hub.docker.com/" target="_blank">Docker Hub</a> account/organization. +After this change the <code>IMAGE_PULL_MODE</code> to <code>remote</code>. It will setup the <code>Makefile</code> goal to pull Docker image from registry. +Then you need to pull image from your repository:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make container-runtime-build container-runtime-snapshot-push</code></pre></div> +<p>When image will be uploaded to repository, you can now write this command to run E2E tests:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make e2e <span style="color:#000">E2E_TEST_SELECTOR</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;^TestConfiguration$&#39;</span> <span style="color:#000">config</span><span style="color:#ce5c00;font-weight:bold">=</span>config.crc.env</code></pre></div> +<h2 id="tips-tricks">Tips &amp; Tricks</h2> + +<h3 id="building-docker-image-on-minikube-for-e2e-tests">Building docker image on minikube (for e2e tests)</h3> + +<p>To be able to work with the docker daemon on <code>minikube</code> machine run the following command before building an image:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span></code></pre></div> +<h3 id="when-pkg-apis-jenkinsio-jenkins-types-go-has-changed">When <code>pkg/apis/jenkinsio/*/jenkins_types.go</code> has changed</h3> + +<p>Run:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make deepcopy-gen</code></pre></div> +<h3 id="getting-the-jenkins-url-and-basic-credentials">Getting the Jenkins URL and basic credentials</h3> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">minikube service jenkins-operator-http-&lt;cr_name&gt; --url +kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.user}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d +kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.password}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d</code></pre></div> +<h1 id="tools">Tools</h1> + +<h2 id="configure-environment-variables">Configure environment variables</h2> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">export</span> <span style="color:#000">GOPATH</span><span style="color:#ce5c00;font-weight:bold">=</span>/home/go <span style="color:#8f5902;font-style:italic"># example value</span> +<span style="color:#204a87">export</span> <span style="color:#000">GOROOT</span><span style="color:#ce5c00;font-weight:bold">=</span>/usr/lib/go-1.12 <span style="color:#8f5902;font-style:italic"># example value</span> +<span style="color:#204a87">export</span> <span style="color:#000">PATH</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#000">$GOPATH</span>/bin:<span style="color:#000">$PATH</span></code></pre></div> +<h2 id="goimports">goimports</h2> + +<pre><code>go get golang.org/x/tools/cmd/goimports +cd $GOPATH/src/golang.org/x/tools/cmd/goimports +go build +go install +</code></pre> + +<h2 id="golint">golint</h2> + +<pre><code>go get -u golang.org/x/lint/golint +cd $GOPATH/src/golang.org/x/lint/golint +go build +go install +</code></pre> + +<h2 id="checkmake">checkmake</h2> + +<pre><code>go get github.com/mrtazz/checkmake +cd $GOPATH/src/github.com/mrtazz/checkmake +go build +go install +</code></pre> + +<h2 id="staticcheck">staticcheck</h2> + +<pre><code>mkdir -p $GOPATH/src/github.com/dominikh/ +cd $GOPATH/src/github.com/dominikh/ +git clone https://github.com/dominikh/go-tools.git +cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck +go build +go install +</code></pre> + + + + + + \ No newline at end of file diff --git a/docs/docs/getting-started/future/schema/index.html b/docs/docs/getting-started/future/schema/index.html new file mode 100644 index 00000000..ff41940f --- /dev/null +++ b/docs/docs/getting-started/future/schema/index.html @@ -0,0 +1,2569 @@ + + + + + + + + + + + + + + + + + + + + + + +Schema | Jenkins Operator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Schema | Jenkins Operator + + +
+ + + +
+
+
+
+
+ + + + + +
+ + + + +
+ + + + +
+
+ + + + + + + + + + + +
+
+ + + +
+

Schema

+
API Schema definitions for Jenkins CRD
+ + +
+

This document contains API scheme for jenkins-operator Custom Resource Definition manifest

+ +
+ + +

Packages:

+ +

jenkins.io

+

+

Package v1alpha2 contains the API Schema definitions for the jenkins.io v1alpha2 API group

+

+Resource Types: + +

Jenkins +

+

+

Jenkins is the Schema for the jenkins API

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+apiVersion
+string
+ +jenkins.io/v1alpha2 + +
+kind
+string +
Jenkins
+metadata
+ + +Kubernetes meta/v1.ObjectMeta + + +
+Refer to the Kubernetes API documentation for the fields of the +metadata field. +
+spec
+ + +JenkinsSpec + + +
+

Spec defines the desired state of the Jenkins

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+master
+ + +JenkinsMaster + + +
+

Master represents Jenkins master pod properties and Jenkins plugins. +Every single change here requires a pod restart.

+
+seedJobs
+ + +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob + + +
+(Optional) +

SeedJobs defines a list of Jenkins Seed Job configurations +More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines

+
+service
+ + +Service + + +
+(Optional) +

Service is the Kubernetes service of the Jenkins master HTTP pod +Defaults to : +port: 8080 +type: ClusterIP

+
+slaveService
+ + +Service + + +
+(Optional) +

Service is the Kubernetes service of the Jenkins slave pods +Defaults to : +port: 50000 +type: ClusterIP

+
+backup
+ + +Backup + + +
+(Optional) +

Backup defines the configuration of a Jenkins backup +More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

+
+restore
+ + +Restore + + +
+(Optional) +

Backup defines the configuration of a Jenkins backup restore +More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

+
+groovyScripts
+ + +GroovyScripts + + +
+(Optional) +

GroovyScripts defines the configuration of Jenkins customization via groovy scripts

+
+configurationAsCode
+ + +ConfigurationAsCode + + +
+(Optional) +

ConfigurationAsCode defines the configuration of Jenkins customization via the Configuration as Code Jenkins plugin

+
+
+status
+ + +JenkinsStatus + + +
+

Status defines the observed state of Jenkins

+
+

AppliedGroovyScript +

+

+(Appears on: +JenkinsStatus) +

+

+

AppliedGroovyScript is the applied groovy script in Jenkins by the operator

+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+configurationType
+ +string + +
+

ConfigurationType is the name of the configuration type(base-groovy, user-groovy, user-casc)

+
+source
+ +string + +
+

Source is the name of source where is located groovy script

+
+name
+ +string + +
+

Name is the name of the groovy script

+
+Hash
+ +string + +
+

Hash is the hash of the groovy script and secrets which it uses

+
+

Backup +

+

+(Appears on: +JenkinsSpec) +

+

+

Backup defines the configuration of a Jenkins backup

+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+containerName
+ +string + +
+

ContainerName is the container name responsible for backup operation

+
+action
+ + +Handler + + +
+

Action defines the action which performs the backup in the backup container sidecar

+
+interval
+ +uint64 + +
+

Interval tells you how often the backup is made in seconds +Defaults to 30.

+
+makeBackupBeforePodDeletion
+ +bool + +
+

MakeBackupBeforePodDeletion tells the operator to make a backup before Jenkins master pod deletion

+
+

ConfigMapRef +

+

+(Appears on: +Customization) +

+

+

ConfigMapRef is the reference to Kubernetes ConfigMap

+

+ + + + + + + + + + + + + +
FieldDescription
+name
+ +string + +
+
+

ConfigurationAsCode +

+

+(Appears on: +JenkinsSpec) +

+

+

ConfigurationAsCode defines configuration of Jenkins customization via the Configuration as Code Jenkins plugin

+

+ + + + + + + + + + + + + +
FieldDescription
+Customization
+ + +Customization + + +
+
+

Container +

+

+(Appears on: +JenkinsMaster) +

+

+

Container defines the Kubernetes container attributes

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+name
+ +string + +
+

Name of the container specified as a DNS_LABEL. +Each container in a pod must have a unique name (DNS_LABEL).

+
+image
+ +string + +
+

Docker image name. +More info: https://kubernetes.io/docs/concepts/containers/images

+
+imagePullPolicy
+ + +Kubernetes core/v1.PullPolicy + + +
+

Image pull policy. +One of Always, Never, IfNotPresent. +Defaults to Always.

+
+resources
+ + +Kubernetes core/v1.ResourceRequirements + + +
+

Compute Resources required by this container. +More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/

+
+command
+ +[]string + +
+(Optional) +

Entrypoint array. Not executed within a shell. +The docker image’s ENTRYPOINT is used if this is not provided. +Variable references $(VAR_NAME) are expanded using the container’s environment. If a variable +cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax +can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, +regardless of whether the variable exists or not. +More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell

+
+args
+ +[]string + +
+(Optional) +

Arguments to the entrypoint. +The docker image’s CMD is used if this is not provided. +Variable references $(VAR_NAME) are expanded using the container’s environment. If a variable +cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax +can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, +regardless of whether the variable exists or not. +More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell

+
+workingDir
+ +string + +
+(Optional) +

Container’s working directory. +If not specified, the container runtime’s default will be used, which +might be configured in the container image.

+
+ports
+ + +[]Kubernetes core/v1.ContainerPort + + +
+(Optional) +

List of ports to expose from the container. Exposing a port here gives +the system additional information about the network connections a +container uses, but is primarily informational. Not specifying a port here +DOES NOT prevent that port from being exposed. Any port which is +listening on the default “0.0.0.0” address inside a container will be +accessible from the network.

+
+envFrom
+ + +[]Kubernetes core/v1.EnvFromSource + + +
+(Optional) +

List of sources to populate environment variables in the container. +The keys defined within a source must be a C_IDENTIFIER. All invalid keys +will be reported as an event when the container is starting. When a key exists in multiple +sources, the value associated with the last source will take precedence. +Values defined by an Env with a duplicate key will take precedence.

+
+env
+ + +[]Kubernetes core/v1.EnvVar + + +
+(Optional) +

List of environment variables to set in the container.

+
+volumeMounts
+ + +[]Kubernetes core/v1.VolumeMount + + +
+(Optional) +

Pod volumes to mount into the container’s filesystem.

+
+livenessProbe
+ + +Kubernetes core/v1.Probe + + +
+(Optional) +

Periodic probe of container liveness. +Container will be restarted if the probe fails.

+
+readinessProbe
+ + +Kubernetes core/v1.Probe + + +
+(Optional) +

Periodic probe of container service readiness. +Container will be removed from service endpoints if the probe fails.

+
+lifecycle
+ + +Kubernetes core/v1.Lifecycle + + +
+(Optional) +

Actions that the management system should take in response to container lifecycle events.

+
+securityContext
+ + +Kubernetes core/v1.SecurityContext + + +
+(Optional) +

Security options the pod should run with. +More info: https://kubernetes.io/docs/concepts/policy/security-context/ +More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/

+
+

Customization +

+

+(Appears on: +ConfigurationAsCode, +GroovyScripts) +

+

+

Customization defines configuration of Jenkins customization

+

+ + + + + + + + + + + + + + + + + +
FieldDescription
+secret
+ + +SecretRef + + +
+
+configurations
+ + +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigMapRef + + +
+
+

GroovyScripts +

+

+(Appears on: +JenkinsSpec) +

+

+

GroovyScripts defines configuration of Jenkins customization via groovy scripts

+

+ + + + + + + + + + + + + +
FieldDescription
+Customization
+ + +Customization + + +
+
+

Handler +

+

+(Appears on: +Backup, +Restore) +

+

+

Handler defines a specific action that should be taken

+

+ + + + + + + + + + + + + +
FieldDescription
+exec
+ + +Kubernetes core/v1.ExecAction + + +
+

Exec specifies the action to take.

+
+

JenkinsCredentialType +(string alias)

+

+(Appears on: +SeedJob) +

+

+

JenkinsCredentialType defines the type of Jenkins credential used in the seed job mechanism

+

+

JenkinsMaster +

+

+(Appears on: +JenkinsSpec) +

+

+

JenkinsMaster defines the Jenkins master pod attributes and plugins, +every single change requires a Jenkins master pod restart

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+masterAnnotations
+ +map[string]string + +
+(Optional) +

Annotations is an unstructured key value map stored with a resource that may be +set by external tools to store and retrieve arbitrary metadata. They are not +queryable and should be preserved when modifying objects. +More info: http://kubernetes.io/docs/user-guide/annotations

+
+nodeSelector
+ +map[string]string + +
+(Optional) +

NodeSelector is a selector which must be true for the pod to fit on a node. +Selector which must match a node’s labels for the pod to be scheduled on that node. +More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/

+
+securityContext
+ + +Kubernetes core/v1.PodSecurityContext + + +
+(Optional) +

SecurityContext that applies to all the containers of the Jenkins +Master. As per kubernetes specification, it can be overridden +for each container individually. +Defaults to: +runAsUser: 1000 +fsGroup: 1000

+
+containers
+ + +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Container + + +
+

List of containers belonging to the pod. +Containers cannot currently be added or removed. +There must be at least one container in a Pod. +Defaults to: +- image: jenkins/jenkins:lts +imagePullPolicy: Always +livenessProbe: +failureThreshold: 12 +httpGet: +path: /login +port: http +scheme: HTTP +initialDelaySeconds: 80 +periodSeconds: 10 +successThreshold: 1 +timeoutSeconds: 5 +name: jenkins-master +readinessProbe: +failureThreshold: 3 +httpGet: +path: /login +port: http +scheme: HTTP +initialDelaySeconds: 30 +periodSeconds: 10 +successThreshold: 1 +timeoutSeconds: 1 +resources: +limits: +cpu: 1500m +memory: 3Gi +requests: +cpu: “1” +memory: 600Mi

+
+imagePullSecrets
+ + +[]Kubernetes core/v1.LocalObjectReference + + +
+(Optional) +

ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. +If specified, these secrets will be passed to individual puller implementations for them to use. For example, +in the case of docker, only DockerConfig type secrets are honored. +More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod

+
+volumes
+ + +[]Kubernetes core/v1.Volume + + +
+(Optional) +

List of volumes that can be mounted by containers belonging to the pod. +More info: https://kubernetes.io/docs/concepts/storage/volumes

+
+basePlugins
+ + +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin + + +
+

BasePlugins contains plugins required by operator +Defaults to : +- name: kubernetes +version: 1.15.7 +- name: workflow-job +version: “2.32” +- name: workflow-aggregator +version: “2.6” +- name: git +version: 3.10.0 +- name: job-dsl +version: “1.74” +- name: configuration-as-code +version: “1.19” +- name: configuration-as-code-support +version: “1.19” +- name: kubernetes-credentials-provider +version: 0.12.1

+
+plugins
+ + +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin + + +
+(Optional) +

Plugins contains plugins required by user

+
+

JenkinsSpec +

+

+(Appears on: +Jenkins) +

+

+

JenkinsSpec defines the desired state of the Jenkins

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+master
+ + +JenkinsMaster + + +
+

Master represents Jenkins master pod properties and Jenkins plugins. +Every single change here requires a pod restart.

+
+seedJobs
+ + +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob + + +
+(Optional) +

SeedJobs defines list of Jenkins Seed Job configurations +More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines

+
+service
+ + +Service + + +
+(Optional) +

Service is Kubernetes service of Jenkins master HTTP pod +Defaults to : +port: 8080 +type: ClusterIP

+
+slaveService
+ + +Service + + +
+(Optional) +

Service is Kubernetes service of Jenkins slave pods +Defaults to : +port: 50000 +type: ClusterIP

+
+backup
+ + +Backup + + +
+(Optional) +

Backup defines configuration of Jenkins backup +More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

+
+restore
+ + +Restore + + +
+(Optional) +

Backup defines configuration of Jenkins backup restore +More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

+
+groovyScripts
+ + +GroovyScripts + + +
+(Optional) +

GroovyScripts defines configuration of Jenkins customization via groovy scripts

+
+configurationAsCode
+ + +ConfigurationAsCode + + +
+(Optional) +

ConfigurationAsCode defines configuration of Jenkins customization via Configuration as Code Jenkins plugin

+
+

JenkinsStatus +

+

+(Appears on: +Jenkins) +

+

+

JenkinsStatus defines the observed state of Jenkins

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+operatorVersion
+ +string + +
+(Optional) +

OperatorVersion is the operator version which manages this CR

+
+provisionStartTime
+ + +Kubernetes meta/v1.Time + + +
+(Optional) +

ProvisionStartTime is a time when Jenkins master pod has been created

+
+baseConfigurationCompletedTime
+ + +Kubernetes meta/v1.Time + + +
+(Optional) +

BaseConfigurationCompletedTime is a time when Jenkins base configuration phase has been completed

+
+userConfigurationCompletedTime
+ + +Kubernetes meta/v1.Time + + +
+(Optional) +

UserConfigurationCompletedTime is a time when Jenkins user configuration phase has been completed

+
+restoredBackup
+ +uint64 + +
+(Optional) +

RestoredBackup is the restored backup number after Jenkins master pod restart

+
+lastBackup
+ +uint64 + +
+(Optional) +

LastBackup is the latest backup number

+
+pendingBackup
+ +uint64 + +
+(Optional) +

PendingBackup is the pending backup number

+
+backupDoneBeforePodDeletion
+ +bool + +
+(Optional) +

BackupDoneBeforePodDeletion tells if backup before pod deletion has been made

+
+userAndPasswordHash
+ +string + +
+(Optional) +

UserAndPasswordHash is a SHA256 hash made from the username and password

+
+createdSeedJobs
+ +[]string + +
+(Optional) +

CreatedSeedJobs contains list of seed job ids already created in Jenkins

+
+appliedGroovyScripts
+ + +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.AppliedGroovyScript + + +
+(Optional) +

AppliedGroovyScripts is a list with all applied groovy scripts in Jenkins by the operator

+
+

Mailgun +

+

+(Appears on: +Notification) +

+

+

Mailgun is handler for Mailgun email service notification channel

+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+domain
+ +string + +
+
+apiKeySecretKeySelector
+ + +SecretKeySelector + + +
+
+recipient
+ +string + +
+
+from
+ +string + +
+
+

MicrosoftTeams +

+

+(Appears on: +Notification) +

+

+

MicrosoftTeams is handler for Microsoft MicrosoftTeams notification channel

+

+ + + + + + + + + + + + + +
FieldDescription
+webHookURLSecretKeySelector
+ + +SecretKeySelector + + +
+

The web hook URL to MicrosoftTeams App

+
+

Notification +

+

+

Notification is a service configuration used to send notifications about Jenkins status

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+loggingLevel
+ + +NotificationLogLevel + + +
+
+verbose
+ +bool + +
+
+name
+ +string + +
+
+slack
+ + +github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Slack + + +
+
+teams
+ + +github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.MicrosoftTeams + + +
+
+mailgun
+ + +github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Mailgun + + +
+
+

NotificationLogLevel +(string alias)

+

+(Appears on: +Notification) +

+

+

NotificationLogLevel defines logging level of Notification

+

+

Plugin +

+

+(Appears on: +JenkinsMaster) +

+

+

Plugin defines Jenkins plugin

+

+ + + + + + + + + + + + + + + + + +
FieldDescription
+name
+ +string + +
+

Name is the name of Jenkins plugin

+
+version
+ +string + +
+

Version is the version of Jenkins plugin

+
+

Restore +

+

+(Appears on: +JenkinsSpec) +

+

+

Restore defines configuration of Jenkins backup restore operation

+

+ + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+containerName
+ +string + +
+

ContainerName is the container name responsible for restore backup operation

+
+action
+ + +Handler + + +
+

Action defines action which performs restore backup in restore container sidecar

+
+recoveryOnce
+ +uint64 + +
+(Optional) +

RecoveryOnce if want to restore specific backup set this field and then Jenkins will be restarted and desired backup will be restored

+
+

SecretKeySelector +

+

+(Appears on: +Mailgun, +MicrosoftTeams, +Slack) +

+

+

SecretKeySelector selects a key of a Secret.

+

+ + + + + + + + + + + + + + + + + +
FieldDescription
+secret
+ + +Kubernetes core/v1.LocalObjectReference + + +
+

The name of the secret in the pod’s namespace to select from.

+
+key
+ +string + +
+

The key of the secret to select from. Must be a valid secret key.

+
+

SecretRef +

+

+(Appears on: +Customization) +

+

+

SecretRef is reference to Kubernetes secret

+

+ + + + + + + + + + + + + +
FieldDescription
+name
+ +string + +
+
+

SeedJob +

+

+(Appears on: +JenkinsSpec) +

+

+

SeedJob defines configuration for seed job +More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+id
+ +string + +
+

ID is the unique seed job name

+
+credentialID
+ +string + +
+

CredentialID is the Kubernetes secret name which stores repository access credentials

+
+description
+ +string + +
+(Optional) +

Description is the description of the seed job

+
+targets
+ +string + +
+

Targets is the repository path where the seed job definitions are

+
+repositoryBranch
+ +string + +
+

RepositoryBranch is the repository branch where the seed job definitions are

+
+repositoryUrl
+ +string + +
+

RepositoryURL is the repository access URL. Can be SSH or HTTPS.

+
+credentialType
+ + +JenkinsCredentialType + + +
+(Optional) +

JenkinsCredentialType is the https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/ credential type

+
+githubPushTrigger
+ +bool + +
+(Optional) +

GitHubPushTrigger is used for GitHub web hooks

+
+buildPeriodically
+ +string + +
+(Optional) +

BuildPeriodically is setting for scheduled trigger

+
+pollSCM
+ +string + +
+(Optional) +

PollSCM is setting for polling changes in SCM

+
+ignoreMissingFiles
+ +bool + +
+(Optional) +

IgnoreMissingFiles is setting for Job DSL API plugin to ignore files that miss

+
+additionalClasspath
+ +string + +
+(Optional) +

AdditionalClasspath is setting for Job DSL API plugin to set Additional Classpath

+
+failOnMissingPlugin
+ +bool + +
+(Optional) +

FailOnMissingPlugin is setting for Job DSL API plugin that fails job if required plugin is missing

+
+unstableOnDeprecation
+ +bool + +
+(Optional) +

UnstableOnDeprecation is setting for Job DSL API plugin that sets build status as unstable if build using deprecated features

+
+

Service +

+

+(Appears on: +JenkinsSpec) +

+

+

Service defines Kubernetes service attributes

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+annotations
+ +map[string]string + +
+(Optional) +

Annotations is an unstructured key value map stored with a resource that may be +set by external tools to store and retrieve arbitrary metadata. They are not +queryable and should be preserved when modifying objects. +More info: http://kubernetes.io/docs/user-guide/annotations

+
+labels
+ +map[string]string + +
+

Route service traffic to pods with label keys and values matching this +selector. If empty or not present, the service is assumed to have an +external process managing its endpoints, which Kubernetes will not +modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. +Ignored if type is ExternalName. +More info: https://kubernetes.io/docs/concepts/services-networking/service/

+
+type
+ + +Kubernetes core/v1.ServiceType + + +
+(Optional) +

Type determines how the Service is exposed. Defaults to ClusterIP. Valid +options are ExternalName, ClusterIP, NodePort, and LoadBalancer. +“ExternalName” maps to the specified externalName. +“ClusterIP” allocates a cluster-internal IP address for load-balancing to +endpoints. Endpoints are determined by the selector or if that is not +specified, by manual construction of an Endpoints object. If clusterIP is +“None”, no virtual IP is allocated and the endpoints are published as a +set of endpoints rather than a stable IP. +“NodePort” builds on ClusterIP and allocates a port on every node which +routes to the clusterIP. +“LoadBalancer” builds on NodePort and creates an +external load-balancer (if supported in the current cloud) which routes +to the clusterIP. +More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services—service-types

+
+port
+ +int32 + +
+

The port that is exposed by this service. +More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies

+
+nodePort
+ +int32 + +
+(Optional) +

The port on each node on which this service is exposed when type=NodePort or LoadBalancer. +Usually assigned by the system. If specified, it will be allocated to the service +if unused, or else creation of the service will fail. +Default is to auto-allocate a port if the ServiceType of this Service requires one. +More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport

+
+loadBalancerSourceRanges
+ +[]string + +
+(Optional) +

If specified and supported by the platform, this will restrict traffic through the cloud-provider +the load-balancer will be restricted to the specified client IPs. This field will be ignored if the +cloud-provider does not support the feature.” +More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/

+
+loadBalancerIP
+ +string + +
+(Optional) +

Only applies to Service Type: LoadBalancer +LoadBalancer will get created with the IP specified in this field. +This feature depends on whether the underlying cloud-provider supports specifying +the loadBalancerIP when a load balancer is created. +This field will be ignored if the cloud-provider does not support the feature.

+
+

Slack +

+

+(Appears on: +Notification) +

+

+

Slack is handler for Slack notification channel

+

+ + + + + + + + + + + + + +
FieldDescription
+webHookURLSecretKeySelector
+ + +SecretKeySelector + + +
+

The web hook URL to Slack App

+
+
+

+Generated with gen-crd-api-reference-docs +on git commit f4c4235. +

+ + + +
Last modified August 5, 2019 +
+
+ + +
+
+
+ + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/docs/getting-started/index.html b/docs/docs/getting-started/index.html index 9f8b3859..a0d318f6 100644 --- a/docs/docs/getting-started/index.html +++ b/docs/docs/getting-started/index.html @@ -197,6 +197,83 @@ + + + + + + + + + + + + @@ -331,6 +414,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -366,35 +455,6 @@ - - - - - - - - - - - - @@ -509,6 +569,28 @@ + + + + + + + + + + + + + + + +
+
+ Future (v0.3.x) +
+

How to work with jenkins-operator latest version +

+
@@ -549,6 +631,12 @@ + + + + + + diff --git a/docs/docs/getting-started/latest/aks/index.html b/docs/docs/getting-started/latest/aks/index.html index 49c07245..804d95ab 100644 --- a/docs/docs/getting-started/latest/aks/index.html +++ b/docs/docs/getting-started/latest/aks/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/latest/configuration/index.html b/docs/docs/getting-started/latest/configuration/index.html index aa74a38a..cac2b596 100644 --- a/docs/docs/getting-started/latest/configuration/index.html +++ b/docs/docs/getting-started/latest/configuration/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/latest/configure-backup-and-restore/index.html b/docs/docs/getting-started/latest/configure-backup-and-restore/index.html index dce21020..120c44d8 100644 --- a/docs/docs/getting-started/latest/configure-backup-and-restore/index.html +++ b/docs/docs/getting-started/latest/configure-backup-and-restore/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/latest/custom-backup-and-restore/index.html b/docs/docs/getting-started/latest/custom-backup-and-restore/index.html index ee5728e9..3287a0b3 100644 --- a/docs/docs/getting-started/latest/custom-backup-and-restore/index.html +++ b/docs/docs/getting-started/latest/custom-backup-and-restore/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/latest/customization/index.html b/docs/docs/getting-started/latest/customization/index.html index e145dbbc..29e702a5 100644 --- a/docs/docs/getting-started/latest/customization/index.html +++ b/docs/docs/getting-started/latest/customization/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/latest/deploy-jenkins/index.html b/docs/docs/getting-started/latest/deploy-jenkins/index.html index abaa6e85..d7e43451 100644 --- a/docs/docs/getting-started/latest/deploy-jenkins/index.html +++ b/docs/docs/getting-started/latest/deploy-jenkins/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/latest/developer-guide/index.html b/docs/docs/getting-started/latest/developer-guide/index.html new file mode 100644 index 00000000..b16fd0a2 --- /dev/null +++ b/docs/docs/getting-started/latest/developer-guide/index.html @@ -0,0 +1,750 @@ + + + + + + + + + + + + + + + + + + + + + + +Developer Guide | Jenkins Operator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Developer Guide | Jenkins Operator + + +
+ + + +
+
+
+
+
+ + + + + +
+ + + + +
+ + + + +
+ +
+ + + +
+

Developer Guide

+
Jenkins Operator for developers
+ + + + +
+

This document explains how to setup your development environment.

+ +
+ + +

Prerequisites

+ + + +

Clone repository and download dependencies

+
mkdir -p $GOPATH/src/github.com/jenkinsci
+cd $GOPATH/src/github.com/jenkinsci/
+git clone git@github.com:jenkinsci/kubernetes-operator.git
+cd kubernetes-operator
+make go-dependencies
+

Build and run with a minikube

+ +

Build and run Jenkins Operator locally:

+
make build minikube-run EXTRA_ARGS='--minikube --local'
+

Once minikube and Jenkins Operator are up and running, apply Jenkins custom resource:

+
kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml
+kubectl get jenkins -o yaml
+kubectl get po
+

Build and run with a remote Kubernetes cluster

+ +

You can also run the controller locally and make it listen to a remote Kubernetes server.

+
make run NAMESPACE=default KUBECTL_CONTEXT=remote-k8s EXTRA_ARGS='--kubeconfig ~/.kube/config'
+

Once minikube and Jenkins Operator are up and running, apply Jenkins custom resource:

+
kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml
+kubectl --context remote-k8s --namespace default get jenkins -o yaml
+kubectl --context remote-k8s --namespace default get po
+

Testing

+ +

Run unit tests:

+
make test
+

Running E2E tests on Linux

+ +

Run e2e tests with minikube:

+
make minikube-start
+eval $(minikube docker-env)
+make build e2e
+

Run the specific e2e test:

+
make build e2e E2E_TEST_SELECTOR='^TestConfiguration$'
+

Running E2E tests on macOS

+ +

At first, you need to start minikube:

+
$ make minikube-start
+$ eval $(minikube docker-env) 
+

Build a Docker image inside the provided Linux container by:

+
$ make indocker
+

Build Jenkins Operator inside a container using:

+
$ make build
+

Then exit the container and run:

+ +
make e2e
+
+ +

Tips & Tricks

+ +

Building docker image on minikube (for e2e tests)

+ +

To be able to work with the docker daemon on minikube machine run the following command before building an image:

+
eval $(minikube docker-env)
+

When pkg/apis/jenkinsio/*/jenkins_types.go has changed

+ +

Run:

+
make deepcopy-gen
+

Getting the Jenkins URL and basic credentials

+
minikube service jenkins-operator-http-<cr_name> --url
+kubectl get secret jenkins-operator-credentials-<cr_name> -o 'jsonpath={.data.user}' | base64 -d
+kubectl get secret jenkins-operator-credentials-<cr_name> -o 'jsonpath={.data.password}' | base64 -d
+

Tools

+ +

Configure environment variables

+
export GOPATH=/home/go # example value
+export GOROOT=/usr/lib/go-1.12 # example value
+export PATH=$GOPATH/bin:$PATH
+

goimports

+ +
go get golang.org/x/tools/cmd/goimports
+cd $GOPATH/src/golang.org/x/tools/cmd/goimports
+go build
+go install
+
+ +

golint

+ +
go get -u golang.org/x/lint/golint
+cd  $GOPATH/src/golang.org/x/lint/golint
+go build
+go install
+
+ +

checkmake

+ +
go get github.com/mrtazz/checkmake
+cd $GOPATH/src/github.com/mrtazz/checkmake
+go build
+go install
+
+ +

staticcheck

+ +
mkdir -p $GOPATH/src/github.com/dominikh/
+cd $GOPATH/src/github.com/dominikh/
+git clone https://github.com/dominikh/go-tools.git
+cd  $GOPATH/src/github.com/dominikh/go-tools/staticcheck
+go build
+go install
+
+ + + +
Last modified August 5, 2019 +
+
+ + +
+
+
+ + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/docs/getting-started/latest/diagnostics/index.html b/docs/docs/getting-started/latest/diagnostics/index.html index 1b0efc48..b8bfa43b 100644 --- a/docs/docs/getting-started/latest/diagnostics/index.html +++ b/docs/docs/getting-started/latest/diagnostics/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/latest/index.html b/docs/docs/getting-started/latest/index.html index 854707f8..f5f122d5 100644 --- a/docs/docs/getting-started/latest/index.html +++ b/docs/docs/getting-started/latest/index.html @@ -197,6 +197,83 @@ + + + + + + + + + + + + @@ -331,6 +414,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -366,35 +455,6 @@ - - - - - - - - - - - - @@ -496,6 +556,8 @@ + +
Deploy Jenkins @@ -510,6 +572,8 @@ + +
Configuration @@ -522,6 +586,8 @@ + +
Customization @@ -536,6 +602,8 @@ + +
AKS @@ -548,6 +616,8 @@ + +
Configure backup and restore @@ -560,6 +630,8 @@ + +
Custom Backup and Restore Providers @@ -576,6 +648,8 @@ + +
Migration from v0.1.x @@ -604,6 +678,8 @@ + +
Schema @@ -621,6 +697,18 @@ + +
+
+ Developer Guide +
+

Jenkins Operator for developers +

+
+ + + +
diff --git a/docs/docs/getting-started/latest/index.xml b/docs/docs/getting-started/latest/index.xml index 1eb1214e..73ab704b 100644 --- a/docs/docs/getting-started/latest/index.xml +++ b/docs/docs/getting-started/latest/index.xml @@ -2924,5 +2924,140 @@ on git commit <code>f4c4235</code>. + + Docs: Developer Guide + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/developer-guide/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/developer-guide/ + + + + + + + +<div class="pageinfo pageinfo-primary"> +<p>This document explains how to setup your development environment.</p> + +</div> + + +<h2 id="prerequisites">Prerequisites</h2> + +<ul> +<li><a href="https://github.com/operator-framework/operator-sdk" target="_blank">operator_sdk</a> version v0.8.1</li> +<li><a href="https://git-scm.com/downloads" target="_blank">git</a></li> +<li><a href="https://golang.org/dl/" target="_blank">go</a> version v1.12+</li> +<li><a href="install_dev_tools.md" target="_blank">goimports, golint, checkmake and staticcheck</a></li> +<li><a href="https://kubernetes.io/docs/tasks/tools/install-minikube/" target="_blank">minikube</a> version v1.1.0+ (preferred Hypervisor - <a href="https://www.virtualbox.org/wiki/Downloads" target="_blank">virtualbox</a>)</li> +<li><a href="https://docs.docker.com/install/" target="_blank">docker</a> version 17.03+</li> +</ul> + +<h2 id="clone-repository-and-download-dependencies">Clone repository and download dependencies</h2> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">mkdir -p <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci +<span style="color:#204a87">cd</span> <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci/ +git clone git@github.com:jenkinsci/kubernetes-operator.git +<span style="color:#204a87">cd</span> kubernetes-operator +make go-dependencies</code></pre></div> +<h2 id="build-and-run-with-a-minikube">Build and run with a minikube</h2> + +<p>Build and run <strong>Jenkins Operator</strong> locally:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build minikube-run <span style="color:#000">EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--minikube --local&#39;</span></code></pre></div> +<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl get jenkins -o yaml +kubectl get po</code></pre></div> +<h2 id="build-and-run-with-a-remote-kubernetes-cluster">Build and run with a remote Kubernetes cluster</h2> + +<p>You can also run the controller locally and make it listen to a remote Kubernetes server.</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make run <span style="color:#000">NAMESPACE</span><span style="color:#ce5c00;font-weight:bold">=</span>default <span style="color:#000">KUBECTL_CONTEXT</span><span style="color:#ce5c00;font-weight:bold">=</span>remote-k8s <span style="color:#000">EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--kubeconfig ~/.kube/config&#39;</span></code></pre></div> +<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl --context remote-k8s --namespace default get jenkins -o yaml +kubectl --context remote-k8s --namespace default get po</code></pre></div> +<h2 id="testing">Testing</h2> + +<p>Run unit tests:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make test</code></pre></div> +<h3 id="running-e2e-tests-on-linux">Running E2E tests on Linux</h3> + +<p>Run e2e tests with minikube:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make minikube-start +<span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> +make build e2e</code></pre></div> +<p>Run the specific e2e test:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build e2e <span style="color:#000">E2E_TEST_SELECTOR</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;^TestConfiguration$&#39;</span></code></pre></div> +<h3 id="running-e2e-tests-on-macos">Running E2E tests on macOS</h3> + +<p>At first, you need to start minikube:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make minikube-start +$ <span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> </code></pre></div> +<p>Build a Docker image inside the provided Linux container by:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make indocker</code></pre></div> +<p>Build <strong>Jenkins Operator</strong> inside a container using:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make build</code></pre></div> +<p>Then exit the container and run:</p> + +<pre><code>make e2e +</code></pre> + +<h2 id="tips-tricks">Tips &amp; Tricks</h2> + +<h3 id="building-docker-image-on-minikube-for-e2e-tests">Building docker image on minikube (for e2e tests)</h3> + +<p>To be able to work with the docker daemon on <code>minikube</code> machine run the following command before building an image:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span></code></pre></div> +<h3 id="when-pkg-apis-jenkinsio-jenkins-types-go-has-changed">When <code>pkg/apis/jenkinsio/*/jenkins_types.go</code> has changed</h3> + +<p>Run:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make deepcopy-gen</code></pre></div> +<h3 id="getting-the-jenkins-url-and-basic-credentials">Getting the Jenkins URL and basic credentials</h3> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">minikube service jenkins-operator-http-&lt;cr_name&gt; --url +kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.user}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d +kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.password}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d</code></pre></div> +<h1 id="tools">Tools</h1> + +<h2 id="configure-environment-variables">Configure environment variables</h2> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">export</span> <span style="color:#000">GOPATH</span><span style="color:#ce5c00;font-weight:bold">=</span>/home/go <span style="color:#8f5902;font-style:italic"># example value</span> +<span style="color:#204a87">export</span> <span style="color:#000">GOROOT</span><span style="color:#ce5c00;font-weight:bold">=</span>/usr/lib/go-1.12 <span style="color:#8f5902;font-style:italic"># example value</span> +<span style="color:#204a87">export</span> <span style="color:#000">PATH</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#000">$GOPATH</span>/bin:<span style="color:#000">$PATH</span></code></pre></div> +<h2 id="goimports">goimports</h2> + +<pre><code>go get golang.org/x/tools/cmd/goimports +cd $GOPATH/src/golang.org/x/tools/cmd/goimports +go build +go install +</code></pre> + +<h2 id="golint">golint</h2> + +<pre><code>go get -u golang.org/x/lint/golint +cd $GOPATH/src/golang.org/x/lint/golint +go build +go install +</code></pre> + +<h2 id="checkmake">checkmake</h2> + +<pre><code>go get github.com/mrtazz/checkmake +cd $GOPATH/src/github.com/mrtazz/checkmake +go build +go install +</code></pre> + +<h2 id="staticcheck">staticcheck</h2> + +<pre><code>mkdir -p $GOPATH/src/github.com/dominikh/ +cd $GOPATH/src/github.com/dominikh/ +git clone https://github.com/dominikh/go-tools.git +cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck +go build +go install +</code></pre> + + + + \ No newline at end of file diff --git a/docs/docs/getting-started/latest/migration/index.html b/docs/docs/getting-started/latest/migration/index.html index 96fa137f..28a58eec 100644 --- a/docs/docs/getting-started/latest/migration/index.html +++ b/docs/docs/getting-started/latest/migration/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/latest/schema/index.html b/docs/docs/getting-started/latest/schema/index.html index b0407d9c..e694d1f5 100644 --- a/docs/docs/getting-started/latest/schema/index.html +++ b/docs/docs/getting-started/latest/schema/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/v0.1.x/aks/index.html b/docs/docs/getting-started/v0.1.x/aks/index.html index 92bf33f8..77847787 100644 --- a/docs/docs/getting-started/v0.1.x/aks/index.html +++ b/docs/docs/getting-started/v0.1.x/aks/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/v0.1.x/configuration/index.html b/docs/docs/getting-started/v0.1.x/configuration/index.html index 50c4dd39..e31a28aa 100644 --- a/docs/docs/getting-started/v0.1.x/configuration/index.html +++ b/docs/docs/getting-started/v0.1.x/configuration/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/v0.1.x/configure-backup-and-restore/index.html b/docs/docs/getting-started/v0.1.x/configure-backup-and-restore/index.html index 7804bd4d..6aed0d3e 100644 --- a/docs/docs/getting-started/v0.1.x/configure-backup-and-restore/index.html +++ b/docs/docs/getting-started/v0.1.x/configure-backup-and-restore/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/v0.1.x/customization/index.html b/docs/docs/getting-started/v0.1.x/customization/index.html index 73d9a590..fe7aaaca 100644 --- a/docs/docs/getting-started/v0.1.x/customization/index.html +++ b/docs/docs/getting-started/v0.1.x/customization/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/v0.1.x/deploy-jenkins/index.html b/docs/docs/getting-started/v0.1.x/deploy-jenkins/index.html index 5b12606a..40cba955 100644 --- a/docs/docs/getting-started/v0.1.x/deploy-jenkins/index.html +++ b/docs/docs/getting-started/v0.1.x/deploy-jenkins/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/developer-guide/index.html b/docs/docs/getting-started/v0.1.x/developer-guide/index.html similarity index 78% rename from docs/docs/developer-guide/index.html rename to docs/docs/getting-started/v0.1.x/developer-guide/index.html index cf536ae3..74976615 100644 --- a/docs/docs/developer-guide/index.html +++ b/docs/docs/getting-started/v0.1.x/developer-guide/index.html @@ -7,7 +7,6 @@ - @@ -24,15 +23,23 @@ Developer Guide | Jenkins Operator - - - - + + + + + + + + + + + + +
@@ -465,6 +540,12 @@ + + + + + + @@ -472,8 +553,22 @@ + + + + + + + + + + @@ -566,79 +661,45 @@ $ eval
minikube service jenkins-operator-http-<cr_name> --url
 kubectl get secret jenkins-operator-credentials-<cr_name> -o 'jsonpath={.data.user}' | base64 -d
 kubectl get secret jenkins-operator-credentials-<cr_name> -o 'jsonpath={.data.password}' | base64 -d
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- Tools -
-

Required tools for building and running Jenkins Operator -

-
- - - - - - - - - - - - - - - - - -
+

Tools

+ +

Configure environment variables

+
export GOPATH=/home/go # example value
+export GOROOT=/usr/lib/go-1.12 # example value
+export PATH=$GOPATH/bin:$PATH
+

goimports

+ +
go get golang.org/x/tools/cmd/goimports
+cd $GOPATH/src/golang.org/x/tools/cmd/goimports
+go build
+go install
+
+ +

golint

+ +
go get -u golang.org/x/lint/golint
+cd  $GOPATH/src/golang.org/x/lint/golint
+go build
+go install
+
+ +

checkmake

+ +
go get github.com/mrtazz/checkmake
+cd $GOPATH/src/github.com/mrtazz/checkmake
+go build
+go install
+
+ +

staticcheck

+ +
mkdir -p $GOPATH/src/github.com/dominikh/
+cd $GOPATH/src/github.com/dominikh/
+git clone https://github.com/dominikh/go-tools.git
+cd  $GOPATH/src/github.com/dominikh/go-tools/staticcheck
+go build
+go install
+
@@ -646,6 +707,7 @@ kubectl get secret jenkins-operator-credentials-<cr_name> -o +
  • + +
  • + + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/v0.1.x/index.html b/docs/docs/getting-started/v0.1.x/index.html index 19dd8c6c..14d3f01d 100644 --- a/docs/docs/getting-started/v0.1.x/index.html +++ b/docs/docs/getting-started/v0.1.x/index.html @@ -197,6 +197,83 @@ + + + + + + + + + + + + @@ -331,6 +414,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -366,35 +455,6 @@ - - - - - - - - - - - - @@ -498,6 +558,8 @@ + +
    Deploy Jenkins @@ -512,6 +574,8 @@ + +
    Configuration @@ -524,6 +588,8 @@ + +
    Customization @@ -538,6 +604,8 @@ + +
    AKS @@ -550,6 +618,8 @@ + +
    Configure backup and restore @@ -573,6 +643,10 @@ + + + + @@ -590,6 +664,8 @@ + +
    Scheme @@ -613,6 +689,18 @@ + + + +
    +
    + Developer Guide +
    +

    Jenkins Operator for developers +

    +
    + +
    diff --git a/docs/docs/getting-started/v0.1.x/index.xml b/docs/docs/getting-started/v0.1.x/index.xml index e5fb9ea8..6b35a5a1 100644 --- a/docs/docs/getting-started/v0.1.x/index.xml +++ b/docs/docs/getting-started/v0.1.x/index.xml @@ -2368,6 +2368,141 @@ Code that defines the data structures can be found <a href="v0.1.1/jenkin or use the default deployment manifest:</p> <pre><code>$ kubectl -n &lt;namespace&gt; apply -f https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/master/deploy/operator.yaml +</code></pre> + + + + + + Docs: Developer Guide + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/developer-guide/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/developer-guide/ + + + + + + + +<div class="pageinfo pageinfo-primary"> +<p>This document explains how to setup your development environment.</p> + +</div> + + +<h2 id="prerequisites">Prerequisites</h2> + +<ul> +<li><a href="https://github.com/operator-framework/operator-sdk" target="_blank">operator_sdk</a> version v0.8.1</li> +<li><a href="https://git-scm.com/downloads" target="_blank">git</a></li> +<li><a href="https://golang.org/dl/" target="_blank">go</a> version v1.12+</li> +<li><a href="install_dev_tools.md" target="_blank">goimports, golint, checkmake and staticcheck</a></li> +<li><a href="https://kubernetes.io/docs/tasks/tools/install-minikube/" target="_blank">minikube</a> version v1.1.0+ (preferred Hypervisor - <a href="https://www.virtualbox.org/wiki/Downloads" target="_blank">virtualbox</a>)</li> +<li><a href="https://docs.docker.com/install/" target="_blank">docker</a> version 17.03+</li> +</ul> + +<h2 id="clone-repository-and-download-dependencies">Clone repository and download dependencies</h2> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">mkdir -p <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci +<span style="color:#204a87">cd</span> <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci/ +git clone git@github.com:jenkinsci/kubernetes-operator.git +<span style="color:#204a87">cd</span> kubernetes-operator +make go-dependencies</code></pre></div> +<h2 id="build-and-run-with-a-minikube">Build and run with a minikube</h2> + +<p>Build and run <strong>Jenkins Operator</strong> locally:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build minikube-run <span style="color:#000">EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--minikube --local&#39;</span></code></pre></div> +<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl get jenkins -o yaml +kubectl get po</code></pre></div> +<h2 id="build-and-run-with-a-remote-kubernetes-cluster">Build and run with a remote Kubernetes cluster</h2> + +<p>You can also run the controller locally and make it listen to a remote Kubernetes server.</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make run <span style="color:#000">NAMESPACE</span><span style="color:#ce5c00;font-weight:bold">=</span>default <span style="color:#000">KUBECTL_CONTEXT</span><span style="color:#ce5c00;font-weight:bold">=</span>remote-k8s <span style="color:#000">EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--kubeconfig ~/.kube/config&#39;</span></code></pre></div> +<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl --context remote-k8s --namespace default get jenkins -o yaml +kubectl --context remote-k8s --namespace default get po</code></pre></div> +<h2 id="testing">Testing</h2> + +<p>Run unit tests:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make test</code></pre></div> +<h3 id="running-e2e-tests-on-linux">Running E2E tests on Linux</h3> + +<p>Run e2e tests with minikube:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make minikube-start +<span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> +make build e2e</code></pre></div> +<p>Run the specific e2e test:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build e2e <span style="color:#000">E2E_TEST_SELECTOR</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;^TestConfiguration$&#39;</span></code></pre></div> +<h3 id="running-e2e-tests-on-macos">Running E2E tests on macOS</h3> + +<p>At first, you need to start minikube:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make minikube-start +$ <span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> </code></pre></div> +<p>Build a Docker image inside the provided Linux container by:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make indocker</code></pre></div> +<p>Build <strong>Jenkins Operator</strong> inside a container using:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make build</code></pre></div> +<p>Then exit the container and run:</p> + +<pre><code>make e2e +</code></pre> + +<h2 id="tips-tricks">Tips &amp; Tricks</h2> + +<h3 id="building-docker-image-on-minikube-for-e2e-tests">Building docker image on minikube (for e2e tests)</h3> + +<p>To be able to work with the docker daemon on <code>minikube</code> machine run the following command before building an image:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span></code></pre></div> +<h3 id="when-pkg-apis-jenkinsio-jenkins-types-go-has-changed">When <code>pkg/apis/jenkinsio/*/jenkins_types.go</code> has changed</h3> + +<p>Run:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make deepcopy-gen</code></pre></div> +<h3 id="getting-the-jenkins-url-and-basic-credentials">Getting the Jenkins URL and basic credentials</h3> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">minikube service jenkins-operator-http-&lt;cr_name&gt; --url +kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.user}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d +kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.password}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d</code></pre></div> +<h1 id="tools">Tools</h1> + +<h2 id="configure-environment-variables">Configure environment variables</h2> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">export</span> <span style="color:#000">GOPATH</span><span style="color:#ce5c00;font-weight:bold">=</span>/home/go <span style="color:#8f5902;font-style:italic"># example value</span> +<span style="color:#204a87">export</span> <span style="color:#000">GOROOT</span><span style="color:#ce5c00;font-weight:bold">=</span>/usr/lib/go-1.12 <span style="color:#8f5902;font-style:italic"># example value</span> +<span style="color:#204a87">export</span> <span style="color:#000">PATH</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#000">$GOPATH</span>/bin:<span style="color:#000">$PATH</span></code></pre></div> +<h2 id="goimports">goimports</h2> + +<pre><code>go get golang.org/x/tools/cmd/goimports +cd $GOPATH/src/golang.org/x/tools/cmd/goimports +go build +go install +</code></pre> + +<h2 id="golint">golint</h2> + +<pre><code>go get -u golang.org/x/lint/golint +cd $GOPATH/src/golang.org/x/lint/golint +go build +go install +</code></pre> + +<h2 id="checkmake">checkmake</h2> + +<pre><code>go get github.com/mrtazz/checkmake +cd $GOPATH/src/github.com/mrtazz/checkmake +go build +go install +</code></pre> + +<h2 id="staticcheck">staticcheck</h2> + +<pre><code>mkdir -p $GOPATH/src/github.com/dominikh/ +cd $GOPATH/src/github.com/dominikh/ +git clone https://github.com/dominikh/go-tools.git +cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck +go build +go install </code></pre> diff --git a/docs/docs/getting-started/v0.1.x/migration-guide-v1alpha1-to-v1alpha2/index.html b/docs/docs/getting-started/v0.1.x/migration-guide-v1alpha1-to-v1alpha2/index.html index 15e2bec5..23c9442d 100644 --- a/docs/docs/getting-started/v0.1.x/migration-guide-v1alpha1-to-v1alpha2/index.html +++ b/docs/docs/getting-started/v0.1.x/migration-guide-v1alpha1-to-v1alpha2/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/getting-started/v0.1.x/scheme/index.html b/docs/docs/getting-started/v0.1.x/scheme/index.html index 172d232f..757b0172 100644 --- a/docs/docs/getting-started/v0.1.x/scheme/index.html +++ b/docs/docs/getting-started/v0.1.x/scheme/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/how-it-works/architecture-and-design/index.html b/docs/docs/how-it-works/architecture-and-design/index.html index 08509e75..7518443f 100644 --- a/docs/docs/how-it-works/architecture-and-design/index.html +++ b/docs/docs/how-it-works/architecture-and-design/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/how-it-works/index.html b/docs/docs/how-it-works/index.html index 380644d0..89e43ffa 100644 --- a/docs/docs/how-it-works/index.html +++ b/docs/docs/how-it-works/index.html @@ -197,6 +197,83 @@ + + + + + + + + + + + + @@ -331,6 +414,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -366,35 +455,6 @@ - - - - - - - - - - - - @@ -501,6 +561,20 @@ + + + + + + + + + + + + + + @@ -538,6 +612,12 @@ + + + + + + diff --git a/docs/docs/how-it-works/jenkins-docker-images/index.html b/docs/docs/how-it-works/jenkins-docker-images/index.html index f9b67604..d0f78287 100644 --- a/docs/docs/how-it-works/jenkins-docker-images/index.html +++ b/docs/docs/how-it-works/jenkins-docker-images/index.html @@ -204,6 +204,83 @@ + + + + + + + + + + + + @@ -338,6 +421,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -373,35 +462,6 @@ - - - - - - - - - - - - diff --git a/docs/docs/index.html b/docs/docs/index.html index 54f11b1f..8e05d7ea 100644 --- a/docs/docs/index.html +++ b/docs/docs/index.html @@ -194,6 +194,83 @@ + + + + + + + + + + + + @@ -328,6 +411,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -363,35 +452,6 @@ - - - - - - - - - - - - @@ -467,6 +527,8 @@ + +
    Installation @@ -485,6 +547,10 @@ + + + +
    How it works @@ -504,6 +570,14 @@ + + + + + + + +
    @@ -534,6 +608,8 @@ + + @@ -547,13 +623,9 @@ -
    -
    - Developer Guide -
    -

    Jenkins Operator for developers -

    -
    + + + diff --git a/docs/docs/index.xml b/docs/docs/index.xml index 37fb59d0..b65e286f 100644 --- a/docs/docs/index.xml +++ b/docs/docs/index.xml @@ -68,6 +68,77 @@ + + Docs: Deploy Jenkins + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/deploy-jenkins/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/deploy-jenkins/ + + + + <p>Once Jenkins Operator is up and running let&rsquo;s deploy actual Jenkins instance. +Create manifest e.g. <strong><code>jenkins_instance.yaml</code></strong> with following data and save it on drive.</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + master: + containers: + - name: jenkins-master + image: jenkins/jenkins:lts + imagePullPolicy: Always + livenessProbe: + failureThreshold: <span style="color:#0000cf;font-weight:bold">12</span> + httpGet: + path: /login + port: http + scheme: HTTP + initialDelaySeconds: <span style="color:#0000cf;font-weight:bold">80</span> + periodSeconds: <span style="color:#0000cf;font-weight:bold">10</span> + successThreshold: <span style="color:#0000cf;font-weight:bold">1</span> + timeoutSeconds: <span style="color:#0000cf;font-weight:bold">5</span> + readinessProbe: + failureThreshold: <span style="color:#0000cf;font-weight:bold">3</span> + httpGet: + path: /login + port: http + scheme: HTTP + initialDelaySeconds: <span style="color:#0000cf;font-weight:bold">30</span> + periodSeconds: <span style="color:#0000cf;font-weight:bold">10</span> + successThreshold: <span style="color:#0000cf;font-weight:bold">1</span> + timeoutSeconds: <span style="color:#0000cf;font-weight:bold">1</span> + resources: + limits: + cpu: 1500m + memory: 3Gi + requests: + cpu: <span style="color:#4e9a06">&#34;1&#34;</span> + memory: 500Mi + seedJobs: + - id: jenkins-operator + targets: <span style="color:#4e9a06">&#34;cicd/jobs/*.jenkins&#34;</span> + description: <span style="color:#4e9a06">&#34;Jenkins Operator repository&#34;</span> + repositoryBranch: master + repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git</code></pre></div> +<p>Deploy a Jenkins to Kubernetes:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl create -f jenkins_instance.yaml</code></pre></div> +<p>Watch the Jenkins instance being created:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl get pods -w</code></pre></div> +<p>Get the Jenkins credentials:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.user}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d +kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.password}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d</code></pre></div> +<p>Connect to the Jenkins instance (minikube):</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">minikube service jenkins-operator-http-&lt;cr_name&gt; --url</code></pre></div> +<p>Connect to the Jenkins instance (actual Kubernetes cluster):</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl port-forward jenkins-&lt;cr_name&gt; <span style="color:#0000cf;font-weight:bold">8080</span>:8080</code></pre></div> +<p>Then open browser with address <code>http://localhost:8080</code>. +<img src="https://jenkinsci.github.io/kubernetes-operator/img/jenkins.png" alt="jenkins" /></p> + + + + Docs: Deploy Jenkins https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/deploy-jenkins/ @@ -214,6 +285,308 @@ kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <s + + Docs: Configuration + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/configuration/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/configuration/ + + + + + +<h2 id="configure-seed-jobs-and-pipelines">Configure Seed Jobs and Pipelines</h2> + +<p>Jenkins operator uses <a href="https://github.com/jenkinsci/job-dsl-plugin" target="_blank">job-dsl</a> and <a href="https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/" target="_blank">kubernetes-credentials-provider</a> plugins for configuring jobs +and deploy keys.</p> + +<h2 id="prepare-job-definitions-and-pipelines">Prepare job definitions and pipelines</h2> + +<p>First you have to prepare pipelines and job definition in your GitHub repository using the following structure:</p> + +<pre><code>cicd/ +├── jobs +│   └── build.jenkins +└── pipelines + └── build.jenkins +</code></pre> + +<p><strong><code>cicd/jobs/build.jenkins</code></strong> is a job definition:</p> + +<pre><code>#!/usr/bin/env groovy + +pipelineJob('build-jenkins-operator') { + displayName('Build jenkins-operator') + + definition { + cpsScm { + scm { + git { + remote { + url('https://github.com/jenkinsci/kubernetes-operator.git') + credentials('jenkins-operator') + } + branches('*/master') + } + } + scriptPath('cicd/pipelines/build.jenkins') + } + } +} +</code></pre> + +<p><strong><code>cicd/pipelines/build.jenkins</code></strong> is an actual Jenkins pipeline:</p> + +<pre><code>#!/usr/bin/env groovy + +def label = &quot;build-jenkins-operator-${UUID.randomUUID().toString()}&quot; +def home = &quot;/home/jenkins&quot; +def workspace = &quot;${home}/workspace/build-jenkins-operator&quot; +def workdir = &quot;${workspace}/src/github.com/jenkinsci/kubernetes-operator/&quot; + +podTemplate(label: label, + containers: [ + containerTemplate(name: 'jnlp', image: 'jenkins/jnlp-slave:alpine'), + containerTemplate(name: 'go', image: 'golang:1-alpine', command: 'cat', ttyEnabled: true), + ], + envVars: [ + envVar(key: 'GOPATH', value: workspace), + ], + ) { + + node(label) { + dir(workdir) { + stage('Init') { + timeout(time: 3, unit: 'MINUTES') { + checkout scm + } + container('go') { + sh 'apk --no-cache --update add make git gcc libc-dev' + } + } + + stage('Dep') { + container('go') { + sh 'make dep' + } + } + + stage('Test') { + container('go') { + sh 'make test' + } + } + + stage('Build') { + container('go') { + sh 'make build' + } + } + } + } +} +</code></pre> + +<h2 id="configure-seed-jobs">Configure Seed Jobs</h2> + +<p>Jenkins Seed Jobs are configured using <code>Jenkins.spec.seedJobs</code> section from your custom resource manifest:</p> + +<pre><code>apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + seedJobs: + - id: jenkins-operator + targets: &quot;cicd/jobs/*.jenkins&quot; + description: &quot;Jenkins Operator repository&quot; + repositoryBranch: master + repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git +</code></pre> + +<p><strong>Jenkins Operator</strong> will automatically discover and configure all the seed jobs.</p> + +<p>You can verify if deploy keys were successfully configured in the Jenkins <strong>Credentials</strong> tab.</p> + +<p><img src="https://jenkinsci.github.io/kubernetes-operator/kubernetes-operator/img/jenkins-credentials.png" alt="jenkins" /></p> + +<p>You can verify if your pipelines were successfully configured in the Jenkins Seed Job console output.</p> + +<p><img src="https://jenkinsci.github.io/kubernetes-operator/kubernetes-operator/img/jenkins-seed.png" alt="jenkins" /></p> + +<p>If your GitHub repository is <strong>private</strong> you have to configure SSH or username/password authentication.</p> + +<h3 id="ssh-authentication">SSH authentication</h3> + +<h4 id="generate-ssh-keys">Generate SSH Keys</h4> + +<p>There are two methods of SSH private key generation:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ openssl genrsa -out &lt;filename&gt; <span style="color:#0000cf;font-weight:bold">2048</span></code></pre></div> +<p>or</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ ssh-keygen -t rsa -b <span style="color:#0000cf;font-weight:bold">2048</span> +$ ssh-keygen -p -f &lt;filename&gt; -m pem</code></pre></div> +<p>Then copy content from generated file.</p> + +<h4 id="public-key">Public key</h4> + +<p>If you want to upload your public key to your Git server you need to extract it.</p> + +<p>If key was generated by <code>openssl</code> then you need to type this to extract public key:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ openssl rsa -in &lt;filename&gt; -pubout &gt; &lt;filename&gt;.pub</code></pre></div> +<p>If key was generated by <code>ssh-keygen</code> the public key content is located in <filename>.pub and there is no need to extract public key</p> + +<h4 id="configure-ssh-authentication">Configure SSH authentication</h4> + +<p>Configure a seed job like this:</p> + +<pre><code>apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + seedJobs: + - id: jenkins-operator-ssh + credentialType: basicSSHUserPrivateKey + credentialID: k8s-ssh + targets: &quot;cicd/jobs/*.jenkins&quot; + description: &quot;Jenkins Operator repository&quot; + repositoryBranch: master + repositoryUrl: git@github.com:jenkinsci/kubernetes-operator.git +</code></pre> + +<p>and create a Kubernetes Secret (name of secret should be the same from <code>credentialID</code> field):</p> + +<pre><code>apiVersion: v1 +kind: Secret +metadata: + name: k8s-ssh +stringData: + privateKey: | + -----BEGIN RSA PRIVATE KEY----- + MIIJKAIBAAKCAgEAxxDpleJjMCN5nusfW/AtBAZhx8UVVlhhhIKXvQ+dFODQIdzO + oDXybs1zVHWOj31zqbbJnsfsVZ9Uf3p9k6xpJ3WFY9b85WasqTDN1xmSd6swD4N8 + ... + username: github_user_name +</code></pre> + +<h3 id="username-password-authentication">Username &amp; password authentication</h3> + +<p>Configure the seed job like:</p> + +<pre><code>apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + seedJobs: + - id: jenkins-operator-user-pass + credentialType: usernamePassword + credentialID: k8s-user-pass + targets: &quot;cicd/jobs/*.jenkins&quot; + description: &quot;Jenkins Operator repository&quot; + repositoryBranch: master + repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git +</code></pre> + +<p>and create a Kubernetes Secret (name of secret should be the same from <code>credentialID</code> field):</p> + +<pre><code>apiVersion: v1 +kind: Secret +metadata: + name: k8s-user-pass +stringData: + username: github_user_name + password: password_or_token +</code></pre> + +<h2 id="http-proxy-for-downloading-plugins">HTTP Proxy for downloading plugins</h2> + +<p>To use forwarding proxy with an operator to download plugins you need to add the following environment variable to Jenkins Custom Resource (CR), e.g.:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containers<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-master<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>env<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>CURL_OPTIONS<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-L<span style="color:#f8f8f8;text-decoration:underline"> </span>-x<span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;proxy_url&gt;</code></pre></div> +<p>In <code>CURL_OPTIONS</code> var you can set additional arguments to <code>curl</code> command.</p> + +<h2 id="pulling-docker-images-from-private-repositories">Pulling Docker images from private repositories</h2> + +<p>To pull a Docker Image from private repository you can use <code>imagePullSecrets</code>.</p> + +<p>Please follow the instructions on <a href="https://kubernetes.io/docs/concepts/containers/images/?origin_team=T42NTAGHM#creating-a-secret-with-a-docker-config" target="_blank">creating a secret with a docker config</a>.</p> + +<h3 id="docker-hub-configuration">Docker Hub Configuration</h3> + +<p>To use Docker Hub additional steps are required.</p> + +<p>Edit the previously created secret:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl -n &lt;namespace&gt; edit secret &lt;name&gt;</code></pre></div> +<p>The <code>.dockerconfigjson</code> key&rsquo;s value needs to be replaced with a modified version.</p> + +<p>After modifications, it needs to be encoded as a Base64 value before setting the <code>.dockerconfigjson</code> key.</p> + +<p>Example config file to modify and use:</p> + +<pre><code>{ + &quot;auths&quot;:{ + &quot;https://index.docker.io/v1/&quot;:{ + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + }, + &quot;auth.docker.io&quot;:{ + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + }, + &quot;registry.docker.io&quot;:{ + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + }, + &quot;docker.io&quot;:{ + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + }, + &quot;https://registry-1.docker.io/v2/&quot;: { + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + }, + &quot;registry-1.docker.io/v2/&quot;: { + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + }, + &quot;registry-1.docker.io&quot;: { + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + }, + &quot;https://registry-1.docker.io&quot;: { + &quot;username&quot;:&quot;user&quot;, + &quot;password&quot;:&quot;password&quot;, + &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, + &quot;auth&quot;:&quot;base64 of string user:password&quot; + } + } +} +</code></pre> + + + + Docs: Configuration https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configuration/ @@ -777,6 +1150,172 @@ The <code>/sbin/tini -s -- /usr/local/bin/jenkins.sh</code> command + + Docs: Customization + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/customization/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/customization/ + + + + + +<p>Jenkins can be customized using groovy scripts or the <a href="https://github.com/jenkinsci/configuration-as-code-plugin" target="_blank">configuration as code plugin</a>. +By using a <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" target="_blank">ConfigMap</a> you can create your own <strong>Jenkins</strong> customized configuration. +Then you must reference the <strong><code>ConfigMap</code></strong> in the <strong>Jenkins</strong> pod customization file in <code>spec.groovyScripts</code> or <code>spec.configurationAsCode</code></p> + +<p>For example create a <strong><code>ConfigMap</code></strong> with name <code>jenkins-operator-user-configuration</code>. Then, modify the <strong>Jenkins</strong> manifest to look like this:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha2<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>example<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurationAsCode<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>groovyScripts<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration</code></pre></div> +<p>Here is an example of <code>jenkins-operator-user-configuration</code>:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ConfigMap<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>-configure-theme.groovy<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">| +</span><span style="color:#8f5902;font-style:italic"> import jenkins.*</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.model.*<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>hudson.*<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>hudson.model.*<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>org.jenkinsci.plugins.simpletheme.ThemeElement<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>org.jenkinsci.plugins.simpletheme.CssTextThemeElement<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>org.jenkinsci.plugins.simpletheme.CssUrlThemeElement<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins.getInstance()<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>def<span style="color:#f8f8f8;text-decoration:underline"> </span>decorator<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins.instance.getDescriptorByType(org.codefirst.SimpleThemeDecorator.class)<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>List&lt;ThemeElement&gt;<span style="color:#f8f8f8;text-decoration:underline"> </span>configElements<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>new<span style="color:#f8f8f8;text-decoration:underline"> </span>ArrayList&lt;&gt;();<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configElements.add(new<span style="color:#f8f8f8;text-decoration:underline"> </span>CssTextThemeElement(<span style="color:#4e9a06">&#34;DEFAULT&#34;</span>));<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configElements.add(new<span style="color:#f8f8f8;text-decoration:underline"> </span>CssUrlThemeElement(<span style="color:#4e9a06">&#34;https://cdn.rawgit.com/afonsof/jenkins-material-theme/gh-pages/dist/material-light-green.css&#34;</span>));<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>decorator.setElements(configElements);<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>decorator.save();<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.save()<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>-system-message.yaml<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">| +</span><span style="color:#8f5902;font-style:italic"> jenkins:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>systemMessage<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Configuration as Code integration works!!!&#34;</span></code></pre></div> +<ul> +<li><code>*.groovy</code> is Groovy script configuration</li> +<li><code>*.yaml is</code> configuration as code</li> +</ul> + +<p>If you want to correct your configuration you can edit it while the <strong>Jenkins Operator</strong> is running. +Jenkins will reconcile and apply the new configuration.</p> + +<h3 id="using-secrets-from-a-groovy-script">Using secrets from a Groovy script</h3> + +<p>If you configured <code>spec.groovyScripts.secret.name</code>, then this secret is available to use from map Groovy scripts. +The secrets are loaded to <code>secrets</code> map.</p> + +<p>Create a <a href="https://kubernetes.io/docs/concepts/configuration/secret/" target="_blank">secret</a> with for example the name <code>jenkins-conf-secrets</code>.</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Secret<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>type<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Opaque<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-conf-secrets<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>namespace<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>default<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>SYSTEM_MESSAGE<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>SGVsbG8gd29ybGQ=</code></pre></div> +<p>Then modify the <strong>Jenkins</strong> pod manifest by changing <code>spec.groovyScripts.secret.name</code> to <code>jenkins-conf-secrets</code>.</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha2<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>example<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurationAsCode<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>secret<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-conf-secrets<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>groovyScripts<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>secret<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-conf-secrets</code></pre></div> +<p>Now you can test that the secret is mounted by applying this <code>ConfigMap</code> for Groovy script:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ConfigMap<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>-system-message.groovy<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">| +</span><span style="color:#8f5902;font-style:italic"> import jenkins.*</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.model.*<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>hudson.*<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>hudson.model.*<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins.getInstance()<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.setSystemMessage(secrets<span style="color:#000;font-weight:bold">[</span><span style="color:#4e9a06">&#34;SYSTEM_MESSAGE&#34;</span><span style="color:#000;font-weight:bold">]</span>)<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.save()</code></pre></div> +<p>Or by applying this configuration as code:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ConfigMap<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>-system-message.yaml<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">| +</span><span style="color:#8f5902;font-style:italic"> jenkins:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>systemMessage<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>${SYSTEM_MESSAGE}</code></pre></div> +<p>After this, you should see the <code>Hello world</code> system message from the <strong>Jenkins</strong> homepage.</p> + +<h2 id="install-plugins">Install Plugins</h2> + +<p>Edit Custom Resource under <code>spec.master.plugins</code>:</p> + +<pre><code>apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + master: + plugins: + - name: simple-theme-plugin + version: 0.5.1 +</code></pre> + +<p>Under <code>spec.master.basePlugins</code> you can find plugins for a valid <strong>Jenkins Operator</strong>:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha2<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>example<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>basePlugins<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>kubernetes<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1.18</span>.<span style="color:#0000cf;font-weight:bold">3</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>workflow-job<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;2.34&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>workflow-aggregator<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;2.6&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>git<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">3.12</span>.<span style="color:#0000cf;font-weight:bold">0</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>job-dsl<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;1.76&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configuration-as-code<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;1.29&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configuration-as-code-support<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;1.19&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>kubernetes-credentials-provider<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">0.12</span>.<span style="color:#0000cf;font-weight:bold">1</span></code></pre></div> +<p>You can change their versions.</p> + +<p>The <strong>Jenkins Operator</strong> will then automatically install plugins after the Jenkins master pod restarts.</p> + + + + Docs: Customization https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/customization/ @@ -1056,6 +1595,30 @@ spec: + + Docs: AKS + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/aks/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/aks/ + + + + <p>Azure AKS managed Kubernetes service adds to every pod the following environment variables:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KUBERNETES_PORT_443_TCP_ADDR<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KUBERNETES_PORT<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>tcp<span style="color:#000;font-weight:bold">:</span>//<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KUBERNETES_PORT_443_TCP<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>tcp<span style="color:#000;font-weight:bold">:</span>//<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KUBERNETES_SERVICE_HOST<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span></code></pre></div> +<p>The operator is aware of it and omits these environment variables when checking if a Jenkins pod environment has been changed. It prevents the +restart of a Jenkins pod over and over again.</p> + + + + Docs: AKS https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/aks/ @@ -1104,6 +1667,88 @@ the restart of a Jenkins pod over and over again.</p> + + Docs: Configure backup and restore + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/configure-backup-and-restore/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/configure-backup-and-restore/ + + + + + +<p>Backup and restore is done by a container sidecar.</p> + +<h3 id="pvc">PVC</h3> + +<h4 id="create-pvc">Create PVC</h4> + +<p>Save to the file named pvc.yaml:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>PersistentVolumeClaim<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;pvc_name<span style="color:#8f5902;font-style:italic">&gt; +</span><span style="color:#8f5902;font-style:italic"> namespace: &lt;namespace&gt;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>accessModes<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>ReadWriteOnce<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>resources<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>requests<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>storage<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>500Gi</code></pre></div> +<p>Run the following command:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ kubectl -n &lt;namespace&gt; create -f pvc.yaml</code></pre></div> +<h4 id="configure-jenkins-cr">Configure Jenkins CR</h4> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha2<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;cr_name<span style="color:#8f5902;font-style:italic">&gt; +</span><span style="color:#8f5902;font-style:italic"> namespace: &lt;namespace&gt;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>securityContext<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>runAsUser<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>fsGroup<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containers<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-master<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>image<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins/jenkins<span style="color:#000;font-weight:bold">:</span>lts<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container responsible for the backup and restore</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>env<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_DIR<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/backup<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>JENKINS_HOME<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_COUNT<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;3&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># keep only the 2 most recent backups</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>image<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>virtuslab/jenkins-operator-backup-pvc<span style="color:#000;font-weight:bold">:</span>v0.<span style="color:#0000cf;font-weight:bold">0.7</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># look at backup/pvc directory</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>imagePullPolicy<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IfNotPresent<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>volumeMounts<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># Jenkins home volume</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># backup volume</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>volumes<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># PVC volume where backups will be stored</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>persistentVolumeClaim<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>claimName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;pvc_name<span style="color:#8f5902;font-style:italic">&gt; +</span><span style="color:#8f5902;font-style:italic"> backup:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containerName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container name is responsible for backup</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>action<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/backup.sh<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># this command is invoked on &#34;backup&#34; container to make backup, for example /home/user/bin/backup.sh &lt;backup_number&gt;, &lt;backup_number&gt; is passed by operator</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>interval<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">30</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># how often make backup in seconds</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>makeBackupBeforePodDeletion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">true</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># make a backup before pod deletion</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>restore<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containerName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container name is responsible for restore backup</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>action<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/restore.sh<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># this command is invoked on &#34;backup&#34; container to make restore backup, for example /home/user/bin/restore.sh &lt;backup_number&gt;, &lt;backup_number&gt; is passed by operator</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">#recoveryOnce: &lt;backup_number&gt; # if want to restore specific backup configure this field and then Jenkins will be restarted and desired backup will be restored</span></code></pre></div> + + + Docs: Configure backup and restore https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configure-backup-and-restore/ @@ -1266,6 +1911,189 @@ the restart of a Jenkins pod over and over again.</p> + + Docs: Custom Backup and Restore Providers + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/custom-backup-and-restore/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/custom-backup-and-restore/ + + + + + +<p>With enough effort one can create a custom backup and restore provider +for the Jenkins Operator.</p> + +<h2 id="requirements">Requirements</h2> + +<p>Two commands (e.g. scripts) are required:</p> + +<ul> +<li>a backup command, e.g. <code>backup.sh</code> that takes one argument, a <strong>backup number</strong></li> +<li>a restore command, e.g. <code>backup.sh</code> that takes one argument, a <strong>backup number</strong></li> +</ul> + +<p>Both scripts need to return an exit code of <code>0</code> on success and <code>1</code> or greater for failure.</p> + +<p>One of those scripts (or the entry point of the container) needs to be responsible +for backup cleanup or rotation if required, or an external system.</p> + +<h2 id="how-it-works">How it works</h2> + +<p>The mechanism relies on basic Kubernetes and UNIX functionalities.</p> + +<p>The backup (and restore) container runs as a sidecar in the same +Kubernetes pod as the Jenkins master.</p> + +<p>Name of the backup and restore containers can be set as necessary using +<code>spec.backup.containerName</code> and <code>spec.restore.containerName</code>. +In most cases it will be the same container, but we allow for less common use cases.</p> + +<p>The operator will call a backup or restore commands inside a sidecar container when necessary:</p> + +<ul> +<li>backup command (defined in <code>spec.backup.action.exec.command</code>) +will be called every <code>N</code> seconds configurable in: <code>spec.backup.interval</code> +and on pod shutdown (if enabled in <code>spec.backup.makeBackupBeforePodDeletion</code>) +with an integer representing the current backup number as first and only argument</li> +<li>restore command (defined in <code>spec.restore.action.exec.command</code>) +will be called at Jenkins startup +with an integer representing the backup number to restore as first and only argument +(can be overridden using <code>spec.restore.recoveryOnce</code>)</li> +</ul> + +<h2 id="example-aws-s3-backup-using-the-cli">Example AWS S3 backup using the CLI</h2> + +<p>This example shows abbreviated version of a simple AWS S3 backup implementation +using: <code>aws-cli</code>, <code>bash</code> and <code>kube2iam</code>.</p> + +<p>In addition to your normal <code>Jenkins</code> <code>CustomResource</code> some additional settings +for backup and restore are required, e.g.:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>example<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>namespace<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>masterAnnotations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>iam.amazonaws.com/role<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;my-example-backup-role&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># tell kube2iam where the AWS IAM role is</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containers<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-master<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>...<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container responsible for backup and restore</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>image<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>quay.io/virtuslab/aws-cli<span style="color:#000;font-weight:bold">:</span><span style="color:#0000cf;font-weight:bold">1.16</span>.<span style="color:#0000cf;font-weight:bold">263</span>-<span style="color:#0000cf;font-weight:bold">2</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>workingDir<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># our container entry point</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>sleep<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>infinity<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>env<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_BUCKET<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>my-example-bucket<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># the S3 bucket name to use</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_PATH<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>my-backup-path<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># the S3 bucket path prefix to use</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>JENKINS_HOME<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># the path to mount jenkins home dir in the backup container</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>volumeMounts<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># Jenkins home volume</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/backup.sh<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup-scripts<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>subPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup.sh<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>readOnly<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">true</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/restore.sh<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup-scripts<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>subPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>restore.sh<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>readOnly<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">true</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>volumes<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup-scripts<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configMap<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>defaultMode<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">0754</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-backup-s3<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>securityContext<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># make sure both containers use the same UID and GUID</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>runAsUser<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>fsGroup<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>...<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containerName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container name responsible for backup</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>interval<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">3600</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># how often make a backup in seconds</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>makeBackupBeforePodDeletion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">true</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># trigger backup just before deleting the pod</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>action<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># this command is invoked on &#34;backup&#34; container to create a backup,</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># &lt;backup_number&gt; is passed by operator,</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># for example /home/user/bin/backup.sh &lt;backup_number&gt;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/backup.sh<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>restore<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containerName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container name is responsible for restore backup</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>action<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># this command is invoked on &#34;backup&#34; container to restore a backup,</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># &lt;backup_number&gt; is passed by operator</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># for example /home/user/bin/restore.sh &lt;backup_number&gt;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/restore.sh<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span><span style="color:#8f5902;font-style:italic"># recoveryOnce: &lt;backup_number&gt; # if want to restore specific backup configure this field and then Jenkins will be restarted and desired backup will be restored</span></code></pre></div> +<p>The actual backup and restore scripts will be provided in a <code>ConfigMap</code>:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ConfigMap<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-backup-s3<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>namespace<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>labels<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>app<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup.sh<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>|<span style="color:#8f5902;font-style:italic">- +</span><span style="color:#8f5902;font-style:italic"> #!/bin/bash -xeu</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>!<span style="color:#f8f8f8;text-decoration:underline"> </span>$<span style="color:#8f5902;font-style:italic"># -eq 1 ]] &amp;&amp; echo &#34;Usage: $0 backup_number&#34; &amp;&amp; exit 1;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_BUCKET}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;BACKUP_BUCKET&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_PATH}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;BACKUP_PATH&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${JENKINS_HOME}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;JENKINS_HOME&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup_number=$<span style="color:#0000cf;font-weight:bold">1</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Running backup #${backup_number}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_TMP_DIR=$(mktemp<span style="color:#f8f8f8;text-decoration:underline"> </span>-d)<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>tar<span style="color:#f8f8f8;text-decoration:underline"> </span>-C<span style="color:#f8f8f8;text-decoration:underline"> </span>${JENKINS_HOME}<span style="color:#f8f8f8;text-decoration:underline"> </span>-czf<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_TMP_DIR}/${backup_number}.tar.gz&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>--exclude<span style="color:#f8f8f8;text-decoration:underline"> </span>jobs/<span style="color:#8f5902;font-style:italic">*/workspace*</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-c<span style="color:#f8f8f8;text-decoration:underline"> </span>jobs<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>\<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>aws<span style="color:#f8f8f8;text-decoration:underline"> </span>s3<span style="color:#f8f8f8;text-decoration:underline"> </span>cp<span style="color:#f8f8f8;text-decoration:underline"> </span>${BACKUP_TMP_DIR}/${backup_number}.tar.gz<span style="color:#f8f8f8;text-decoration:underline"> </span>s3<span style="color:#000;font-weight:bold">:</span>//${BACKUP_BUCKET}/${BACKUP_PATH}/${backup_number}.tar.gz<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span>Done<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>restore.sh<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>|<span style="color:#8f5902;font-style:italic">- +</span><span style="color:#8f5902;font-style:italic"> #!/bin/bash -xeu</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>!<span style="color:#f8f8f8;text-decoration:underline"> </span>$<span style="color:#8f5902;font-style:italic"># -eq 1 ]] &amp;&amp; echo &#34;Usage: $0 backup_number&#34; &amp;&amp; exit 1</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_BUCKET}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;BACKUP_BUCKET&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_PATH}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;BACKUP_PATH&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${JENKINS_HOME}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;JENKINS_HOME&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup_number=$<span style="color:#0000cf;font-weight:bold">1</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Running restore #${backup_number}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_TMP_DIR=$(mktemp<span style="color:#f8f8f8;text-decoration:underline"> </span>-d)<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>aws<span style="color:#f8f8f8;text-decoration:underline"> </span>s3<span style="color:#f8f8f8;text-decoration:underline"> </span>cp<span style="color:#f8f8f8;text-decoration:underline"> </span>s3<span style="color:#000;font-weight:bold">:</span>//${BACKUP_BUCKET}/${BACKUP_PATH}/${backup_number}.tar.gz<span style="color:#f8f8f8;text-decoration:underline"> </span>${BACKUP_TMP_DIR}/${backup_number}.tar.gz<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>tar<span style="color:#f8f8f8;text-decoration:underline"> </span>-C<span style="color:#f8f8f8;text-decoration:underline"> </span>${JENKINS_HOME}<span style="color:#f8f8f8;text-decoration:underline"> </span>-zxf<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_TMP_DIR}/${backup_number}.tar.gz&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span>Done</code></pre></div> +<p>In our example we will use S3 bucket lifecycle policy to keep +the number of backups under control, e.g. Cloud Formation fragment:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml"><span style="color:#f8f8f8;text-decoration:underline"> </span>Type<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>AWS<span style="color:#000;font-weight:bold">::</span>S3<span style="color:#000;font-weight:bold">::</span>Bucket<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Properties<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BucketName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>my-example-bucket<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>...<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>LifecycleConfiguration<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Rules<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>Id<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BackupCleanup<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Status<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Enabled<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Prefix<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>my-backup-path<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ExpirationInDays<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">7</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>NoncurrentVersionExpirationInDays<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">14</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>AbortIncompleteMultipartUpload<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>DaysAfterInitiation<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">3</span></code></pre></div> + + + Docs: Custom Backup and Restore Providers https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/custom-backup-and-restore/ @@ -1529,62 +2357,29 @@ and add explicit references to the existing <code>ConfigMap</code> a - Docs: Tools - https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/tools/ + Docs: Diagnostics + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/diagnostics/ Mon, 05 Aug 2019 00:00:00 +0000 - https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/tools/ + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/diagnostics/ +<p>Turn on debug in <strong>Jenkins Operator</strong> deployment:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">sed -i <span style="color:#4e9a06">&#39;s|\(args:\).*|\1\ [&#34;--debug&#34;\]|&#39;</span> deploy/operator.yaml +kubectl apply -f deploy/operator.yaml</code></pre></div> +<p>Watch Kubernetes events:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl get events --sort-by<span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;{.lastTimestamp}&#39;</span></code></pre></div> +<p>Verify Jenkins master logs:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl logs -f jenkins-&lt;cr_name&gt;</code></pre></div> +<p>Verify the <code>jenkins-operator</code> logs:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl logs deployment/jenkins-operator</code></pre></div> +<h2 id="troubleshooting">Troubleshooting</h2> - -<div class="pageinfo pageinfo-primary"> -<p>This document explains how to install the Go tools used by the development process.</p> - -</div> - - -<h2 id="configure-environment-variables">Configure environment variables</h2> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">export</span> <span style="color:#000">GOPATH</span><span style="color:#ce5c00;font-weight:bold">=</span>/home/go <span style="color:#8f5902;font-style:italic"># example value</span> -<span style="color:#204a87">export</span> <span style="color:#000">GOROOT</span><span style="color:#ce5c00;font-weight:bold">=</span>/usr/lib/go-1.12 <span style="color:#8f5902;font-style:italic"># example value</span> -<span style="color:#204a87">export</span> <span style="color:#000">PATH</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#000">$GOPATH</span>/bin:<span style="color:#000">$PATH</span></code></pre></div> -<h2 id="goimports">goimports</h2> - -<pre><code>go get golang.org/x/tools/cmd/goimports -cd $GOPATH/src/golang.org/x/tools/cmd/goimports -go build -go install -</code></pre> - -<h2 id="golint">golint</h2> - -<pre><code>go get -u golang.org/x/lint/golint -cd $GOPATH/src/golang.org/x/lint/golint -go build -go install -</code></pre> - -<h2 id="checkmake">checkmake</h2> - -<pre><code>go get github.com/mrtazz/checkmake -cd $GOPATH/src/github.com/mrtazz/checkmake -go build -go install -</code></pre> - -<h2 id="staticcheck">staticcheck</h2> - -<pre><code>mkdir -p $GOPATH/src/github.com/dominikh/ -cd $GOPATH/src/github.com/dominikh/ -git clone https://github.com/dominikh/go-tools.git -cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck -go build -go install -</code></pre> - +<p>Delete the Jenkins master pod and wait for the new one to come up:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl delete pod jenkins-&lt;cr_name&gt;</code></pre></div> @@ -1642,6 +2437,1993 @@ kubectl apply -f deploy/operator.yaml</code></pre></div> + + Docs: Schema + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/schema/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/schema/ + + + + + +<div class="pageinfo pageinfo-primary"> +<p>This document contains API scheme for <code>jenkins-operator</code> Custom Resource Definition manifest</p> + +</div> + + +<p>Packages:</p> +<ul> +<li> +<a href="#jenkins.io">jenkins.io</a> +</li> +</ul> +<h2 id="jenkins.io">jenkins.io</h2> +<p> +<p>Package v1alpha2 contains the API Schema definitions for the jenkins.io v1alpha2 API group</p> +</p> +Resource Types: +<ul><li> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Jenkins">Jenkins</a> +</li></ul> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Jenkins">Jenkins +</h3> +<p> +<p>Jenkins is the Schema for the jenkins API</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>apiVersion</code></br> +string</td> +<td> +<code> +jenkins.io/v1alpha2 +</code> +</td> +</tr> +<tr> +<td> +<code>kind</code></br> +string +</td> +<td><code>Jenkins</code></td> +</tr> +<tr> +<td> +<code>metadata</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#objectmeta-v1-meta"> +Kubernetes meta/v1.ObjectMeta +</a> +</em> +</td> +<td> +Refer to the Kubernetes API documentation for the fields of the +<code>metadata</code> field. +</td> +</tr> +<tr> +<td> +<code>spec</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsSpec"> +JenkinsSpec +</a> +</em> +</td> +<td> +<p>Spec defines the desired state of the Jenkins</p> +<br/> +<br/> +<table> +<tr> +<td> +<code>master</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsMaster"> +JenkinsMaster +</a> +</em> +</td> +<td> +<p>Master represents Jenkins master pod properties and Jenkins plugins. +Every single change here requires a pod restart.</p> +</td> +</tr> +<tr> +<td> +<code>seedJobs</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>SeedJobs defines a list of Jenkins Seed Job configurations +More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines</a></p> +</td> +</tr> +<tr> +<td> +<code>service</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service"> +Service +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Service is the Kubernetes service of the Jenkins master HTTP pod +Defaults to : +port: 8080 +type: ClusterIP</p> +</td> +</tr> +<tr> +<td> +<code>slaveService</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service"> +Service +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Service is the Kubernetes service of the Jenkins slave pods +Defaults to : +port: 50000 +type: ClusterIP</p> +</td> +</tr> +<tr> +<td> +<code>backup</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Backup"> +Backup +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Backup defines the configuration of a Jenkins backup +More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore</a></p> +</td> +</tr> +<tr> +<td> +<code>restore</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Restore"> +Restore +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Backup defines the configuration of a Jenkins backup restore +More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore</a></p> +</td> +</tr> +<tr> +<td> +<code>groovyScripts</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.GroovyScripts"> +GroovyScripts +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>GroovyScripts defines the configuration of Jenkins customization via groovy scripts</p> +</td> +</tr> +<tr> +<td> +<code>configurationAsCode</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigurationAsCode"> +ConfigurationAsCode +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>ConfigurationAsCode defines the configuration of Jenkins customization via the Configuration as Code Jenkins plugin</p> +</td> +</tr> +</table> +</td> +</tr> +<tr> +<td> +<code>status</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsStatus"> +JenkinsStatus +</a> +</em> +</td> +<td> +<p>Status defines the observed state of Jenkins</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.AppliedGroovyScript">AppliedGroovyScript +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsStatus">JenkinsStatus</a>) +</p> +<p> +<p>AppliedGroovyScript is the applied groovy script in Jenkins by the operator</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>configurationType</code></br> +<em> +string +</em> +</td> +<td> +<p>ConfigurationType is the name of the configuration type(base-groovy, user-groovy, user-casc)</p> +</td> +</tr> +<tr> +<td> +<code>source</code></br> +<em> +string +</em> +</td> +<td> +<p>Source is the name of source where is located groovy script</p> +</td> +</tr> +<tr> +<td> +<code>name</code></br> +<em> +string +</em> +</td> +<td> +<p>Name is the name of the groovy script</p> +</td> +</tr> +<tr> +<td> +<code>Hash</code></br> +<em> +string +</em> +</td> +<td> +<p>Hash is the hash of the groovy script and secrets which it uses</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Backup">Backup +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> +<p>Backup defines the configuration of a Jenkins backup</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>containerName</code></br> +<em> +string +</em> +</td> +<td> +<p>ContainerName is the container name responsible for backup operation</p> +</td> +</tr> +<tr> +<td> +<code>action</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Handler"> +Handler +</a> +</em> +</td> +<td> +<p>Action defines the action which performs the backup in the backup container sidecar</p> +</td> +</tr> +<tr> +<td> +<code>interval</code></br> +<em> +uint64 +</em> +</td> +<td> +<p>Interval tells you how often the backup is made in seconds +Defaults to 30.</p> +</td> +</tr> +<tr> +<td> +<code>makeBackupBeforePodDeletion</code></br> +<em> +bool +</em> +</td> +<td> +<p>MakeBackupBeforePodDeletion tells the operator to make a backup before Jenkins master pod deletion</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigMapRef">ConfigMapRef +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Customization">Customization</a>) +</p> +<p> +<p>ConfigMapRef is the reference to Kubernetes ConfigMap</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>name</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigurationAsCode">ConfigurationAsCode +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> +<p>ConfigurationAsCode defines configuration of Jenkins customization via the Configuration as Code Jenkins plugin</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>Customization</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Customization"> +Customization +</a> +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Container">Container +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsMaster">JenkinsMaster</a>) +</p> +<p> +<p>Container defines the Kubernetes container attributes</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>name</code></br> +<em> +string +</em> +</td> +<td> +<p>Name of the container specified as a DNS_LABEL. +Each container in a pod must have a unique name (DNS_LABEL).</p> +</td> +</tr> +<tr> +<td> +<code>image</code></br> +<em> +string +</em> +</td> +<td> +<p>Docker image name. +More info: <a href="https://kubernetes.io/docs/concepts/containers/images">https://kubernetes.io/docs/concepts/containers/images</a></p> +</td> +</tr> +<tr> +<td> +<code>imagePullPolicy</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#pullpolicy-v1-core"> +Kubernetes core/v1.PullPolicy +</a> +</em> +</td> +<td> +<p>Image pull policy. +One of Always, Never, IfNotPresent. +Defaults to Always.</p> +</td> +</tr> +<tr> +<td> +<code>resources</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#resourcerequirements-v1-core"> +Kubernetes core/v1.ResourceRequirements +</a> +</em> +</td> +<td> +<p>Compute Resources required by this container. +More info: <a href="https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/">https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/</a></p> +</td> +</tr> +<tr> +<td> +<code>command</code></br> +<em> +[]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Entrypoint array. Not executed within a shell. +The docker image&rsquo;s ENTRYPOINT is used if this is not provided. +Variable references $(VAR_NAME) are expanded using the container&rsquo;s environment. If a variable +cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax +can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, +regardless of whether the variable exists or not. +More info: <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell">https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell</a></p> +</td> +</tr> +<tr> +<td> +<code>args</code></br> +<em> +[]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Arguments to the entrypoint. +The docker image&rsquo;s CMD is used if this is not provided. +Variable references $(VAR_NAME) are expanded using the container&rsquo;s environment. If a variable +cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax +can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, +regardless of whether the variable exists or not. +More info: <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell">https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell</a></p> +</td> +</tr> +<tr> +<td> +<code>workingDir</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Container&rsquo;s working directory. +If not specified, the container runtime&rsquo;s default will be used, which +might be configured in the container image.</p> +</td> +</tr> +<tr> +<td> +<code>ports</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#containerport-v1-core"> +[]Kubernetes core/v1.ContainerPort +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>List of ports to expose from the container. Exposing a port here gives +the system additional information about the network connections a +container uses, but is primarily informational. Not specifying a port here +DOES NOT prevent that port from being exposed. Any port which is +listening on the default &ldquo;0.0.0.0&rdquo; address inside a container will be +accessible from the network.</p> +</td> +</tr> +<tr> +<td> +<code>envFrom</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#envfromsource-v1-core"> +[]Kubernetes core/v1.EnvFromSource +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>List of sources to populate environment variables in the container. +The keys defined within a source must be a C_IDENTIFIER. All invalid keys +will be reported as an event when the container is starting. When a key exists in multiple +sources, the value associated with the last source will take precedence. +Values defined by an Env with a duplicate key will take precedence.</p> +</td> +</tr> +<tr> +<td> +<code>env</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#envvar-v1-core"> +[]Kubernetes core/v1.EnvVar +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>List of environment variables to set in the container.</p> +</td> +</tr> +<tr> +<td> +<code>volumeMounts</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#volumemount-v1-core"> +[]Kubernetes core/v1.VolumeMount +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Pod volumes to mount into the container&rsquo;s filesystem.</p> +</td> +</tr> +<tr> +<td> +<code>livenessProbe</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#probe-v1-core"> +Kubernetes core/v1.Probe +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Periodic probe of container liveness. +Container will be restarted if the probe fails.</p> +</td> +</tr> +<tr> +<td> +<code>readinessProbe</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#probe-v1-core"> +Kubernetes core/v1.Probe +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Periodic probe of container service readiness. +Container will be removed from service endpoints if the probe fails.</p> +</td> +</tr> +<tr> +<td> +<code>lifecycle</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#lifecycle-v1-core"> +Kubernetes core/v1.Lifecycle +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Actions that the management system should take in response to container lifecycle events.</p> +</td> +</tr> +<tr> +<td> +<code>securityContext</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#securitycontext-v1-core"> +Kubernetes core/v1.SecurityContext +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Security options the pod should run with. +More info: <a href="https://kubernetes.io/docs/concepts/policy/security-context/">https://kubernetes.io/docs/concepts/policy/security-context/</a> +More info: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/">https://kubernetes.io/docs/tasks/configure-pod-container/security-context/</a></p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Customization">Customization +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.ConfigurationAsCode">ConfigurationAsCode</a>, +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.GroovyScripts">GroovyScripts</a>) +</p> +<p> +<p>Customization defines configuration of Jenkins customization</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>secret</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretRef"> +SecretRef +</a> +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>configurations</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigMapRef"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigMapRef +</a> +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.GroovyScripts">GroovyScripts +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> +<p>GroovyScripts defines configuration of Jenkins customization via groovy scripts</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>Customization</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Customization"> +Customization +</a> +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Handler">Handler +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Backup">Backup</a>, +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Restore">Restore</a>) +</p> +<p> +<p>Handler defines a specific action that should be taken</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>exec</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#execaction-v1-core"> +Kubernetes core/v1.ExecAction +</a> +</em> +</td> +<td> +<p>Exec specifies the action to take.</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsCredentialType">JenkinsCredentialType +(<code>string</code> alias)</p></h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.SeedJob">SeedJob</a>) +</p> +<p> +<p>JenkinsCredentialType defines the type of Jenkins credential used in the seed job mechanism</p> +</p> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsMaster">JenkinsMaster +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> +<p>JenkinsMaster defines the Jenkins master pod attributes and plugins, +every single change requires a Jenkins master pod restart</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>masterAnnotations</code></br> +<em> +map[string]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Annotations is an unstructured key value map stored with a resource that may be +set by external tools to store and retrieve arbitrary metadata. They are not +queryable and should be preserved when modifying objects. +More info: <a href="http://kubernetes.io/docs/user-guide/annotations">http://kubernetes.io/docs/user-guide/annotations</a></p> +</td> +</tr> +<tr> +<td> +<code>nodeSelector</code></br> +<em> +map[string]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>NodeSelector is a selector which must be true for the pod to fit on a node. +Selector which must match a node&rsquo;s labels for the pod to be scheduled on that node. +More info: <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/">https://kubernetes.io/docs/concepts/configuration/assign-pod-node/</a></p> +</td> +</tr> +<tr> +<td> +<code>securityContext</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#podsecuritycontext-v1-core"> +Kubernetes core/v1.PodSecurityContext +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>SecurityContext that applies to all the containers of the Jenkins +Master. As per kubernetes specification, it can be overridden +for each container individually. +Defaults to: +runAsUser: 1000 +fsGroup: 1000</p> +</td> +</tr> +<tr> +<td> +<code>containers</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Container"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Container +</a> +</em> +</td> +<td> +<p>List of containers belonging to the pod. +Containers cannot currently be added or removed. +There must be at least one container in a Pod. +Defaults to: +- image: jenkins/jenkins:lts +imagePullPolicy: Always +livenessProbe: +failureThreshold: 12 +httpGet: +path: /login +port: http +scheme: HTTP +initialDelaySeconds: 80 +periodSeconds: 10 +successThreshold: 1 +timeoutSeconds: 5 +name: jenkins-master +readinessProbe: +failureThreshold: 3 +httpGet: +path: /login +port: http +scheme: HTTP +initialDelaySeconds: 30 +periodSeconds: 10 +successThreshold: 1 +timeoutSeconds: 1 +resources: +limits: +cpu: 1500m +memory: 3Gi +requests: +cpu: &ldquo;1&rdquo; +memory: 600Mi</p> +</td> +</tr> +<tr> +<td> +<code>imagePullSecrets</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#localobjectreference-v1-core"> +[]Kubernetes core/v1.LocalObjectReference +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. +If specified, these secrets will be passed to individual puller implementations for them to use. For example, +in the case of docker, only DockerConfig type secrets are honored. +More info: <a href="https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod">https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod</a></p> +</td> +</tr> +<tr> +<td> +<code>volumes</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#volume-v1-core"> +[]Kubernetes core/v1.Volume +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>List of volumes that can be mounted by containers belonging to the pod. +More info: <a href="https://kubernetes.io/docs/concepts/storage/volumes">https://kubernetes.io/docs/concepts/storage/volumes</a></p> +</td> +</tr> +<tr> +<td> +<code>basePlugins</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin +</a> +</em> +</td> +<td> +<p>BasePlugins contains plugins required by operator +Defaults to : +- name: kubernetes +version: 1.15.7 +- name: workflow-job +version: &ldquo;2.32&rdquo; +- name: workflow-aggregator +version: &ldquo;2.6&rdquo; +- name: git +version: 3.10.0 +- name: job-dsl +version: &ldquo;1.74&rdquo; +- name: configuration-as-code +version: &ldquo;1.19&rdquo; +- name: configuration-as-code-support +version: &ldquo;1.19&rdquo; +- name: kubernetes-credentials-provider +version: 0.12.1</p> +</td> +</tr> +<tr> +<td> +<code>plugins</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Plugins contains plugins required by user</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsSpec">JenkinsSpec +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Jenkins">Jenkins</a>) +</p> +<p> +<p>JenkinsSpec defines the desired state of the Jenkins</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>master</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsMaster"> +JenkinsMaster +</a> +</em> +</td> +<td> +<p>Master represents Jenkins master pod properties and Jenkins plugins. +Every single change here requires a pod restart.</p> +</td> +</tr> +<tr> +<td> +<code>seedJobs</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>SeedJobs defines list of Jenkins Seed Job configurations +More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines</a></p> +</td> +</tr> +<tr> +<td> +<code>service</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service"> +Service +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Service is Kubernetes service of Jenkins master HTTP pod +Defaults to : +port: 8080 +type: ClusterIP</p> +</td> +</tr> +<tr> +<td> +<code>slaveService</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service"> +Service +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Service is Kubernetes service of Jenkins slave pods +Defaults to : +port: 50000 +type: ClusterIP</p> +</td> +</tr> +<tr> +<td> +<code>backup</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Backup"> +Backup +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Backup defines configuration of Jenkins backup +More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore</a></p> +</td> +</tr> +<tr> +<td> +<code>restore</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Restore"> +Restore +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Backup defines configuration of Jenkins backup restore +More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore</a></p> +</td> +</tr> +<tr> +<td> +<code>groovyScripts</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.GroovyScripts"> +GroovyScripts +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>GroovyScripts defines configuration of Jenkins customization via groovy scripts</p> +</td> +</tr> +<tr> +<td> +<code>configurationAsCode</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigurationAsCode"> +ConfigurationAsCode +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>ConfigurationAsCode defines configuration of Jenkins customization via Configuration as Code Jenkins plugin</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsStatus">JenkinsStatus +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Jenkins">Jenkins</a>) +</p> +<p> +<p>JenkinsStatus defines the observed state of Jenkins</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>operatorVersion</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>OperatorVersion is the operator version which manages this CR</p> +</td> +</tr> +<tr> +<td> +<code>provisionStartTime</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#time-v1-meta"> +Kubernetes meta/v1.Time +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>ProvisionStartTime is a time when Jenkins master pod has been created</p> +</td> +</tr> +<tr> +<td> +<code>baseConfigurationCompletedTime</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#time-v1-meta"> +Kubernetes meta/v1.Time +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>BaseConfigurationCompletedTime is a time when Jenkins base configuration phase has been completed</p> +</td> +</tr> +<tr> +<td> +<code>userConfigurationCompletedTime</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#time-v1-meta"> +Kubernetes meta/v1.Time +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>UserConfigurationCompletedTime is a time when Jenkins user configuration phase has been completed</p> +</td> +</tr> +<tr> +<td> +<code>restoredBackup</code></br> +<em> +uint64 +</em> +</td> +<td> +<em>(Optional)</em> +<p>RestoredBackup is the restored backup number after Jenkins master pod restart</p> +</td> +</tr> +<tr> +<td> +<code>lastBackup</code></br> +<em> +uint64 +</em> +</td> +<td> +<em>(Optional)</em> +<p>LastBackup is the latest backup number</p> +</td> +</tr> +<tr> +<td> +<code>pendingBackup</code></br> +<em> +uint64 +</em> +</td> +<td> +<em>(Optional)</em> +<p>PendingBackup is the pending backup number</p> +</td> +</tr> +<tr> +<td> +<code>backupDoneBeforePodDeletion</code></br> +<em> +bool +</em> +</td> +<td> +<em>(Optional)</em> +<p>BackupDoneBeforePodDeletion tells if backup before pod deletion has been made</p> +</td> +</tr> +<tr> +<td> +<code>userAndPasswordHash</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>UserAndPasswordHash is a SHA256 hash made from the username and password</p> +</td> +</tr> +<tr> +<td> +<code>createdSeedJobs</code></br> +<em> +[]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>CreatedSeedJobs contains list of seed job ids already created in Jenkins</p> +</td> +</tr> +<tr> +<td> +<code>appliedGroovyScripts</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.AppliedGroovyScript"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.AppliedGroovyScript +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>AppliedGroovyScripts is a list with all applied groovy scripts in Jenkins by the operator</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Mailgun">Mailgun +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Notification">Notification</a>) +</p> +<p> +<p>Mailgun is handler for Mailgun email service notification channel</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>domain</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>apiKeySecretKeySelector</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector"> +SecretKeySelector +</a> +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>recipient</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>from</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.MicrosoftTeams">MicrosoftTeams +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Notification">Notification</a>) +</p> +<p> +<p>MicrosoftTeams is handler for Microsoft MicrosoftTeams notification channel</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>webHookURLSecretKeySelector</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector"> +SecretKeySelector +</a> +</em> +</td> +<td> +<p>The web hook URL to MicrosoftTeams App</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Notification">Notification +</h3> +<p> +<p>Notification is a service configuration used to send notifications about Jenkins status</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>loggingLevel</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.NotificationLogLevel"> +NotificationLogLevel +</a> +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>verbose</code></br> +<em> +bool +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>name</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>slack</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Slack"> +github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Slack +</a> +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>teams</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.MicrosoftTeams"> +github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.MicrosoftTeams +</a> +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>mailgun</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Mailgun"> +github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Mailgun +</a> +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.NotificationLogLevel">NotificationLogLevel +(<code>string</code> alias)</p></h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Notification">Notification</a>) +</p> +<p> +<p>NotificationLogLevel defines logging level of Notification</p> +</p> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin">Plugin +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsMaster">JenkinsMaster</a>) +</p> +<p> +<p>Plugin defines Jenkins plugin</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>name</code></br> +<em> +string +</em> +</td> +<td> +<p>Name is the name of Jenkins plugin</p> +</td> +</tr> +<tr> +<td> +<code>version</code></br> +<em> +string +</em> +</td> +<td> +<p>Version is the version of Jenkins plugin</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Restore">Restore +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> +<p>Restore defines configuration of Jenkins backup restore operation</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>containerName</code></br> +<em> +string +</em> +</td> +<td> +<p>ContainerName is the container name responsible for restore backup operation</p> +</td> +</tr> +<tr> +<td> +<code>action</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Handler"> +Handler +</a> +</em> +</td> +<td> +<p>Action defines action which performs restore backup in restore container sidecar</p> +</td> +</tr> +<tr> +<td> +<code>recoveryOnce</code></br> +<em> +uint64 +</em> +</td> +<td> +<em>(Optional)</em> +<p>RecoveryOnce if want to restore specific backup set this field and then Jenkins will be restarted and desired backup will be restored</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector">SecretKeySelector +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Mailgun">Mailgun</a>, +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.MicrosoftTeams">MicrosoftTeams</a>, +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Slack">Slack</a>) +</p> +<p> +<p>SecretKeySelector selects a key of a Secret.</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>secret</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#localobjectreference-v1-core"> +Kubernetes core/v1.LocalObjectReference +</a> +</em> +</td> +<td> +<p>The name of the secret in the pod&rsquo;s namespace to select from.</p> +</td> +</tr> +<tr> +<td> +<code>key</code></br> +<em> +string +</em> +</td> +<td> +<p>The key of the secret to select from. Must be a valid secret key.</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretRef">SecretRef +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Customization">Customization</a>) +</p> +<p> +<p>SecretRef is reference to Kubernetes secret</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>name</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob">SeedJob +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> +<p>SeedJob defines configuration for seed job +More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines</a></p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>id</code></br> +<em> +string +</em> +</td> +<td> +<p>ID is the unique seed job name</p> +</td> +</tr> +<tr> +<td> +<code>credentialID</code></br> +<em> +string +</em> +</td> +<td> +<p>CredentialID is the Kubernetes secret name which stores repository access credentials</p> +</td> +</tr> +<tr> +<td> +<code>description</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Description is the description of the seed job</p> +</td> +</tr> +<tr> +<td> +<code>targets</code></br> +<em> +string +</em> +</td> +<td> +<p>Targets is the repository path where the seed job definitions are</p> +</td> +</tr> +<tr> +<td> +<code>repositoryBranch</code></br> +<em> +string +</em> +</td> +<td> +<p>RepositoryBranch is the repository branch where the seed job definitions are</p> +</td> +</tr> +<tr> +<td> +<code>repositoryUrl</code></br> +<em> +string +</em> +</td> +<td> +<p>RepositoryURL is the repository access URL. Can be SSH or HTTPS.</p> +</td> +</tr> +<tr> +<td> +<code>credentialType</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsCredentialType"> +JenkinsCredentialType +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>JenkinsCredentialType is the <a href="https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/">https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/</a> credential type</p> +</td> +</tr> +<tr> +<td> +<code>githubPushTrigger</code></br> +<em> +bool +</em> +</td> +<td> +<em>(Optional)</em> +<p>GitHubPushTrigger is used for GitHub web hooks</p> +</td> +</tr> +<tr> +<td> +<code>buildPeriodically</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>BuildPeriodically is setting for scheduled trigger</p> +</td> +</tr> +<tr> +<td> +<code>pollSCM</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>PollSCM is setting for polling changes in SCM</p> +</td> +</tr> +<tr> +<td> +<code>ignoreMissingFiles</code></br> +<em> +bool +</em> +</td> +<td> +<em>(Optional)</em> +<p>IgnoreMissingFiles is setting for Job DSL API plugin to ignore files that miss</p> +</td> +</tr> +<tr> +<td> +<code>additionalClasspath</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>AdditionalClasspath is setting for Job DSL API plugin to set Additional Classpath</p> +</td> +</tr> +<tr> +<td> +<code>failOnMissingPlugin</code></br> +<em> +bool +</em> +</td> +<td> +<em>(Optional)</em> +<p>FailOnMissingPlugin is setting for Job DSL API plugin that fails job if required plugin is missing</p> +</td> +</tr> +<tr> +<td> +<code>unstableOnDeprecation</code></br> +<em> +bool +</em> +</td> +<td> +<em>(Optional)</em> +<p>UnstableOnDeprecation is setting for Job DSL API plugin that sets build status as unstable if build using deprecated features</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service">Service +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> +<p>Service defines Kubernetes service attributes</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>annotations</code></br> +<em> +map[string]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Annotations is an unstructured key value map stored with a resource that may be +set by external tools to store and retrieve arbitrary metadata. They are not +queryable and should be preserved when modifying objects. +More info: <a href="http://kubernetes.io/docs/user-guide/annotations">http://kubernetes.io/docs/user-guide/annotations</a></p> +</td> +</tr> +<tr> +<td> +<code>labels</code></br> +<em> +map[string]string +</em> +</td> +<td> +<p>Route service traffic to pods with label keys and values matching this +selector. If empty or not present, the service is assumed to have an +external process managing its endpoints, which Kubernetes will not +modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. +Ignored if type is ExternalName. +More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/">https://kubernetes.io/docs/concepts/services-networking/service/</a></p> +</td> +</tr> +<tr> +<td> +<code>type</code></br> +<em> +<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#servicetype-v1-core"> +Kubernetes core/v1.ServiceType +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>Type determines how the Service is exposed. Defaults to ClusterIP. Valid +options are ExternalName, ClusterIP, NodePort, and LoadBalancer. +&ldquo;ExternalName&rdquo; maps to the specified externalName. +&ldquo;ClusterIP&rdquo; allocates a cluster-internal IP address for load-balancing to +endpoints. Endpoints are determined by the selector or if that is not +specified, by manual construction of an Endpoints object. If clusterIP is +&ldquo;None&rdquo;, no virtual IP is allocated and the endpoints are published as a +set of endpoints rather than a stable IP. +&ldquo;NodePort&rdquo; builds on ClusterIP and allocates a port on every node which +routes to the clusterIP. +&ldquo;LoadBalancer&rdquo; builds on NodePort and creates an +external load-balancer (if supported in the current cloud) which routes +to the clusterIP. +More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types">https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services&mdash;service-types</a></p> +</td> +</tr> +<tr> +<td> +<code>port</code></br> +<em> +int32 +</em> +</td> +<td> +<p>The port that is exposed by this service. +More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies">https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies</a></p> +</td> +</tr> +<tr> +<td> +<code>nodePort</code></br> +<em> +int32 +</em> +</td> +<td> +<em>(Optional)</em> +<p>The port on each node on which this service is exposed when type=NodePort or LoadBalancer. +Usually assigned by the system. If specified, it will be allocated to the service +if unused, or else creation of the service will fail. +Default is to auto-allocate a port if the ServiceType of this Service requires one. +More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport">https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport</a></p> +</td> +</tr> +<tr> +<td> +<code>loadBalancerSourceRanges</code></br> +<em> +[]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>If specified and supported by the platform, this will restrict traffic through the cloud-provider +the load-balancer will be restricted to the specified client IPs. This field will be ignored if the +cloud-provider does not support the feature.&rdquo; +More info: <a href="https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/">https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/</a></p> +</td> +</tr> +<tr> +<td> +<code>loadBalancerIP</code></br> +<em> +string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Only applies to Service Type: LoadBalancer +LoadBalancer will get created with the IP specified in this field. +This feature depends on whether the underlying cloud-provider supports specifying +the loadBalancerIP when a load balancer is created. +This field will be ignored if the cloud-provider does not support the feature.</p> +</td> +</tr> +</tbody> +</table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Slack">Slack +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Notification">Notification</a>) +</p> +<p> +<p>Slack is handler for Slack notification channel</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>webHookURLSecretKeySelector</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector"> +SecretKeySelector +</a> +</em> +</td> +<td> +<p>The web hook URL to Slack App</p> +</td> +</tr> +</tbody> +</table> +<hr/> +<p><em> +Generated with <code>gen-crd-api-reference-docs</code> +on git commit <code>f4c4235</code>. +</em></p> + + + + Docs: Schema https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/schema/ @@ -5398,6 +8180,431 @@ Code that defines the data structures can be found <a href="v0.1.1/jenkin or use the default deployment manifest:</p> <pre><code>$ kubectl -n &lt;namespace&gt; apply -f https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/master/deploy/operator.yaml +</code></pre> + + + + + + Docs: Developer Guide + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/developer-guide/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/developer-guide/ + + + + + + + +<div class="pageinfo pageinfo-primary"> +<p>This document explains how to setup your development environment.</p> + +</div> + + +<h2 id="prerequisites">Prerequisites</h2> + +<ul> +<li><a href="https://github.com/operator-framework/operator-sdk" target="_blank">operator_sdk</a> version v0.8.1</li> +<li><a href="https://git-scm.com/downloads" target="_blank">git</a></li> +<li><a href="https://golang.org/dl/" target="_blank">go</a> version v1.12+</li> +<li><a href="install_dev_tools.md" target="_blank">goimports, golint, checkmake and staticcheck</a></li> +<li><a href="https://kubernetes.io/docs/tasks/tools/install-minikube/" target="_blank">minikube</a> version v1.1.0+ (preferred Hypervisor - <a href="https://www.virtualbox.org/wiki/Downloads" target="_blank">virtualbox</a>)</li> +<li><a href="https://docs.docker.com/install/" target="_blank">docker</a> version 17.03+</li> +</ul> + +<h2 id="clone-repository-and-download-dependencies">Clone repository and download dependencies</h2> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">mkdir -p <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci +<span style="color:#204a87">cd</span> <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci/ +git clone git@github.com:jenkinsci/kubernetes-operator.git +<span style="color:#204a87">cd</span> kubernetes-operator +make go-dependencies</code></pre></div> +<h2 id="build-and-run-with-a-minikube">Build and run with a minikube</h2> + +<p>Build and run <strong>Jenkins Operator</strong> locally:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build minikube-run <span style="color:#000">OPERATOR_EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--jenkins-api-hostname=$(eval minikube ip) --jenkins-api-use-nodeport=true&#39;</span></code></pre></div> +<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl get jenkins -o yaml +kubectl get po</code></pre></div> +<h2 id="build-and-run-with-a-remote-kubernetes-cluster">Build and run with a remote Kubernetes cluster</h2> + +<p>You can also run the controller locally and make it listen to a remote Kubernetes server.</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make run <span style="color:#000">NAMESPACE</span><span style="color:#ce5c00;font-weight:bold">=</span>default <span style="color:#000">KUBECTL_CONTEXT</span><span style="color:#ce5c00;font-weight:bold">=</span>remote-k8s <span style="color:#000">OPERATOR_EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--kubeconfig ~/.kube/config&#39;</span></code></pre></div> +<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl --context remote-k8s --namespace default get jenkins -o yaml +kubectl --context remote-k8s --namespace default get po</code></pre></div> +<h2 id="testing">Testing</h2> + +<p>Run unit tests:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make test</code></pre></div> +<h3 id="running-e2e-tests-on-linux">Running E2E tests on Linux</h3> + +<p>Run e2e tests with minikube:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make minikube-start +<span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> +make build e2e <span style="color:#000">config</span><span style="color:#ce5c00;font-weight:bold">=</span>config.minikube.env <span style="color:#000">CONTAINER_RUNTIME</span><span style="color:#ce5c00;font-weight:bold">=</span>podman</code></pre></div> +<p><code>config.minikube.env</code> is the E2E test profile which provides all connection info to operator to run on minikube.</p> + +<p>Run the specific e2e test:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build e2e <span style="color:#000">E2E_TEST_SELECTOR</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;^TestConfiguration$&#39;</span> <span style="color:#000">config</span><span style="color:#ce5c00;font-weight:bold">=</span>config.minikube.env <span style="color:#000">CONTAINER_RUNTIME</span><span style="color:#ce5c00;font-weight:bold">=</span>podman</code></pre></div> +<p>If you want to run E2E tests on CRC (Code Ready Containers by OpenShift), you should use <code>config.crc.env</code> profile instead of <code>config.minikube.env</code>. +If you have some trouble with <code>podman</code> (for example building) then check <a href="#using-docker-instead-of-podman">how to use docker instead of podman</a>.</p> + +<h3 id="running-e2e-tests-on-macos">Running E2E tests on macOS</h3> + +<p>At first, you need to start minikube:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make minikube-start +$ <span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> </code></pre></div> +<p>Build a Docker image inside the provided Linux container by:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make indocker</code></pre></div> +<p>Build <strong>Jenkins Operator</strong> inside a container using:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make build</code></pre></div> +<p>Then exit the container and run:</p> + +<pre><code>make e2e config=config.minikube.env +</code></pre> + +<p>or using <code>crc</code> as cluster software:</p> + +<pre><code>make e2e config=config.crc.env +</code></pre> + +<h3 id="using-docker-instead-of-podman">Using Docker instead of podman</h3> + +<p>If you have trouble with building image using the <code>podman</code>, you can set additional flag <code>IMAGE_PULL_MODE</code> to pull image from the organization.</p> + +<p>At first, you need to edit <code>config.base.env</code> and change the <code>DOCKER_ORGANIZATION</code> to your <a href="https://hub.docker.com/" target="_blank">Docker Hub</a> account/organization. +After this change the <code>IMAGE_PULL_MODE</code> to <code>remote</code>. It will setup the <code>Makefile</code> goal to pull Docker image from registry. +Then you need to pull image from your repository:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make container-runtime-build container-runtime-snapshot-push</code></pre></div> +<p>When image will be uploaded to repository, you can now write this command to run E2E tests:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make e2e <span style="color:#000">E2E_TEST_SELECTOR</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;^TestConfiguration$&#39;</span> <span style="color:#000">config</span><span style="color:#ce5c00;font-weight:bold">=</span>config.crc.env</code></pre></div> +<h2 id="tips-tricks">Tips &amp; Tricks</h2> + +<h3 id="building-docker-image-on-minikube-for-e2e-tests">Building docker image on minikube (for e2e tests)</h3> + +<p>To be able to work with the docker daemon on <code>minikube</code> machine run the following command before building an image:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span></code></pre></div> +<h3 id="when-pkg-apis-jenkinsio-jenkins-types-go-has-changed">When <code>pkg/apis/jenkinsio/*/jenkins_types.go</code> has changed</h3> + +<p>Run:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make deepcopy-gen</code></pre></div> +<h3 id="getting-the-jenkins-url-and-basic-credentials">Getting the Jenkins URL and basic credentials</h3> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">minikube service jenkins-operator-http-&lt;cr_name&gt; --url +kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.user}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d +kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.password}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d</code></pre></div> +<h1 id="tools">Tools</h1> + +<h2 id="configure-environment-variables">Configure environment variables</h2> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">export</span> <span style="color:#000">GOPATH</span><span style="color:#ce5c00;font-weight:bold">=</span>/home/go <span style="color:#8f5902;font-style:italic"># example value</span> +<span style="color:#204a87">export</span> <span style="color:#000">GOROOT</span><span style="color:#ce5c00;font-weight:bold">=</span>/usr/lib/go-1.12 <span style="color:#8f5902;font-style:italic"># example value</span> +<span style="color:#204a87">export</span> <span style="color:#000">PATH</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#000">$GOPATH</span>/bin:<span style="color:#000">$PATH</span></code></pre></div> +<h2 id="goimports">goimports</h2> + +<pre><code>go get golang.org/x/tools/cmd/goimports +cd $GOPATH/src/golang.org/x/tools/cmd/goimports +go build +go install +</code></pre> + +<h2 id="golint">golint</h2> + +<pre><code>go get -u golang.org/x/lint/golint +cd $GOPATH/src/golang.org/x/lint/golint +go build +go install +</code></pre> + +<h2 id="checkmake">checkmake</h2> + +<pre><code>go get github.com/mrtazz/checkmake +cd $GOPATH/src/github.com/mrtazz/checkmake +go build +go install +</code></pre> + +<h2 id="staticcheck">staticcheck</h2> + +<pre><code>mkdir -p $GOPATH/src/github.com/dominikh/ +cd $GOPATH/src/github.com/dominikh/ +git clone https://github.com/dominikh/go-tools.git +cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck +go build +go install +</code></pre> + + + + + + Docs: Developer Guide + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/developer-guide/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/developer-guide/ + + + + + + + +<div class="pageinfo pageinfo-primary"> +<p>This document explains how to setup your development environment.</p> + +</div> + + +<h2 id="prerequisites">Prerequisites</h2> + +<ul> +<li><a href="https://github.com/operator-framework/operator-sdk" target="_blank">operator_sdk</a> version v0.8.1</li> +<li><a href="https://git-scm.com/downloads" target="_blank">git</a></li> +<li><a href="https://golang.org/dl/" target="_blank">go</a> version v1.12+</li> +<li><a href="install_dev_tools.md" target="_blank">goimports, golint, checkmake and staticcheck</a></li> +<li><a href="https://kubernetes.io/docs/tasks/tools/install-minikube/" target="_blank">minikube</a> version v1.1.0+ (preferred Hypervisor - <a href="https://www.virtualbox.org/wiki/Downloads" target="_blank">virtualbox</a>)</li> +<li><a href="https://docs.docker.com/install/" target="_blank">docker</a> version 17.03+</li> +</ul> + +<h2 id="clone-repository-and-download-dependencies">Clone repository and download dependencies</h2> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">mkdir -p <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci +<span style="color:#204a87">cd</span> <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci/ +git clone git@github.com:jenkinsci/kubernetes-operator.git +<span style="color:#204a87">cd</span> kubernetes-operator +make go-dependencies</code></pre></div> +<h2 id="build-and-run-with-a-minikube">Build and run with a minikube</h2> + +<p>Build and run <strong>Jenkins Operator</strong> locally:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build minikube-run <span style="color:#000">EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--minikube --local&#39;</span></code></pre></div> +<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl get jenkins -o yaml +kubectl get po</code></pre></div> +<h2 id="build-and-run-with-a-remote-kubernetes-cluster">Build and run with a remote Kubernetes cluster</h2> + +<p>You can also run the controller locally and make it listen to a remote Kubernetes server.</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make run <span style="color:#000">NAMESPACE</span><span style="color:#ce5c00;font-weight:bold">=</span>default <span style="color:#000">KUBECTL_CONTEXT</span><span style="color:#ce5c00;font-weight:bold">=</span>remote-k8s <span style="color:#000">EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--kubeconfig ~/.kube/config&#39;</span></code></pre></div> +<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl --context remote-k8s --namespace default get jenkins -o yaml +kubectl --context remote-k8s --namespace default get po</code></pre></div> +<h2 id="testing">Testing</h2> + +<p>Run unit tests:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make test</code></pre></div> +<h3 id="running-e2e-tests-on-linux">Running E2E tests on Linux</h3> + +<p>Run e2e tests with minikube:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make minikube-start +<span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> +make build e2e</code></pre></div> +<p>Run the specific e2e test:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build e2e <span style="color:#000">E2E_TEST_SELECTOR</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;^TestConfiguration$&#39;</span></code></pre></div> +<h3 id="running-e2e-tests-on-macos">Running E2E tests on macOS</h3> + +<p>At first, you need to start minikube:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make minikube-start +$ <span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> </code></pre></div> +<p>Build a Docker image inside the provided Linux container by:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make indocker</code></pre></div> +<p>Build <strong>Jenkins Operator</strong> inside a container using:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make build</code></pre></div> +<p>Then exit the container and run:</p> + +<pre><code>make e2e +</code></pre> + +<h2 id="tips-tricks">Tips &amp; Tricks</h2> + +<h3 id="building-docker-image-on-minikube-for-e2e-tests">Building docker image on minikube (for e2e tests)</h3> + +<p>To be able to work with the docker daemon on <code>minikube</code> machine run the following command before building an image:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span></code></pre></div> +<h3 id="when-pkg-apis-jenkinsio-jenkins-types-go-has-changed">When <code>pkg/apis/jenkinsio/*/jenkins_types.go</code> has changed</h3> + +<p>Run:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make deepcopy-gen</code></pre></div> +<h3 id="getting-the-jenkins-url-and-basic-credentials">Getting the Jenkins URL and basic credentials</h3> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">minikube service jenkins-operator-http-&lt;cr_name&gt; --url +kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.user}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d +kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.password}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d</code></pre></div> +<h1 id="tools">Tools</h1> + +<h2 id="configure-environment-variables">Configure environment variables</h2> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">export</span> <span style="color:#000">GOPATH</span><span style="color:#ce5c00;font-weight:bold">=</span>/home/go <span style="color:#8f5902;font-style:italic"># example value</span> +<span style="color:#204a87">export</span> <span style="color:#000">GOROOT</span><span style="color:#ce5c00;font-weight:bold">=</span>/usr/lib/go-1.12 <span style="color:#8f5902;font-style:italic"># example value</span> +<span style="color:#204a87">export</span> <span style="color:#000">PATH</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#000">$GOPATH</span>/bin:<span style="color:#000">$PATH</span></code></pre></div> +<h2 id="goimports">goimports</h2> + +<pre><code>go get golang.org/x/tools/cmd/goimports +cd $GOPATH/src/golang.org/x/tools/cmd/goimports +go build +go install +</code></pre> + +<h2 id="golint">golint</h2> + +<pre><code>go get -u golang.org/x/lint/golint +cd $GOPATH/src/golang.org/x/lint/golint +go build +go install +</code></pre> + +<h2 id="checkmake">checkmake</h2> + +<pre><code>go get github.com/mrtazz/checkmake +cd $GOPATH/src/github.com/mrtazz/checkmake +go build +go install +</code></pre> + +<h2 id="staticcheck">staticcheck</h2> + +<pre><code>mkdir -p $GOPATH/src/github.com/dominikh/ +cd $GOPATH/src/github.com/dominikh/ +git clone https://github.com/dominikh/go-tools.git +cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck +go build +go install +</code></pre> + + + + + + Docs: Developer Guide + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/developer-guide/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/developer-guide/ + + + + + + + +<div class="pageinfo pageinfo-primary"> +<p>This document explains how to setup your development environment.</p> + +</div> + + +<h2 id="prerequisites">Prerequisites</h2> + +<ul> +<li><a href="https://github.com/operator-framework/operator-sdk" target="_blank">operator_sdk</a> version v0.8.1</li> +<li><a href="https://git-scm.com/downloads" target="_blank">git</a></li> +<li><a href="https://golang.org/dl/" target="_blank">go</a> version v1.12+</li> +<li><a href="install_dev_tools.md" target="_blank">goimports, golint, checkmake and staticcheck</a></li> +<li><a href="https://kubernetes.io/docs/tasks/tools/install-minikube/" target="_blank">minikube</a> version v1.1.0+ (preferred Hypervisor - <a href="https://www.virtualbox.org/wiki/Downloads" target="_blank">virtualbox</a>)</li> +<li><a href="https://docs.docker.com/install/" target="_blank">docker</a> version 17.03+</li> +</ul> + +<h2 id="clone-repository-and-download-dependencies">Clone repository and download dependencies</h2> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">mkdir -p <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci +<span style="color:#204a87">cd</span> <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci/ +git clone git@github.com:jenkinsci/kubernetes-operator.git +<span style="color:#204a87">cd</span> kubernetes-operator +make go-dependencies</code></pre></div> +<h2 id="build-and-run-with-a-minikube">Build and run with a minikube</h2> + +<p>Build and run <strong>Jenkins Operator</strong> locally:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build minikube-run <span style="color:#000">EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--minikube --local&#39;</span></code></pre></div> +<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl get jenkins -o yaml +kubectl get po</code></pre></div> +<h2 id="build-and-run-with-a-remote-kubernetes-cluster">Build and run with a remote Kubernetes cluster</h2> + +<p>You can also run the controller locally and make it listen to a remote Kubernetes server.</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make run <span style="color:#000">NAMESPACE</span><span style="color:#ce5c00;font-weight:bold">=</span>default <span style="color:#000">KUBECTL_CONTEXT</span><span style="color:#ce5c00;font-weight:bold">=</span>remote-k8s <span style="color:#000">EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--kubeconfig ~/.kube/config&#39;</span></code></pre></div> +<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml +kubectl --context remote-k8s --namespace default get jenkins -o yaml +kubectl --context remote-k8s --namespace default get po</code></pre></div> +<h2 id="testing">Testing</h2> + +<p>Run unit tests:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make test</code></pre></div> +<h3 id="running-e2e-tests-on-linux">Running E2E tests on Linux</h3> + +<p>Run e2e tests with minikube:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make minikube-start +<span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> +make build e2e</code></pre></div> +<p>Run the specific e2e test:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build e2e <span style="color:#000">E2E_TEST_SELECTOR</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;^TestConfiguration$&#39;</span></code></pre></div> +<h3 id="running-e2e-tests-on-macos">Running E2E tests on macOS</h3> + +<p>At first, you need to start minikube:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make minikube-start +$ <span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> </code></pre></div> +<p>Build a Docker image inside the provided Linux container by:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make indocker</code></pre></div> +<p>Build <strong>Jenkins Operator</strong> inside a container using:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make build</code></pre></div> +<p>Then exit the container and run:</p> + +<pre><code>make e2e +</code></pre> + +<h2 id="tips-tricks">Tips &amp; Tricks</h2> + +<h3 id="building-docker-image-on-minikube-for-e2e-tests">Building docker image on minikube (for e2e tests)</h3> + +<p>To be able to work with the docker daemon on <code>minikube</code> machine run the following command before building an image:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span></code></pre></div> +<h3 id="when-pkg-apis-jenkinsio-jenkins-types-go-has-changed">When <code>pkg/apis/jenkinsio/*/jenkins_types.go</code> has changed</h3> + +<p>Run:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make deepcopy-gen</code></pre></div> +<h3 id="getting-the-jenkins-url-and-basic-credentials">Getting the Jenkins URL and basic credentials</h3> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">minikube service jenkins-operator-http-&lt;cr_name&gt; --url +kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.user}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d +kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.password}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d</code></pre></div> +<h1 id="tools">Tools</h1> + +<h2 id="configure-environment-variables">Configure environment variables</h2> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">export</span> <span style="color:#000">GOPATH</span><span style="color:#ce5c00;font-weight:bold">=</span>/home/go <span style="color:#8f5902;font-style:italic"># example value</span> +<span style="color:#204a87">export</span> <span style="color:#000">GOROOT</span><span style="color:#ce5c00;font-weight:bold">=</span>/usr/lib/go-1.12 <span style="color:#8f5902;font-style:italic"># example value</span> +<span style="color:#204a87">export</span> <span style="color:#000">PATH</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#000">$GOPATH</span>/bin:<span style="color:#000">$PATH</span></code></pre></div> +<h2 id="goimports">goimports</h2> + +<pre><code>go get golang.org/x/tools/cmd/goimports +cd $GOPATH/src/golang.org/x/tools/cmd/goimports +go build +go install +</code></pre> + +<h2 id="golint">golint</h2> + +<pre><code>go get -u golang.org/x/lint/golint +cd $GOPATH/src/golang.org/x/lint/golint +go build +go install +</code></pre> + +<h2 id="checkmake">checkmake</h2> + +<pre><code>go get github.com/mrtazz/checkmake +cd $GOPATH/src/github.com/mrtazz/checkmake +go build +go install +</code></pre> + +<h2 id="staticcheck">staticcheck</h2> + +<pre><code>mkdir -p $GOPATH/src/github.com/dominikh/ +cd $GOPATH/src/github.com/dominikh/ +git clone https://github.com/dominikh/go-tools.git +cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck +go build +go install </code></pre> diff --git a/docs/docs/installation/index.html b/docs/docs/installation/index.html index 617c2704..7df84818 100644 --- a/docs/docs/installation/index.html +++ b/docs/docs/installation/index.html @@ -197,6 +197,83 @@ + + + + + + + + + + + + @@ -331,6 +414,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -366,35 +455,6 @@ - - - - - - - - - - - - @@ -547,6 +607,26 @@ All container images can be found at +
  • + +
  • + + + + + + + + + + + + + @@ -331,6 +414,12 @@ Migration guide from v1alpha1 to v1alpha2 + + + + Developer Guide + + @@ -366,35 +455,6 @@ - - - - - - - - - - - - @@ -601,6 +661,26 @@ $ kubectl -n jenkins apply -f role_binding_jenkins.yaml
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 8bb61c54..e25104c3 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -7,6 +7,11 @@ 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/deploy-jenkins/ + 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/deploy-jenkins/ 2019-08-05T00:00:00+00:00 @@ -22,6 +27,11 @@ 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/configuration/ + 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configuration/ 2019-08-05T00:00:00+00:00 @@ -32,6 +42,11 @@ 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/customization/ + 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/customization/ 2019-08-05T00:00:00+00:00 @@ -47,6 +62,11 @@ 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/aks/ + 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/aks/ 2019-08-05T00:00:00+00:00 @@ -57,6 +77,11 @@ 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/configure-backup-and-restore/ + 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configure-backup-and-restore/ 2019-08-05T00:00:00+00:00 @@ -67,11 +92,21 @@ 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/custom-backup-and-restore/ + 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/custom-backup-and-restore/ 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/ + 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/ 2019-08-05T00:00:00+00:00 @@ -113,7 +148,7 @@ - https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/tools/ + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/diagnostics/ 2019-08-05T00:00:00+00:00 @@ -127,6 +162,11 @@ 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/schema/ + 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/schema/ 2019-08-05T00:00:00+00:00 @@ -148,7 +188,17 @@ - https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/ + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/developer-guide/ + 2019-08-05T00:00:00+00:00 + + + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/developer-guide/ + 2019-08-05T00:00:00+00:00 + + + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/developer-guide/ 2019-08-05T00:00:00+00:00 From 80b0839e5d2366e00119abb028e64b437f9354fa Mon Sep 17 00:00:00 2001 From: Jakub Al-Khalili Date: Thu, 19 Dec 2019 11:38:01 +0100 Subject: [PATCH 10/12] Fix nodePort issue, remove --namespace argument from Makefile --- Makefile | 2 +- pkg/controller/jenkins/jenkins_controller.go | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 5a30d4d4..e64a83f9 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ PACKAGES_FOR_UNIT_TESTS = $(shell go list -f '{{.ImportPath}}/' ./... | grep -v E2E_TEST_SELECTOR ?= .* JENKINS_API_HOSTNAME := $(shell $(JENKINS_API_HOSTNAME_COMMAND)) -OPERATOR_ARGS ?= --jenkins-api-hostname=$(JENKINS_API_HOSTNAME) --jenkins-api-port=$(JENKINS_API_PORT) --jenkins-api-use-nodeport=$(JENKINS_API_USE_NODEPORT) --namespace=$(NAMESPACE) $(OPERATOR_EXTRA_ARGS) +OPERATOR_ARGS ?= --jenkins-api-hostname=$(JENKINS_API_HOSTNAME) --jenkins-api-port=$(JENKINS_API_PORT) --jenkins-api-use-nodeport=$(JENKINS_API_USE_NODEPORT) $(OPERATOR_EXTRA_ARGS) .DEFAULT_GOAL := help diff --git a/pkg/controller/jenkins/jenkins_controller.go b/pkg/controller/jenkins/jenkins_controller.go index 79607a44..f60fe83f 100644 --- a/pkg/controller/jenkins/jenkins_controller.go +++ b/pkg/controller/jenkins/jenkins_controller.go @@ -445,9 +445,16 @@ func (r *ReconcileJenkins) setDefaults(jenkins *v1alpha2.Jenkins, logger logr.Lo if reflect.DeepEqual(jenkins.Spec.Service, v1alpha2.Service{}) { logger.Info("Setting default Jenkins master service") changed = true - jenkins.Spec.Service = v1alpha2.Service{ - Type: corev1.ServiceTypeClusterIP, - Port: constants.DefaultHTTPPortInt32, + if r.jenkinsAPIConnectionSettings.UseNodePort { + jenkins.Spec.Service = v1alpha2.Service{ + Type: corev1.ServiceTypeNodePort, + Port: constants.DefaultHTTPPortInt32, + } + } else { + jenkins.Spec.Service = v1alpha2.Service{ + Type: corev1.ServiceTypeClusterIP, + Port: constants.DefaultHTTPPortInt32, + } } } if reflect.DeepEqual(jenkins.Spec.SlaveService, v1alpha2.Service{}) { From 9b4a04c32f6171fc65dd8852695457a19de7abe8 Mon Sep 17 00:00:00 2001 From: Jakub Al-Khalili Date: Thu, 19 Dec 2019 13:24:51 +0100 Subject: [PATCH 11/12] Cosmetic changes --- pkg/controller/jenkins/jenkins_controller.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/pkg/controller/jenkins/jenkins_controller.go b/pkg/controller/jenkins/jenkins_controller.go index f60fe83f..39f32a09 100644 --- a/pkg/controller/jenkins/jenkins_controller.go +++ b/pkg/controller/jenkins/jenkins_controller.go @@ -445,16 +445,14 @@ func (r *ReconcileJenkins) setDefaults(jenkins *v1alpha2.Jenkins, logger logr.Lo if reflect.DeepEqual(jenkins.Spec.Service, v1alpha2.Service{}) { logger.Info("Setting default Jenkins master service") changed = true + + var serviceType = corev1.ServiceTypeClusterIP if r.jenkinsAPIConnectionSettings.UseNodePort { - jenkins.Spec.Service = v1alpha2.Service{ - Type: corev1.ServiceTypeNodePort, - Port: constants.DefaultHTTPPortInt32, - } - } else { - jenkins.Spec.Service = v1alpha2.Service{ - Type: corev1.ServiceTypeClusterIP, - Port: constants.DefaultHTTPPortInt32, - } + serviceType = corev1.ServiceTypeNodePort + } + jenkins.Spec.Service = v1alpha2.Service{ + Type: serviceType, + Port: constants.DefaultHTTPPortInt32, } } if reflect.DeepEqual(jenkins.Spec.SlaveService, v1alpha2.Service{}) { From fb1eb95fd0a5f66bd70971f01f8c4e58addfdcf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20S=C4=99k?= Date: Wed, 25 Dec 2019 12:06:06 +0100 Subject: [PATCH 12/12] Update docs --- ...operator.v0.2.2.clusterserviceversion.yaml | 2 +- .../v0.1.x => }/developer-guide/index.html | 0 docs/docs/developer-guide/index.xml | 83 + .../tools}/index.html | 0 .../getting-started/future/aks/index.html | 606 ---- .../future/configuration/index.html | 911 ----- .../configure-backup-and-restore/index.html | 682 ---- .../custom-backup-and-restore/index.html | 778 ----- .../future/customization/index.html | 763 ----- .../future/deploy-jenkins/index.html | 653 ---- .../future/developer-guide/index.html | 771 ----- docs/docs/getting-started/future/index.html | 752 ---- docs/docs/getting-started/future/index.xml | 3020 ----------------- .../getting-started/future/schema/index.html | 2569 -------------- .../latest/developer-guide/index.html | 750 ---- docs/docs/getting-started/latest/index.xml | 525 +-- docs/docs/getting-started/v0.1.x/index.xml | 135 - .../_index.md} | 48 - .../content/en/docs/Developer Guide/tools.md | 57 + .../en/docs/Getting Started/future/_index.md | 18 - .../en/docs/Getting Started/future/aks.md | 24 - .../Getting Started/future/configuration.md | 325 -- .../future/configure-backup-and-restore.md | 86 - .../future/custom-backup-and-restore.md | 184 - .../Getting Started/future/customization.md | 186 - .../Getting Started/future/deploy-jenkins.md | 89 - .../Getting Started/future/developer-guide.md | 227 -- .../Getting Started/future/diagnostics.md | 42 - .../en/docs/Getting Started/future/schema.md | 1979 ----------- .../Getting Started/latest/developer-guide.md | 198 -- 30 files changed, 444 insertions(+), 16019 deletions(-) rename docs/docs/{getting-started/v0.1.x => }/developer-guide/index.html (100%) create mode 100644 docs/docs/developer-guide/index.xml rename docs/docs/{getting-started/future/diagnostics => developer-guide/tools}/index.html (100%) delete mode 100644 docs/docs/getting-started/future/aks/index.html delete mode 100644 docs/docs/getting-started/future/configuration/index.html delete mode 100644 docs/docs/getting-started/future/configure-backup-and-restore/index.html delete mode 100644 docs/docs/getting-started/future/custom-backup-and-restore/index.html delete mode 100644 docs/docs/getting-started/future/customization/index.html delete mode 100644 docs/docs/getting-started/future/deploy-jenkins/index.html delete mode 100644 docs/docs/getting-started/future/developer-guide/index.html delete mode 100644 docs/docs/getting-started/future/index.html delete mode 100644 docs/docs/getting-started/future/index.xml delete mode 100644 docs/docs/getting-started/future/schema/index.html delete mode 100644 docs/docs/getting-started/latest/developer-guide/index.html rename website/content/en/docs/{Getting Started/v0.1.x/developer-guide.md => Developer Guide/_index.md} (82%) create mode 100644 website/content/en/docs/Developer Guide/tools.md delete mode 100644 website/content/en/docs/Getting Started/future/_index.md delete mode 100644 website/content/en/docs/Getting Started/future/aks.md delete mode 100644 website/content/en/docs/Getting Started/future/configuration.md delete mode 100644 website/content/en/docs/Getting Started/future/configure-backup-and-restore.md delete mode 100644 website/content/en/docs/Getting Started/future/custom-backup-and-restore.md delete mode 100644 website/content/en/docs/Getting Started/future/customization.md delete mode 100644 website/content/en/docs/Getting Started/future/deploy-jenkins.md delete mode 100644 website/content/en/docs/Getting Started/future/developer-guide.md delete mode 100644 website/content/en/docs/Getting Started/future/diagnostics.md delete mode 100644 website/content/en/docs/Getting Started/future/schema.md delete mode 100644 website/content/en/docs/Getting Started/latest/developer-guide.md diff --git a/deploy/olm-catalog/jenkins-operator/0.2.2/jenkins-operator.v0.2.2.clusterserviceversion.yaml b/deploy/olm-catalog/jenkins-operator/0.2.2/jenkins-operator.v0.2.2.clusterserviceversion.yaml index 6cfc6845..90a5b3a9 100644 --- a/deploy/olm-catalog/jenkins-operator/0.2.2/jenkins-operator.v0.2.2.clusterserviceversion.yaml +++ b/deploy/olm-catalog/jenkins-operator/0.2.2/jenkins-operator.v0.2.2.clusterserviceversion.yaml @@ -235,7 +235,7 @@ spec: serviceAccountName: jenkins-operator strategy: deployment installModes: - - supported: false + - supported: true type: OwnNamespace - supported: true type: SingleNamespace diff --git a/docs/docs/getting-started/v0.1.x/developer-guide/index.html b/docs/docs/developer-guide/index.html similarity index 100% rename from docs/docs/getting-started/v0.1.x/developer-guide/index.html rename to docs/docs/developer-guide/index.html diff --git a/docs/docs/developer-guide/index.xml b/docs/docs/developer-guide/index.xml new file mode 100644 index 00000000..cabc8bcd --- /dev/null +++ b/docs/docs/developer-guide/index.xml @@ -0,0 +1,83 @@ + + + Jenkins Operator – Developer Guide + https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/ + Recent Hugo news from gohugo.io + Hugo -- gohugo.io + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/img/hugo.png + GoHugo.io + https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/ + + + + + + + + + + + + Docs: Tools + https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/tools/ + Mon, 05 Aug 2019 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/tools/ + + + + + + + +<div class="pageinfo pageinfo-primary"> +<p>This document explains how to install the Go tools used by the development process.</p> + +</div> + + +<h2 id="configure-environment-variables">Configure environment variables</h2> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">export</span> <span style="color:#000">GOPATH</span><span style="color:#ce5c00;font-weight:bold">=</span>/home/go <span style="color:#8f5902;font-style:italic"># example value</span> +<span style="color:#204a87">export</span> <span style="color:#000">GOROOT</span><span style="color:#ce5c00;font-weight:bold">=</span>/usr/lib/go-1.12 <span style="color:#8f5902;font-style:italic"># example value</span> +<span style="color:#204a87">export</span> <span style="color:#000">PATH</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#000">$GOPATH</span>/bin:<span style="color:#000">$PATH</span></code></pre></div> +<h2 id="goimports">goimports</h2> + +<pre><code>go get golang.org/x/tools/cmd/goimports +cd $GOPATH/src/golang.org/x/tools/cmd/goimports +go build +go install +</code></pre> + +<h2 id="golint">golint</h2> + +<pre><code>go get -u golang.org/x/lint/golint +cd $GOPATH/src/golang.org/x/lint/golint +go build +go install +</code></pre> + +<h2 id="checkmake">checkmake</h2> + +<pre><code>go get github.com/mrtazz/checkmake +cd $GOPATH/src/github.com/mrtazz/checkmake +go build +go install +</code></pre> + +<h2 id="staticcheck">staticcheck</h2> + +<pre><code>mkdir -p $GOPATH/src/github.com/dominikh/ +cd $GOPATH/src/github.com/dominikh/ +git clone https://github.com/dominikh/go-tools.git +cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck +go build +go install +</code></pre> + + + + + + \ No newline at end of file diff --git a/docs/docs/getting-started/future/diagnostics/index.html b/docs/docs/developer-guide/tools/index.html similarity index 100% rename from docs/docs/getting-started/future/diagnostics/index.html rename to docs/docs/developer-guide/tools/index.html diff --git a/docs/docs/getting-started/future/aks/index.html b/docs/docs/getting-started/future/aks/index.html deleted file mode 100644 index c69d4c7a..00000000 --- a/docs/docs/getting-started/future/aks/index.html +++ /dev/null @@ -1,606 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -AKS | Jenkins Operator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AKS | Jenkins Operator - - -
    - - - -
    -
    -
    -
    -
    - - - - - -
    - - - - -
    - - - - -
    -
    - - - - - - - - - - - -
    -
    - - - -
    -

    AKS

    -
    Additional configuration for Azure Kubernetes Service
    -

    Azure AKS managed Kubernetes service adds to every pod the following environment variables:

    -
    - name: KUBERNETES_PORT_443_TCP_ADDR
    -  value:
    -- name: KUBERNETES_PORT
    -  value: tcp://
    -- name: KUBERNETES_PORT_443_TCP
    -  value: tcp://
    -- name: KUBERNETES_SERVICE_HOST
    -  value:
    -

    The operator is aware of it and omits these environment variables when checking if a Jenkins pod environment has been changed. It prevents the -restart of a Jenkins pod over and over again.

    - - - -
    Last modified August 5, 2019 -
    -
    - - -
    -
    -
    - - - - -
    - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/docs/getting-started/future/configuration/index.html b/docs/docs/getting-started/future/configuration/index.html deleted file mode 100644 index f848febc..00000000 --- a/docs/docs/getting-started/future/configuration/index.html +++ /dev/null @@ -1,911 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -Configuration | Jenkins Operator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Configuration | Jenkins Operator - - -
    - - - -
    -
    -
    -
    -
    - - - - - -
    - - - - -
    - - - - -
    - -
    - - - -
    -

    Configuration

    -
    How to configure Jenkins with Operator
    - - -

    Configure Seed Jobs and Pipelines

    - -

    Jenkins operator uses job-dsl and kubernetes-credentials-provider plugins for configuring jobs -and deploy keys.

    - -

    Prepare job definitions and pipelines

    - -

    First you have to prepare pipelines and job definition in your GitHub repository using the following structure:

    - -
    cicd/
    -├── jobs
    -│   └── build.jenkins
    -└── pipelines
    -    └── build.jenkins
    -
    - -

    cicd/jobs/build.jenkins is a job definition:

    - -
    #!/usr/bin/env groovy
    -
    -pipelineJob('build-jenkins-operator') {
    -    displayName('Build jenkins-operator')
    -
    -    definition {
    -        cpsScm {
    -            scm {
    -                git {
    -                    remote {
    -                        url('https://github.com/jenkinsci/kubernetes-operator.git')
    -                        credentials('jenkins-operator')
    -                    }
    -                    branches('*/master')
    -                }
    -            }
    -            scriptPath('cicd/pipelines/build.jenkins')
    -        }
    -    }
    -}
    -
    - -

    cicd/pipelines/build.jenkins is an actual Jenkins pipeline:

    - -
    #!/usr/bin/env groovy
    -
    -def label = "build-jenkins-operator-${UUID.randomUUID().toString()}"
    -def home = "/home/jenkins"
    -def workspace = "${home}/workspace/build-jenkins-operator"
    -def workdir = "${workspace}/src/github.com/jenkinsci/kubernetes-operator/"
    -
    -podTemplate(label: label,
    -        containers: [
    -                containerTemplate(name: 'jnlp', image: 'jenkins/jnlp-slave:alpine'),
    -                containerTemplate(name: 'go', image: 'golang:1-alpine', command: 'cat', ttyEnabled: true),
    -        ],
    -        envVars: [
    -                envVar(key: 'GOPATH', value: workspace),
    -        ],
    -        ) {
    -
    -    node(label) {
    -        dir(workdir) {
    -            stage('Init') {
    -                timeout(time: 3, unit: 'MINUTES') {
    -                    checkout scm
    -                }
    -                container('go') {
    -                    sh 'apk --no-cache --update add make git gcc libc-dev'
    -                }
    -            }
    -
    -            stage('Dep') {
    -                container('go') {
    -                    sh 'make dep'
    -                }
    -            }
    -
    -            stage('Test') {
    -                container('go') {
    -                    sh 'make test'
    -                }
    -            }
    -
    -            stage('Build') {
    -                container('go') {
    -                    sh 'make build'
    -                }
    -            }
    -        }
    -    }
    -}
    -
    - -

    Configure Seed Jobs

    - -

    Jenkins Seed Jobs are configured using Jenkins.spec.seedJobs section from your custom resource manifest:

    - -
    apiVersion: jenkins.io/v1alpha2
    -kind: Jenkins
    -metadata:
    -  name: example
    -spec:
    -  seedJobs:
    -  - id: jenkins-operator
    -    targets: "cicd/jobs/*.jenkins"
    -    description: "Jenkins Operator repository"
    -    repositoryBranch: master
    -    repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git
    -
    - -

    Jenkins Operator will automatically discover and configure all the seed jobs.

    - -

    You can verify if deploy keys were successfully configured in the Jenkins Credentials tab.

    - -

    jenkins

    - -

    You can verify if your pipelines were successfully configured in the Jenkins Seed Job console output.

    - -

    jenkins

    - -

    If your GitHub repository is private you have to configure SSH or username/password authentication.

    - -

    SSH authentication

    - -

    Generate SSH Keys

    - -

    There are two methods of SSH private key generation:

    -
    $ openssl genrsa -out <filename> 2048
    -

    or

    -
    $ ssh-keygen -t rsa -b 2048
    -$ ssh-keygen -p -f <filename> -m pem
    -

    Then copy content from generated file.

    - -

    Public key

    - -

    If you want to upload your public key to your Git server you need to extract it.

    - -

    If key was generated by openssl then you need to type this to extract public key:

    -
    $ openssl rsa -in <filename> -pubout > <filename>.pub
    -

    If key was generated by ssh-keygen the public key content is located in .pub and there is no need to extract public key

    - -

    Configure SSH authentication

    - -

    Configure a seed job like this:

    - -
    apiVersion: jenkins.io/v1alpha2
    -kind: Jenkins
    -metadata:
    -  name: example
    -spec:
    -  seedJobs:
    -  - id: jenkins-operator-ssh
    -    credentialType: basicSSHUserPrivateKey
    -    credentialID: k8s-ssh
    -    targets: "cicd/jobs/*.jenkins"
    -    description: "Jenkins Operator repository"
    -    repositoryBranch: master
    -    repositoryUrl: git@github.com:jenkinsci/kubernetes-operator.git
    -
    - -

    and create a Kubernetes Secret (name of secret should be the same from credentialID field):

    - -
    apiVersion: v1
    -kind: Secret
    -metadata:
    -  name: k8s-ssh
    -stringData:
    -  privateKey: |
    -    -----BEGIN RSA PRIVATE KEY-----
    -    MIIJKAIBAAKCAgEAxxDpleJjMCN5nusfW/AtBAZhx8UVVlhhhIKXvQ+dFODQIdzO
    -    oDXybs1zVHWOj31zqbbJnsfsVZ9Uf3p9k6xpJ3WFY9b85WasqTDN1xmSd6swD4N8
    -    ...
    -  username: github_user_name
    -
    - -

    Username & password authentication

    - -

    Configure the seed job like:

    - -
    apiVersion: jenkins.io/v1alpha2
    -kind: Jenkins
    -metadata:
    -  name: example
    -spec:
    -  seedJobs:
    -  - id: jenkins-operator-user-pass
    -    credentialType: usernamePassword
    -    credentialID: k8s-user-pass
    -    targets: "cicd/jobs/*.jenkins"
    -    description: "Jenkins Operator repository"
    -    repositoryBranch: master
    -    repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git
    -
    - -

    and create a Kubernetes Secret (name of secret should be the same from credentialID field):

    - -
    apiVersion: v1
    -kind: Secret
    -metadata:
    -  name: k8s-user-pass
    -stringData:
    -  username: github_user_name
    -  password: password_or_token
    -
    - -

    HTTP Proxy for downloading plugins

    - -

    To use forwarding proxy with an operator to download plugins you need to add the following environment variable to Jenkins Custom Resource (CR), e.g.:

    -
    spec:
    -  master:
    -    containers:
    -      - name: jenkins-master
    -        env:
    -          - name: CURL_OPTIONS
    -            value: -L -x <proxy_url>
    -

    In CURL_OPTIONS var you can set additional arguments to curl command.

    - -

    Pulling Docker images from private repositories

    - -

    To pull a Docker Image from private repository you can use imagePullSecrets.

    - -

    Please follow the instructions on creating a secret with a docker config.

    - -

    Docker Hub Configuration

    - -

    To use Docker Hub additional steps are required.

    - -

    Edit the previously created secret:

    -
    kubectl -n <namespace> edit secret <name>
    -

    The .dockerconfigjson key’s value needs to be replaced with a modified version.

    - -

    After modifications, it needs to be encoded as a Base64 value before setting the .dockerconfigjson key.

    - -

    Example config file to modify and use:

    - -
    {
    -    "auths":{
    -        "https://index.docker.io/v1/":{
    -            "username":"user",
    -            "password":"password",
    -            "email":"yourdockeremail@gmail.com",
    -            "auth":"base64 of string user:password"
    -        },
    -        "auth.docker.io":{
    -            "username":"user",
    -            "password":"password",
    -            "email":"yourdockeremail@gmail.com",
    -            "auth":"base64 of string user:password"
    -        },
    -        "registry.docker.io":{
    -            "username":"user",
    -            "password":"password",
    -            "email":"yourdockeremail@gmail.com",
    -            "auth":"base64 of string user:password"
    -        },
    -        "docker.io":{
    -            "username":"user",
    -            "password":"password",
    -            "email":"yourdockeremail@gmail.com",
    -            "auth":"base64 of string user:password"
    -        },
    -        "https://registry-1.docker.io/v2/": {
    -            "username":"user",
    -            "password":"password",
    -            "email":"yourdockeremail@gmail.com",
    -            "auth":"base64 of string user:password"
    -        },
    -        "registry-1.docker.io/v2/": {
    -            "username":"user",
    -            "password":"password",
    -            "email":"yourdockeremail@gmail.com",
    -            "auth":"base64 of string user:password"
    -        },
    -        "registry-1.docker.io": {
    -            "username":"user",
    -            "password":"password",
    -            "email":"yourdockeremail@gmail.com",
    -            "auth":"base64 of string user:password"
    -        },
    -        "https://registry-1.docker.io": {
    -            "username":"user",
    -            "password":"password",
    -            "email":"yourdockeremail@gmail.com",
    -            "auth":"base64 of string user:password"
    -        }
    -    }
    -}
    -
    - - - -
    Last modified August 5, 2019 -
    -
    - - -
    -
    -
    - - - - -
    - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/docs/getting-started/future/configure-backup-and-restore/index.html b/docs/docs/getting-started/future/configure-backup-and-restore/index.html deleted file mode 100644 index 5dabd514..00000000 --- a/docs/docs/getting-started/future/configure-backup-and-restore/index.html +++ /dev/null @@ -1,682 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -Configure backup and restore | Jenkins Operator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Configure backup and restore | Jenkins Operator - - -
    - - - -
    -
    -
    -
    -
    - - - - - -
    - - - - -
    - - - - -
    -
    - - - - - - - - - - - - - - - -
    -
    - - - -
    -

    Configure backup and restore

    -
    Prevent loss of job history
    - - -

    Backup and restore is done by a container sidecar.

    - -

    PVC

    - -

    Create PVC

    - -

    Save to the file named pvc.yaml:

    -
    apiVersion: v1
    -kind: PersistentVolumeClaim
    -metadata:
    -  name: <pvc_name>
    -  namespace: <namespace>
    -spec:
    -  accessModes:
    -  - ReadWriteOnce
    -  resources:
    -    requests:
    -      storage: 500Gi
    -

    Run the following command:

    -
    $ kubectl -n <namespace> create -f pvc.yaml
    -

    Configure Jenkins CR

    -
    apiVersion: jenkins.io/v1alpha2
    -kind: Jenkins
    -metadata:
    -  name: <cr_name>
    -  namespace: <namespace>
    -spec:
    -  master:
    -    securityContext:
    -      runAsUser: 1000
    -      fsGroup: 1000
    -    containers:
    -    - name: jenkins-master
    -      image: jenkins/jenkins:lts
    -    - name: backup # container responsible for the backup and restore
    -      env:
    -      - name: BACKUP_DIR
    -        value: /backup
    -      - name: JENKINS_HOME
    -        value: /jenkins-home
    -      - name: BACKUP_COUNT
    -        value: "3" # keep only the 2 most recent backups
    -      image: virtuslab/jenkins-operator-backup-pvc:v0.0.7 # look at backup/pvc directory
    -      imagePullPolicy: IfNotPresent
    -      volumeMounts:
    -      - mountPath: /jenkins-home # Jenkins home volume
    -        name: jenkins-home
    -      - mountPath: /backup # backup volume
    -        name: backup
    -    volumes:
    -    - name: backup # PVC volume where backups will be stored
    -      persistentVolumeClaim:
    -        claimName: <pvc_name>
    -  backup:
    -    containerName: backup # container name is responsible for backup
    -    action:
    -      exec:
    -        command:
    -        - /home/user/bin/backup.sh # this command is invoked on "backup" container to make backup, for example /home/user/bin/backup.sh <backup_number>, <backup_number> is passed by operator
    -    interval: 30 # how often make backup in seconds
    -    makeBackupBeforePodDeletion: true # make a backup before pod deletion
    -  restore:
    -    containerName: backup # container name is responsible for restore backup
    -    action:
    -      exec:
    -        command:
    -        - /home/user/bin/restore.sh # this command is invoked on "backup" container to make restore backup, for example /home/user/bin/restore.sh <backup_number>, <backup_number> is passed by operator
    -    #recoveryOnce: <backup_number> # if want to restore specific backup configure this field and then Jenkins will be restarted and desired backup will be restored
    - - -
    Last modified August 5, 2019 -
    -
    - - -
    -
    -
    - - - - -
    - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/docs/getting-started/future/custom-backup-and-restore/index.html b/docs/docs/getting-started/future/custom-backup-and-restore/index.html deleted file mode 100644 index 7791cafc..00000000 --- a/docs/docs/getting-started/future/custom-backup-and-restore/index.html +++ /dev/null @@ -1,778 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -Custom Backup and Restore Providers | Jenkins Operator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Custom Backup and Restore Providers | Jenkins Operator - - -
    - - - -
    -
    -
    -
    -
    - - - - - -
    - - - - -
    - - - - -
    - -
    - - - -
    -

    Custom Backup and Restore Providers

    -
    Custom backup and restore provider
    - - -

    With enough effort one can create a custom backup and restore provider -for the Jenkins Operator.

    - -

    Requirements

    - -

    Two commands (e.g. scripts) are required:

    - -
      -
    • a backup command, e.g. backup.sh that takes one argument, a backup number
    • -
    • a restore command, e.g. backup.sh that takes one argument, a backup number
    • -
    - -

    Both scripts need to return an exit code of 0 on success and 1 or greater for failure.

    - -

    One of those scripts (or the entry point of the container) needs to be responsible -for backup cleanup or rotation if required, or an external system.

    - -

    How it works

    - -

    The mechanism relies on basic Kubernetes and UNIX functionalities.

    - -

    The backup (and restore) container runs as a sidecar in the same -Kubernetes pod as the Jenkins master.

    - -

    Name of the backup and restore containers can be set as necessary using -spec.backup.containerName and spec.restore.containerName. -In most cases it will be the same container, but we allow for less common use cases.

    - -

    The operator will call a backup or restore commands inside a sidecar container when necessary:

    - -
      -
    • backup command (defined in spec.backup.action.exec.command) -will be called every N seconds configurable in: spec.backup.interval -and on pod shutdown (if enabled in spec.backup.makeBackupBeforePodDeletion) -with an integer representing the current backup number as first and only argument
    • -
    • restore command (defined in spec.restore.action.exec.command) -will be called at Jenkins startup -with an integer representing the backup number to restore as first and only argument -(can be overridden using spec.restore.recoveryOnce)
    • -
    - -

    Example AWS S3 backup using the CLI

    - -

    This example shows abbreviated version of a simple AWS S3 backup implementation -using: aws-cli, bash and kube2iam.

    - -

    In addition to your normal Jenkins CustomResource some additional settings -for backup and restore are required, e.g.:

    -
    kind: Jenkins
    -apiVersion: jenkins.io/v1alpha1
    -metadata:
    -  name: example
    -  namespace: jenkins
    -spec:
    -  master:
    -    masterAnnotations:
    -      iam.amazonaws.com/role: "my-example-backup-role" # tell kube2iam where the AWS IAM role is
    -    containers:
    -      - name: jenkins-master
    -        ...
    -      - name: backup # container responsible for backup and restore
    -        image: quay.io/virtuslab/aws-cli:1.16.263-2
    -        workingDir: /home/user/bin/
    -        command: # our container entry point
    -          - sleep
    -          - infinity
    -        env:
    -          - name: BACKUP_BUCKET
    -            value: my-example-bucket # the S3 bucket name to use
    -          - name: BACKUP_PATH
    -            value: my-backup-path # the S3 bucket path prefix to use
    -          - name: JENKINS_HOME
    -            value: /jenkins-home # the path to mount jenkins home dir in the backup container
    -        volumeMounts:
    -          - mountPath: /jenkins-home # Jenkins home volume
    -            name: jenkins-home
    -          - mountPath: /home/user/bin/backup.sh
    -            name: backup-scripts
    -            subPath: backup.sh
    -            readOnly: true
    -          - mountPath: /home/user/bin/restore.sh
    -            name: backup-scripts
    -            subPath: restore.sh
    -            readOnly: true
    -    volumes:
    -      - name: backup-scripts
    -        configMap:
    -          defaultMode: 0754
    -          name: jenkins-operator-backup-s3
    -    securityContext: # make sure both containers use the same UID and GUID
    -      runAsUser: 1000
    -      fsGroup: 1000
    -  ...
    -  backup:
    -    containerName: backup # container name responsible for backup
    -    interval: 3600 # how often make a backup in seconds
    -    makeBackupBeforePodDeletion: true # trigger backup just before deleting the pod
    -    action:
    -      exec:
    -        command:
    -          # this command is invoked on "backup" container to create a backup,
    -          # <backup_number> is passed by operator,
    -          # for example /home/user/bin/backup.sh <backup_number>
    -          - /home/user/bin/backup.sh
    -  restore:
    -    containerName: backup # container name is responsible for restore backup
    -    action:
    -      exec:
    -        command:
    -          # this command is invoked on "backup" container to restore a backup,
    -          # <backup_number> is passed by operator
    -          # for example /home/user/bin/restore.sh <backup_number>
    -          - /home/user/bin/restore.sh
    -#    recoveryOnce: <backup_number> # if want to restore specific backup configure this field and then Jenkins will be restarted and desired backup will be restored
    -

    The actual backup and restore scripts will be provided in a ConfigMap:

    -
    kind: ConfigMap
    -apiVersion: v1
    -metadata:
    -  name: jenkins-operator-backup-s3
    -  namespace: jenkins
    -  labels:
    -    app: jenkins-operator
    -data:
    -  backup.sh: |-
    -    #!/bin/bash -xeu
    -    [[ ! $# -eq 1 ]] && echo "Usage: $0 backup_number" && exit 1;
    -    [[ -z "${BACKUP_BUCKET}" ]] && echo "Required 'BACKUP_BUCKET' env not set" && exit 1;
    -    [[ -z "${BACKUP_PATH}" ]] && echo "Required 'BACKUP_PATH' env not set" && exit 1;
    -    [[ -z "${JENKINS_HOME}" ]] && echo "Required 'JENKINS_HOME' env not set" && exit 1;
    -
    -    backup_number=$1
    -    echo "Running backup #${backup_number}"
    -
    -    BACKUP_TMP_DIR=$(mktemp -d)
    -    tar -C ${JENKINS_HOME} -czf "${BACKUP_TMP_DIR}/${backup_number}.tar.gz" --exclude jobs/*/workspace* -c jobs && \
    -
    -    aws s3 cp ${BACKUP_TMP_DIR}/${backup_number}.tar.gz s3://${BACKUP_BUCKET}/${BACKUP_PATH}/${backup_number}.tar.gz
    -    echo Done
    -
    -  restore.sh: |-
    -    #!/bin/bash -xeu
    -    [[ ! $# -eq 1 ]] && echo "Usage: $0 backup_number" && exit 1
    -    [[ -z "${BACKUP_BUCKET}" ]] && echo "Required 'BACKUP_BUCKET' env not set" && exit 1;
    -    [[ -z "${BACKUP_PATH}" ]] && echo "Required 'BACKUP_PATH' env not set" && exit 1;
    -    [[ -z "${JENKINS_HOME}" ]] && echo "Required 'JENKINS_HOME' env not set" && exit 1;
    -
    -    backup_number=$1
    -    echo "Running restore #${backup_number}"
    -
    -    BACKUP_TMP_DIR=$(mktemp -d)
    -    aws s3 cp s3://${BACKUP_BUCKET}/${BACKUP_PATH}/${backup_number}.tar.gz ${BACKUP_TMP_DIR}/${backup_number}.tar.gz
    -
    -    tar -C ${JENKINS_HOME} -zxf "${BACKUP_TMP_DIR}/${backup_number}.tar.gz"
    -    echo Done
    -

    In our example we will use S3 bucket lifecycle policy to keep -the number of backups under control, e.g. Cloud Formation fragment:

    -
        Type: AWS::S3::Bucket
    -    Properties:
    -      BucketName: my-example-bucket
    -      ...
    -      LifecycleConfiguration:
    -        Rules:
    -          - Id: BackupCleanup
    -            Status: Enabled
    -            Prefix: my-backup-path
    -            ExpirationInDays: 7
    -            NoncurrentVersionExpirationInDays: 14
    -            AbortIncompleteMultipartUpload:
    -              DaysAfterInitiation: 3
    - - -
    Last modified August 5, 2019 -
    -
    - - -
    -
    -
    - - - - -
    - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/docs/getting-started/future/customization/index.html b/docs/docs/getting-started/future/customization/index.html deleted file mode 100644 index 4f74c278..00000000 --- a/docs/docs/getting-started/future/customization/index.html +++ /dev/null @@ -1,763 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -Customization | Jenkins Operator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Customization | Jenkins Operator - - -
    - - - -
    -
    -
    -
    -
    - - - - - -
    - - - - -
    - - - - -
    -
    - - - - - - - - - - - - - - - -
    -
    - - - -
    -

    Customization

    -
    How to customize Jenkins
    - - -

    Jenkins can be customized using groovy scripts or the configuration as code plugin. -By using a ConfigMap you can create your own Jenkins customized configuration. -Then you must reference the ConfigMap in the Jenkins pod customization file in spec.groovyScripts or spec.configurationAsCode

    - -

    For example create a ConfigMap with name jenkins-operator-user-configuration. Then, modify the Jenkins manifest to look like this:

    -
    apiVersion: jenkins.io/v1alpha2
    -kind: Jenkins
    -metadata:
    -  name: example
    -spec:
    -  configurationAsCode:
    -    configurations: 
    -    - name: jenkins-operator-user-configuration
    -  groovyScripts:
    -    configurations:
    -    - name: jenkins-operator-user-configuration
    -

    Here is an example of jenkins-operator-user-configuration:

    -
    apiVersion: v1
    -kind: ConfigMap
    -metadata:
    -  name: jenkins-operator-user-configuration
    -data:
    -  1-configure-theme.groovy: | 
    -    import jenkins.*
    -    import jenkins.model.*
    -    import hudson.*
    -    import hudson.model.*
    -    import org.jenkinsci.plugins.simpletheme.ThemeElement
    -    import org.jenkinsci.plugins.simpletheme.CssTextThemeElement
    -    import org.jenkinsci.plugins.simpletheme.CssUrlThemeElement
    -
    -    Jenkins jenkins = Jenkins.getInstance()
    -
    -    def decorator = Jenkins.instance.getDescriptorByType(org.codefirst.SimpleThemeDecorator.class)
    -
    -    List<ThemeElement> configElements = new ArrayList<>();
    -    configElements.add(new CssTextThemeElement("DEFAULT"));
    -    configElements.add(new CssUrlThemeElement("https://cdn.rawgit.com/afonsof/jenkins-material-theme/gh-pages/dist/material-light-green.css"));
    -    decorator.setElements(configElements);
    -    decorator.save();
    -
    -    jenkins.save()
    -  1-system-message.yaml: |
    -    jenkins:
    -      systemMessage: "Configuration as Code integration works!!!"
    -
      -
    • *.groovy is Groovy script configuration
    • -
    • *.yaml is configuration as code
    • -
    - -

    If you want to correct your configuration you can edit it while the Jenkins Operator is running. -Jenkins will reconcile and apply the new configuration.

    - -

    Using secrets from a Groovy script

    - -

    If you configured spec.groovyScripts.secret.name, then this secret is available to use from map Groovy scripts. -The secrets are loaded to secrets map.

    - -

    Create a secret with for example the name jenkins-conf-secrets.

    -
    kind: Secret
    -apiVersion: v1
    -type: Opaque
    -metadata:
    -  name: jenkins-conf-secrets
    -  namespace: default
    -data:
    -  SYSTEM_MESSAGE: SGVsbG8gd29ybGQ=
    -

    Then modify the Jenkins pod manifest by changing spec.groovyScripts.secret.name to jenkins-conf-secrets.

    -
    apiVersion: jenkins.io/v1alpha2
    -kind: Jenkins
    -metadata:
    -  name: example
    -spec:
    -  configurationAsCode:
    -    configurations: 
    -    - name: jenkins-operator-user-configuration
    -    secret:
    -      name: jenkins-conf-secrets
    -  groovyScripts:
    -    configurations:
    -    - name: jenkins-operator-user-configuration
    -    secret:
    -      name: jenkins-conf-secrets
    -

    Now you can test that the secret is mounted by applying this ConfigMap for Groovy script:

    -
    apiVersion: v1
    -kind: ConfigMap
    -metadata:
    -  name: jenkins-operator-user-configuration
    -data:
    -  1-system-message.groovy: | 
    -    import jenkins.*
    -    import jenkins.model.*
    -    import hudson.*
    -    import hudson.model.*
    -    Jenkins jenkins = Jenkins.getInstance()
    -    
    -    jenkins.setSystemMessage(secrets["SYSTEM_MESSAGE"])
    -    jenkins.save()
    -

    Or by applying this configuration as code:

    -
    apiVersion: v1
    -kind: ConfigMap
    -metadata:
    -  name: jenkins-operator-user-configuration
    -data:
    -  1-system-message.yaml: |
    -    jenkins:
    -      systemMessage: ${SYSTEM_MESSAGE}
    -

    After this, you should see the Hello world system message from the Jenkins homepage.

    - -

    Install Plugins

    - -

    Edit Custom Resource under spec.master.plugins:

    - -
    apiVersion: jenkins.io/v1alpha2
    -kind: Jenkins
    -metadata:
    -  name: example
    -spec:
    -  master:
    -   plugins:
    -   - name: simple-theme-plugin
    -     version: 0.5.1
    -
    - -

    Under spec.master.basePlugins you can find plugins for a valid Jenkins Operator:

    -
    apiVersion: jenkins.io/v1alpha2
    -kind: Jenkins
    -metadata:
    -  name: example
    -spec:
    -  master:
    -    basePlugins:
    -    - name: kubernetes
    -      version: 1.18.3
    -    - name: workflow-job
    -      version: "2.34"
    -    - name: workflow-aggregator
    -      version: "2.6"
    -    - name: git
    -      version: 3.12.0
    -    - name: job-dsl
    -      version: "1.76"
    -    - name: configuration-as-code
    -      version: "1.29"
    -    - name: configuration-as-code-support
    -      version: "1.19"
    -    - name: kubernetes-credentials-provider
    -      version: 0.12.1
    -

    You can change their versions.

    - -

    The Jenkins Operator will then automatically install plugins after the Jenkins master pod restarts.

    - - - -
    Last modified August 5, 2019 -
    -
    - - -
    -
    -
    - - - - -
    - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/docs/getting-started/future/deploy-jenkins/index.html b/docs/docs/getting-started/future/deploy-jenkins/index.html deleted file mode 100644 index 391e6fe6..00000000 --- a/docs/docs/getting-started/future/deploy-jenkins/index.html +++ /dev/null @@ -1,653 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -Deploy Jenkins | Jenkins Operator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Deploy Jenkins | Jenkins Operator - - -
    - - - -
    -
    -
    -
    -
    - - - - - -
    - - - - -
    - - - - -
    -
    - - - - - - - - - - - -
    -
    - - - -
    -

    Deploy Jenkins

    -
    Deploy production ready Jenkins Operator manifest
    -

    Once Jenkins Operator is up and running let’s deploy actual Jenkins instance. -Create manifest e.g. jenkins_instance.yaml with following data and save it on drive.

    -
    apiVersion: jenkins.io/v1alpha2
    -kind: Jenkins
    -metadata:
    -  name: example
    -spec:
    -  master:
    -    containers:
    -    - name: jenkins-master
    -      image: jenkins/jenkins:lts
    -      imagePullPolicy: Always
    -      livenessProbe:
    -        failureThreshold: 12
    -        httpGet:
    -          path: /login
    -          port: http
    -          scheme: HTTP
    -        initialDelaySeconds: 80
    -        periodSeconds: 10
    -        successThreshold: 1
    -        timeoutSeconds: 5
    -      readinessProbe:
    -        failureThreshold: 3
    -        httpGet:
    -          path: /login
    -          port: http
    -          scheme: HTTP
    -        initialDelaySeconds: 30
    -        periodSeconds: 10
    -        successThreshold: 1
    -        timeoutSeconds: 1
    -      resources:
    -        limits:
    -          cpu: 1500m
    -          memory: 3Gi
    -        requests:
    -          cpu: "1"
    -          memory: 500Mi
    -  seedJobs:
    -  - id: jenkins-operator
    -    targets: "cicd/jobs/*.jenkins"
    -    description: "Jenkins Operator repository"
    -    repositoryBranch: master
    -    repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git
    -

    Deploy a Jenkins to Kubernetes:

    -
    kubectl create -f jenkins_instance.yaml
    -

    Watch the Jenkins instance being created:

    -
    kubectl get pods -w
    -

    Get the Jenkins credentials:

    -
    kubectl get secret jenkins-operator-credentials-<cr_name> -o 'jsonpath={.data.user}' | base64 -d
    -kubectl get secret jenkins-operator-credentials-<cr_name> -o 'jsonpath={.data.password}' | base64 -d
    -

    Connect to the Jenkins instance (minikube):

    -
    minikube service jenkins-operator-http-<cr_name> --url
    -

    Connect to the Jenkins instance (actual Kubernetes cluster):

    -
    kubectl port-forward jenkins-<cr_name> 8080:8080
    -

    Then open browser with address http://localhost:8080. -jenkins

    - - - -
    Last modified August 5, 2019 -
    -
    - - -
    -
    -
    - - - - -
    - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/docs/getting-started/future/developer-guide/index.html b/docs/docs/getting-started/future/developer-guide/index.html deleted file mode 100644 index 8c5b77cb..00000000 --- a/docs/docs/getting-started/future/developer-guide/index.html +++ /dev/null @@ -1,771 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -Developer Guide | Jenkins Operator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Developer Guide | Jenkins Operator - - -
    - - - -
    -
    -
    -
    -
    - - - - - -
    - - - - -
    - - - - -
    - -
    - - - -
    -

    Developer Guide

    -
    Jenkins Operator for developers
    - - - - -
    -

    This document explains how to setup your development environment.

    - -
    - - -

    Prerequisites

    - - - -

    Clone repository and download dependencies

    -
    mkdir -p $GOPATH/src/github.com/jenkinsci
    -cd $GOPATH/src/github.com/jenkinsci/
    -git clone git@github.com:jenkinsci/kubernetes-operator.git
    -cd kubernetes-operator
    -make go-dependencies
    -

    Build and run with a minikube

    - -

    Build and run Jenkins Operator locally:

    -
    make build minikube-run OPERATOR_EXTRA_ARGS='--jenkins-api-hostname=$(eval minikube ip) --jenkins-api-use-nodeport=true'
    -

    Once minikube and Jenkins Operator are up and running, apply Jenkins custom resource:

    -
    kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml
    -kubectl get jenkins -o yaml
    -kubectl get po
    -

    Build and run with a remote Kubernetes cluster

    - -

    You can also run the controller locally and make it listen to a remote Kubernetes server.

    -
    make run NAMESPACE=default KUBECTL_CONTEXT=remote-k8s OPERATOR_EXTRA_ARGS='--kubeconfig ~/.kube/config'
    -

    Once minikube and Jenkins Operator are up and running, apply Jenkins custom resource:

    -
    kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml
    -kubectl --context remote-k8s --namespace default get jenkins -o yaml
    -kubectl --context remote-k8s --namespace default get po
    -

    Testing

    - -

    Run unit tests:

    -
    make test
    -

    Running E2E tests on Linux

    - -

    Run e2e tests with minikube:

    -
    make minikube-start
    -eval $(minikube docker-env)
    -make build e2e config=config.minikube.env CONTAINER_RUNTIME=podman
    -

    config.minikube.env is the E2E test profile which provides all connection info to operator to run on minikube.

    - -

    Run the specific e2e test:

    -
    make build e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.minikube.env CONTAINER_RUNTIME=podman
    -

    If you want to run E2E tests on CRC (Code Ready Containers by OpenShift), you should use config.crc.env profile instead of config.minikube.env. -If you have some trouble with podman (for example building) then check how to use docker instead of podman.

    - -

    Running E2E tests on macOS

    - -

    At first, you need to start minikube:

    -
    $ make minikube-start
    -$ eval $(minikube docker-env) 
    -

    Build a Docker image inside the provided Linux container by:

    -
    $ make indocker
    -

    Build Jenkins Operator inside a container using:

    -
    $ make build
    -

    Then exit the container and run:

    - -
    make e2e config=config.minikube.env
    -
    - -

    or using crc as cluster software:

    - -
    make e2e config=config.crc.env
    -
    - -

    Using Docker instead of podman

    - -

    If you have trouble with building image using the podman, you can set additional flag IMAGE_PULL_MODE to pull image from the organization.

    - -

    At first, you need to edit config.base.env and change the DOCKER_ORGANIZATION to your Docker Hub account/organization. -After this change the IMAGE_PULL_MODE to remote. It will setup the Makefile goal to pull Docker image from registry. -Then you need to pull image from your repository:

    -
    $ make container-runtime-build container-runtime-snapshot-push
    -

    When image will be uploaded to repository, you can now write this command to run E2E tests:

    -
    $ make e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.crc.env
    -

    Tips & Tricks

    - -

    Building docker image on minikube (for e2e tests)

    - -

    To be able to work with the docker daemon on minikube machine run the following command before building an image:

    -
    eval $(minikube docker-env)
    -

    When pkg/apis/jenkinsio/*/jenkins_types.go has changed

    - -

    Run:

    -
    make deepcopy-gen
    -

    Getting the Jenkins URL and basic credentials

    -
    minikube service jenkins-operator-http-<cr_name> --url
    -kubectl get secret jenkins-operator-credentials-<cr_name> -o 'jsonpath={.data.user}' | base64 -d
    -kubectl get secret jenkins-operator-credentials-<cr_name> -o 'jsonpath={.data.password}' | base64 -d
    -

    Tools

    - -

    Configure environment variables

    -
    export GOPATH=/home/go # example value
    -export GOROOT=/usr/lib/go-1.12 # example value
    -export PATH=$GOPATH/bin:$PATH
    -

    goimports

    - -
    go get golang.org/x/tools/cmd/goimports
    -cd $GOPATH/src/golang.org/x/tools/cmd/goimports
    -go build
    -go install
    -
    - -

    golint

    - -
    go get -u golang.org/x/lint/golint
    -cd  $GOPATH/src/golang.org/x/lint/golint
    -go build
    -go install
    -
    - -

    checkmake

    - -
    go get github.com/mrtazz/checkmake
    -cd $GOPATH/src/github.com/mrtazz/checkmake
    -go build
    -go install
    -
    - -

    staticcheck

    - -
    mkdir -p $GOPATH/src/github.com/dominikh/
    -cd $GOPATH/src/github.com/dominikh/
    -git clone https://github.com/dominikh/go-tools.git
    -cd  $GOPATH/src/github.com/dominikh/go-tools/staticcheck
    -go build
    -go install
    -
    - - - -
    Last modified August 5, 2019 -
    -
    - - -
    -
    -
    - - - - -
    - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/docs/getting-started/future/index.html b/docs/docs/getting-started/future/index.html deleted file mode 100644 index da8ab204..00000000 --- a/docs/docs/getting-started/future/index.html +++ /dev/null @@ -1,752 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - -Future (v0.3.x) | Jenkins Operator - - - - - - - - - - - - - - - - - - - - - - - - Future (v0.3.x) | Jenkins Operator - - -
    - - - -
    -
    -
    -
    -
    - - - - - -
    - - - - -
    - - - - -
    -
    - - - - - - - - - - - - - -
    -
    - - - -
    -

    Future (v0.3.x)

    -
    How to work with jenkins-operator latest version
    - - - - -
    -

    This document describes a getting started guide for Jenkins Operator v0.3.x and an additional configuration.

    - -
    - - -

    First Steps

    - -

    Prepare your Kubernetes cluster and set up your kubectl access.

    - -

    Once you have running Kubernetes cluster you can focus on installing Jenkins Operator according to the Installation guide.

    - -
    - - - - -
    - - - - -
    -
    - Deploy Jenkins -
    -

    Deploy production ready Jenkins Operator manifest -

    -
    - - - - - - - - - -
    -
    - Configuration -
    -

    How to configure Jenkins with Operator -

    -
    - - - - - - - -
    -
    - Customization -
    -

    How to customize Jenkins -

    -
    - - - - - - - - - -
    -
    - AKS -
    -

    Additional configuration for Azure Kubernetes Service -

    -
    - - - - - - - -
    -
    - Configure backup and restore -
    -

    Prevent loss of job history -

    -
    - - - - - - - -
    -
    - Custom Backup and Restore Providers -
    -

    Custom backup and restore provider -

    -
    - - - - - - - - - - - - - - - - - - - -
    -
    - Diagnostics -
    -

    How to deal with Jenkins Operator problems -

    -
    - - - - - - - -
    -
    - Schema -
    -

    API Schema definitions for Jenkins CRD -

    -
    - - - - - - - - - - - -
    -
    - Developer Guide -
    -

    Jenkins Operator for developers -

    -
    - - - - - - - -
    - - - -
    Last modified August 5, 2019 -
    -
    - -
    -
    -
    - - - - -
    - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/docs/getting-started/future/index.xml b/docs/docs/getting-started/future/index.xml deleted file mode 100644 index 9faa4556..00000000 --- a/docs/docs/getting-started/future/index.xml +++ /dev/null @@ -1,3020 +0,0 @@ - - - Jenkins Operator – Future (v0.3.x) - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/ - Recent Hugo news from gohugo.io - Hugo -- gohugo.io - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/img/hugo.png - GoHugo.io - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/ - - - - - - - - - - - - Docs: Deploy Jenkins - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/deploy-jenkins/ - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/deploy-jenkins/ - - - - <p>Once Jenkins Operator is up and running let&rsquo;s deploy actual Jenkins instance. -Create manifest e.g. <strong><code>jenkins_instance.yaml</code></strong> with following data and save it on drive.</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - master: - containers: - - name: jenkins-master - image: jenkins/jenkins:lts - imagePullPolicy: Always - livenessProbe: - failureThreshold: <span style="color:#0000cf;font-weight:bold">12</span> - httpGet: - path: /login - port: http - scheme: HTTP - initialDelaySeconds: <span style="color:#0000cf;font-weight:bold">80</span> - periodSeconds: <span style="color:#0000cf;font-weight:bold">10</span> - successThreshold: <span style="color:#0000cf;font-weight:bold">1</span> - timeoutSeconds: <span style="color:#0000cf;font-weight:bold">5</span> - readinessProbe: - failureThreshold: <span style="color:#0000cf;font-weight:bold">3</span> - httpGet: - path: /login - port: http - scheme: HTTP - initialDelaySeconds: <span style="color:#0000cf;font-weight:bold">30</span> - periodSeconds: <span style="color:#0000cf;font-weight:bold">10</span> - successThreshold: <span style="color:#0000cf;font-weight:bold">1</span> - timeoutSeconds: <span style="color:#0000cf;font-weight:bold">1</span> - resources: - limits: - cpu: 1500m - memory: 3Gi - requests: - cpu: <span style="color:#4e9a06">&#34;1&#34;</span> - memory: 500Mi - seedJobs: - - id: jenkins-operator - targets: <span style="color:#4e9a06">&#34;cicd/jobs/*.jenkins&#34;</span> - description: <span style="color:#4e9a06">&#34;Jenkins Operator repository&#34;</span> - repositoryBranch: master - repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git</code></pre></div> -<p>Deploy a Jenkins to Kubernetes:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl create -f jenkins_instance.yaml</code></pre></div> -<p>Watch the Jenkins instance being created:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl get pods -w</code></pre></div> -<p>Get the Jenkins credentials:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.user}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d -kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.password}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d</code></pre></div> -<p>Connect to the Jenkins instance (minikube):</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">minikube service jenkins-operator-http-&lt;cr_name&gt; --url</code></pre></div> -<p>Connect to the Jenkins instance (actual Kubernetes cluster):</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl port-forward jenkins-&lt;cr_name&gt; <span style="color:#0000cf;font-weight:bold">8080</span>:8080</code></pre></div> -<p>Then open browser with address <code>http://localhost:8080</code>. -<img src="https://jenkinsci.github.io/kubernetes-operator/img/jenkins.png" alt="jenkins" /></p> - - - - - - Docs: Configuration - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/configuration/ - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/configuration/ - - - - - -<h2 id="configure-seed-jobs-and-pipelines">Configure Seed Jobs and Pipelines</h2> - -<p>Jenkins operator uses <a href="https://github.com/jenkinsci/job-dsl-plugin" target="_blank">job-dsl</a> and <a href="https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/" target="_blank">kubernetes-credentials-provider</a> plugins for configuring jobs -and deploy keys.</p> - -<h2 id="prepare-job-definitions-and-pipelines">Prepare job definitions and pipelines</h2> - -<p>First you have to prepare pipelines and job definition in your GitHub repository using the following structure:</p> - -<pre><code>cicd/ -├── jobs -│   └── build.jenkins -└── pipelines - └── build.jenkins -</code></pre> - -<p><strong><code>cicd/jobs/build.jenkins</code></strong> is a job definition:</p> - -<pre><code>#!/usr/bin/env groovy - -pipelineJob('build-jenkins-operator') { - displayName('Build jenkins-operator') - - definition { - cpsScm { - scm { - git { - remote { - url('https://github.com/jenkinsci/kubernetes-operator.git') - credentials('jenkins-operator') - } - branches('*/master') - } - } - scriptPath('cicd/pipelines/build.jenkins') - } - } -} -</code></pre> - -<p><strong><code>cicd/pipelines/build.jenkins</code></strong> is an actual Jenkins pipeline:</p> - -<pre><code>#!/usr/bin/env groovy - -def label = &quot;build-jenkins-operator-${UUID.randomUUID().toString()}&quot; -def home = &quot;/home/jenkins&quot; -def workspace = &quot;${home}/workspace/build-jenkins-operator&quot; -def workdir = &quot;${workspace}/src/github.com/jenkinsci/kubernetes-operator/&quot; - -podTemplate(label: label, - containers: [ - containerTemplate(name: 'jnlp', image: 'jenkins/jnlp-slave:alpine'), - containerTemplate(name: 'go', image: 'golang:1-alpine', command: 'cat', ttyEnabled: true), - ], - envVars: [ - envVar(key: 'GOPATH', value: workspace), - ], - ) { - - node(label) { - dir(workdir) { - stage('Init') { - timeout(time: 3, unit: 'MINUTES') { - checkout scm - } - container('go') { - sh 'apk --no-cache --update add make git gcc libc-dev' - } - } - - stage('Dep') { - container('go') { - sh 'make dep' - } - } - - stage('Test') { - container('go') { - sh 'make test' - } - } - - stage('Build') { - container('go') { - sh 'make build' - } - } - } - } -} -</code></pre> - -<h2 id="configure-seed-jobs">Configure Seed Jobs</h2> - -<p>Jenkins Seed Jobs are configured using <code>Jenkins.spec.seedJobs</code> section from your custom resource manifest:</p> - -<pre><code>apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - seedJobs: - - id: jenkins-operator - targets: &quot;cicd/jobs/*.jenkins&quot; - description: &quot;Jenkins Operator repository&quot; - repositoryBranch: master - repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git -</code></pre> - -<p><strong>Jenkins Operator</strong> will automatically discover and configure all the seed jobs.</p> - -<p>You can verify if deploy keys were successfully configured in the Jenkins <strong>Credentials</strong> tab.</p> - -<p><img src="https://jenkinsci.github.io/kubernetes-operator/kubernetes-operator/img/jenkins-credentials.png" alt="jenkins" /></p> - -<p>You can verify if your pipelines were successfully configured in the Jenkins Seed Job console output.</p> - -<p><img src="https://jenkinsci.github.io/kubernetes-operator/kubernetes-operator/img/jenkins-seed.png" alt="jenkins" /></p> - -<p>If your GitHub repository is <strong>private</strong> you have to configure SSH or username/password authentication.</p> - -<h3 id="ssh-authentication">SSH authentication</h3> - -<h4 id="generate-ssh-keys">Generate SSH Keys</h4> - -<p>There are two methods of SSH private key generation:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ openssl genrsa -out &lt;filename&gt; <span style="color:#0000cf;font-weight:bold">2048</span></code></pre></div> -<p>or</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ ssh-keygen -t rsa -b <span style="color:#0000cf;font-weight:bold">2048</span> -$ ssh-keygen -p -f &lt;filename&gt; -m pem</code></pre></div> -<p>Then copy content from generated file.</p> - -<h4 id="public-key">Public key</h4> - -<p>If you want to upload your public key to your Git server you need to extract it.</p> - -<p>If key was generated by <code>openssl</code> then you need to type this to extract public key:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ openssl rsa -in &lt;filename&gt; -pubout &gt; &lt;filename&gt;.pub</code></pre></div> -<p>If key was generated by <code>ssh-keygen</code> the public key content is located in <filename>.pub and there is no need to extract public key</p> - -<h4 id="configure-ssh-authentication">Configure SSH authentication</h4> - -<p>Configure a seed job like this:</p> - -<pre><code>apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - seedJobs: - - id: jenkins-operator-ssh - credentialType: basicSSHUserPrivateKey - credentialID: k8s-ssh - targets: &quot;cicd/jobs/*.jenkins&quot; - description: &quot;Jenkins Operator repository&quot; - repositoryBranch: master - repositoryUrl: git@github.com:jenkinsci/kubernetes-operator.git -</code></pre> - -<p>and create a Kubernetes Secret (name of secret should be the same from <code>credentialID</code> field):</p> - -<pre><code>apiVersion: v1 -kind: Secret -metadata: - name: k8s-ssh -stringData: - privateKey: | - -----BEGIN RSA PRIVATE KEY----- - MIIJKAIBAAKCAgEAxxDpleJjMCN5nusfW/AtBAZhx8UVVlhhhIKXvQ+dFODQIdzO - oDXybs1zVHWOj31zqbbJnsfsVZ9Uf3p9k6xpJ3WFY9b85WasqTDN1xmSd6swD4N8 - ... - username: github_user_name -</code></pre> - -<h3 id="username-password-authentication">Username &amp; password authentication</h3> - -<p>Configure the seed job like:</p> - -<pre><code>apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - seedJobs: - - id: jenkins-operator-user-pass - credentialType: usernamePassword - credentialID: k8s-user-pass - targets: &quot;cicd/jobs/*.jenkins&quot; - description: &quot;Jenkins Operator repository&quot; - repositoryBranch: master - repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git -</code></pre> - -<p>and create a Kubernetes Secret (name of secret should be the same from <code>credentialID</code> field):</p> - -<pre><code>apiVersion: v1 -kind: Secret -metadata: - name: k8s-user-pass -stringData: - username: github_user_name - password: password_or_token -</code></pre> - -<h2 id="http-proxy-for-downloading-plugins">HTTP Proxy for downloading plugins</h2> - -<p>To use forwarding proxy with an operator to download plugins you need to add the following environment variable to Jenkins Custom Resource (CR), e.g.:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containers<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-master<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>env<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>CURL_OPTIONS<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-L<span style="color:#f8f8f8;text-decoration:underline"> </span>-x<span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;proxy_url&gt;</code></pre></div> -<p>In <code>CURL_OPTIONS</code> var you can set additional arguments to <code>curl</code> command.</p> - -<h2 id="pulling-docker-images-from-private-repositories">Pulling Docker images from private repositories</h2> - -<p>To pull a Docker Image from private repository you can use <code>imagePullSecrets</code>.</p> - -<p>Please follow the instructions on <a href="https://kubernetes.io/docs/concepts/containers/images/?origin_team=T42NTAGHM#creating-a-secret-with-a-docker-config" target="_blank">creating a secret with a docker config</a>.</p> - -<h3 id="docker-hub-configuration">Docker Hub Configuration</h3> - -<p>To use Docker Hub additional steps are required.</p> - -<p>Edit the previously created secret:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl -n &lt;namespace&gt; edit secret &lt;name&gt;</code></pre></div> -<p>The <code>.dockerconfigjson</code> key&rsquo;s value needs to be replaced with a modified version.</p> - -<p>After modifications, it needs to be encoded as a Base64 value before setting the <code>.dockerconfigjson</code> key.</p> - -<p>Example config file to modify and use:</p> - -<pre><code>{ - &quot;auths&quot;:{ - &quot;https://index.docker.io/v1/&quot;:{ - &quot;username&quot;:&quot;user&quot;, - &quot;password&quot;:&quot;password&quot;, - &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, - &quot;auth&quot;:&quot;base64 of string user:password&quot; - }, - &quot;auth.docker.io&quot;:{ - &quot;username&quot;:&quot;user&quot;, - &quot;password&quot;:&quot;password&quot;, - &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, - &quot;auth&quot;:&quot;base64 of string user:password&quot; - }, - &quot;registry.docker.io&quot;:{ - &quot;username&quot;:&quot;user&quot;, - &quot;password&quot;:&quot;password&quot;, - &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, - &quot;auth&quot;:&quot;base64 of string user:password&quot; - }, - &quot;docker.io&quot;:{ - &quot;username&quot;:&quot;user&quot;, - &quot;password&quot;:&quot;password&quot;, - &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, - &quot;auth&quot;:&quot;base64 of string user:password&quot; - }, - &quot;https://registry-1.docker.io/v2/&quot;: { - &quot;username&quot;:&quot;user&quot;, - &quot;password&quot;:&quot;password&quot;, - &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, - &quot;auth&quot;:&quot;base64 of string user:password&quot; - }, - &quot;registry-1.docker.io/v2/&quot;: { - &quot;username&quot;:&quot;user&quot;, - &quot;password&quot;:&quot;password&quot;, - &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, - &quot;auth&quot;:&quot;base64 of string user:password&quot; - }, - &quot;registry-1.docker.io&quot;: { - &quot;username&quot;:&quot;user&quot;, - &quot;password&quot;:&quot;password&quot;, - &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, - &quot;auth&quot;:&quot;base64 of string user:password&quot; - }, - &quot;https://registry-1.docker.io&quot;: { - &quot;username&quot;:&quot;user&quot;, - &quot;password&quot;:&quot;password&quot;, - &quot;email&quot;:&quot;yourdockeremail@gmail.com&quot;, - &quot;auth&quot;:&quot;base64 of string user:password&quot; - } - } -} -</code></pre> - - - - - - Docs: Customization - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/customization/ - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/customization/ - - - - - -<p>Jenkins can be customized using groovy scripts or the <a href="https://github.com/jenkinsci/configuration-as-code-plugin" target="_blank">configuration as code plugin</a>. -By using a <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" target="_blank">ConfigMap</a> you can create your own <strong>Jenkins</strong> customized configuration. -Then you must reference the <strong><code>ConfigMap</code></strong> in the <strong>Jenkins</strong> pod customization file in <code>spec.groovyScripts</code> or <code>spec.configurationAsCode</code></p> - -<p>For example create a <strong><code>ConfigMap</code></strong> with name <code>jenkins-operator-user-configuration</code>. Then, modify the <strong>Jenkins</strong> manifest to look like this:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha2<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>example<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurationAsCode<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>groovyScripts<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration</code></pre></div> -<p>Here is an example of <code>jenkins-operator-user-configuration</code>:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ConfigMap<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>-configure-theme.groovy<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">| -</span><span style="color:#8f5902;font-style:italic"> import jenkins.*</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.model.*<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>hudson.*<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>hudson.model.*<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>org.jenkinsci.plugins.simpletheme.ThemeElement<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>org.jenkinsci.plugins.simpletheme.CssTextThemeElement<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>org.jenkinsci.plugins.simpletheme.CssUrlThemeElement<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins.getInstance()<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>def<span style="color:#f8f8f8;text-decoration:underline"> </span>decorator<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins.instance.getDescriptorByType(org.codefirst.SimpleThemeDecorator.class)<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>List&lt;ThemeElement&gt;<span style="color:#f8f8f8;text-decoration:underline"> </span>configElements<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>new<span style="color:#f8f8f8;text-decoration:underline"> </span>ArrayList&lt;&gt;();<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configElements.add(new<span style="color:#f8f8f8;text-decoration:underline"> </span>CssTextThemeElement(<span style="color:#4e9a06">&#34;DEFAULT&#34;</span>));<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configElements.add(new<span style="color:#f8f8f8;text-decoration:underline"> </span>CssUrlThemeElement(<span style="color:#4e9a06">&#34;https://cdn.rawgit.com/afonsof/jenkins-material-theme/gh-pages/dist/material-light-green.css&#34;</span>));<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>decorator.setElements(configElements);<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>decorator.save();<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.save()<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>-system-message.yaml<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">| -</span><span style="color:#8f5902;font-style:italic"> jenkins:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>systemMessage<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Configuration as Code integration works!!!&#34;</span></code></pre></div> -<ul> -<li><code>*.groovy</code> is Groovy script configuration</li> -<li><code>*.yaml is</code> configuration as code</li> -</ul> - -<p>If you want to correct your configuration you can edit it while the <strong>Jenkins Operator</strong> is running. -Jenkins will reconcile and apply the new configuration.</p> - -<h3 id="using-secrets-from-a-groovy-script">Using secrets from a Groovy script</h3> - -<p>If you configured <code>spec.groovyScripts.secret.name</code>, then this secret is available to use from map Groovy scripts. -The secrets are loaded to <code>secrets</code> map.</p> - -<p>Create a <a href="https://kubernetes.io/docs/concepts/configuration/secret/" target="_blank">secret</a> with for example the name <code>jenkins-conf-secrets</code>.</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Secret<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>type<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Opaque<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-conf-secrets<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>namespace<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>default<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>SYSTEM_MESSAGE<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>SGVsbG8gd29ybGQ=</code></pre></div> -<p>Then modify the <strong>Jenkins</strong> pod manifest by changing <code>spec.groovyScripts.secret.name</code> to <code>jenkins-conf-secrets</code>.</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha2<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>example<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurationAsCode<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>secret<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-conf-secrets<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>groovyScripts<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>secret<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-conf-secrets</code></pre></div> -<p>Now you can test that the secret is mounted by applying this <code>ConfigMap</code> for Groovy script:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ConfigMap<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>-system-message.groovy<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">| -</span><span style="color:#8f5902;font-style:italic"> import jenkins.*</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.model.*<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>hudson.*<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>import<span style="color:#f8f8f8;text-decoration:underline"> </span>hudson.model.*<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins<span style="color:#f8f8f8;text-decoration:underline"> </span>=<span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins.getInstance()<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.setSystemMessage(secrets<span style="color:#000;font-weight:bold">[</span><span style="color:#4e9a06">&#34;SYSTEM_MESSAGE&#34;</span><span style="color:#000;font-weight:bold">]</span>)<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.save()</code></pre></div> -<p>Or by applying this configuration as code:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ConfigMap<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>-system-message.yaml<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">| -</span><span style="color:#8f5902;font-style:italic"> jenkins:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>systemMessage<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>${SYSTEM_MESSAGE}</code></pre></div> -<p>After this, you should see the <code>Hello world</code> system message from the <strong>Jenkins</strong> homepage.</p> - -<h2 id="install-plugins">Install Plugins</h2> - -<p>Edit Custom Resource under <code>spec.master.plugins</code>:</p> - -<pre><code>apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - master: - plugins: - - name: simple-theme-plugin - version: 0.5.1 -</code></pre> - -<p>Under <code>spec.master.basePlugins</code> you can find plugins for a valid <strong>Jenkins Operator</strong>:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha2<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>example<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>basePlugins<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>kubernetes<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1.18</span>.<span style="color:#0000cf;font-weight:bold">3</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>workflow-job<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;2.34&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>workflow-aggregator<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;2.6&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>git<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">3.12</span>.<span style="color:#0000cf;font-weight:bold">0</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>job-dsl<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;1.76&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configuration-as-code<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;1.29&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configuration-as-code-support<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;1.19&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>kubernetes-credentials-provider<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">0.12</span>.<span style="color:#0000cf;font-weight:bold">1</span></code></pre></div> -<p>You can change their versions.</p> - -<p>The <strong>Jenkins Operator</strong> will then automatically install plugins after the Jenkins master pod restarts.</p> - - - - - - Docs: AKS - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/aks/ - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/aks/ - - - - <p>Azure AKS managed Kubernetes service adds to every pod the following environment variables:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KUBERNETES_PORT_443_TCP_ADDR<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KUBERNETES_PORT<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>tcp<span style="color:#000;font-weight:bold">:</span>//<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KUBERNETES_PORT_443_TCP<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>tcp<span style="color:#000;font-weight:bold">:</span>//<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>KUBERNETES_SERVICE_HOST<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span></code></pre></div> -<p>The operator is aware of it and omits these environment variables when checking if a Jenkins pod environment has been changed. It prevents the -restart of a Jenkins pod over and over again.</p> - - - - - - Docs: Configure backup and restore - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/configure-backup-and-restore/ - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/configure-backup-and-restore/ - - - - - -<p>Backup and restore is done by a container sidecar.</p> - -<h3 id="pvc">PVC</h3> - -<h4 id="create-pvc">Create PVC</h4> - -<p>Save to the file named pvc.yaml:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>PersistentVolumeClaim<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;pvc_name<span style="color:#8f5902;font-style:italic">&gt; -</span><span style="color:#8f5902;font-style:italic"> namespace: &lt;namespace&gt;</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>accessModes<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>ReadWriteOnce<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>resources<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>requests<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>storage<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>500Gi</code></pre></div> -<p>Run the following command:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ kubectl -n &lt;namespace&gt; create -f pvc.yaml</code></pre></div> -<h4 id="configure-jenkins-cr">Configure Jenkins CR</h4> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha2<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;cr_name<span style="color:#8f5902;font-style:italic">&gt; -</span><span style="color:#8f5902;font-style:italic"> namespace: &lt;namespace&gt;</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>securityContext<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>runAsUser<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>fsGroup<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containers<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-master<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>image<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins/jenkins<span style="color:#000;font-weight:bold">:</span>lts<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container responsible for the backup and restore</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>env<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_DIR<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/backup<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>JENKINS_HOME<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_COUNT<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;3&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># keep only the 2 most recent backups</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>image<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>virtuslab/jenkins-operator-backup-pvc<span style="color:#000;font-weight:bold">:</span>v0.<span style="color:#0000cf;font-weight:bold">0.7</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># look at backup/pvc directory</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>imagePullPolicy<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IfNotPresent<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>volumeMounts<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># Jenkins home volume</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># backup volume</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>volumes<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># PVC volume where backups will be stored</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>persistentVolumeClaim<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>claimName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;pvc_name<span style="color:#8f5902;font-style:italic">&gt; -</span><span style="color:#8f5902;font-style:italic"> backup:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containerName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container name is responsible for backup</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>action<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/backup.sh<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># this command is invoked on &#34;backup&#34; container to make backup, for example /home/user/bin/backup.sh &lt;backup_number&gt;, &lt;backup_number&gt; is passed by operator</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>interval<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">30</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># how often make backup in seconds</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>makeBackupBeforePodDeletion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">true</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># make a backup before pod deletion</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>restore<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containerName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container name is responsible for restore backup</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>action<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/restore.sh<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># this command is invoked on &#34;backup&#34; container to make restore backup, for example /home/user/bin/restore.sh &lt;backup_number&gt;, &lt;backup_number&gt; is passed by operator</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">#recoveryOnce: &lt;backup_number&gt; # if want to restore specific backup configure this field and then Jenkins will be restarted and desired backup will be restored</span></code></pre></div> - - - - - Docs: Custom Backup and Restore Providers - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/custom-backup-and-restore/ - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/custom-backup-and-restore/ - - - - - -<p>With enough effort one can create a custom backup and restore provider -for the Jenkins Operator.</p> - -<h2 id="requirements">Requirements</h2> - -<p>Two commands (e.g. scripts) are required:</p> - -<ul> -<li>a backup command, e.g. <code>backup.sh</code> that takes one argument, a <strong>backup number</strong></li> -<li>a restore command, e.g. <code>backup.sh</code> that takes one argument, a <strong>backup number</strong></li> -</ul> - -<p>Both scripts need to return an exit code of <code>0</code> on success and <code>1</code> or greater for failure.</p> - -<p>One of those scripts (or the entry point of the container) needs to be responsible -for backup cleanup or rotation if required, or an external system.</p> - -<h2 id="how-it-works">How it works</h2> - -<p>The mechanism relies on basic Kubernetes and UNIX functionalities.</p> - -<p>The backup (and restore) container runs as a sidecar in the same -Kubernetes pod as the Jenkins master.</p> - -<p>Name of the backup and restore containers can be set as necessary using -<code>spec.backup.containerName</code> and <code>spec.restore.containerName</code>. -In most cases it will be the same container, but we allow for less common use cases.</p> - -<p>The operator will call a backup or restore commands inside a sidecar container when necessary:</p> - -<ul> -<li>backup command (defined in <code>spec.backup.action.exec.command</code>) -will be called every <code>N</code> seconds configurable in: <code>spec.backup.interval</code> -and on pod shutdown (if enabled in <code>spec.backup.makeBackupBeforePodDeletion</code>) -with an integer representing the current backup number as first and only argument</li> -<li>restore command (defined in <code>spec.restore.action.exec.command</code>) -will be called at Jenkins startup -with an integer representing the backup number to restore as first and only argument -(can be overridden using <code>spec.restore.recoveryOnce</code>)</li> -</ul> - -<h2 id="example-aws-s3-backup-using-the-cli">Example AWS S3 backup using the CLI</h2> - -<p>This example shows abbreviated version of a simple AWS S3 backup implementation -using: <code>aws-cli</code>, <code>bash</code> and <code>kube2iam</code>.</p> - -<p>In addition to your normal <code>Jenkins</code> <code>CustomResource</code> some additional settings -for backup and restore are required, e.g.:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha1<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>example<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>namespace<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>masterAnnotations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>iam.amazonaws.com/role<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;my-example-backup-role&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># tell kube2iam where the AWS IAM role is</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containers<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-master<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>...<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container responsible for backup and restore</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>image<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>quay.io/virtuslab/aws-cli<span style="color:#000;font-weight:bold">:</span><span style="color:#0000cf;font-weight:bold">1.16</span>.<span style="color:#0000cf;font-weight:bold">263</span>-<span style="color:#0000cf;font-weight:bold">2</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>workingDir<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># our container entry point</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>sleep<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>infinity<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>env<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_BUCKET<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>my-example-bucket<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># the S3 bucket name to use</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_PATH<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>my-backup-path<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># the S3 bucket path prefix to use</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>JENKINS_HOME<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># the path to mount jenkins home dir in the backup container</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>volumeMounts<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># Jenkins home volume</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/backup.sh<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup-scripts<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>subPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup.sh<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>readOnly<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">true</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/restore.sh<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup-scripts<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>subPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>restore.sh<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>readOnly<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">true</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>volumes<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup-scripts<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configMap<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>defaultMode<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">0754</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-backup-s3<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>securityContext<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># make sure both containers use the same UID and GUID</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>runAsUser<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>fsGroup<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1000</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>...<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containerName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container name responsible for backup</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>interval<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">3600</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># how often make a backup in seconds</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>makeBackupBeforePodDeletion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#204a87;font-weight:bold">true</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># trigger backup just before deleting the pod</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>action<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># this command is invoked on &#34;backup&#34; container to create a backup,</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># &lt;backup_number&gt; is passed by operator,</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># for example /home/user/bin/backup.sh &lt;backup_number&gt;</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/backup.sh<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>restore<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containerName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container name is responsible for restore backup</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>action<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># this command is invoked on &#34;backup&#34; container to restore a backup,</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># &lt;backup_number&gt; is passed by operator</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># for example /home/user/bin/restore.sh &lt;backup_number&gt;</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/restore.sh<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span><span style="color:#8f5902;font-style:italic"># recoveryOnce: &lt;backup_number&gt; # if want to restore specific backup configure this field and then Jenkins will be restarted and desired backup will be restored</span></code></pre></div> -<p>The actual backup and restore scripts will be provided in a <code>ConfigMap</code>:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ConfigMap<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-backup-s3<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>namespace<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>labels<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>app<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup.sh<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>|<span style="color:#8f5902;font-style:italic">- -</span><span style="color:#8f5902;font-style:italic"> #!/bin/bash -xeu</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>!<span style="color:#f8f8f8;text-decoration:underline"> </span>$<span style="color:#8f5902;font-style:italic"># -eq 1 ]] &amp;&amp; echo &#34;Usage: $0 backup_number&#34; &amp;&amp; exit 1;</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_BUCKET}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;BACKUP_BUCKET&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_PATH}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;BACKUP_PATH&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${JENKINS_HOME}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;JENKINS_HOME&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup_number=$<span style="color:#0000cf;font-weight:bold">1</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Running backup #${backup_number}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_TMP_DIR=$(mktemp<span style="color:#f8f8f8;text-decoration:underline"> </span>-d)<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>tar<span style="color:#f8f8f8;text-decoration:underline"> </span>-C<span style="color:#f8f8f8;text-decoration:underline"> </span>${JENKINS_HOME}<span style="color:#f8f8f8;text-decoration:underline"> </span>-czf<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_TMP_DIR}/${backup_number}.tar.gz&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>--exclude<span style="color:#f8f8f8;text-decoration:underline"> </span>jobs/<span style="color:#8f5902;font-style:italic">*/workspace*</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-c<span style="color:#f8f8f8;text-decoration:underline"> </span>jobs<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>\<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>aws<span style="color:#f8f8f8;text-decoration:underline"> </span>s3<span style="color:#f8f8f8;text-decoration:underline"> </span>cp<span style="color:#f8f8f8;text-decoration:underline"> </span>${BACKUP_TMP_DIR}/${backup_number}.tar.gz<span style="color:#f8f8f8;text-decoration:underline"> </span>s3<span style="color:#000;font-weight:bold">:</span>//${BACKUP_BUCKET}/${BACKUP_PATH}/${backup_number}.tar.gz<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span>Done<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>restore.sh<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>|<span style="color:#8f5902;font-style:italic">- -</span><span style="color:#8f5902;font-style:italic"> #!/bin/bash -xeu</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>!<span style="color:#f8f8f8;text-decoration:underline"> </span>$<span style="color:#8f5902;font-style:italic"># -eq 1 ]] &amp;&amp; echo &#34;Usage: $0 backup_number&#34; &amp;&amp; exit 1</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_BUCKET}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;BACKUP_BUCKET&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_PATH}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;BACKUP_PATH&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">[[</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-z<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${JENKINS_HOME}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#000;font-weight:bold">]]</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Required &#39;JENKINS_HOME&#39; env not set&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>exit<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1</span>;<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup_number=$<span style="color:#0000cf;font-weight:bold">1</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;Running restore #${backup_number}&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_TMP_DIR=$(mktemp<span style="color:#f8f8f8;text-decoration:underline"> </span>-d)<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>aws<span style="color:#f8f8f8;text-decoration:underline"> </span>s3<span style="color:#f8f8f8;text-decoration:underline"> </span>cp<span style="color:#f8f8f8;text-decoration:underline"> </span>s3<span style="color:#000;font-weight:bold">:</span>//${BACKUP_BUCKET}/${BACKUP_PATH}/${backup_number}.tar.gz<span style="color:#f8f8f8;text-decoration:underline"> </span>${BACKUP_TMP_DIR}/${backup_number}.tar.gz<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>tar<span style="color:#f8f8f8;text-decoration:underline"> </span>-C<span style="color:#f8f8f8;text-decoration:underline"> </span>${JENKINS_HOME}<span style="color:#f8f8f8;text-decoration:underline"> </span>-zxf<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;${BACKUP_TMP_DIR}/${backup_number}.tar.gz&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>echo<span style="color:#f8f8f8;text-decoration:underline"> </span>Done</code></pre></div> -<p>In our example we will use S3 bucket lifecycle policy to keep -the number of backups under control, e.g. Cloud Formation fragment:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml"><span style="color:#f8f8f8;text-decoration:underline"> </span>Type<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>AWS<span style="color:#000;font-weight:bold">::</span>S3<span style="color:#000;font-weight:bold">::</span>Bucket<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Properties<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BucketName<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>my-example-bucket<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>...<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>LifecycleConfiguration<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Rules<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>Id<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BackupCleanup<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Status<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Enabled<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Prefix<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>my-backup-path<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>ExpirationInDays<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">7</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>NoncurrentVersionExpirationInDays<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">14</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>AbortIncompleteMultipartUpload<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>DaysAfterInitiation<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">3</span></code></pre></div> - - - - - Docs: Diagnostics - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/diagnostics/ - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/diagnostics/ - - - - - -<p>Turn on debug in <strong>Jenkins Operator</strong> deployment:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">sed -i <span style="color:#4e9a06">&#39;s|\(args:\).*|\1\ [&#34;--debug&#34;\]|&#39;</span> deploy/operator.yaml -kubectl apply -f deploy/operator.yaml</code></pre></div> -<p>Watch Kubernetes events:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl get events --sort-by<span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;{.lastTimestamp}&#39;</span></code></pre></div> -<p>Verify Jenkins master logs:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl logs -f jenkins-&lt;cr_name&gt;</code></pre></div> -<p>Verify the <code>jenkins-operator</code> logs:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl logs deployment/jenkins-operator</code></pre></div> -<h2 id="troubleshooting">Troubleshooting</h2> - -<p>Delete the Jenkins master pod and wait for the new one to come up:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl delete pod jenkins-&lt;cr_name&gt;</code></pre></div> - - - - - Docs: Schema - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/schema/ - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/schema/ - - - - - -<div class="pageinfo pageinfo-primary"> -<p>This document contains API scheme for <code>jenkins-operator</code> Custom Resource Definition manifest</p> - -</div> - - -<p>Packages:</p> -<ul> -<li> -<a href="#jenkins.io">jenkins.io</a> -</li> -</ul> -<h2 id="jenkins.io">jenkins.io</h2> -<p> -<p>Package v1alpha2 contains the API Schema definitions for the jenkins.io v1alpha2 API group</p> -</p> -Resource Types: -<ul><li> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Jenkins">Jenkins</a> -</li></ul> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Jenkins">Jenkins -</h3> -<p> -<p>Jenkins is the Schema for the jenkins API</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>apiVersion</code></br> -string</td> -<td> -<code> -jenkins.io/v1alpha2 -</code> -</td> -</tr> -<tr> -<td> -<code>kind</code></br> -string -</td> -<td><code>Jenkins</code></td> -</tr> -<tr> -<td> -<code>metadata</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#objectmeta-v1-meta"> -Kubernetes meta/v1.ObjectMeta -</a> -</em> -</td> -<td> -Refer to the Kubernetes API documentation for the fields of the -<code>metadata</code> field. -</td> -</tr> -<tr> -<td> -<code>spec</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsSpec"> -JenkinsSpec -</a> -</em> -</td> -<td> -<p>Spec defines the desired state of the Jenkins</p> -<br/> -<br/> -<table> -<tr> -<td> -<code>master</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsMaster"> -JenkinsMaster -</a> -</em> -</td> -<td> -<p>Master represents Jenkins master pod properties and Jenkins plugins. -Every single change here requires a pod restart.</p> -</td> -</tr> -<tr> -<td> -<code>seedJobs</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob"> -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>SeedJobs defines a list of Jenkins Seed Job configurations -More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines</a></p> -</td> -</tr> -<tr> -<td> -<code>service</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service"> -Service -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Service is the Kubernetes service of the Jenkins master HTTP pod -Defaults to : -port: 8080 -type: ClusterIP</p> -</td> -</tr> -<tr> -<td> -<code>slaveService</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service"> -Service -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Service is the Kubernetes service of the Jenkins slave pods -Defaults to : -port: 50000 -type: ClusterIP</p> -</td> -</tr> -<tr> -<td> -<code>backup</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Backup"> -Backup -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Backup defines the configuration of a Jenkins backup -More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore</a></p> -</td> -</tr> -<tr> -<td> -<code>restore</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Restore"> -Restore -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Backup defines the configuration of a Jenkins backup restore -More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore</a></p> -</td> -</tr> -<tr> -<td> -<code>groovyScripts</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.GroovyScripts"> -GroovyScripts -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>GroovyScripts defines the configuration of Jenkins customization via groovy scripts</p> -</td> -</tr> -<tr> -<td> -<code>configurationAsCode</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigurationAsCode"> -ConfigurationAsCode -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>ConfigurationAsCode defines the configuration of Jenkins customization via the Configuration as Code Jenkins plugin</p> -</td> -</tr> -</table> -</td> -</tr> -<tr> -<td> -<code>status</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsStatus"> -JenkinsStatus -</a> -</em> -</td> -<td> -<p>Status defines the observed state of Jenkins</p> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.AppliedGroovyScript">AppliedGroovyScript -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsStatus">JenkinsStatus</a>) -</p> -<p> -<p>AppliedGroovyScript is the applied groovy script in Jenkins by the operator</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>configurationType</code></br> -<em> -string -</em> -</td> -<td> -<p>ConfigurationType is the name of the configuration type(base-groovy, user-groovy, user-casc)</p> -</td> -</tr> -<tr> -<td> -<code>source</code></br> -<em> -string -</em> -</td> -<td> -<p>Source is the name of source where is located groovy script</p> -</td> -</tr> -<tr> -<td> -<code>name</code></br> -<em> -string -</em> -</td> -<td> -<p>Name is the name of the groovy script</p> -</td> -</tr> -<tr> -<td> -<code>Hash</code></br> -<em> -string -</em> -</td> -<td> -<p>Hash is the hash of the groovy script and secrets which it uses</p> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Backup">Backup -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) -</p> -<p> -<p>Backup defines the configuration of a Jenkins backup</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>containerName</code></br> -<em> -string -</em> -</td> -<td> -<p>ContainerName is the container name responsible for backup operation</p> -</td> -</tr> -<tr> -<td> -<code>action</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Handler"> -Handler -</a> -</em> -</td> -<td> -<p>Action defines the action which performs the backup in the backup container sidecar</p> -</td> -</tr> -<tr> -<td> -<code>interval</code></br> -<em> -uint64 -</em> -</td> -<td> -<p>Interval tells you how often the backup is made in seconds -Defaults to 30.</p> -</td> -</tr> -<tr> -<td> -<code>makeBackupBeforePodDeletion</code></br> -<em> -bool -</em> -</td> -<td> -<p>MakeBackupBeforePodDeletion tells the operator to make a backup before Jenkins master pod deletion</p> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigMapRef">ConfigMapRef -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Customization">Customization</a>) -</p> -<p> -<p>ConfigMapRef is the reference to Kubernetes ConfigMap</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>name</code></br> -<em> -string -</em> -</td> -<td> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigurationAsCode">ConfigurationAsCode -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) -</p> -<p> -<p>ConfigurationAsCode defines configuration of Jenkins customization via the Configuration as Code Jenkins plugin</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>Customization</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Customization"> -Customization -</a> -</em> -</td> -<td> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Container">Container -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsMaster">JenkinsMaster</a>) -</p> -<p> -<p>Container defines the Kubernetes container attributes</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>name</code></br> -<em> -string -</em> -</td> -<td> -<p>Name of the container specified as a DNS_LABEL. -Each container in a pod must have a unique name (DNS_LABEL).</p> -</td> -</tr> -<tr> -<td> -<code>image</code></br> -<em> -string -</em> -</td> -<td> -<p>Docker image name. -More info: <a href="https://kubernetes.io/docs/concepts/containers/images">https://kubernetes.io/docs/concepts/containers/images</a></p> -</td> -</tr> -<tr> -<td> -<code>imagePullPolicy</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#pullpolicy-v1-core"> -Kubernetes core/v1.PullPolicy -</a> -</em> -</td> -<td> -<p>Image pull policy. -One of Always, Never, IfNotPresent. -Defaults to Always.</p> -</td> -</tr> -<tr> -<td> -<code>resources</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#resourcerequirements-v1-core"> -Kubernetes core/v1.ResourceRequirements -</a> -</em> -</td> -<td> -<p>Compute Resources required by this container. -More info: <a href="https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/">https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/</a></p> -</td> -</tr> -<tr> -<td> -<code>command</code></br> -<em> -[]string -</em> -</td> -<td> -<em>(Optional)</em> -<p>Entrypoint array. Not executed within a shell. -The docker image&rsquo;s ENTRYPOINT is used if this is not provided. -Variable references $(VAR_NAME) are expanded using the container&rsquo;s environment. If a variable -cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax -can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, -regardless of whether the variable exists or not. -More info: <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell">https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell</a></p> -</td> -</tr> -<tr> -<td> -<code>args</code></br> -<em> -[]string -</em> -</td> -<td> -<em>(Optional)</em> -<p>Arguments to the entrypoint. -The docker image&rsquo;s CMD is used if this is not provided. -Variable references $(VAR_NAME) are expanded using the container&rsquo;s environment. If a variable -cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax -can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, -regardless of whether the variable exists or not. -More info: <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell">https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell</a></p> -</td> -</tr> -<tr> -<td> -<code>workingDir</code></br> -<em> -string -</em> -</td> -<td> -<em>(Optional)</em> -<p>Container&rsquo;s working directory. -If not specified, the container runtime&rsquo;s default will be used, which -might be configured in the container image.</p> -</td> -</tr> -<tr> -<td> -<code>ports</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#containerport-v1-core"> -[]Kubernetes core/v1.ContainerPort -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>List of ports to expose from the container. Exposing a port here gives -the system additional information about the network connections a -container uses, but is primarily informational. Not specifying a port here -DOES NOT prevent that port from being exposed. Any port which is -listening on the default &ldquo;0.0.0.0&rdquo; address inside a container will be -accessible from the network.</p> -</td> -</tr> -<tr> -<td> -<code>envFrom</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#envfromsource-v1-core"> -[]Kubernetes core/v1.EnvFromSource -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>List of sources to populate environment variables in the container. -The keys defined within a source must be a C_IDENTIFIER. All invalid keys -will be reported as an event when the container is starting. When a key exists in multiple -sources, the value associated with the last source will take precedence. -Values defined by an Env with a duplicate key will take precedence.</p> -</td> -</tr> -<tr> -<td> -<code>env</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#envvar-v1-core"> -[]Kubernetes core/v1.EnvVar -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>List of environment variables to set in the container.</p> -</td> -</tr> -<tr> -<td> -<code>volumeMounts</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#volumemount-v1-core"> -[]Kubernetes core/v1.VolumeMount -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Pod volumes to mount into the container&rsquo;s filesystem.</p> -</td> -</tr> -<tr> -<td> -<code>livenessProbe</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#probe-v1-core"> -Kubernetes core/v1.Probe -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Periodic probe of container liveness. -Container will be restarted if the probe fails.</p> -</td> -</tr> -<tr> -<td> -<code>readinessProbe</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#probe-v1-core"> -Kubernetes core/v1.Probe -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Periodic probe of container service readiness. -Container will be removed from service endpoints if the probe fails.</p> -</td> -</tr> -<tr> -<td> -<code>lifecycle</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#lifecycle-v1-core"> -Kubernetes core/v1.Lifecycle -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Actions that the management system should take in response to container lifecycle events.</p> -</td> -</tr> -<tr> -<td> -<code>securityContext</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#securitycontext-v1-core"> -Kubernetes core/v1.SecurityContext -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Security options the pod should run with. -More info: <a href="https://kubernetes.io/docs/concepts/policy/security-context/">https://kubernetes.io/docs/concepts/policy/security-context/</a> -More info: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/">https://kubernetes.io/docs/tasks/configure-pod-container/security-context/</a></p> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Customization">Customization -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.ConfigurationAsCode">ConfigurationAsCode</a>, -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.GroovyScripts">GroovyScripts</a>) -</p> -<p> -<p>Customization defines configuration of Jenkins customization</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>secret</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretRef"> -SecretRef -</a> -</em> -</td> -<td> -</td> -</tr> -<tr> -<td> -<code>configurations</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigMapRef"> -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigMapRef -</a> -</em> -</td> -<td> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.GroovyScripts">GroovyScripts -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) -</p> -<p> -<p>GroovyScripts defines configuration of Jenkins customization via groovy scripts</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>Customization</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Customization"> -Customization -</a> -</em> -</td> -<td> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Handler">Handler -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Backup">Backup</a>, -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Restore">Restore</a>) -</p> -<p> -<p>Handler defines a specific action that should be taken</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>exec</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#execaction-v1-core"> -Kubernetes core/v1.ExecAction -</a> -</em> -</td> -<td> -<p>Exec specifies the action to take.</p> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsCredentialType">JenkinsCredentialType -(<code>string</code> alias)</p></h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.SeedJob">SeedJob</a>) -</p> -<p> -<p>JenkinsCredentialType defines the type of Jenkins credential used in the seed job mechanism</p> -</p> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsMaster">JenkinsMaster -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) -</p> -<p> -<p>JenkinsMaster defines the Jenkins master pod attributes and plugins, -every single change requires a Jenkins master pod restart</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>masterAnnotations</code></br> -<em> -map[string]string -</em> -</td> -<td> -<em>(Optional)</em> -<p>Annotations is an unstructured key value map stored with a resource that may be -set by external tools to store and retrieve arbitrary metadata. They are not -queryable and should be preserved when modifying objects. -More info: <a href="http://kubernetes.io/docs/user-guide/annotations">http://kubernetes.io/docs/user-guide/annotations</a></p> -</td> -</tr> -<tr> -<td> -<code>nodeSelector</code></br> -<em> -map[string]string -</em> -</td> -<td> -<em>(Optional)</em> -<p>NodeSelector is a selector which must be true for the pod to fit on a node. -Selector which must match a node&rsquo;s labels for the pod to be scheduled on that node. -More info: <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/">https://kubernetes.io/docs/concepts/configuration/assign-pod-node/</a></p> -</td> -</tr> -<tr> -<td> -<code>securityContext</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#podsecuritycontext-v1-core"> -Kubernetes core/v1.PodSecurityContext -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>SecurityContext that applies to all the containers of the Jenkins -Master. As per kubernetes specification, it can be overridden -for each container individually. -Defaults to: -runAsUser: 1000 -fsGroup: 1000</p> -</td> -</tr> -<tr> -<td> -<code>containers</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Container"> -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Container -</a> -</em> -</td> -<td> -<p>List of containers belonging to the pod. -Containers cannot currently be added or removed. -There must be at least one container in a Pod. -Defaults to: -- image: jenkins/jenkins:lts -imagePullPolicy: Always -livenessProbe: -failureThreshold: 12 -httpGet: -path: /login -port: http -scheme: HTTP -initialDelaySeconds: 80 -periodSeconds: 10 -successThreshold: 1 -timeoutSeconds: 5 -name: jenkins-master -readinessProbe: -failureThreshold: 3 -httpGet: -path: /login -port: http -scheme: HTTP -initialDelaySeconds: 30 -periodSeconds: 10 -successThreshold: 1 -timeoutSeconds: 1 -resources: -limits: -cpu: 1500m -memory: 3Gi -requests: -cpu: &ldquo;1&rdquo; -memory: 600Mi</p> -</td> -</tr> -<tr> -<td> -<code>imagePullSecrets</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#localobjectreference-v1-core"> -[]Kubernetes core/v1.LocalObjectReference -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. -If specified, these secrets will be passed to individual puller implementations for them to use. For example, -in the case of docker, only DockerConfig type secrets are honored. -More info: <a href="https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod">https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod</a></p> -</td> -</tr> -<tr> -<td> -<code>volumes</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#volume-v1-core"> -[]Kubernetes core/v1.Volume -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>List of volumes that can be mounted by containers belonging to the pod. -More info: <a href="https://kubernetes.io/docs/concepts/storage/volumes">https://kubernetes.io/docs/concepts/storage/volumes</a></p> -</td> -</tr> -<tr> -<td> -<code>basePlugins</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin"> -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin -</a> -</em> -</td> -<td> -<p>BasePlugins contains plugins required by operator -Defaults to : -- name: kubernetes -version: 1.15.7 -- name: workflow-job -version: &ldquo;2.32&rdquo; -- name: workflow-aggregator -version: &ldquo;2.6&rdquo; -- name: git -version: 3.10.0 -- name: job-dsl -version: &ldquo;1.74&rdquo; -- name: configuration-as-code -version: &ldquo;1.19&rdquo; -- name: configuration-as-code-support -version: &ldquo;1.19&rdquo; -- name: kubernetes-credentials-provider -version: 0.12.1</p> -</td> -</tr> -<tr> -<td> -<code>plugins</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin"> -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Plugins contains plugins required by user</p> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsSpec">JenkinsSpec -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Jenkins">Jenkins</a>) -</p> -<p> -<p>JenkinsSpec defines the desired state of the Jenkins</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>master</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsMaster"> -JenkinsMaster -</a> -</em> -</td> -<td> -<p>Master represents Jenkins master pod properties and Jenkins plugins. -Every single change here requires a pod restart.</p> -</td> -</tr> -<tr> -<td> -<code>seedJobs</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob"> -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>SeedJobs defines list of Jenkins Seed Job configurations -More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines</a></p> -</td> -</tr> -<tr> -<td> -<code>service</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service"> -Service -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Service is Kubernetes service of Jenkins master HTTP pod -Defaults to : -port: 8080 -type: ClusterIP</p> -</td> -</tr> -<tr> -<td> -<code>slaveService</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service"> -Service -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Service is Kubernetes service of Jenkins slave pods -Defaults to : -port: 50000 -type: ClusterIP</p> -</td> -</tr> -<tr> -<td> -<code>backup</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Backup"> -Backup -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Backup defines configuration of Jenkins backup -More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore</a></p> -</td> -</tr> -<tr> -<td> -<code>restore</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Restore"> -Restore -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Backup defines configuration of Jenkins backup restore -More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore</a></p> -</td> -</tr> -<tr> -<td> -<code>groovyScripts</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.GroovyScripts"> -GroovyScripts -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>GroovyScripts defines configuration of Jenkins customization via groovy scripts</p> -</td> -</tr> -<tr> -<td> -<code>configurationAsCode</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigurationAsCode"> -ConfigurationAsCode -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>ConfigurationAsCode defines configuration of Jenkins customization via Configuration as Code Jenkins plugin</p> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsStatus">JenkinsStatus -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Jenkins">Jenkins</a>) -</p> -<p> -<p>JenkinsStatus defines the observed state of Jenkins</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>operatorVersion</code></br> -<em> -string -</em> -</td> -<td> -<em>(Optional)</em> -<p>OperatorVersion is the operator version which manages this CR</p> -</td> -</tr> -<tr> -<td> -<code>provisionStartTime</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#time-v1-meta"> -Kubernetes meta/v1.Time -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>ProvisionStartTime is a time when Jenkins master pod has been created</p> -</td> -</tr> -<tr> -<td> -<code>baseConfigurationCompletedTime</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#time-v1-meta"> -Kubernetes meta/v1.Time -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>BaseConfigurationCompletedTime is a time when Jenkins base configuration phase has been completed</p> -</td> -</tr> -<tr> -<td> -<code>userConfigurationCompletedTime</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#time-v1-meta"> -Kubernetes meta/v1.Time -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>UserConfigurationCompletedTime is a time when Jenkins user configuration phase has been completed</p> -</td> -</tr> -<tr> -<td> -<code>restoredBackup</code></br> -<em> -uint64 -</em> -</td> -<td> -<em>(Optional)</em> -<p>RestoredBackup is the restored backup number after Jenkins master pod restart</p> -</td> -</tr> -<tr> -<td> -<code>lastBackup</code></br> -<em> -uint64 -</em> -</td> -<td> -<em>(Optional)</em> -<p>LastBackup is the latest backup number</p> -</td> -</tr> -<tr> -<td> -<code>pendingBackup</code></br> -<em> -uint64 -</em> -</td> -<td> -<em>(Optional)</em> -<p>PendingBackup is the pending backup number</p> -</td> -</tr> -<tr> -<td> -<code>backupDoneBeforePodDeletion</code></br> -<em> -bool -</em> -</td> -<td> -<em>(Optional)</em> -<p>BackupDoneBeforePodDeletion tells if backup before pod deletion has been made</p> -</td> -</tr> -<tr> -<td> -<code>userAndPasswordHash</code></br> -<em> -string -</em> -</td> -<td> -<em>(Optional)</em> -<p>UserAndPasswordHash is a SHA256 hash made from the username and password</p> -</td> -</tr> -<tr> -<td> -<code>createdSeedJobs</code></br> -<em> -[]string -</em> -</td> -<td> -<em>(Optional)</em> -<p>CreatedSeedJobs contains list of seed job ids already created in Jenkins</p> -</td> -</tr> -<tr> -<td> -<code>appliedGroovyScripts</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.AppliedGroovyScript"> -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.AppliedGroovyScript -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>AppliedGroovyScripts is a list with all applied groovy scripts in Jenkins by the operator</p> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Mailgun">Mailgun -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Notification">Notification</a>) -</p> -<p> -<p>Mailgun is handler for Mailgun email service notification channel</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>domain</code></br> -<em> -string -</em> -</td> -<td> -</td> -</tr> -<tr> -<td> -<code>apiKeySecretKeySelector</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector"> -SecretKeySelector -</a> -</em> -</td> -<td> -</td> -</tr> -<tr> -<td> -<code>recipient</code></br> -<em> -string -</em> -</td> -<td> -</td> -</tr> -<tr> -<td> -<code>from</code></br> -<em> -string -</em> -</td> -<td> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.MicrosoftTeams">MicrosoftTeams -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Notification">Notification</a>) -</p> -<p> -<p>MicrosoftTeams is handler for Microsoft MicrosoftTeams notification channel</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>webHookURLSecretKeySelector</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector"> -SecretKeySelector -</a> -</em> -</td> -<td> -<p>The web hook URL to MicrosoftTeams App</p> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Notification">Notification -</h3> -<p> -<p>Notification is a service configuration used to send notifications about Jenkins status</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>loggingLevel</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.NotificationLogLevel"> -NotificationLogLevel -</a> -</em> -</td> -<td> -</td> -</tr> -<tr> -<td> -<code>verbose</code></br> -<em> -bool -</em> -</td> -<td> -</td> -</tr> -<tr> -<td> -<code>name</code></br> -<em> -string -</em> -</td> -<td> -</td> -</tr> -<tr> -<td> -<code>slack</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Slack"> -github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Slack -</a> -</em> -</td> -<td> -</td> -</tr> -<tr> -<td> -<code>teams</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.MicrosoftTeams"> -github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.MicrosoftTeams -</a> -</em> -</td> -<td> -</td> -</tr> -<tr> -<td> -<code>mailgun</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Mailgun"> -github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Mailgun -</a> -</em> -</td> -<td> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.NotificationLogLevel">NotificationLogLevel -(<code>string</code> alias)</p></h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Notification">Notification</a>) -</p> -<p> -<p>NotificationLogLevel defines logging level of Notification</p> -</p> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin">Plugin -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsMaster">JenkinsMaster</a>) -</p> -<p> -<p>Plugin defines Jenkins plugin</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>name</code></br> -<em> -string -</em> -</td> -<td> -<p>Name is the name of Jenkins plugin</p> -</td> -</tr> -<tr> -<td> -<code>version</code></br> -<em> -string -</em> -</td> -<td> -<p>Version is the version of Jenkins plugin</p> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Restore">Restore -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) -</p> -<p> -<p>Restore defines configuration of Jenkins backup restore operation</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>containerName</code></br> -<em> -string -</em> -</td> -<td> -<p>ContainerName is the container name responsible for restore backup operation</p> -</td> -</tr> -<tr> -<td> -<code>action</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Handler"> -Handler -</a> -</em> -</td> -<td> -<p>Action defines action which performs restore backup in restore container sidecar</p> -</td> -</tr> -<tr> -<td> -<code>recoveryOnce</code></br> -<em> -uint64 -</em> -</td> -<td> -<em>(Optional)</em> -<p>RecoveryOnce if want to restore specific backup set this field and then Jenkins will be restarted and desired backup will be restored</p> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector">SecretKeySelector -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Mailgun">Mailgun</a>, -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.MicrosoftTeams">MicrosoftTeams</a>, -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Slack">Slack</a>) -</p> -<p> -<p>SecretKeySelector selects a key of a Secret.</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>secret</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#localobjectreference-v1-core"> -Kubernetes core/v1.LocalObjectReference -</a> -</em> -</td> -<td> -<p>The name of the secret in the pod&rsquo;s namespace to select from.</p> -</td> -</tr> -<tr> -<td> -<code>key</code></br> -<em> -string -</em> -</td> -<td> -<p>The key of the secret to select from. Must be a valid secret key.</p> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretRef">SecretRef -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Customization">Customization</a>) -</p> -<p> -<p>SecretRef is reference to Kubernetes secret</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>name</code></br> -<em> -string -</em> -</td> -<td> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob">SeedJob -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) -</p> -<p> -<p>SeedJob defines configuration for seed job -More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines</a></p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>id</code></br> -<em> -string -</em> -</td> -<td> -<p>ID is the unique seed job name</p> -</td> -</tr> -<tr> -<td> -<code>credentialID</code></br> -<em> -string -</em> -</td> -<td> -<p>CredentialID is the Kubernetes secret name which stores repository access credentials</p> -</td> -</tr> -<tr> -<td> -<code>description</code></br> -<em> -string -</em> -</td> -<td> -<em>(Optional)</em> -<p>Description is the description of the seed job</p> -</td> -</tr> -<tr> -<td> -<code>targets</code></br> -<em> -string -</em> -</td> -<td> -<p>Targets is the repository path where the seed job definitions are</p> -</td> -</tr> -<tr> -<td> -<code>repositoryBranch</code></br> -<em> -string -</em> -</td> -<td> -<p>RepositoryBranch is the repository branch where the seed job definitions are</p> -</td> -</tr> -<tr> -<td> -<code>repositoryUrl</code></br> -<em> -string -</em> -</td> -<td> -<p>RepositoryURL is the repository access URL. Can be SSH or HTTPS.</p> -</td> -</tr> -<tr> -<td> -<code>credentialType</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsCredentialType"> -JenkinsCredentialType -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>JenkinsCredentialType is the <a href="https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/">https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/</a> credential type</p> -</td> -</tr> -<tr> -<td> -<code>githubPushTrigger</code></br> -<em> -bool -</em> -</td> -<td> -<em>(Optional)</em> -<p>GitHubPushTrigger is used for GitHub web hooks</p> -</td> -</tr> -<tr> -<td> -<code>buildPeriodically</code></br> -<em> -string -</em> -</td> -<td> -<em>(Optional)</em> -<p>BuildPeriodically is setting for scheduled trigger</p> -</td> -</tr> -<tr> -<td> -<code>pollSCM</code></br> -<em> -string -</em> -</td> -<td> -<em>(Optional)</em> -<p>PollSCM is setting for polling changes in SCM</p> -</td> -</tr> -<tr> -<td> -<code>ignoreMissingFiles</code></br> -<em> -bool -</em> -</td> -<td> -<em>(Optional)</em> -<p>IgnoreMissingFiles is setting for Job DSL API plugin to ignore files that miss</p> -</td> -</tr> -<tr> -<td> -<code>additionalClasspath</code></br> -<em> -string -</em> -</td> -<td> -<em>(Optional)</em> -<p>AdditionalClasspath is setting for Job DSL API plugin to set Additional Classpath</p> -</td> -</tr> -<tr> -<td> -<code>failOnMissingPlugin</code></br> -<em> -bool -</em> -</td> -<td> -<em>(Optional)</em> -<p>FailOnMissingPlugin is setting for Job DSL API plugin that fails job if required plugin is missing</p> -</td> -</tr> -<tr> -<td> -<code>unstableOnDeprecation</code></br> -<em> -bool -</em> -</td> -<td> -<em>(Optional)</em> -<p>UnstableOnDeprecation is setting for Job DSL API plugin that sets build status as unstable if build using deprecated features</p> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service">Service -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) -</p> -<p> -<p>Service defines Kubernetes service attributes</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>annotations</code></br> -<em> -map[string]string -</em> -</td> -<td> -<em>(Optional)</em> -<p>Annotations is an unstructured key value map stored with a resource that may be -set by external tools to store and retrieve arbitrary metadata. They are not -queryable and should be preserved when modifying objects. -More info: <a href="http://kubernetes.io/docs/user-guide/annotations">http://kubernetes.io/docs/user-guide/annotations</a></p> -</td> -</tr> -<tr> -<td> -<code>labels</code></br> -<em> -map[string]string -</em> -</td> -<td> -<p>Route service traffic to pods with label keys and values matching this -selector. If empty or not present, the service is assumed to have an -external process managing its endpoints, which Kubernetes will not -modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. -Ignored if type is ExternalName. -More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/">https://kubernetes.io/docs/concepts/services-networking/service/</a></p> -</td> -</tr> -<tr> -<td> -<code>type</code></br> -<em> -<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#servicetype-v1-core"> -Kubernetes core/v1.ServiceType -</a> -</em> -</td> -<td> -<em>(Optional)</em> -<p>Type determines how the Service is exposed. Defaults to ClusterIP. Valid -options are ExternalName, ClusterIP, NodePort, and LoadBalancer. -&ldquo;ExternalName&rdquo; maps to the specified externalName. -&ldquo;ClusterIP&rdquo; allocates a cluster-internal IP address for load-balancing to -endpoints. Endpoints are determined by the selector or if that is not -specified, by manual construction of an Endpoints object. If clusterIP is -&ldquo;None&rdquo;, no virtual IP is allocated and the endpoints are published as a -set of endpoints rather than a stable IP. -&ldquo;NodePort&rdquo; builds on ClusterIP and allocates a port on every node which -routes to the clusterIP. -&ldquo;LoadBalancer&rdquo; builds on NodePort and creates an -external load-balancer (if supported in the current cloud) which routes -to the clusterIP. -More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types">https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services&mdash;service-types</a></p> -</td> -</tr> -<tr> -<td> -<code>port</code></br> -<em> -int32 -</em> -</td> -<td> -<p>The port that is exposed by this service. -More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies">https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies</a></p> -</td> -</tr> -<tr> -<td> -<code>nodePort</code></br> -<em> -int32 -</em> -</td> -<td> -<em>(Optional)</em> -<p>The port on each node on which this service is exposed when type=NodePort or LoadBalancer. -Usually assigned by the system. If specified, it will be allocated to the service -if unused, or else creation of the service will fail. -Default is to auto-allocate a port if the ServiceType of this Service requires one. -More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport">https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport</a></p> -</td> -</tr> -<tr> -<td> -<code>loadBalancerSourceRanges</code></br> -<em> -[]string -</em> -</td> -<td> -<em>(Optional)</em> -<p>If specified and supported by the platform, this will restrict traffic through the cloud-provider -the load-balancer will be restricted to the specified client IPs. This field will be ignored if the -cloud-provider does not support the feature.&rdquo; -More info: <a href="https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/">https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/</a></p> -</td> -</tr> -<tr> -<td> -<code>loadBalancerIP</code></br> -<em> -string -</em> -</td> -<td> -<em>(Optional)</em> -<p>Only applies to Service Type: LoadBalancer -LoadBalancer will get created with the IP specified in this field. -This feature depends on whether the underlying cloud-provider supports specifying -the loadBalancerIP when a load balancer is created. -This field will be ignored if the cloud-provider does not support the feature.</p> -</td> -</tr> -</tbody> -</table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Slack">Slack -</h3> -<p> -(<em>Appears on:</em> -<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Notification">Notification</a>) -</p> -<p> -<p>Slack is handler for Slack notification channel</p> -</p> -<table> -<thead> -<tr> -<th>Field</th> -<th>Description</th> -</tr> -</thead> -<tbody> -<tr> -<td> -<code>webHookURLSecretKeySelector</code></br> -<em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector"> -SecretKeySelector -</a> -</em> -</td> -<td> -<p>The web hook URL to Slack App</p> -</td> -</tr> -</tbody> -</table> -<hr/> -<p><em> -Generated with <code>gen-crd-api-reference-docs</code> -on git commit <code>f4c4235</code>. -</em></p> - - - - - - Docs: Developer Guide - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/developer-guide/ - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/future/developer-guide/ - - - - - - - -<div class="pageinfo pageinfo-primary"> -<p>This document explains how to setup your development environment.</p> - -</div> - - -<h2 id="prerequisites">Prerequisites</h2> - -<ul> -<li><a href="https://github.com/operator-framework/operator-sdk" target="_blank">operator_sdk</a> version v0.8.1</li> -<li><a href="https://git-scm.com/downloads" target="_blank">git</a></li> -<li><a href="https://golang.org/dl/" target="_blank">go</a> version v1.12+</li> -<li><a href="install_dev_tools.md" target="_blank">goimports, golint, checkmake and staticcheck</a></li> -<li><a href="https://kubernetes.io/docs/tasks/tools/install-minikube/" target="_blank">minikube</a> version v1.1.0+ (preferred Hypervisor - <a href="https://www.virtualbox.org/wiki/Downloads" target="_blank">virtualbox</a>)</li> -<li><a href="https://docs.docker.com/install/" target="_blank">docker</a> version 17.03+</li> -</ul> - -<h2 id="clone-repository-and-download-dependencies">Clone repository and download dependencies</h2> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">mkdir -p <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci -<span style="color:#204a87">cd</span> <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci/ -git clone git@github.com:jenkinsci/kubernetes-operator.git -<span style="color:#204a87">cd</span> kubernetes-operator -make go-dependencies</code></pre></div> -<h2 id="build-and-run-with-a-minikube">Build and run with a minikube</h2> - -<p>Build and run <strong>Jenkins Operator</strong> locally:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build minikube-run <span style="color:#000">OPERATOR_EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--jenkins-api-hostname=$(eval minikube ip) --jenkins-api-use-nodeport=true&#39;</span></code></pre></div> -<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml -kubectl get jenkins -o yaml -kubectl get po</code></pre></div> -<h2 id="build-and-run-with-a-remote-kubernetes-cluster">Build and run with a remote Kubernetes cluster</h2> - -<p>You can also run the controller locally and make it listen to a remote Kubernetes server.</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make run <span style="color:#000">NAMESPACE</span><span style="color:#ce5c00;font-weight:bold">=</span>default <span style="color:#000">KUBECTL_CONTEXT</span><span style="color:#ce5c00;font-weight:bold">=</span>remote-k8s <span style="color:#000">OPERATOR_EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--kubeconfig ~/.kube/config&#39;</span></code></pre></div> -<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml -kubectl --context remote-k8s --namespace default get jenkins -o yaml -kubectl --context remote-k8s --namespace default get po</code></pre></div> -<h2 id="testing">Testing</h2> - -<p>Run unit tests:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make test</code></pre></div> -<h3 id="running-e2e-tests-on-linux">Running E2E tests on Linux</h3> - -<p>Run e2e tests with minikube:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make minikube-start -<span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> -make build e2e <span style="color:#000">config</span><span style="color:#ce5c00;font-weight:bold">=</span>config.minikube.env <span style="color:#000">CONTAINER_RUNTIME</span><span style="color:#ce5c00;font-weight:bold">=</span>podman</code></pre></div> -<p><code>config.minikube.env</code> is the E2E test profile which provides all connection info to operator to run on minikube.</p> - -<p>Run the specific e2e test:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build e2e <span style="color:#000">E2E_TEST_SELECTOR</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;^TestConfiguration$&#39;</span> <span style="color:#000">config</span><span style="color:#ce5c00;font-weight:bold">=</span>config.minikube.env <span style="color:#000">CONTAINER_RUNTIME</span><span style="color:#ce5c00;font-weight:bold">=</span>podman</code></pre></div> -<p>If you want to run E2E tests on CRC (Code Ready Containers by OpenShift), you should use <code>config.crc.env</code> profile instead of <code>config.minikube.env</code>. -If you have some trouble with <code>podman</code> (for example building) then check <a href="#using-docker-instead-of-podman">how to use docker instead of podman</a>.</p> - -<h3 id="running-e2e-tests-on-macos">Running E2E tests on macOS</h3> - -<p>At first, you need to start minikube:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make minikube-start -$ <span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> </code></pre></div> -<p>Build a Docker image inside the provided Linux container by:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make indocker</code></pre></div> -<p>Build <strong>Jenkins Operator</strong> inside a container using:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make build</code></pre></div> -<p>Then exit the container and run:</p> - -<pre><code>make e2e config=config.minikube.env -</code></pre> - -<p>or using <code>crc</code> as cluster software:</p> - -<pre><code>make e2e config=config.crc.env -</code></pre> - -<h3 id="using-docker-instead-of-podman">Using Docker instead of podman</h3> - -<p>If you have trouble with building image using the <code>podman</code>, you can set additional flag <code>IMAGE_PULL_MODE</code> to pull image from the organization.</p> - -<p>At first, you need to edit <code>config.base.env</code> and change the <code>DOCKER_ORGANIZATION</code> to your <a href="https://hub.docker.com/" target="_blank">Docker Hub</a> account/organization. -After this change the <code>IMAGE_PULL_MODE</code> to <code>remote</code>. It will setup the <code>Makefile</code> goal to pull Docker image from registry. -Then you need to pull image from your repository:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make container-runtime-build container-runtime-snapshot-push</code></pre></div> -<p>When image will be uploaded to repository, you can now write this command to run E2E tests:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make e2e <span style="color:#000">E2E_TEST_SELECTOR</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;^TestConfiguration$&#39;</span> <span style="color:#000">config</span><span style="color:#ce5c00;font-weight:bold">=</span>config.crc.env</code></pre></div> -<h2 id="tips-tricks">Tips &amp; Tricks</h2> - -<h3 id="building-docker-image-on-minikube-for-e2e-tests">Building docker image on minikube (for e2e tests)</h3> - -<p>To be able to work with the docker daemon on <code>minikube</code> machine run the following command before building an image:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span></code></pre></div> -<h3 id="when-pkg-apis-jenkinsio-jenkins-types-go-has-changed">When <code>pkg/apis/jenkinsio/*/jenkins_types.go</code> has changed</h3> - -<p>Run:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make deepcopy-gen</code></pre></div> -<h3 id="getting-the-jenkins-url-and-basic-credentials">Getting the Jenkins URL and basic credentials</h3> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">minikube service jenkins-operator-http-&lt;cr_name&gt; --url -kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.user}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d -kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.password}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d</code></pre></div> -<h1 id="tools">Tools</h1> - -<h2 id="configure-environment-variables">Configure environment variables</h2> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">export</span> <span style="color:#000">GOPATH</span><span style="color:#ce5c00;font-weight:bold">=</span>/home/go <span style="color:#8f5902;font-style:italic"># example value</span> -<span style="color:#204a87">export</span> <span style="color:#000">GOROOT</span><span style="color:#ce5c00;font-weight:bold">=</span>/usr/lib/go-1.12 <span style="color:#8f5902;font-style:italic"># example value</span> -<span style="color:#204a87">export</span> <span style="color:#000">PATH</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#000">$GOPATH</span>/bin:<span style="color:#000">$PATH</span></code></pre></div> -<h2 id="goimports">goimports</h2> - -<pre><code>go get golang.org/x/tools/cmd/goimports -cd $GOPATH/src/golang.org/x/tools/cmd/goimports -go build -go install -</code></pre> - -<h2 id="golint">golint</h2> - -<pre><code>go get -u golang.org/x/lint/golint -cd $GOPATH/src/golang.org/x/lint/golint -go build -go install -</code></pre> - -<h2 id="checkmake">checkmake</h2> - -<pre><code>go get github.com/mrtazz/checkmake -cd $GOPATH/src/github.com/mrtazz/checkmake -go build -go install -</code></pre> - -<h2 id="staticcheck">staticcheck</h2> - -<pre><code>mkdir -p $GOPATH/src/github.com/dominikh/ -cd $GOPATH/src/github.com/dominikh/ -git clone https://github.com/dominikh/go-tools.git -cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck -go build -go install -</code></pre> - - - - - - \ No newline at end of file diff --git a/docs/docs/getting-started/future/schema/index.html b/docs/docs/getting-started/future/schema/index.html deleted file mode 100644 index ff41940f..00000000 --- a/docs/docs/getting-started/future/schema/index.html +++ /dev/null @@ -1,2569 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -Schema | Jenkins Operator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Schema | Jenkins Operator - - -
    - - - -
    -
    -
    -
    -
    - - - - - -
    - - - - -
    - - - - -
    -
    - - - - - - - - - - - -
    -
    - - - -
    -

    Schema

    -
    API Schema definitions for Jenkins CRD
    - - -
    -

    This document contains API scheme for jenkins-operator Custom Resource Definition manifest

    - -
    - - -

    Packages:

    - -

    jenkins.io

    -

    -

    Package v1alpha2 contains the API Schema definitions for the jenkins.io v1alpha2 API group

    -

    -Resource Types: - -

    Jenkins -

    -

    -

    Jenkins is the Schema for the jenkins API

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -apiVersion
    -string
    - -jenkins.io/v1alpha2 - -
    -kind
    -string -
    Jenkins
    -metadata
    - - -Kubernetes meta/v1.ObjectMeta - - -
    -Refer to the Kubernetes API documentation for the fields of the -metadata field. -
    -spec
    - - -JenkinsSpec - - -
    -

    Spec defines the desired state of the Jenkins

    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -master
    - - -JenkinsMaster - - -
    -

    Master represents Jenkins master pod properties and Jenkins plugins. -Every single change here requires a pod restart.

    -
    -seedJobs
    - - -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob - - -
    -(Optional) -

    SeedJobs defines a list of Jenkins Seed Job configurations -More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines

    -
    -service
    - - -Service - - -
    -(Optional) -

    Service is the Kubernetes service of the Jenkins master HTTP pod -Defaults to : -port: 8080 -type: ClusterIP

    -
    -slaveService
    - - -Service - - -
    -(Optional) -

    Service is the Kubernetes service of the Jenkins slave pods -Defaults to : -port: 50000 -type: ClusterIP

    -
    -backup
    - - -Backup - - -
    -(Optional) -

    Backup defines the configuration of a Jenkins backup -More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

    -
    -restore
    - - -Restore - - -
    -(Optional) -

    Backup defines the configuration of a Jenkins backup restore -More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

    -
    -groovyScripts
    - - -GroovyScripts - - -
    -(Optional) -

    GroovyScripts defines the configuration of Jenkins customization via groovy scripts

    -
    -configurationAsCode
    - - -ConfigurationAsCode - - -
    -(Optional) -

    ConfigurationAsCode defines the configuration of Jenkins customization via the Configuration as Code Jenkins plugin

    -
    -
    -status
    - - -JenkinsStatus - - -
    -

    Status defines the observed state of Jenkins

    -
    -

    AppliedGroovyScript -

    -

    -(Appears on: -JenkinsStatus) -

    -

    -

    AppliedGroovyScript is the applied groovy script in Jenkins by the operator

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -configurationType
    - -string - -
    -

    ConfigurationType is the name of the configuration type(base-groovy, user-groovy, user-casc)

    -
    -source
    - -string - -
    -

    Source is the name of source where is located groovy script

    -
    -name
    - -string - -
    -

    Name is the name of the groovy script

    -
    -Hash
    - -string - -
    -

    Hash is the hash of the groovy script and secrets which it uses

    -
    -

    Backup -

    -

    -(Appears on: -JenkinsSpec) -

    -

    -

    Backup defines the configuration of a Jenkins backup

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -containerName
    - -string - -
    -

    ContainerName is the container name responsible for backup operation

    -
    -action
    - - -Handler - - -
    -

    Action defines the action which performs the backup in the backup container sidecar

    -
    -interval
    - -uint64 - -
    -

    Interval tells you how often the backup is made in seconds -Defaults to 30.

    -
    -makeBackupBeforePodDeletion
    - -bool - -
    -

    MakeBackupBeforePodDeletion tells the operator to make a backup before Jenkins master pod deletion

    -
    -

    ConfigMapRef -

    -

    -(Appears on: -Customization) -

    -

    -

    ConfigMapRef is the reference to Kubernetes ConfigMap

    -

    - - - - - - - - - - - - - -
    FieldDescription
    -name
    - -string - -
    -
    -

    ConfigurationAsCode -

    -

    -(Appears on: -JenkinsSpec) -

    -

    -

    ConfigurationAsCode defines configuration of Jenkins customization via the Configuration as Code Jenkins plugin

    -

    - - - - - - - - - - - - - -
    FieldDescription
    -Customization
    - - -Customization - - -
    -
    -

    Container -

    -

    -(Appears on: -JenkinsMaster) -

    -

    -

    Container defines the Kubernetes container attributes

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -name
    - -string - -
    -

    Name of the container specified as a DNS_LABEL. -Each container in a pod must have a unique name (DNS_LABEL).

    -
    -image
    - -string - -
    -

    Docker image name. -More info: https://kubernetes.io/docs/concepts/containers/images

    -
    -imagePullPolicy
    - - -Kubernetes core/v1.PullPolicy - - -
    -

    Image pull policy. -One of Always, Never, IfNotPresent. -Defaults to Always.

    -
    -resources
    - - -Kubernetes core/v1.ResourceRequirements - - -
    -

    Compute Resources required by this container. -More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/

    -
    -command
    - -[]string - -
    -(Optional) -

    Entrypoint array. Not executed within a shell. -The docker image’s ENTRYPOINT is used if this is not provided. -Variable references $(VAR_NAME) are expanded using the container’s environment. If a variable -cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax -can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, -regardless of whether the variable exists or not. -More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell

    -
    -args
    - -[]string - -
    -(Optional) -

    Arguments to the entrypoint. -The docker image’s CMD is used if this is not provided. -Variable references $(VAR_NAME) are expanded using the container’s environment. If a variable -cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax -can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, -regardless of whether the variable exists or not. -More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell

    -
    -workingDir
    - -string - -
    -(Optional) -

    Container’s working directory. -If not specified, the container runtime’s default will be used, which -might be configured in the container image.

    -
    -ports
    - - -[]Kubernetes core/v1.ContainerPort - - -
    -(Optional) -

    List of ports to expose from the container. Exposing a port here gives -the system additional information about the network connections a -container uses, but is primarily informational. Not specifying a port here -DOES NOT prevent that port from being exposed. Any port which is -listening on the default “0.0.0.0” address inside a container will be -accessible from the network.

    -
    -envFrom
    - - -[]Kubernetes core/v1.EnvFromSource - - -
    -(Optional) -

    List of sources to populate environment variables in the container. -The keys defined within a source must be a C_IDENTIFIER. All invalid keys -will be reported as an event when the container is starting. When a key exists in multiple -sources, the value associated with the last source will take precedence. -Values defined by an Env with a duplicate key will take precedence.

    -
    -env
    - - -[]Kubernetes core/v1.EnvVar - - -
    -(Optional) -

    List of environment variables to set in the container.

    -
    -volumeMounts
    - - -[]Kubernetes core/v1.VolumeMount - - -
    -(Optional) -

    Pod volumes to mount into the container’s filesystem.

    -
    -livenessProbe
    - - -Kubernetes core/v1.Probe - - -
    -(Optional) -

    Periodic probe of container liveness. -Container will be restarted if the probe fails.

    -
    -readinessProbe
    - - -Kubernetes core/v1.Probe - - -
    -(Optional) -

    Periodic probe of container service readiness. -Container will be removed from service endpoints if the probe fails.

    -
    -lifecycle
    - - -Kubernetes core/v1.Lifecycle - - -
    -(Optional) -

    Actions that the management system should take in response to container lifecycle events.

    -
    -securityContext
    - - -Kubernetes core/v1.SecurityContext - - -
    -(Optional) -

    Security options the pod should run with. -More info: https://kubernetes.io/docs/concepts/policy/security-context/ -More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/

    -
    -

    Customization -

    -

    -(Appears on: -ConfigurationAsCode, -GroovyScripts) -

    -

    -

    Customization defines configuration of Jenkins customization

    -

    - - - - - - - - - - - - - - - - - -
    FieldDescription
    -secret
    - - -SecretRef - - -
    -
    -configurations
    - - -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigMapRef - - -
    -
    -

    GroovyScripts -

    -

    -(Appears on: -JenkinsSpec) -

    -

    -

    GroovyScripts defines configuration of Jenkins customization via groovy scripts

    -

    - - - - - - - - - - - - - -
    FieldDescription
    -Customization
    - - -Customization - - -
    -
    -

    Handler -

    -

    -(Appears on: -Backup, -Restore) -

    -

    -

    Handler defines a specific action that should be taken

    -

    - - - - - - - - - - - - - -
    FieldDescription
    -exec
    - - -Kubernetes core/v1.ExecAction - - -
    -

    Exec specifies the action to take.

    -
    -

    JenkinsCredentialType -(string alias)

    -

    -(Appears on: -SeedJob) -

    -

    -

    JenkinsCredentialType defines the type of Jenkins credential used in the seed job mechanism

    -

    -

    JenkinsMaster -

    -

    -(Appears on: -JenkinsSpec) -

    -

    -

    JenkinsMaster defines the Jenkins master pod attributes and plugins, -every single change requires a Jenkins master pod restart

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -masterAnnotations
    - -map[string]string - -
    -(Optional) -

    Annotations is an unstructured key value map stored with a resource that may be -set by external tools to store and retrieve arbitrary metadata. They are not -queryable and should be preserved when modifying objects. -More info: http://kubernetes.io/docs/user-guide/annotations

    -
    -nodeSelector
    - -map[string]string - -
    -(Optional) -

    NodeSelector is a selector which must be true for the pod to fit on a node. -Selector which must match a node’s labels for the pod to be scheduled on that node. -More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/

    -
    -securityContext
    - - -Kubernetes core/v1.PodSecurityContext - - -
    -(Optional) -

    SecurityContext that applies to all the containers of the Jenkins -Master. As per kubernetes specification, it can be overridden -for each container individually. -Defaults to: -runAsUser: 1000 -fsGroup: 1000

    -
    -containers
    - - -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Container - - -
    -

    List of containers belonging to the pod. -Containers cannot currently be added or removed. -There must be at least one container in a Pod. -Defaults to: -- image: jenkins/jenkins:lts -imagePullPolicy: Always -livenessProbe: -failureThreshold: 12 -httpGet: -path: /login -port: http -scheme: HTTP -initialDelaySeconds: 80 -periodSeconds: 10 -successThreshold: 1 -timeoutSeconds: 5 -name: jenkins-master -readinessProbe: -failureThreshold: 3 -httpGet: -path: /login -port: http -scheme: HTTP -initialDelaySeconds: 30 -periodSeconds: 10 -successThreshold: 1 -timeoutSeconds: 1 -resources: -limits: -cpu: 1500m -memory: 3Gi -requests: -cpu: “1” -memory: 600Mi

    -
    -imagePullSecrets
    - - -[]Kubernetes core/v1.LocalObjectReference - - -
    -(Optional) -

    ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. -If specified, these secrets will be passed to individual puller implementations for them to use. For example, -in the case of docker, only DockerConfig type secrets are honored. -More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod

    -
    -volumes
    - - -[]Kubernetes core/v1.Volume - - -
    -(Optional) -

    List of volumes that can be mounted by containers belonging to the pod. -More info: https://kubernetes.io/docs/concepts/storage/volumes

    -
    -basePlugins
    - - -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin - - -
    -

    BasePlugins contains plugins required by operator -Defaults to : -- name: kubernetes -version: 1.15.7 -- name: workflow-job -version: “2.32” -- name: workflow-aggregator -version: “2.6” -- name: git -version: 3.10.0 -- name: job-dsl -version: “1.74” -- name: configuration-as-code -version: “1.19” -- name: configuration-as-code-support -version: “1.19” -- name: kubernetes-credentials-provider -version: 0.12.1

    -
    -plugins
    - - -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin - - -
    -(Optional) -

    Plugins contains plugins required by user

    -
    -

    JenkinsSpec -

    -

    -(Appears on: -Jenkins) -

    -

    -

    JenkinsSpec defines the desired state of the Jenkins

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -master
    - - -JenkinsMaster - - -
    -

    Master represents Jenkins master pod properties and Jenkins plugins. -Every single change here requires a pod restart.

    -
    -seedJobs
    - - -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob - - -
    -(Optional) -

    SeedJobs defines list of Jenkins Seed Job configurations -More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines

    -
    -service
    - - -Service - - -
    -(Optional) -

    Service is Kubernetes service of Jenkins master HTTP pod -Defaults to : -port: 8080 -type: ClusterIP

    -
    -slaveService
    - - -Service - - -
    -(Optional) -

    Service is Kubernetes service of Jenkins slave pods -Defaults to : -port: 50000 -type: ClusterIP

    -
    -backup
    - - -Backup - - -
    -(Optional) -

    Backup defines configuration of Jenkins backup -More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

    -
    -restore
    - - -Restore - - -
    -(Optional) -

    Backup defines configuration of Jenkins backup restore -More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

    -
    -groovyScripts
    - - -GroovyScripts - - -
    -(Optional) -

    GroovyScripts defines configuration of Jenkins customization via groovy scripts

    -
    -configurationAsCode
    - - -ConfigurationAsCode - - -
    -(Optional) -

    ConfigurationAsCode defines configuration of Jenkins customization via Configuration as Code Jenkins plugin

    -
    -

    JenkinsStatus -

    -

    -(Appears on: -Jenkins) -

    -

    -

    JenkinsStatus defines the observed state of Jenkins

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -operatorVersion
    - -string - -
    -(Optional) -

    OperatorVersion is the operator version which manages this CR

    -
    -provisionStartTime
    - - -Kubernetes meta/v1.Time - - -
    -(Optional) -

    ProvisionStartTime is a time when Jenkins master pod has been created

    -
    -baseConfigurationCompletedTime
    - - -Kubernetes meta/v1.Time - - -
    -(Optional) -

    BaseConfigurationCompletedTime is a time when Jenkins base configuration phase has been completed

    -
    -userConfigurationCompletedTime
    - - -Kubernetes meta/v1.Time - - -
    -(Optional) -

    UserConfigurationCompletedTime is a time when Jenkins user configuration phase has been completed

    -
    -restoredBackup
    - -uint64 - -
    -(Optional) -

    RestoredBackup is the restored backup number after Jenkins master pod restart

    -
    -lastBackup
    - -uint64 - -
    -(Optional) -

    LastBackup is the latest backup number

    -
    -pendingBackup
    - -uint64 - -
    -(Optional) -

    PendingBackup is the pending backup number

    -
    -backupDoneBeforePodDeletion
    - -bool - -
    -(Optional) -

    BackupDoneBeforePodDeletion tells if backup before pod deletion has been made

    -
    -userAndPasswordHash
    - -string - -
    -(Optional) -

    UserAndPasswordHash is a SHA256 hash made from the username and password

    -
    -createdSeedJobs
    - -[]string - -
    -(Optional) -

    CreatedSeedJobs contains list of seed job ids already created in Jenkins

    -
    -appliedGroovyScripts
    - - -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.AppliedGroovyScript - - -
    -(Optional) -

    AppliedGroovyScripts is a list with all applied groovy scripts in Jenkins by the operator

    -
    -

    Mailgun -

    -

    -(Appears on: -Notification) -

    -

    -

    Mailgun is handler for Mailgun email service notification channel

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -domain
    - -string - -
    -
    -apiKeySecretKeySelector
    - - -SecretKeySelector - - -
    -
    -recipient
    - -string - -
    -
    -from
    - -string - -
    -
    -

    MicrosoftTeams -

    -

    -(Appears on: -Notification) -

    -

    -

    MicrosoftTeams is handler for Microsoft MicrosoftTeams notification channel

    -

    - - - - - - - - - - - - - -
    FieldDescription
    -webHookURLSecretKeySelector
    - - -SecretKeySelector - - -
    -

    The web hook URL to MicrosoftTeams App

    -
    -

    Notification -

    -

    -

    Notification is a service configuration used to send notifications about Jenkins status

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -loggingLevel
    - - -NotificationLogLevel - - -
    -
    -verbose
    - -bool - -
    -
    -name
    - -string - -
    -
    -slack
    - - -github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Slack - - -
    -
    -teams
    - - -github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.MicrosoftTeams - - -
    -
    -mailgun
    - - -github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Mailgun - - -
    -
    -

    NotificationLogLevel -(string alias)

    -

    -(Appears on: -Notification) -

    -

    -

    NotificationLogLevel defines logging level of Notification

    -

    -

    Plugin -

    -

    -(Appears on: -JenkinsMaster) -

    -

    -

    Plugin defines Jenkins plugin

    -

    - - - - - - - - - - - - - - - - - -
    FieldDescription
    -name
    - -string - -
    -

    Name is the name of Jenkins plugin

    -
    -version
    - -string - -
    -

    Version is the version of Jenkins plugin

    -
    -

    Restore -

    -

    -(Appears on: -JenkinsSpec) -

    -

    -

    Restore defines configuration of Jenkins backup restore operation

    -

    - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -containerName
    - -string - -
    -

    ContainerName is the container name responsible for restore backup operation

    -
    -action
    - - -Handler - - -
    -

    Action defines action which performs restore backup in restore container sidecar

    -
    -recoveryOnce
    - -uint64 - -
    -(Optional) -

    RecoveryOnce if want to restore specific backup set this field and then Jenkins will be restarted and desired backup will be restored

    -
    -

    SecretKeySelector -

    -

    -(Appears on: -Mailgun, -MicrosoftTeams, -Slack) -

    -

    -

    SecretKeySelector selects a key of a Secret.

    -

    - - - - - - - - - - - - - - - - - -
    FieldDescription
    -secret
    - - -Kubernetes core/v1.LocalObjectReference - - -
    -

    The name of the secret in the pod’s namespace to select from.

    -
    -key
    - -string - -
    -

    The key of the secret to select from. Must be a valid secret key.

    -
    -

    SecretRef -

    -

    -(Appears on: -Customization) -

    -

    -

    SecretRef is reference to Kubernetes secret

    -

    - - - - - - - - - - - - - -
    FieldDescription
    -name
    - -string - -
    -
    -

    SeedJob -

    -

    -(Appears on: -JenkinsSpec) -

    -

    -

    SeedJob defines configuration for seed job -More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -id
    - -string - -
    -

    ID is the unique seed job name

    -
    -credentialID
    - -string - -
    -

    CredentialID is the Kubernetes secret name which stores repository access credentials

    -
    -description
    - -string - -
    -(Optional) -

    Description is the description of the seed job

    -
    -targets
    - -string - -
    -

    Targets is the repository path where the seed job definitions are

    -
    -repositoryBranch
    - -string - -
    -

    RepositoryBranch is the repository branch where the seed job definitions are

    -
    -repositoryUrl
    - -string - -
    -

    RepositoryURL is the repository access URL. Can be SSH or HTTPS.

    -
    -credentialType
    - - -JenkinsCredentialType - - -
    -(Optional) -

    JenkinsCredentialType is the https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/ credential type

    -
    -githubPushTrigger
    - -bool - -
    -(Optional) -

    GitHubPushTrigger is used for GitHub web hooks

    -
    -buildPeriodically
    - -string - -
    -(Optional) -

    BuildPeriodically is setting for scheduled trigger

    -
    -pollSCM
    - -string - -
    -(Optional) -

    PollSCM is setting for polling changes in SCM

    -
    -ignoreMissingFiles
    - -bool - -
    -(Optional) -

    IgnoreMissingFiles is setting for Job DSL API plugin to ignore files that miss

    -
    -additionalClasspath
    - -string - -
    -(Optional) -

    AdditionalClasspath is setting for Job DSL API plugin to set Additional Classpath

    -
    -failOnMissingPlugin
    - -bool - -
    -(Optional) -

    FailOnMissingPlugin is setting for Job DSL API plugin that fails job if required plugin is missing

    -
    -unstableOnDeprecation
    - -bool - -
    -(Optional) -

    UnstableOnDeprecation is setting for Job DSL API plugin that sets build status as unstable if build using deprecated features

    -
    -

    Service -

    -

    -(Appears on: -JenkinsSpec) -

    -

    -

    Service defines Kubernetes service attributes

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -annotations
    - -map[string]string - -
    -(Optional) -

    Annotations is an unstructured key value map stored with a resource that may be -set by external tools to store and retrieve arbitrary metadata. They are not -queryable and should be preserved when modifying objects. -More info: http://kubernetes.io/docs/user-guide/annotations

    -
    -labels
    - -map[string]string - -
    -

    Route service traffic to pods with label keys and values matching this -selector. If empty or not present, the service is assumed to have an -external process managing its endpoints, which Kubernetes will not -modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. -Ignored if type is ExternalName. -More info: https://kubernetes.io/docs/concepts/services-networking/service/

    -
    -type
    - - -Kubernetes core/v1.ServiceType - - -
    -(Optional) -

    Type determines how the Service is exposed. Defaults to ClusterIP. Valid -options are ExternalName, ClusterIP, NodePort, and LoadBalancer. -“ExternalName” maps to the specified externalName. -“ClusterIP” allocates a cluster-internal IP address for load-balancing to -endpoints. Endpoints are determined by the selector or if that is not -specified, by manual construction of an Endpoints object. If clusterIP is -“None”, no virtual IP is allocated and the endpoints are published as a -set of endpoints rather than a stable IP. -“NodePort” builds on ClusterIP and allocates a port on every node which -routes to the clusterIP. -“LoadBalancer” builds on NodePort and creates an -external load-balancer (if supported in the current cloud) which routes -to the clusterIP. -More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services—service-types

    -
    -port
    - -int32 - -
    -

    The port that is exposed by this service. -More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies

    -
    -nodePort
    - -int32 - -
    -(Optional) -

    The port on each node on which this service is exposed when type=NodePort or LoadBalancer. -Usually assigned by the system. If specified, it will be allocated to the service -if unused, or else creation of the service will fail. -Default is to auto-allocate a port if the ServiceType of this Service requires one. -More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport

    -
    -loadBalancerSourceRanges
    - -[]string - -
    -(Optional) -

    If specified and supported by the platform, this will restrict traffic through the cloud-provider -the load-balancer will be restricted to the specified client IPs. This field will be ignored if the -cloud-provider does not support the feature.” -More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/

    -
    -loadBalancerIP
    - -string - -
    -(Optional) -

    Only applies to Service Type: LoadBalancer -LoadBalancer will get created with the IP specified in this field. -This feature depends on whether the underlying cloud-provider supports specifying -the loadBalancerIP when a load balancer is created. -This field will be ignored if the cloud-provider does not support the feature.

    -
    -

    Slack -

    -

    -(Appears on: -Notification) -

    -

    -

    Slack is handler for Slack notification channel

    -

    - - - - - - - - - - - - - -
    FieldDescription
    -webHookURLSecretKeySelector
    - - -SecretKeySelector - - -
    -

    The web hook URL to Slack App

    -
    -
    -

    -Generated with gen-crd-api-reference-docs -on git commit f4c4235. -

    - - - -
    Last modified August 5, 2019 -
    -
    - - -
    -
    -
    - - - - -
    - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/docs/getting-started/latest/developer-guide/index.html b/docs/docs/getting-started/latest/developer-guide/index.html deleted file mode 100644 index b16fd0a2..00000000 --- a/docs/docs/getting-started/latest/developer-guide/index.html +++ /dev/null @@ -1,750 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -Developer Guide | Jenkins Operator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Developer Guide | Jenkins Operator - - -
    - - - -
    -
    -
    -
    -
    - - - - - -
    - - - - -
    - - - - -
    - -
    - - - -
    -

    Developer Guide

    -
    Jenkins Operator for developers
    - - - - -
    -

    This document explains how to setup your development environment.

    - -
    - - -

    Prerequisites

    - - - -

    Clone repository and download dependencies

    -
    mkdir -p $GOPATH/src/github.com/jenkinsci
    -cd $GOPATH/src/github.com/jenkinsci/
    -git clone git@github.com:jenkinsci/kubernetes-operator.git
    -cd kubernetes-operator
    -make go-dependencies
    -

    Build and run with a minikube

    - -

    Build and run Jenkins Operator locally:

    -
    make build minikube-run EXTRA_ARGS='--minikube --local'
    -

    Once minikube and Jenkins Operator are up and running, apply Jenkins custom resource:

    -
    kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml
    -kubectl get jenkins -o yaml
    -kubectl get po
    -

    Build and run with a remote Kubernetes cluster

    - -

    You can also run the controller locally and make it listen to a remote Kubernetes server.

    -
    make run NAMESPACE=default KUBECTL_CONTEXT=remote-k8s EXTRA_ARGS='--kubeconfig ~/.kube/config'
    -

    Once minikube and Jenkins Operator are up and running, apply Jenkins custom resource:

    -
    kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml
    -kubectl --context remote-k8s --namespace default get jenkins -o yaml
    -kubectl --context remote-k8s --namespace default get po
    -

    Testing

    - -

    Run unit tests:

    -
    make test
    -

    Running E2E tests on Linux

    - -

    Run e2e tests with minikube:

    -
    make minikube-start
    -eval $(minikube docker-env)
    -make build e2e
    -

    Run the specific e2e test:

    -
    make build e2e E2E_TEST_SELECTOR='^TestConfiguration$'
    -

    Running E2E tests on macOS

    - -

    At first, you need to start minikube:

    -
    $ make minikube-start
    -$ eval $(minikube docker-env) 
    -

    Build a Docker image inside the provided Linux container by:

    -
    $ make indocker
    -

    Build Jenkins Operator inside a container using:

    -
    $ make build
    -

    Then exit the container and run:

    - -
    make e2e
    -
    - -

    Tips & Tricks

    - -

    Building docker image on minikube (for e2e tests)

    - -

    To be able to work with the docker daemon on minikube machine run the following command before building an image:

    -
    eval $(minikube docker-env)
    -

    When pkg/apis/jenkinsio/*/jenkins_types.go has changed

    - -

    Run:

    -
    make deepcopy-gen
    -

    Getting the Jenkins URL and basic credentials

    -
    minikube service jenkins-operator-http-<cr_name> --url
    -kubectl get secret jenkins-operator-credentials-<cr_name> -o 'jsonpath={.data.user}' | base64 -d
    -kubectl get secret jenkins-operator-credentials-<cr_name> -o 'jsonpath={.data.password}' | base64 -d
    -

    Tools

    - -

    Configure environment variables

    -
    export GOPATH=/home/go # example value
    -export GOROOT=/usr/lib/go-1.12 # example value
    -export PATH=$GOPATH/bin:$PATH
    -

    goimports

    - -
    go get golang.org/x/tools/cmd/goimports
    -cd $GOPATH/src/golang.org/x/tools/cmd/goimports
    -go build
    -go install
    -
    - -

    golint

    - -
    go get -u golang.org/x/lint/golint
    -cd  $GOPATH/src/golang.org/x/lint/golint
    -go build
    -go install
    -
    - -

    checkmake

    - -
    go get github.com/mrtazz/checkmake
    -cd $GOPATH/src/github.com/mrtazz/checkmake
    -go build
    -go install
    -
    - -

    staticcheck

    - -
    mkdir -p $GOPATH/src/github.com/dominikh/
    -cd $GOPATH/src/github.com/dominikh/
    -git clone https://github.com/dominikh/go-tools.git
    -cd  $GOPATH/src/github.com/dominikh/go-tools/staticcheck
    -go build
    -go install
    -
    - - - -
    Last modified August 5, 2019 -
    -
    - - -
    -
    -
    - - - - -
    - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/docs/getting-started/latest/index.xml b/docs/docs/getting-started/latest/index.xml index 73ab704b..97a7854e 100644 --- a/docs/docs/getting-started/latest/index.xml +++ b/docs/docs/getting-started/latest/index.xml @@ -1,10 +1,10 @@ - Jenkins Operator – Latest (v0.2.x) + Jenkins Operator – Latest (v0.3.x) https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/ Recent Hugo news from gohugo.io Hugo -- gohugo.io - Mon, 05 Aug 2019 00:00:00 +0000 + Fri, 20 Dec 2019 00:00:00 +0000 https://jenkinsci.github.io/kubernetes-operator/img/hugo.png GoHugo.io @@ -22,7 +22,7 @@ Docs: Deploy Jenkins https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/deploy-jenkins/ - Mon, 05 Aug 2019 00:00:00 +0000 + Fri, 20 Dec 2019 00:00:00 +0000 https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/deploy-jenkins/ @@ -93,7 +93,7 @@ kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <s Docs: Configuration https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configuration/ - Mon, 05 Aug 2019 00:00:00 +0000 + Fri, 20 Dec 2019 00:00:00 +0000 https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configuration/ @@ -395,7 +395,7 @@ stringData: Docs: Customization https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/customization/ - Mon, 05 Aug 2019 00:00:00 +0000 + Fri, 20 Dec 2019 00:00:00 +0000 https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/customization/ @@ -536,13 +536,13 @@ spec: </span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>basePlugins<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>kubernetes<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1.18</span>.<span style="color:#0000cf;font-weight:bold">3</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">1.18.3</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>workflow-job<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;2.34&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>workflow-aggregator<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;2.6&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>git<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">3.12</span>.<span style="color:#0000cf;font-weight:bold">0</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">3.12.0</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>job-dsl<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;1.76&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configuration-as-code<span style="color:#f8f8f8;text-decoration:underline"> @@ -550,7 +550,7 @@ spec: </span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configuration-as-code-support<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;1.19&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>kubernetes-credentials-provider<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">0.12</span>.<span style="color:#0000cf;font-weight:bold">1</span></code></pre></div> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>version<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#0000cf;font-weight:bold">0.12.1</span></code></pre></div> <p>You can change their versions.</p> <p>The <strong>Jenkins Operator</strong> will then automatically install plugins after the Jenkins master pod restarts.</p> @@ -561,7 +561,7 @@ spec: Docs: AKS https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/aks/ - Mon, 05 Aug 2019 00:00:00 +0000 + Fri, 20 Dec 2019 00:00:00 +0000 https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/aks/ @@ -585,7 +585,7 @@ restart of a Jenkins pod over and over again.</p> Docs: Configure backup and restore https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configure-backup-and-restore/ - Mon, 05 Aug 2019 00:00:00 +0000 + Fri, 20 Dec 2019 00:00:00 +0000 https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configure-backup-and-restore/ @@ -635,7 +635,7 @@ restart of a Jenkins pod over and over again.</p> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>BACKUP_COUNT<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#4e9a06">&#34;3&#34;</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># keep only the 2 most recent backups</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>image<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>virtuslab/jenkins-operator-backup-pvc<span style="color:#000;font-weight:bold">:</span>v0.<span style="color:#0000cf;font-weight:bold">0.7</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># look at backup/pvc directory</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>image<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>virtuslab/jenkins-operator-backup-pvc<span style="color:#000;font-weight:bold">:</span>v0<span style="color:#0000cf;font-weight:bold">.0.7</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># look at backup/pvc directory</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>imagePullPolicy<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>IfNotPresent<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>volumeMounts<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>mountPath<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/jenkins-home<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># Jenkins home volume</span><span style="color:#f8f8f8;text-decoration:underline"> @@ -667,7 +667,7 @@ restart of a Jenkins pod over and over again.</p> Docs: Custom Backup and Restore Providers https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/custom-backup-and-restore/ - Mon, 05 Aug 2019 00:00:00 +0000 + Fri, 20 Dec 2019 00:00:00 +0000 https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/custom-backup-and-restore/ @@ -736,7 +736,7 @@ for backup and restore are required, e.g.:</p> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-master<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>...<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>backup<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># container responsible for backup and restore</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>image<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>quay.io/virtuslab/aws-cli<span style="color:#000;font-weight:bold">:</span><span style="color:#0000cf;font-weight:bold">1.16</span>.<span style="color:#0000cf;font-weight:bold">263</span>-<span style="color:#0000cf;font-weight:bold">2</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>image<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>quay.io/virtuslab/aws-cli<span style="color:#000;font-weight:bold">:</span><span style="color:#0000cf;font-weight:bold">1.16.263-2</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>workingDir<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/home/user/bin/<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic"># our container entry point</span><span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>sleep<span style="color:#f8f8f8;text-decoration:underline"> @@ -848,72 +848,123 @@ the number of backups under control, e.g. Cloud Formation fragment:</p> - Docs: Migration from v0.1.x - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/migration/ - Mon, 05 Aug 2019 00:00:00 +0000 + Docs: Notifications + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/notifications/ + Fri, 20 Dec 2019 00:00:00 +0000 - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/migration/ + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/notifications/ -<h3 id="major-changes">Major Changes</h3> +<h2 id="slack">Slack</h2> -<h4 id="adding-the-seed-job-agent">Adding the seed job agent</h4> +<p>Please follow <a href="https://api.slack.com/incoming-webhooks" target="_blank">this</a> instructions to get web hook URL.</p> -<p>From version <code>v0.2.0</code> seed jobs are not run by master executors, but by a dedicated agent deployed as a Kubernetes Pod.</p> +<p>Create web hook secret with name <code>jenkins-operator-notification-data</code>. Contains key <code>url</code> with provided web hook URL.</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ kubectl create secret generic jenkins-operator-notification-data --from-literal<span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#000">url</span><span style="color:#ce5c00;font-weight:bold">=</span>&lt;webhook_url&gt;</code></pre></div> +<p>Example configuration for Slack:</p> -<p>We&rsquo;ve had disabled master executors for security reasons.</p> +<pre><code>kind: Jenkins +spec: + master: + notifications: + - loggingLevel: info + verbose: true + name: &lt;name&gt; + slack: + webHookURLSecretKeySelector: + secret: + name: &lt;secret_name&gt; + key: &lt;key&gt; +</code></pre> -<h4 id="replacing-configuration-jobs-with-groovy-scripts">Replacing configuration jobs with Groovy scripts</h4> +<h2 id="microsoft-teams">Microsoft Teams</h2> -<p>In <code>v0.1.x</code> <strong>Jenkins Operator</strong> user configuration application was implemented using <strong>Jenkins</strong> jobs -and this mechanism was replaced since <code>v0.2.0</code> with Groovy scripts implementing the same functionality.</p> +<p>Please follow <a href="https://docs.microsoft.com/en-gb/outlook/actionable-messages/send-via-connectors" target="_blank">this</a> instructions to get web hook URL.</p> -<p>As a result, the <strong>Jenkins</strong> configuration jobs (&ldquo;Configure Seed Jobs&rdquo;, &ldquo;jenkins-operator-base-configuration&rdquo;, &ldquo;jenkins-operator-user-configuration&rdquo;) are no longer visible in <strong>Jenkins</strong> UI.</p> +<p>Example configuration for Microsoft Teams:</p> -<p>In <code>v0.1.x</code> you can see if any of the configuration jobs failed or succeded in the <strong>Jenkins</strong> UI (job build logs). -Instead, you can make sure the operator is running correctly by inspecting its logs, e.g.:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ kubectl -n logs deployment/jenkins-operator</code></pre></div> -<h4 id="making-user-configuration-sources-configurable">Making User Configuration sources configurable</h4> +<pre><code>kind: Jenkins +spec: + master: + notifications: + - loggingLevel: info + verbose: true + name: &lt;name&gt; + teams: + webHookURLSecretKeySelector: + secret: + name: &lt;secret_name&gt; + key: &lt;key&gt; +</code></pre> -<p>In <code>v0.1.x</code> <strong>Jenkins Operator</strong> user configuration was stored in a <code>ConfigMap</code> and a <code>Secret</code> -named <code>jenkins-operator-user-configuration-&lt;cr_name&gt;</code>, and its name was hardcoded in the operator.</p> +<h2 id="mailgun">Mailgun</h2> -<p>Since <code>v0.2.0</code> the user configuration can be stored in a multiple <code>ConfigMap</code> and <code>Secret</code> manifests -and has to be explicitly pointed to with <code>spec.configurationAsCode.configurations</code> and <code>spec.configurationAsCode.secret</code> -for the Configuration as Code plugin, -and <code>spec.groovyScripts.configurations</code> and <code>spec.groovyScripts.secret</code> for the more advanced groovy scripts.</p> +<p>Example configuration for Mailgun:</p> -<h3 id="migration">Migration</h3> +<pre><code>kind: Jenkins +spec: + master: + notifications: + - loggingLevel: info + verbose: true + name: &lt;name&gt; + mailgun: + domain: &lt;domain&gt; + apiKeySecretKeySelector: + secret: + name: &lt;secret_name&gt; + key: &lt;key&gt; + recipient: &lt;your_email&gt; + from: &lt;mailgun_email&gt; +</code></pre> + +<h2 id="debug-options">Debug options</h2> + +<p>As you see there is two debugging options:</p> + +<ul> +<li><p><code>loggingLevel</code> (warning/info) - Set level of messages to send.</p></li> + +<li><p><code>verbose</code> - Print stacktrace and additional error messages</p></li> +</ul> + +<h2 id="multiple-providers">Multiple providers</h2> + +<p>You can use multiple providers to send notification to another communication channels at the same time. +For example you will send notifications to Slack and Teams.</p> + +<pre><code>kind: Jenkins +spec: + master: + notifications: + - loggingLevel: info + verbose: true + name: nslack + slack: + webHookURLSecretKeySelector: + secret: + name: &lt;secret_name&gt; + key: &lt;key&gt; + - loggingLevel: info + verbose: true + name: nteams + teams: + webHookURLSecretKeySelector: + secret: + name: &lt;secret_name&gt; + key: &lt;key&gt; +</code></pre> -<p>If you want to use <code>v0.1.x</code> operator configuration with <code>v0.2.x</code> you have to modify your Jenkins Custom Resource(s) -and add explicit references to the existing <code>ConfigMap</code> and <code>Secret</code>, e.g.:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins.io/v1alpha2<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Jenkins<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;cr_name&gt;<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>...<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurationAsCode<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration-&lt;cr_name<span style="color:#8f5902;font-style:italic">&gt; -</span><span style="color:#8f5902;font-style:italic"> secret:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration-&lt;cr_name<span style="color:#8f5902;font-style:italic">&gt; -</span><span style="color:#8f5902;font-style:italic"> groovyScripts:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>configurations<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration-&lt;cr_name<span style="color:#8f5902;font-style:italic">&gt; -</span><span style="color:#8f5902;font-style:italic"> secret:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-user-configuration-&lt;cr_name<span style="color:#8f5902;font-style:italic">&gt; -</span><span style="color:#8f5902;font-style:italic"> ...</span></code></pre></div> Docs: Diagnostics https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/diagnostics/ - Mon, 05 Aug 2019 00:00:00 +0000 + Fri, 20 Dec 2019 00:00:00 +0000 https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/diagnostics/ @@ -940,7 +991,7 @@ kubectl apply -f deploy/operator.yaml</code></pre></div> Docs: Schema https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/schema/ - Mon, 05 Aug 2019 00:00:00 +0000 + Fri, 20 Dec 2019 00:00:00 +0000 https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/schema/ @@ -962,7 +1013,7 @@ kubectl apply -f deploy/operator.yaml</code></pre></div> </ul> <h2 id="jenkins.io">jenkins.io</h2> <p> -<p>Package v1alpha2 contains the API Schema definitions for the jenkins.io v1alpha2 API group</p> +<p>Package v1alpha2 contains API Schema definitions for the jenkins.io v1alpha2 API group</p> </p> Resource Types: <ul><li> @@ -1051,12 +1102,26 @@ Every single change here requires a pod restart.</p> </td> <td> <em>(Optional)</em> -<p>SeedJobs defines a list of Jenkins Seed Job configurations +<p>SeedJobs defines list of Jenkins Seed Job configurations More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines</a></p> </td> </tr> <tr> <td> +<code>notifications</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Notification"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Notification +</a> +</em> +</td> +<td> +<p>Notifications defines list of a services which are used to inform about Jenkins status +Can be used to integrate chat services like Slack, Microsoft Teams or Mailgun</p> +</td> +</tr> +<tr> +<td> <code>service</code></br> <em> <a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service"> @@ -1066,7 +1131,7 @@ Service </td> <td> <em>(Optional)</em> -<p>Service is the Kubernetes service of the Jenkins master HTTP pod +<p>Service is Kubernetes service of Jenkins master HTTP pod Defaults to : port: 8080 type: ClusterIP</p> @@ -1083,7 +1148,7 @@ Service </td> <td> <em>(Optional)</em> -<p>Service is the Kubernetes service of the Jenkins slave pods +<p>Service is Kubernetes service of Jenkins slave pods Defaults to : port: 50000 type: ClusterIP</p> @@ -1100,7 +1165,7 @@ Backup </td> <td> <em>(Optional)</em> -<p>Backup defines the configuration of a Jenkins backup +<p>Backup defines configuration of Jenkins backup More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore</a></p> </td> </tr> @@ -1115,7 +1180,7 @@ Restore </td> <td> <em>(Optional)</em> -<p>Backup defines the configuration of a Jenkins backup restore +<p>Backup defines configuration of Jenkins backup restore More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore">https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore</a></p> </td> </tr> @@ -1130,7 +1195,7 @@ GroovyScripts </td> <td> <em>(Optional)</em> -<p>GroovyScripts defines the configuration of Jenkins customization via groovy scripts</p> +<p>GroovyScripts defines configuration of Jenkins customization via groovy scripts</p> </td> </tr> <tr> @@ -1144,7 +1209,7 @@ ConfigurationAsCode </td> <td> <em>(Optional)</em> -<p>ConfigurationAsCode defines the configuration of Jenkins customization via the Configuration as Code Jenkins plugin</p> +<p>ConfigurationAsCode defines configuration of Jenkins customization via Configuration as Code Jenkins plugin</p> </td> </tr> </table> @@ -1235,7 +1300,7 @@ string <a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) </p> <p> -<p>Backup defines the configuration of a Jenkins backup</p> +<p>Backup defines configuration of Jenkins backup</p> </p> <table> <thead> @@ -1266,7 +1331,7 @@ Handler </em> </td> <td> -<p>Action defines the action which performs the backup in the backup container sidecar</p> +<p>Action defines action which performs backup in backup container sidecar</p> </td> </tr> <tr> @@ -1277,7 +1342,7 @@ uint64 </em> </td> <td> -<p>Interval tells you how often the backup is made in seconds +<p>Interval tells how often make backup in seconds Defaults to 30.</p> </td> </tr> @@ -1289,7 +1354,7 @@ bool </em> </td> <td> -<p>MakeBackupBeforePodDeletion tells the operator to make a backup before Jenkins master pod deletion</p> +<p>MakeBackupBeforePodDeletion tells operator to make backup before Jenkins master pod deletion</p> </td> </tr> </tbody> @@ -1301,7 +1366,7 @@ bool <a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Customization">Customization</a>) </p> <p> -<p>ConfigMapRef is the reference to Kubernetes ConfigMap</p> +<p>ConfigMapRef is reference to Kubernetes ConfigMap</p> </p> <table> <thead> @@ -1330,7 +1395,7 @@ string <a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) </p> <p> -<p>ConfigurationAsCode defines configuration of Jenkins customization via the Configuration as Code Jenkins plugin</p> +<p>ConfigurationAsCode defines configuration of Jenkins customization via Configuration as Code Jenkins plugin</p> </p> <table> <thead> @@ -1361,7 +1426,7 @@ Customization <a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsMaster">JenkinsMaster</a>) </p> <p> -<p>Container defines the Kubernetes container attributes</p> +<p>Container defines Kubernetes container attributes</p> </p> <table> <thead> @@ -1716,7 +1781,7 @@ Kubernetes core/v1.ExecAction <a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.SeedJob">SeedJob</a>) </p> <p> -<p>JenkinsCredentialType defines the type of Jenkins credential used in the seed job mechanism</p> +<p>JenkinsCredentialType defines type of Jenkins credential used to seed job mechanism</p> </p> <h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsMaster">JenkinsMaster </h3> @@ -1738,7 +1803,7 @@ every single change requires a Jenkins master pod restart</p> <tbody> <tr> <td> -<code>masterAnnotations</code></br> +<code>annotations</code></br> <em> map[string]string </em> @@ -1753,6 +1818,22 @@ More info: <a href="http://kubernetes.io/docs/user-guide/annotations" </tr> <tr> <td> +<code>masterAnnotations</code></br> +<em> +map[string]string +</em> +</td> +<td> +<em>(Optional)</em> +<p>Annotations is an unstructured key value map stored with a resource that may be +set by external tools to store and retrieve arbitrary metadata. They are not +queryable and should be preserved when modifying objects. +More info: <a href="http://kubernetes.io/docs/user-guide/annotations">http://kubernetes.io/docs/user-guide/annotations</a> +Deprecated: will be removed in the future, please use Annotations(annotations)</p> +</td> +</tr> +<tr> +<td> <code>nodeSelector</code></br> <em> map[string]string @@ -1906,6 +1987,17 @@ version: 0.12.1</p> <p>Plugins contains plugins required by user</p> </td> </tr> +<tr> +<td> +<code>disableCSRFProtection</code></br> +<em> +bool +</em> +</td> +<td> +<p>DisableCSRFProtection allows you to toggle CSRF Protection on Jenkins</p> +</td> +</tr> </tbody> </table> <h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.JenkinsSpec">JenkinsSpec @@ -1956,6 +2048,20 @@ More info: <a href="https://github.com/jenkinsci/kubernetes-operator/blob </tr> <tr> <td> +<code>notifications</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Notification"> +[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Notification +</a> +</em> +</td> +<td> +<p>Notifications defines list of a services which are used to inform about Jenkins status +Can be used to integrate chat services like Slack, Microsoft Teams or Mailgun</p> +</td> +</tr> +<tr> +<td> <code>service</code></br> <em> <a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Service"> @@ -2176,7 +2282,7 @@ string </td> <td> <em>(Optional)</em> -<p>UserAndPasswordHash is a SHA256 hash made from the username and password</p> +<p>UserAndPasswordHash is a SHA256 hash made from user and password</p> </td> </tr> <tr> @@ -2188,7 +2294,7 @@ string </td> <td> <em>(Optional)</em> -<p>CreatedSeedJobs contains list of seed job ids already created in Jenkins</p> +<p>CreatedSeedJobs contains list of seed job id already created in Jenkins</p> </td> </tr> <tr> @@ -2303,6 +2409,10 @@ SecretKeySelector <h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Notification">Notification </h3> <p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.JenkinsSpec">JenkinsSpec</a>) +</p> +<p> <p>Notification is a service configuration used to send notifications about Jenkins status</p> </p> <table> @@ -2315,10 +2425,10 @@ SecretKeySelector <tbody> <tr> <td> -<code>loggingLevel</code></br> +<code>level</code></br> <em> -<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.NotificationLogLevel"> -NotificationLogLevel +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.NotificationLevel"> +NotificationLevel </a> </em> </td> @@ -2381,16 +2491,28 @@ github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Mailgun <td> </td> </tr> +<tr> +<td> +<code>smtp</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SMTP"> +github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SMTP +</a> +</em> +</td> +<td> +</td> +</tr> </tbody> </table> -<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.NotificationLogLevel">NotificationLogLevel +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.NotificationLevel">NotificationLevel (<code>string</code> alias)</p></h3> <p> (<em>Appears on:</em> <a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Notification">Notification</a>) </p> <p> -<p>NotificationLogLevel defines logging level of Notification</p> +<p>NotificationLevel defines the level of a Notification</p> </p> <h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin">Plugin </h3> @@ -2488,12 +2610,106 @@ uint64 </tr> </tbody> </table> +<h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SMTP">SMTP +</h3> +<p> +(<em>Appears on:</em> +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Notification">Notification</a>) +</p> +<p> +<p>SMTP is handler for sending emails via this protocol</p> +</p> +<table> +<thead> +<tr> +<th>Field</th> +<th>Description</th> +</tr> +</thead> +<tbody> +<tr> +<td> +<code>usernameSecretKeySelector</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector"> +SecretKeySelector +</a> +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>passwordSecretKeySelector</code></br> +<em> +<a href="#github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector"> +SecretKeySelector +</a> +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>port</code></br> +<em> +int +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>server</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>tlsInsecureSkipVerify</code></br> +<em> +bool +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>from</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +<tr> +<td> +<code>to</code></br> +<em> +string +</em> +</td> +<td> +</td> +</tr> +</tbody> +</table> <h3 id="github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SecretKeySelector">SecretKeySelector </h3> <p> (<em>Appears on:</em> <a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Mailgun">Mailgun</a>, <a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.MicrosoftTeams">MicrosoftTeams</a>, +<a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.SMTP">SMTP</a>, <a href="#github.com%2fjenkinsci%2fkubernetes-operator%2fpkg%2fapis%2fjenkins%2fv1alpha2.Slack">Slack</a>) </p> <p> @@ -2622,7 +2838,7 @@ string </em> </td> <td> -<p>Targets is the repository path where the seed job definitions are</p> +<p>Targets is the repository path where are seed job definitions</p> </td> </tr> <tr> @@ -2633,7 +2849,7 @@ string </em> </td> <td> -<p>RepositoryBranch is the repository branch where the seed job definitions are</p> +<p>RepositoryBranch is the repository branch where are seed job definitions</p> </td> </tr> <tr> @@ -2830,7 +3046,7 @@ int32 </em> </td> <td> -<p>The port that is exposed by this service. +<p>The port that are exposed by this service. More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies">https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies</a></p> </td> </tr> @@ -2845,7 +3061,7 @@ int32 <em>(Optional)</em> <p>The port on each node on which this service is exposed when type=NodePort or LoadBalancer. Usually assigned by the system. If specified, it will be allocated to the service -if unused, or else creation of the service will fail. +if unused or else creation of the service will fail. Default is to auto-allocate a port if the ServiceType of this Service requires one. More info: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport">https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport</a></p> </td> @@ -2860,7 +3076,7 @@ More info: <a href="https://kubernetes.io/docs/concepts/services-networki <td> <em>(Optional)</em> <p>If specified and supported by the platform, this will restrict traffic through the cloud-provider -the load-balancer will be restricted to the specified client IPs. This field will be ignored if the +load-balancer will be restricted to the specified client IPs. This field will be ignored if the cloud-provider does not support the feature.&rdquo; More info: <a href="https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/">https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/</a></p> </td> @@ -2918,146 +3134,11 @@ SecretKeySelector <hr/> <p><em> Generated with <code>gen-crd-api-reference-docs</code> -on git commit <code>f4c4235</code>. +on git commit <code>b6e1057</code>. </em></p> - - - Docs: Developer Guide - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/developer-guide/ - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/developer-guide/ - - - - - - -<div class="pageinfo pageinfo-primary"> -<p>This document explains how to setup your development environment.</p> - -</div> - - -<h2 id="prerequisites">Prerequisites</h2> - -<ul> -<li><a href="https://github.com/operator-framework/operator-sdk" target="_blank">operator_sdk</a> version v0.8.1</li> -<li><a href="https://git-scm.com/downloads" target="_blank">git</a></li> -<li><a href="https://golang.org/dl/" target="_blank">go</a> version v1.12+</li> -<li><a href="install_dev_tools.md" target="_blank">goimports, golint, checkmake and staticcheck</a></li> -<li><a href="https://kubernetes.io/docs/tasks/tools/install-minikube/" target="_blank">minikube</a> version v1.1.0+ (preferred Hypervisor - <a href="https://www.virtualbox.org/wiki/Downloads" target="_blank">virtualbox</a>)</li> -<li><a href="https://docs.docker.com/install/" target="_blank">docker</a> version 17.03+</li> -</ul> - -<h2 id="clone-repository-and-download-dependencies">Clone repository and download dependencies</h2> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">mkdir -p <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci -<span style="color:#204a87">cd</span> <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci/ -git clone git@github.com:jenkinsci/kubernetes-operator.git -<span style="color:#204a87">cd</span> kubernetes-operator -make go-dependencies</code></pre></div> -<h2 id="build-and-run-with-a-minikube">Build and run with a minikube</h2> - -<p>Build and run <strong>Jenkins Operator</strong> locally:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build minikube-run <span style="color:#000">EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--minikube --local&#39;</span></code></pre></div> -<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml -kubectl get jenkins -o yaml -kubectl get po</code></pre></div> -<h2 id="build-and-run-with-a-remote-kubernetes-cluster">Build and run with a remote Kubernetes cluster</h2> - -<p>You can also run the controller locally and make it listen to a remote Kubernetes server.</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make run <span style="color:#000">NAMESPACE</span><span style="color:#ce5c00;font-weight:bold">=</span>default <span style="color:#000">KUBECTL_CONTEXT</span><span style="color:#ce5c00;font-weight:bold">=</span>remote-k8s <span style="color:#000">EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--kubeconfig ~/.kube/config&#39;</span></code></pre></div> -<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml -kubectl --context remote-k8s --namespace default get jenkins -o yaml -kubectl --context remote-k8s --namespace default get po</code></pre></div> -<h2 id="testing">Testing</h2> - -<p>Run unit tests:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make test</code></pre></div> -<h3 id="running-e2e-tests-on-linux">Running E2E tests on Linux</h3> - -<p>Run e2e tests with minikube:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make minikube-start -<span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> -make build e2e</code></pre></div> -<p>Run the specific e2e test:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build e2e <span style="color:#000">E2E_TEST_SELECTOR</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;^TestConfiguration$&#39;</span></code></pre></div> -<h3 id="running-e2e-tests-on-macos">Running E2E tests on macOS</h3> - -<p>At first, you need to start minikube:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make minikube-start -$ <span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> </code></pre></div> -<p>Build a Docker image inside the provided Linux container by:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make indocker</code></pre></div> -<p>Build <strong>Jenkins Operator</strong> inside a container using:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make build</code></pre></div> -<p>Then exit the container and run:</p> - -<pre><code>make e2e -</code></pre> - -<h2 id="tips-tricks">Tips &amp; Tricks</h2> - -<h3 id="building-docker-image-on-minikube-for-e2e-tests">Building docker image on minikube (for e2e tests)</h3> - -<p>To be able to work with the docker daemon on <code>minikube</code> machine run the following command before building an image:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span></code></pre></div> -<h3 id="when-pkg-apis-jenkinsio-jenkins-types-go-has-changed">When <code>pkg/apis/jenkinsio/*/jenkins_types.go</code> has changed</h3> - -<p>Run:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make deepcopy-gen</code></pre></div> -<h3 id="getting-the-jenkins-url-and-basic-credentials">Getting the Jenkins URL and basic credentials</h3> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">minikube service jenkins-operator-http-&lt;cr_name&gt; --url -kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.user}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d -kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.password}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d</code></pre></div> -<h1 id="tools">Tools</h1> - -<h2 id="configure-environment-variables">Configure environment variables</h2> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">export</span> <span style="color:#000">GOPATH</span><span style="color:#ce5c00;font-weight:bold">=</span>/home/go <span style="color:#8f5902;font-style:italic"># example value</span> -<span style="color:#204a87">export</span> <span style="color:#000">GOROOT</span><span style="color:#ce5c00;font-weight:bold">=</span>/usr/lib/go-1.12 <span style="color:#8f5902;font-style:italic"># example value</span> -<span style="color:#204a87">export</span> <span style="color:#000">PATH</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#000">$GOPATH</span>/bin:<span style="color:#000">$PATH</span></code></pre></div> -<h2 id="goimports">goimports</h2> - -<pre><code>go get golang.org/x/tools/cmd/goimports -cd $GOPATH/src/golang.org/x/tools/cmd/goimports -go build -go install -</code></pre> - -<h2 id="golint">golint</h2> - -<pre><code>go get -u golang.org/x/lint/golint -cd $GOPATH/src/golang.org/x/lint/golint -go build -go install -</code></pre> - -<h2 id="checkmake">checkmake</h2> - -<pre><code>go get github.com/mrtazz/checkmake -cd $GOPATH/src/github.com/mrtazz/checkmake -go build -go install -</code></pre> - -<h2 id="staticcheck">staticcheck</h2> - -<pre><code>mkdir -p $GOPATH/src/github.com/dominikh/ -cd $GOPATH/src/github.com/dominikh/ -git clone https://github.com/dominikh/go-tools.git -cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck -go build -go install -</code></pre> - - - - \ No newline at end of file diff --git a/docs/docs/getting-started/v0.1.x/index.xml b/docs/docs/getting-started/v0.1.x/index.xml index 6b35a5a1..e5fb9ea8 100644 --- a/docs/docs/getting-started/v0.1.x/index.xml +++ b/docs/docs/getting-started/v0.1.x/index.xml @@ -2368,141 +2368,6 @@ Code that defines the data structures can be found <a href="v0.1.1/jenkin or use the default deployment manifest:</p> <pre><code>$ kubectl -n &lt;namespace&gt; apply -f https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/master/deploy/operator.yaml -</code></pre> - - - - - - Docs: Developer Guide - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/developer-guide/ - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/developer-guide/ - - - - - - - -<div class="pageinfo pageinfo-primary"> -<p>This document explains how to setup your development environment.</p> - -</div> - - -<h2 id="prerequisites">Prerequisites</h2> - -<ul> -<li><a href="https://github.com/operator-framework/operator-sdk" target="_blank">operator_sdk</a> version v0.8.1</li> -<li><a href="https://git-scm.com/downloads" target="_blank">git</a></li> -<li><a href="https://golang.org/dl/" target="_blank">go</a> version v1.12+</li> -<li><a href="install_dev_tools.md" target="_blank">goimports, golint, checkmake and staticcheck</a></li> -<li><a href="https://kubernetes.io/docs/tasks/tools/install-minikube/" target="_blank">minikube</a> version v1.1.0+ (preferred Hypervisor - <a href="https://www.virtualbox.org/wiki/Downloads" target="_blank">virtualbox</a>)</li> -<li><a href="https://docs.docker.com/install/" target="_blank">docker</a> version 17.03+</li> -</ul> - -<h2 id="clone-repository-and-download-dependencies">Clone repository and download dependencies</h2> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">mkdir -p <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci -<span style="color:#204a87">cd</span> <span style="color:#000">$GOPATH</span>/src/github.com/jenkinsci/ -git clone git@github.com:jenkinsci/kubernetes-operator.git -<span style="color:#204a87">cd</span> kubernetes-operator -make go-dependencies</code></pre></div> -<h2 id="build-and-run-with-a-minikube">Build and run with a minikube</h2> - -<p>Build and run <strong>Jenkins Operator</strong> locally:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build minikube-run <span style="color:#000">EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--minikube --local&#39;</span></code></pre></div> -<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml -kubectl get jenkins -o yaml -kubectl get po</code></pre></div> -<h2 id="build-and-run-with-a-remote-kubernetes-cluster">Build and run with a remote Kubernetes cluster</h2> - -<p>You can also run the controller locally and make it listen to a remote Kubernetes server.</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make run <span style="color:#000">NAMESPACE</span><span style="color:#ce5c00;font-weight:bold">=</span>default <span style="color:#000">KUBECTL_CONTEXT</span><span style="color:#ce5c00;font-weight:bold">=</span>remote-k8s <span style="color:#000">EXTRA_ARGS</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;--kubeconfig ~/.kube/config&#39;</span></code></pre></div> -<p>Once minikube and <strong>Jenkins Operator</strong> are up and running, apply Jenkins custom resource:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml -kubectl --context remote-k8s --namespace default get jenkins -o yaml -kubectl --context remote-k8s --namespace default get po</code></pre></div> -<h2 id="testing">Testing</h2> - -<p>Run unit tests:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make test</code></pre></div> -<h3 id="running-e2e-tests-on-linux">Running E2E tests on Linux</h3> - -<p>Run e2e tests with minikube:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make minikube-start -<span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> -make build e2e</code></pre></div> -<p>Run the specific e2e test:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make build e2e <span style="color:#000">E2E_TEST_SELECTOR</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;^TestConfiguration$&#39;</span></code></pre></div> -<h3 id="running-e2e-tests-on-macos">Running E2E tests on macOS</h3> - -<p>At first, you need to start minikube:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make minikube-start -$ <span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span> </code></pre></div> -<p>Build a Docker image inside the provided Linux container by:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make indocker</code></pre></div> -<p>Build <strong>Jenkins Operator</strong> inside a container using:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ make build</code></pre></div> -<p>Then exit the container and run:</p> - -<pre><code>make e2e -</code></pre> - -<h2 id="tips-tricks">Tips &amp; Tricks</h2> - -<h3 id="building-docker-image-on-minikube-for-e2e-tests">Building docker image on minikube (for e2e tests)</h3> - -<p>To be able to work with the docker daemon on <code>minikube</code> machine run the following command before building an image:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">eval</span> <span style="color:#204a87;font-weight:bold">$(</span>minikube docker-env<span style="color:#204a87;font-weight:bold">)</span></code></pre></div> -<h3 id="when-pkg-apis-jenkinsio-jenkins-types-go-has-changed">When <code>pkg/apis/jenkinsio/*/jenkins_types.go</code> has changed</h3> - -<p>Run:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">make deepcopy-gen</code></pre></div> -<h3 id="getting-the-jenkins-url-and-basic-credentials">Getting the Jenkins URL and basic credentials</h3> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">minikube service jenkins-operator-http-&lt;cr_name&gt; --url -kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.user}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d -kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <span style="color:#4e9a06">&#39;jsonpath={.data.password}&#39;</span> <span style="color:#000;font-weight:bold">|</span> base64 -d</code></pre></div> -<h1 id="tools">Tools</h1> - -<h2 id="configure-environment-variables">Configure environment variables</h2> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#204a87">export</span> <span style="color:#000">GOPATH</span><span style="color:#ce5c00;font-weight:bold">=</span>/home/go <span style="color:#8f5902;font-style:italic"># example value</span> -<span style="color:#204a87">export</span> <span style="color:#000">GOROOT</span><span style="color:#ce5c00;font-weight:bold">=</span>/usr/lib/go-1.12 <span style="color:#8f5902;font-style:italic"># example value</span> -<span style="color:#204a87">export</span> <span style="color:#000">PATH</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#000">$GOPATH</span>/bin:<span style="color:#000">$PATH</span></code></pre></div> -<h2 id="goimports">goimports</h2> - -<pre><code>go get golang.org/x/tools/cmd/goimports -cd $GOPATH/src/golang.org/x/tools/cmd/goimports -go build -go install -</code></pre> - -<h2 id="golint">golint</h2> - -<pre><code>go get -u golang.org/x/lint/golint -cd $GOPATH/src/golang.org/x/lint/golint -go build -go install -</code></pre> - -<h2 id="checkmake">checkmake</h2> - -<pre><code>go get github.com/mrtazz/checkmake -cd $GOPATH/src/github.com/mrtazz/checkmake -go build -go install -</code></pre> - -<h2 id="staticcheck">staticcheck</h2> - -<pre><code>mkdir -p $GOPATH/src/github.com/dominikh/ -cd $GOPATH/src/github.com/dominikh/ -git clone https://github.com/dominikh/go-tools.git -cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck -go build -go install </code></pre> diff --git a/website/content/en/docs/Getting Started/v0.1.x/developer-guide.md b/website/content/en/docs/Developer Guide/_index.md similarity index 82% rename from website/content/en/docs/Getting Started/v0.1.x/developer-guide.md rename to website/content/en/docs/Developer Guide/_index.md index 056f54ac..20541c88 100644 --- a/website/content/en/docs/Getting Started/v0.1.x/developer-guide.md +++ b/website/content/en/docs/Developer Guide/_index.md @@ -137,54 +137,6 @@ kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.us kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.password}' | base64 -d ``` -# Tools - -## Configure environment variables - -```bash -export GOPATH=/home/go # example value -export GOROOT=/usr/lib/go-1.12 # example value -export PATH=$GOPATH/bin:$PATH -``` - -## goimports - -``` -go get golang.org/x/tools/cmd/goimports -cd $GOPATH/src/golang.org/x/tools/cmd/goimports -go build -go install -``` - -## golint - -``` -go get -u golang.org/x/lint/golint -cd $GOPATH/src/golang.org/x/lint/golint -go build -go install -``` - -## checkmake -``` -go get github.com/mrtazz/checkmake -cd $GOPATH/src/github.com/mrtazz/checkmake -go build -go install -``` - -## staticcheck - -``` -mkdir -p $GOPATH/src/github.com/dominikh/ -cd $GOPATH/src/github.com/dominikh/ -git clone https://github.com/dominikh/go-tools.git -cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck -go build -go install -``` - - [dep_tool]:https://golang.github.io/dep/docs/installation.html [git_tool]:https://git-scm.com/downloads [go_tool]:https://golang.org/dl/ diff --git a/website/content/en/docs/Developer Guide/tools.md b/website/content/en/docs/Developer Guide/tools.md new file mode 100644 index 00000000..95285d80 --- /dev/null +++ b/website/content/en/docs/Developer Guide/tools.md @@ -0,0 +1,57 @@ +--- +title: "Tools" +linkTitle: "Tools" +weight: 30 +date: 2019-08-05 +description: > + Required tools for building and running Jenkins Operator +--- + +{{% pageinfo %}} +This document explains how to install the Go tools used by the development process. +{{% /pageinfo %}} + +## Configure environment variables + +```bash +export GOPATH=/home/go # example value +export GOROOT=/usr/lib/go-1.12 # example value +export PATH=$GOPATH/bin:$PATH +``` + +## goimports + +``` +go get golang.org/x/tools/cmd/goimports +cd $GOPATH/src/golang.org/x/tools/cmd/goimports +go build +go install +``` + +## golint + +``` +go get -u golang.org/x/lint/golint +cd $GOPATH/src/golang.org/x/lint/golint +go build +go install +``` + +## checkmake +``` +go get github.com/mrtazz/checkmake +cd $GOPATH/src/github.com/mrtazz/checkmake +go build +go install +``` + +## staticcheck + +``` +mkdir -p $GOPATH/src/github.com/dominikh/ +cd $GOPATH/src/github.com/dominikh/ +git clone https://github.com/dominikh/go-tools.git +cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck +go build +go install +``` diff --git a/website/content/en/docs/Getting Started/future/_index.md b/website/content/en/docs/Getting Started/future/_index.md deleted file mode 100644 index 4cddd338..00000000 --- a/website/content/en/docs/Getting Started/future/_index.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: "Future (v0.3.x)" -linkTitle: "Future (v0.3.x)" -weight: 10 -date: 2019-08-05 -description: > - How to work with jenkins-operator latest version ---- - -{{% pageinfo %}} -This document describes a getting started guide for **Jenkins Operator** `v0.3.x` and an additional configuration. -{{% /pageinfo %}} - -## First Steps - -Prepare your Kubernetes cluster and set up your `kubectl` access. - -Once you have running Kubernetes cluster you can focus on installing **Jenkins Operator** according to the [Installation](/docs/installation/) guide. diff --git a/website/content/en/docs/Getting Started/future/aks.md b/website/content/en/docs/Getting Started/future/aks.md deleted file mode 100644 index 7eab9a40..00000000 --- a/website/content/en/docs/Getting Started/future/aks.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: "AKS" -linkTitle: "AKS" -weight: 10 -date: 2019-08-05 -description: > - Additional configuration for Azure Kubernetes Service ---- - -Azure AKS managed Kubernetes service adds to every pod the following environment variables: - -```yaml -- name: KUBERNETES_PORT_443_TCP_ADDR - value: -- name: KUBERNETES_PORT - value: tcp:// -- name: KUBERNETES_PORT_443_TCP - value: tcp:// -- name: KUBERNETES_SERVICE_HOST - value: -``` - -The operator is aware of it and omits these environment variables when checking if a Jenkins pod environment has been changed. It prevents the -restart of a Jenkins pod over and over again. \ No newline at end of file diff --git a/website/content/en/docs/Getting Started/future/configuration.md b/website/content/en/docs/Getting Started/future/configuration.md deleted file mode 100644 index ef8086b1..00000000 --- a/website/content/en/docs/Getting Started/future/configuration.md +++ /dev/null @@ -1,325 +0,0 @@ ---- -title: "Configuration" -linkTitle: "Configuration" -weight: 2 -date: 2019-08-05 -description: > - How to configure Jenkins with Operator ---- - -## Configure Seed Jobs and Pipelines - -Jenkins operator uses [job-dsl][job-dsl] and [kubernetes-credentials-provider][kubernetes-credentials-provider] plugins for configuring jobs -and deploy keys. - -## Prepare job definitions and pipelines - -First you have to prepare pipelines and job definition in your GitHub repository using the following structure: - -``` -cicd/ -├── jobs -│   └── build.jenkins -└── pipelines - └── build.jenkins -``` - -**`cicd/jobs/build.jenkins`** is a job definition: - -``` -#!/usr/bin/env groovy - -pipelineJob('build-jenkins-operator') { - displayName('Build jenkins-operator') - - definition { - cpsScm { - scm { - git { - remote { - url('https://github.com/jenkinsci/kubernetes-operator.git') - credentials('jenkins-operator') - } - branches('*/master') - } - } - scriptPath('cicd/pipelines/build.jenkins') - } - } -} -``` - -**`cicd/pipelines/build.jenkins`** is an actual Jenkins pipeline: - -``` -#!/usr/bin/env groovy - -def label = "build-jenkins-operator-${UUID.randomUUID().toString()}" -def home = "/home/jenkins" -def workspace = "${home}/workspace/build-jenkins-operator" -def workdir = "${workspace}/src/github.com/jenkinsci/kubernetes-operator/" - -podTemplate(label: label, - containers: [ - containerTemplate(name: 'jnlp', image: 'jenkins/jnlp-slave:alpine'), - containerTemplate(name: 'go', image: 'golang:1-alpine', command: 'cat', ttyEnabled: true), - ], - envVars: [ - envVar(key: 'GOPATH', value: workspace), - ], - ) { - - node(label) { - dir(workdir) { - stage('Init') { - timeout(time: 3, unit: 'MINUTES') { - checkout scm - } - container('go') { - sh 'apk --no-cache --update add make git gcc libc-dev' - } - } - - stage('Dep') { - container('go') { - sh 'make dep' - } - } - - stage('Test') { - container('go') { - sh 'make test' - } - } - - stage('Build') { - container('go') { - sh 'make build' - } - } - } - } -} -``` - -## Configure Seed Jobs - -Jenkins Seed Jobs are configured using `Jenkins.spec.seedJobs` section from your custom resource manifest: - -``` -apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - seedJobs: - - id: jenkins-operator - targets: "cicd/jobs/*.jenkins" - description: "Jenkins Operator repository" - repositoryBranch: master - repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git -``` - -**Jenkins Operator** will automatically discover and configure all the seed jobs. - -You can verify if deploy keys were successfully configured in the Jenkins **Credentials** tab. - -![jenkins](/kubernetes-operator/img/jenkins-credentials.png) - -You can verify if your pipelines were successfully configured in the Jenkins Seed Job console output. - -![jenkins](/kubernetes-operator/img/jenkins-seed.png) - -If your GitHub repository is **private** you have to configure SSH or username/password authentication. - -### SSH authentication - -#### Generate SSH Keys - -There are two methods of SSH private key generation: - -```bash -$ openssl genrsa -out 2048 -``` - -or - -```bash -$ ssh-keygen -t rsa -b 2048 -$ ssh-keygen -p -f -m pem -``` - -Then copy content from generated file. - -#### Public key - -If you want to upload your public key to your Git server you need to extract it. - -If key was generated by `openssl` then you need to type this to extract public key: - -```bash -$ openssl rsa -in -pubout > .pub -``` - -If key was generated by `ssh-keygen` the public key content is located in .pub and there is no need to extract public key - -#### Configure SSH authentication - -Configure a seed job like this: - -``` -apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - seedJobs: - - id: jenkins-operator-ssh - credentialType: basicSSHUserPrivateKey - credentialID: k8s-ssh - targets: "cicd/jobs/*.jenkins" - description: "Jenkins Operator repository" - repositoryBranch: master - repositoryUrl: git@github.com:jenkinsci/kubernetes-operator.git -``` - -and create a Kubernetes Secret (name of secret should be the same from `credentialID` field): - -``` -apiVersion: v1 -kind: Secret -metadata: - name: k8s-ssh -stringData: - privateKey: | - -----BEGIN RSA PRIVATE KEY----- - MIIJKAIBAAKCAgEAxxDpleJjMCN5nusfW/AtBAZhx8UVVlhhhIKXvQ+dFODQIdzO - oDXybs1zVHWOj31zqbbJnsfsVZ9Uf3p9k6xpJ3WFY9b85WasqTDN1xmSd6swD4N8 - ... - username: github_user_name -``` - -### Username & password authentication - -Configure the seed job like: - -``` -apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - seedJobs: - - id: jenkins-operator-user-pass - credentialType: usernamePassword - credentialID: k8s-user-pass - targets: "cicd/jobs/*.jenkins" - description: "Jenkins Operator repository" - repositoryBranch: master - repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git -``` - -and create a Kubernetes Secret (name of secret should be the same from `credentialID` field): - -``` -apiVersion: v1 -kind: Secret -metadata: - name: k8s-user-pass -stringData: - username: github_user_name - password: password_or_token -``` - -## HTTP Proxy for downloading plugins - -To use forwarding proxy with an operator to download plugins you need to add the following environment variable to Jenkins Custom Resource (CR), e.g.: - -```yaml -spec: - master: - containers: - - name: jenkins-master - env: - - name: CURL_OPTIONS - value: -L -x -``` - -In `CURL_OPTIONS` var you can set additional arguments to `curl` command. - -## Pulling Docker images from private repositories - -To pull a Docker Image from private repository you can use `imagePullSecrets`. - -Please follow the instructions on [creating a secret with a docker config](https://kubernetes.io/docs/concepts/containers/images/?origin_team=T42NTAGHM#creating-a-secret-with-a-docker-config). - -### Docker Hub Configuration -To use Docker Hub additional steps are required. - -Edit the previously created secret: -```bash -kubectl -n edit secret -``` - -The `.dockerconfigjson` key's value needs to be replaced with a modified version. - -After modifications, it needs to be encoded as a Base64 value before setting the `.dockerconfigjson` key. - -Example config file to modify and use: -``` -{ - "auths":{ - "https://index.docker.io/v1/":{ - "username":"user", - "password":"password", - "email":"yourdockeremail@gmail.com", - "auth":"base64 of string user:password" - }, - "auth.docker.io":{ - "username":"user", - "password":"password", - "email":"yourdockeremail@gmail.com", - "auth":"base64 of string user:password" - }, - "registry.docker.io":{ - "username":"user", - "password":"password", - "email":"yourdockeremail@gmail.com", - "auth":"base64 of string user:password" - }, - "docker.io":{ - "username":"user", - "password":"password", - "email":"yourdockeremail@gmail.com", - "auth":"base64 of string user:password" - }, - "https://registry-1.docker.io/v2/": { - "username":"user", - "password":"password", - "email":"yourdockeremail@gmail.com", - "auth":"base64 of string user:password" - }, - "registry-1.docker.io/v2/": { - "username":"user", - "password":"password", - "email":"yourdockeremail@gmail.com", - "auth":"base64 of string user:password" - }, - "registry-1.docker.io": { - "username":"user", - "password":"password", - "email":"yourdockeremail@gmail.com", - "auth":"base64 of string user:password" - }, - "https://registry-1.docker.io": { - "username":"user", - "password":"password", - "email":"yourdockeremail@gmail.com", - "auth":"base64 of string user:password" - } - } -} -``` - -[job-dsl]:https://github.com/jenkinsci/job-dsl-plugin -[kubernetes-credentials-provider]:https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/ diff --git a/website/content/en/docs/Getting Started/future/configure-backup-and-restore.md b/website/content/en/docs/Getting Started/future/configure-backup-and-restore.md deleted file mode 100644 index c8987e0e..00000000 --- a/website/content/en/docs/Getting Started/future/configure-backup-and-restore.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -title: "Configure backup and restore" -linkTitle: "Configure backup and restore" -weight: 10 -date: 2019-08-05 -description: > - Prevent loss of job history ---- - -Backup and restore is done by a container sidecar. - -### PVC - -#### Create PVC - -Save to the file named pvc.yaml: -```yaml -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: - namespace: -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 500Gi -``` - -Run the following command: -```bash -$ kubectl -n create -f pvc.yaml -``` - -#### Configure Jenkins CR - -```yaml -apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: - namespace: -spec: - master: - securityContext: - runAsUser: 1000 - fsGroup: 1000 - containers: - - name: jenkins-master - image: jenkins/jenkins:lts - - name: backup # container responsible for the backup and restore - env: - - name: BACKUP_DIR - value: /backup - - name: JENKINS_HOME - value: /jenkins-home - - name: BACKUP_COUNT - value: "3" # keep only the 2 most recent backups - image: virtuslab/jenkins-operator-backup-pvc:v0.0.7 # look at backup/pvc directory - imagePullPolicy: IfNotPresent - volumeMounts: - - mountPath: /jenkins-home # Jenkins home volume - name: jenkins-home - - mountPath: /backup # backup volume - name: backup - volumes: - - name: backup # PVC volume where backups will be stored - persistentVolumeClaim: - claimName: - backup: - containerName: backup # container name is responsible for backup - action: - exec: - command: - - /home/user/bin/backup.sh # this command is invoked on "backup" container to make backup, for example /home/user/bin/backup.sh , is passed by operator - interval: 30 # how often make backup in seconds - makeBackupBeforePodDeletion: true # make a backup before pod deletion - restore: - containerName: backup # container name is responsible for restore backup - action: - exec: - command: - - /home/user/bin/restore.sh # this command is invoked on "backup" container to make restore backup, for example /home/user/bin/restore.sh , is passed by operator - #recoveryOnce: # if want to restore specific backup configure this field and then Jenkins will be restarted and desired backup will be restored -``` diff --git a/website/content/en/docs/Getting Started/future/custom-backup-and-restore.md b/website/content/en/docs/Getting Started/future/custom-backup-and-restore.md deleted file mode 100644 index cc927599..00000000 --- a/website/content/en/docs/Getting Started/future/custom-backup-and-restore.md +++ /dev/null @@ -1,184 +0,0 @@ ---- -title: "Custom Backup and Restore Providers" -linkTitle: "Custom Backup and Restore Providers" -weight: 10 -date: 2019-08-05 -description: > - Custom backup and restore provider ---- - -With enough effort one can create a custom backup and restore provider -for the Jenkins Operator. - -## Requirements - -Two commands (e.g. scripts) are required: - -- a backup command, e.g. `backup.sh` that takes one argument, a **backup number** -- a restore command, e.g. `backup.sh` that takes one argument, a **backup number** - -Both scripts need to return an exit code of `0` on success and `1` or greater for failure. - -One of those scripts (or the entry point of the container) needs to be responsible -for backup cleanup or rotation if required, or an external system. - -## How it works - -The mechanism relies on basic Kubernetes and UNIX functionalities. - -The backup (and restore) container runs as a sidecar in the same -Kubernetes pod as the Jenkins master. - -Name of the backup and restore containers can be set as necessary using -`spec.backup.containerName` and `spec.restore.containerName`. -In most cases it will be the same container, but we allow for less common use cases. - -The operator will call a backup or restore commands inside a sidecar container when necessary: - -- backup command (defined in `spec.backup.action.exec.command`) - will be called every `N` seconds configurable in: `spec.backup.interval` - and on pod shutdown (if enabled in `spec.backup.makeBackupBeforePodDeletion`) - with an integer representing the current backup number as first and only argument -- restore command (defined in `spec.restore.action.exec.command`) - will be called at Jenkins startup - with an integer representing the backup number to restore as first and only argument - (can be overridden using `spec.restore.recoveryOnce`) - -## Example AWS S3 backup using the CLI - -This example shows abbreviated version of a simple AWS S3 backup implementation -using: `aws-cli`, `bash` and `kube2iam`. - -In addition to your normal `Jenkins` `CustomResource` some additional settings -for backup and restore are required, e.g.: - -```yaml -kind: Jenkins -apiVersion: jenkins.io/v1alpha1 -metadata: - name: example - namespace: jenkins -spec: - master: - masterAnnotations: - iam.amazonaws.com/role: "my-example-backup-role" # tell kube2iam where the AWS IAM role is - containers: - - name: jenkins-master - ... - - name: backup # container responsible for backup and restore - image: quay.io/virtuslab/aws-cli:1.16.263-2 - workingDir: /home/user/bin/ - command: # our container entry point - - sleep - - infinity - env: - - name: BACKUP_BUCKET - value: my-example-bucket # the S3 bucket name to use - - name: BACKUP_PATH - value: my-backup-path # the S3 bucket path prefix to use - - name: JENKINS_HOME - value: /jenkins-home # the path to mount jenkins home dir in the backup container - volumeMounts: - - mountPath: /jenkins-home # Jenkins home volume - name: jenkins-home - - mountPath: /home/user/bin/backup.sh - name: backup-scripts - subPath: backup.sh - readOnly: true - - mountPath: /home/user/bin/restore.sh - name: backup-scripts - subPath: restore.sh - readOnly: true - volumes: - - name: backup-scripts - configMap: - defaultMode: 0754 - name: jenkins-operator-backup-s3 - securityContext: # make sure both containers use the same UID and GUID - runAsUser: 1000 - fsGroup: 1000 - ... - backup: - containerName: backup # container name responsible for backup - interval: 3600 # how often make a backup in seconds - makeBackupBeforePodDeletion: true # trigger backup just before deleting the pod - action: - exec: - command: - # this command is invoked on "backup" container to create a backup, - # is passed by operator, - # for example /home/user/bin/backup.sh - - /home/user/bin/backup.sh - restore: - containerName: backup # container name is responsible for restore backup - action: - exec: - command: - # this command is invoked on "backup" container to restore a backup, - # is passed by operator - # for example /home/user/bin/restore.sh - - /home/user/bin/restore.sh -# recoveryOnce: # if want to restore specific backup configure this field and then Jenkins will be restarted and desired backup will be restored -``` - -The actual backup and restore scripts will be provided in a `ConfigMap`: - -```yaml -kind: ConfigMap -apiVersion: v1 -metadata: - name: jenkins-operator-backup-s3 - namespace: jenkins - labels: - app: jenkins-operator -data: - backup.sh: |- - #!/bin/bash -xeu - [[ ! $# -eq 1 ]] && echo "Usage: $0 backup_number" && exit 1; - [[ -z "${BACKUP_BUCKET}" ]] && echo "Required 'BACKUP_BUCKET' env not set" && exit 1; - [[ -z "${BACKUP_PATH}" ]] && echo "Required 'BACKUP_PATH' env not set" && exit 1; - [[ -z "${JENKINS_HOME}" ]] && echo "Required 'JENKINS_HOME' env not set" && exit 1; - - backup_number=$1 - echo "Running backup #${backup_number}" - - BACKUP_TMP_DIR=$(mktemp -d) - tar -C ${JENKINS_HOME} -czf "${BACKUP_TMP_DIR}/${backup_number}.tar.gz" --exclude jobs/*/workspace* -c jobs && \ - - aws s3 cp ${BACKUP_TMP_DIR}/${backup_number}.tar.gz s3://${BACKUP_BUCKET}/${BACKUP_PATH}/${backup_number}.tar.gz - echo Done - - restore.sh: |- - #!/bin/bash -xeu - [[ ! $# -eq 1 ]] && echo "Usage: $0 backup_number" && exit 1 - [[ -z "${BACKUP_BUCKET}" ]] && echo "Required 'BACKUP_BUCKET' env not set" && exit 1; - [[ -z "${BACKUP_PATH}" ]] && echo "Required 'BACKUP_PATH' env not set" && exit 1; - [[ -z "${JENKINS_HOME}" ]] && echo "Required 'JENKINS_HOME' env not set" && exit 1; - - backup_number=$1 - echo "Running restore #${backup_number}" - - BACKUP_TMP_DIR=$(mktemp -d) - aws s3 cp s3://${BACKUP_BUCKET}/${BACKUP_PATH}/${backup_number}.tar.gz ${BACKUP_TMP_DIR}/${backup_number}.tar.gz - - tar -C ${JENKINS_HOME} -zxf "${BACKUP_TMP_DIR}/${backup_number}.tar.gz" - echo Done -``` - -In our example we will use S3 bucket lifecycle policy to keep -the number of backups under control, e.g. Cloud Formation fragment: -```yaml - Type: AWS::S3::Bucket - Properties: - BucketName: my-example-bucket - ... - LifecycleConfiguration: - Rules: - - Id: BackupCleanup - Status: Enabled - Prefix: my-backup-path - ExpirationInDays: 7 - NoncurrentVersionExpirationInDays: 14 - AbortIncompleteMultipartUpload: - DaysAfterInitiation: 3 -``` diff --git a/website/content/en/docs/Getting Started/future/customization.md b/website/content/en/docs/Getting Started/future/customization.md deleted file mode 100644 index 7d953c71..00000000 --- a/website/content/en/docs/Getting Started/future/customization.md +++ /dev/null @@ -1,186 +0,0 @@ ---- -title: "Customization" -linkTitle: "Customization" -weight: 3 -date: 2019-08-05 -description: > - How to customize Jenkins ---- - -Jenkins can be customized using groovy scripts or the [configuration as code plugin](https://github.com/jenkinsci/configuration-as-code-plugin). -By using a [ConfigMap](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/) you can create your own **Jenkins** customized configuration. -Then you must reference the **`ConfigMap`** in the **Jenkins** pod customization file in `spec.groovyScripts` or `spec.configurationAsCode` - -For example create a **`ConfigMap`** with name `jenkins-operator-user-configuration`. Then, modify the **Jenkins** manifest to look like this: - -```yaml -apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - configurationAsCode: - configurations: - - name: jenkins-operator-user-configuration - groovyScripts: - configurations: - - name: jenkins-operator-user-configuration -``` - -Here is an example of `jenkins-operator-user-configuration`: -```yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: jenkins-operator-user-configuration -data: - 1-configure-theme.groovy: | - import jenkins.* - import jenkins.model.* - import hudson.* - import hudson.model.* - import org.jenkinsci.plugins.simpletheme.ThemeElement - import org.jenkinsci.plugins.simpletheme.CssTextThemeElement - import org.jenkinsci.plugins.simpletheme.CssUrlThemeElement - - Jenkins jenkins = Jenkins.getInstance() - - def decorator = Jenkins.instance.getDescriptorByType(org.codefirst.SimpleThemeDecorator.class) - - List configElements = new ArrayList<>(); - configElements.add(new CssTextThemeElement("DEFAULT")); - configElements.add(new CssUrlThemeElement("https://cdn.rawgit.com/afonsof/jenkins-material-theme/gh-pages/dist/material-light-green.css")); - decorator.setElements(configElements); - decorator.save(); - - jenkins.save() - 1-system-message.yaml: | - jenkins: - systemMessage: "Configuration as Code integration works!!!" -``` - -* `*.groovy` is Groovy script configuration -* `*.yaml is` configuration as code - -If you want to correct your configuration you can edit it while the **Jenkins Operator** is running. -Jenkins will reconcile and apply the new configuration. - -### Using secrets from a Groovy script - -If you configured `spec.groovyScripts.secret.name`, then this secret is available to use from map Groovy scripts. -The secrets are loaded to `secrets` map. - -Create a [secret](https://kubernetes.io/docs/concepts/configuration/secret/) with for example the name `jenkins-conf-secrets`. - -```yaml -kind: Secret -apiVersion: v1 -type: Opaque -metadata: - name: jenkins-conf-secrets - namespace: default -data: - SYSTEM_MESSAGE: SGVsbG8gd29ybGQ= -``` - -Then modify the **Jenkins** pod manifest by changing `spec.groovyScripts.secret.name` to `jenkins-conf-secrets`. - -```yaml -apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - configurationAsCode: - configurations: - - name: jenkins-operator-user-configuration - secret: - name: jenkins-conf-secrets - groovyScripts: - configurations: - - name: jenkins-operator-user-configuration - secret: - name: jenkins-conf-secrets -``` - -Now you can test that the secret is mounted by applying this `ConfigMap` for Groovy script: - -```yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: jenkins-operator-user-configuration -data: - 1-system-message.groovy: | - import jenkins.* - import jenkins.model.* - import hudson.* - import hudson.model.* - Jenkins jenkins = Jenkins.getInstance() - - jenkins.setSystemMessage(secrets["SYSTEM_MESSAGE"]) - jenkins.save() -``` - -Or by applying this configuration as code: -```yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: jenkins-operator-user-configuration -data: - 1-system-message.yaml: | - jenkins: - systemMessage: ${SYSTEM_MESSAGE} -``` - - -After this, you should see the `Hello world` system message from the **Jenkins** homepage. - -## Install Plugins - -Edit Custom Resource under `spec.master.plugins`: - -``` -apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - master: - plugins: - - name: simple-theme-plugin - version: 0.5.1 -``` - -Under `spec.master.basePlugins` you can find plugins for a valid **Jenkins Operator**: - -```yaml -apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - master: - basePlugins: - - name: kubernetes - version: 1.18.3 - - name: workflow-job - version: "2.34" - - name: workflow-aggregator - version: "2.6" - - name: git - version: 3.12.0 - - name: job-dsl - version: "1.76" - - name: configuration-as-code - version: "1.29" - - name: configuration-as-code-support - version: "1.19" - - name: kubernetes-credentials-provider - version: 0.12.1 -``` - -You can change their versions. - -The **Jenkins Operator** will then automatically install plugins after the Jenkins master pod restarts. diff --git a/website/content/en/docs/Getting Started/future/deploy-jenkins.md b/website/content/en/docs/Getting Started/future/deploy-jenkins.md deleted file mode 100644 index 4f7b5a96..00000000 --- a/website/content/en/docs/Getting Started/future/deploy-jenkins.md +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: "Deploy Jenkins" -linkTitle: "Deploy Jenkins" -weight: 1 -date: 2019-08-05 -description: > - Deploy production ready Jenkins Operator manifest ---- - -Once Jenkins Operator is up and running let's deploy actual Jenkins instance. -Create manifest e.g. **`jenkins_instance.yaml`** with following data and save it on drive. - -```bash -apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - master: - containers: - - name: jenkins-master - image: jenkins/jenkins:lts - imagePullPolicy: Always - livenessProbe: - failureThreshold: 12 - httpGet: - path: /login - port: http - scheme: HTTP - initialDelaySeconds: 80 - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 5 - readinessProbe: - failureThreshold: 3 - httpGet: - path: /login - port: http - scheme: HTTP - initialDelaySeconds: 30 - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 1 - resources: - limits: - cpu: 1500m - memory: 3Gi - requests: - cpu: "1" - memory: 500Mi - seedJobs: - - id: jenkins-operator - targets: "cicd/jobs/*.jenkins" - description: "Jenkins Operator repository" - repositoryBranch: master - repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git -``` - -Deploy a Jenkins to Kubernetes: - -```bash -kubectl create -f jenkins_instance.yaml -``` -Watch the Jenkins instance being created: - -```bash -kubectl get pods -w -``` - -Get the Jenkins credentials: - -```bash -kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.user}' | base64 -d -kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.password}' | base64 -d -``` - -Connect to the Jenkins instance (minikube): - -```bash -minikube service jenkins-operator-http- --url -``` - -Connect to the Jenkins instance (actual Kubernetes cluster): - -```bash -kubectl port-forward jenkins- 8080:8080 -``` -Then open browser with address `http://localhost:8080`. -![jenkins](/img/jenkins.png) diff --git a/website/content/en/docs/Getting Started/future/developer-guide.md b/website/content/en/docs/Getting Started/future/developer-guide.md deleted file mode 100644 index 9d5c402c..00000000 --- a/website/content/en/docs/Getting Started/future/developer-guide.md +++ /dev/null @@ -1,227 +0,0 @@ ---- -title: "Developer Guide" -linkTitle: "Developer Guide" -weight: 60 -date: 2019-08-05 -description: > - Jenkins Operator for developers ---- - -{{% pageinfo %}} -This document explains how to setup your development environment. -{{% /pageinfo %}} - -## Prerequisites - -- [operator_sdk][operator_sdk] version v0.8.1 -- [git][git_tool] -- [go][go_tool] version v1.12+ -- [goimports, golint, checkmake and staticcheck][install_dev_tools] -- [minikube][minikube] version v1.1.0+ (preferred Hypervisor - [virtualbox][virtualbox]) -- [docker][docker_tool] version 17.03+ - -## Clone repository and download dependencies - -```bash -mkdir -p $GOPATH/src/github.com/jenkinsci -cd $GOPATH/src/github.com/jenkinsci/ -git clone git@github.com:jenkinsci/kubernetes-operator.git -cd kubernetes-operator -make go-dependencies -``` - -## Build and run with a minikube - -Build and run **Jenkins Operator** locally: - -```bash -make build minikube-run OPERATOR_EXTRA_ARGS='--jenkins-api-hostname=$(eval minikube ip) --jenkins-api-use-nodeport=true' -``` - -Once minikube and **Jenkins Operator** are up and running, apply Jenkins custom resource: - -```bash -kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml -kubectl get jenkins -o yaml -kubectl get po -``` - -## Build and run with a remote Kubernetes cluster - -You can also run the controller locally and make it listen to a remote Kubernetes server. - -```bash -make run NAMESPACE=default KUBECTL_CONTEXT=remote-k8s OPERATOR_EXTRA_ARGS='--kubeconfig ~/.kube/config' -``` - -Once minikube and **Jenkins Operator** are up and running, apply Jenkins custom resource: - -```bash -kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml -kubectl --context remote-k8s --namespace default get jenkins -o yaml -kubectl --context remote-k8s --namespace default get po -``` - -## Testing - -Run unit tests: - -```bash -make test -``` - -### Running E2E tests on Linux - -Run e2e tests with minikube: - -```bash -make minikube-start -eval $(minikube docker-env) -make build e2e config=config.minikube.env CONTAINER_RUNTIME=podman -``` - -`config.minikube.env` is the E2E test profile which provides all connection info to operator to run on minikube. - -Run the specific e2e test: - -```bash -make build e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.minikube.env CONTAINER_RUNTIME=podman -``` - -If you want to run E2E tests on CRC (Code Ready Containers by OpenShift), you should use `config.crc.env` profile instead of `config.minikube.env`. -If you have some trouble with `podman` (for example building) then check [how to use docker instead of podman](#using-docker-instead-of-podman). - - -### Running E2E tests on macOS - -At first, you need to start minikube: -```bash -$ make minikube-start -$ eval $(minikube docker-env) -``` - -Build a Docker image inside the provided Linux container by: -```bash -$ make indocker -``` - -Build **Jenkins Operator** inside a container using: - - -```bash -$ make build -``` - -Then exit the container and run: -``` -make e2e config=config.minikube.env -``` - -or using `crc` as cluster software: -``` -make e2e config=config.crc.env -``` - -### Using Docker instead of podman - -If you have trouble with building image using the `podman`, you can set additional flag `IMAGE_PULL_MODE` to pull image from the organization. - -At first, you need to edit `config.base.env` and change the `DOCKER_ORGANIZATION` to your [Docker Hub](https://hub.docker.com/) account/organization. -After this change the `IMAGE_PULL_MODE` to `remote`. It will setup the `Makefile` goal to pull Docker image from registry. -Then you need to pull image from your repository: - -```bash -$ make container-runtime-build container-runtime-snapshot-push -``` - -When image will be uploaded to repository, you can now write this command to run E2E tests: - -```bash -$ make e2e E2E_TEST_SELECTOR='^TestConfiguration$' config=config.crc.env -``` - -## Tips & Tricks - -### Building docker image on minikube (for e2e tests) - -To be able to work with the docker daemon on `minikube` machine run the following command before building an image: - -```bash -eval $(minikube docker-env) -``` - -### When `pkg/apis/jenkinsio/*/jenkins_types.go` has changed - -Run: - -```bash -make deepcopy-gen -``` - -### Getting the Jenkins URL and basic credentials - -```bash -minikube service jenkins-operator-http- --url -kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.user}' | base64 -d -kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.password}' | base64 -d -``` - -# Tools - -## Configure environment variables - -```bash -export GOPATH=/home/go # example value -export GOROOT=/usr/lib/go-1.12 # example value -export PATH=$GOPATH/bin:$PATH -``` - -## goimports - -``` -go get golang.org/x/tools/cmd/goimports -cd $GOPATH/src/golang.org/x/tools/cmd/goimports -go build -go install -``` - -## golint - -``` -go get -u golang.org/x/lint/golint -cd $GOPATH/src/golang.org/x/lint/golint -go build -go install -``` - -## checkmake -``` -go get github.com/mrtazz/checkmake -cd $GOPATH/src/github.com/mrtazz/checkmake -go build -go install -``` - -## staticcheck - -``` -mkdir -p $GOPATH/src/github.com/dominikh/ -cd $GOPATH/src/github.com/dominikh/ -git clone https://github.com/dominikh/go-tools.git -cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck -go build -go install -``` - - -[dep_tool]:https://golang.github.io/dep/docs/installation.html -[git_tool]:https://git-scm.com/downloads -[go_tool]:https://golang.org/dl/ -[operator_sdk]:https://github.com/operator-framework/operator-sdk -[fork_guide]:https://help.github.com/articles/fork-a-repo/ -[docker_tool]:https://docs.docker.com/install/ -[kubectl_tool]:https://kubernetes.io/docs/tasks/tools/install-kubectl/ -[minikube]:https://kubernetes.io/docs/tasks/tools/install-minikube/ -[virtualbox]:https://www.virtualbox.org/wiki/Downloads -[jenkins-operator]:../README.md -[install_dev_tools]:install_dev_tools.md diff --git a/website/content/en/docs/Getting Started/future/diagnostics.md b/website/content/en/docs/Getting Started/future/diagnostics.md deleted file mode 100644 index 87286adb..00000000 --- a/website/content/en/docs/Getting Started/future/diagnostics.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: "Diagnostics" -linkTitle: "Diagnostics" -weight: 40 -date: 2019-08-05 -description: > - How to deal with Jenkins Operator problems ---- - - -Turn on debug in **Jenkins Operator** deployment: - -```bash -sed -i 's|\(args:\).*|\1\ ["--debug"\]|' deploy/operator.yaml -kubectl apply -f deploy/operator.yaml -``` - -Watch Kubernetes events: - -```bash -kubectl get events --sort-by='{.lastTimestamp}' -``` - -Verify Jenkins master logs: - -```bash -kubectl logs -f jenkins- -``` - -Verify the `jenkins-operator` logs: - -```bash -kubectl logs deployment/jenkins-operator -``` - -## Troubleshooting - -Delete the Jenkins master pod and wait for the new one to come up: - -```bash -kubectl delete pod jenkins- -``` diff --git a/website/content/en/docs/Getting Started/future/schema.md b/website/content/en/docs/Getting Started/future/schema.md deleted file mode 100644 index 008414be..00000000 --- a/website/content/en/docs/Getting Started/future/schema.md +++ /dev/null @@ -1,1979 +0,0 @@ ---- -title: "Schema" -linkTitle: "Schema" -weight: 40 -date: 2019-08-05 -description: > - API Schema definitions for Jenkins CRD ---- - -{{% pageinfo %}} -This document contains API scheme for `jenkins-operator` Custom Resource Definition manifest -{{% /pageinfo %}} - -

    Packages:

    - -

    jenkins.io

    -

    -

    Package v1alpha2 contains the API Schema definitions for the jenkins.io v1alpha2 API group

    -

    -Resource Types: - -

    Jenkins -

    -

    -

    Jenkins is the Schema for the jenkins API

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -apiVersion
    -string
    - -jenkins.io/v1alpha2 - -
    -kind
    -string -
    Jenkins
    -metadata
    - - -Kubernetes meta/v1.ObjectMeta - - -
    -Refer to the Kubernetes API documentation for the fields of the -metadata field. -
    -spec
    - - -JenkinsSpec - - -
    -

    Spec defines the desired state of the Jenkins

    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -master
    - - -JenkinsMaster - - -
    -

    Master represents Jenkins master pod properties and Jenkins plugins. -Every single change here requires a pod restart.

    -
    -seedJobs
    - - -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob - - -
    -(Optional) -

    SeedJobs defines a list of Jenkins Seed Job configurations -More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines

    -
    -service
    - - -Service - - -
    -(Optional) -

    Service is the Kubernetes service of the Jenkins master HTTP pod -Defaults to : -port: 8080 -type: ClusterIP

    -
    -slaveService
    - - -Service - - -
    -(Optional) -

    Service is the Kubernetes service of the Jenkins slave pods -Defaults to : -port: 50000 -type: ClusterIP

    -
    -backup
    - - -Backup - - -
    -(Optional) -

    Backup defines the configuration of a Jenkins backup -More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

    -
    -restore
    - - -Restore - - -
    -(Optional) -

    Backup defines the configuration of a Jenkins backup restore -More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

    -
    -groovyScripts
    - - -GroovyScripts - - -
    -(Optional) -

    GroovyScripts defines the configuration of Jenkins customization via groovy scripts

    -
    -configurationAsCode
    - - -ConfigurationAsCode - - -
    -(Optional) -

    ConfigurationAsCode defines the configuration of Jenkins customization via the Configuration as Code Jenkins plugin

    -
    -
    -status
    - - -JenkinsStatus - - -
    -

    Status defines the observed state of Jenkins

    -
    -

    AppliedGroovyScript -

    -

    -(Appears on: -JenkinsStatus) -

    -

    -

    AppliedGroovyScript is the applied groovy script in Jenkins by the operator

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -configurationType
    - -string - -
    -

    ConfigurationType is the name of the configuration type(base-groovy, user-groovy, user-casc)

    -
    -source
    - -string - -
    -

    Source is the name of source where is located groovy script

    -
    -name
    - -string - -
    -

    Name is the name of the groovy script

    -
    -Hash
    - -string - -
    -

    Hash is the hash of the groovy script and secrets which it uses

    -
    -

    Backup -

    -

    -(Appears on: -JenkinsSpec) -

    -

    -

    Backup defines the configuration of a Jenkins backup

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -containerName
    - -string - -
    -

    ContainerName is the container name responsible for backup operation

    -
    -action
    - - -Handler - - -
    -

    Action defines the action which performs the backup in the backup container sidecar

    -
    -interval
    - -uint64 - -
    -

    Interval tells you how often the backup is made in seconds -Defaults to 30.

    -
    -makeBackupBeforePodDeletion
    - -bool - -
    -

    MakeBackupBeforePodDeletion tells the operator to make a backup before Jenkins master pod deletion

    -
    -

    ConfigMapRef -

    -

    -(Appears on: -Customization) -

    -

    -

    ConfigMapRef is the reference to Kubernetes ConfigMap

    -

    - - - - - - - - - - - - - -
    FieldDescription
    -name
    - -string - -
    -
    -

    ConfigurationAsCode -

    -

    -(Appears on: -JenkinsSpec) -

    -

    -

    ConfigurationAsCode defines configuration of Jenkins customization via the Configuration as Code Jenkins plugin

    -

    - - - - - - - - - - - - - -
    FieldDescription
    -Customization
    - - -Customization - - -
    -
    -

    Container -

    -

    -(Appears on: -JenkinsMaster) -

    -

    -

    Container defines the Kubernetes container attributes

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -name
    - -string - -
    -

    Name of the container specified as a DNS_LABEL. -Each container in a pod must have a unique name (DNS_LABEL).

    -
    -image
    - -string - -
    -

    Docker image name. -More info: https://kubernetes.io/docs/concepts/containers/images

    -
    -imagePullPolicy
    - - -Kubernetes core/v1.PullPolicy - - -
    -

    Image pull policy. -One of Always, Never, IfNotPresent. -Defaults to Always.

    -
    -resources
    - - -Kubernetes core/v1.ResourceRequirements - - -
    -

    Compute Resources required by this container. -More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/

    -
    -command
    - -[]string - -
    -(Optional) -

    Entrypoint array. Not executed within a shell. -The docker image’s ENTRYPOINT is used if this is not provided. -Variable references $(VAR_NAME) are expanded using the container’s environment. If a variable -cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax -can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, -regardless of whether the variable exists or not. -More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell

    -
    -args
    - -[]string - -
    -(Optional) -

    Arguments to the entrypoint. -The docker image’s CMD is used if this is not provided. -Variable references $(VAR_NAME) are expanded using the container’s environment. If a variable -cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax -can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, -regardless of whether the variable exists or not. -More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell

    -
    -workingDir
    - -string - -
    -(Optional) -

    Container’s working directory. -If not specified, the container runtime’s default will be used, which -might be configured in the container image.

    -
    -ports
    - - -[]Kubernetes core/v1.ContainerPort - - -
    -(Optional) -

    List of ports to expose from the container. Exposing a port here gives -the system additional information about the network connections a -container uses, but is primarily informational. Not specifying a port here -DOES NOT prevent that port from being exposed. Any port which is -listening on the default “0.0.0.0” address inside a container will be -accessible from the network.

    -
    -envFrom
    - - -[]Kubernetes core/v1.EnvFromSource - - -
    -(Optional) -

    List of sources to populate environment variables in the container. -The keys defined within a source must be a C_IDENTIFIER. All invalid keys -will be reported as an event when the container is starting. When a key exists in multiple -sources, the value associated with the last source will take precedence. -Values defined by an Env with a duplicate key will take precedence.

    -
    -env
    - - -[]Kubernetes core/v1.EnvVar - - -
    -(Optional) -

    List of environment variables to set in the container.

    -
    -volumeMounts
    - - -[]Kubernetes core/v1.VolumeMount - - -
    -(Optional) -

    Pod volumes to mount into the container’s filesystem.

    -
    -livenessProbe
    - - -Kubernetes core/v1.Probe - - -
    -(Optional) -

    Periodic probe of container liveness. -Container will be restarted if the probe fails.

    -
    -readinessProbe
    - - -Kubernetes core/v1.Probe - - -
    -(Optional) -

    Periodic probe of container service readiness. -Container will be removed from service endpoints if the probe fails.

    -
    -lifecycle
    - - -Kubernetes core/v1.Lifecycle - - -
    -(Optional) -

    Actions that the management system should take in response to container lifecycle events.

    -
    -securityContext
    - - -Kubernetes core/v1.SecurityContext - - -
    -(Optional) -

    Security options the pod should run with. -More info: https://kubernetes.io/docs/concepts/policy/security-context/ -More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/

    -
    -

    Customization -

    -

    -(Appears on: -ConfigurationAsCode, -GroovyScripts) -

    -

    -

    Customization defines configuration of Jenkins customization

    -

    - - - - - - - - - - - - - - - - - -
    FieldDescription
    -secret
    - - -SecretRef - - -
    -
    -configurations
    - - -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.ConfigMapRef - - -
    -
    -

    GroovyScripts -

    -

    -(Appears on: -JenkinsSpec) -

    -

    -

    GroovyScripts defines configuration of Jenkins customization via groovy scripts

    -

    - - - - - - - - - - - - - -
    FieldDescription
    -Customization
    - - -Customization - - -
    -
    -

    Handler -

    -

    -(Appears on: -Backup, -Restore) -

    -

    -

    Handler defines a specific action that should be taken

    -

    - - - - - - - - - - - - - -
    FieldDescription
    -exec
    - - -Kubernetes core/v1.ExecAction - - -
    -

    Exec specifies the action to take.

    -
    -

    JenkinsCredentialType -(string alias)

    -

    -(Appears on: -SeedJob) -

    -

    -

    JenkinsCredentialType defines the type of Jenkins credential used in the seed job mechanism

    -

    -

    JenkinsMaster -

    -

    -(Appears on: -JenkinsSpec) -

    -

    -

    JenkinsMaster defines the Jenkins master pod attributes and plugins, -every single change requires a Jenkins master pod restart

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -masterAnnotations
    - -map[string]string - -
    -(Optional) -

    Annotations is an unstructured key value map stored with a resource that may be -set by external tools to store and retrieve arbitrary metadata. They are not -queryable and should be preserved when modifying objects. -More info: http://kubernetes.io/docs/user-guide/annotations

    -
    -nodeSelector
    - -map[string]string - -
    -(Optional) -

    NodeSelector is a selector which must be true for the pod to fit on a node. -Selector which must match a node’s labels for the pod to be scheduled on that node. -More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/

    -
    -securityContext
    - - -Kubernetes core/v1.PodSecurityContext - - -
    -(Optional) -

    SecurityContext that applies to all the containers of the Jenkins -Master. As per kubernetes specification, it can be overridden -for each container individually. -Defaults to: -runAsUser: 1000 -fsGroup: 1000

    -
    -containers
    - - -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Container - - -
    -

    List of containers belonging to the pod. -Containers cannot currently be added or removed. -There must be at least one container in a Pod. -Defaults to: -- image: jenkins/jenkins:lts -imagePullPolicy: Always -livenessProbe: -failureThreshold: 12 -httpGet: -path: /login -port: http -scheme: HTTP -initialDelaySeconds: 80 -periodSeconds: 10 -successThreshold: 1 -timeoutSeconds: 5 -name: jenkins-master -readinessProbe: -failureThreshold: 3 -httpGet: -path: /login -port: http -scheme: HTTP -initialDelaySeconds: 30 -periodSeconds: 10 -successThreshold: 1 -timeoutSeconds: 1 -resources: -limits: -cpu: 1500m -memory: 3Gi -requests: -cpu: “1” -memory: 600Mi

    -
    -imagePullSecrets
    - - -[]Kubernetes core/v1.LocalObjectReference - - -
    -(Optional) -

    ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. -If specified, these secrets will be passed to individual puller implementations for them to use. For example, -in the case of docker, only DockerConfig type secrets are honored. -More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod

    -
    -volumes
    - - -[]Kubernetes core/v1.Volume - - -
    -(Optional) -

    List of volumes that can be mounted by containers belonging to the pod. -More info: https://kubernetes.io/docs/concepts/storage/volumes

    -
    -basePlugins
    - - -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin - - -
    -

    BasePlugins contains plugins required by operator -Defaults to : -- name: kubernetes -version: 1.15.7 -- name: workflow-job -version: “2.32” -- name: workflow-aggregator -version: “2.6” -- name: git -version: 3.10.0 -- name: job-dsl -version: “1.74” -- name: configuration-as-code -version: “1.19” -- name: configuration-as-code-support -version: “1.19” -- name: kubernetes-credentials-provider -version: 0.12.1

    -
    -plugins
    - - -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Plugin - - -
    -(Optional) -

    Plugins contains plugins required by user

    -
    -

    JenkinsSpec -

    -

    -(Appears on: -Jenkins) -

    -

    -

    JenkinsSpec defines the desired state of the Jenkins

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -master
    - - -JenkinsMaster - - -
    -

    Master represents Jenkins master pod properties and Jenkins plugins. -Every single change here requires a pod restart.

    -
    -seedJobs
    - - -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.SeedJob - - -
    -(Optional) -

    SeedJobs defines list of Jenkins Seed Job configurations -More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines

    -
    -service
    - - -Service - - -
    -(Optional) -

    Service is Kubernetes service of Jenkins master HTTP pod -Defaults to : -port: 8080 -type: ClusterIP

    -
    -slaveService
    - - -Service - - -
    -(Optional) -

    Service is Kubernetes service of Jenkins slave pods -Defaults to : -port: 50000 -type: ClusterIP

    -
    -backup
    - - -Backup - - -
    -(Optional) -

    Backup defines configuration of Jenkins backup -More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

    -
    -restore
    - - -Restore - - -
    -(Optional) -

    Backup defines configuration of Jenkins backup restore -More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-backup-and-restore

    -
    -groovyScripts
    - - -GroovyScripts - - -
    -(Optional) -

    GroovyScripts defines configuration of Jenkins customization via groovy scripts

    -
    -configurationAsCode
    - - -ConfigurationAsCode - - -
    -(Optional) -

    ConfigurationAsCode defines configuration of Jenkins customization via Configuration as Code Jenkins plugin

    -
    -

    JenkinsStatus -

    -

    -(Appears on: -Jenkins) -

    -

    -

    JenkinsStatus defines the observed state of Jenkins

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -operatorVersion
    - -string - -
    -(Optional) -

    OperatorVersion is the operator version which manages this CR

    -
    -provisionStartTime
    - - -Kubernetes meta/v1.Time - - -
    -(Optional) -

    ProvisionStartTime is a time when Jenkins master pod has been created

    -
    -baseConfigurationCompletedTime
    - - -Kubernetes meta/v1.Time - - -
    -(Optional) -

    BaseConfigurationCompletedTime is a time when Jenkins base configuration phase has been completed

    -
    -userConfigurationCompletedTime
    - - -Kubernetes meta/v1.Time - - -
    -(Optional) -

    UserConfigurationCompletedTime is a time when Jenkins user configuration phase has been completed

    -
    -restoredBackup
    - -uint64 - -
    -(Optional) -

    RestoredBackup is the restored backup number after Jenkins master pod restart

    -
    -lastBackup
    - -uint64 - -
    -(Optional) -

    LastBackup is the latest backup number

    -
    -pendingBackup
    - -uint64 - -
    -(Optional) -

    PendingBackup is the pending backup number

    -
    -backupDoneBeforePodDeletion
    - -bool - -
    -(Optional) -

    BackupDoneBeforePodDeletion tells if backup before pod deletion has been made

    -
    -userAndPasswordHash
    - -string - -
    -(Optional) -

    UserAndPasswordHash is a SHA256 hash made from the username and password

    -
    -createdSeedJobs
    - -[]string - -
    -(Optional) -

    CreatedSeedJobs contains list of seed job ids already created in Jenkins

    -
    -appliedGroovyScripts
    - - -[][]github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.AppliedGroovyScript - - -
    -(Optional) -

    AppliedGroovyScripts is a list with all applied groovy scripts in Jenkins by the operator

    -
    -

    Mailgun -

    -

    -(Appears on: -Notification) -

    -

    -

    Mailgun is handler for Mailgun email service notification channel

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -domain
    - -string - -
    -
    -apiKeySecretKeySelector
    - - -SecretKeySelector - - -
    -
    -recipient
    - -string - -
    -
    -from
    - -string - -
    -
    -

    MicrosoftTeams -

    -

    -(Appears on: -Notification) -

    -

    -

    MicrosoftTeams is handler for Microsoft MicrosoftTeams notification channel

    -

    - - - - - - - - - - - - - -
    FieldDescription
    -webHookURLSecretKeySelector
    - - -SecretKeySelector - - -
    -

    The web hook URL to MicrosoftTeams App

    -
    -

    Notification -

    -

    -

    Notification is a service configuration used to send notifications about Jenkins status

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -loggingLevel
    - - -NotificationLogLevel - - -
    -
    -verbose
    - -bool - -
    -
    -name
    - -string - -
    -
    -slack
    - - -github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Slack - - -
    -
    -teams
    - - -github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.MicrosoftTeams - - -
    -
    -mailgun
    - - -github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2.Mailgun - - -
    -
    -

    NotificationLogLevel -(string alias)

    -

    -(Appears on: -Notification) -

    -

    -

    NotificationLogLevel defines logging level of Notification

    -

    -

    Plugin -

    -

    -(Appears on: -JenkinsMaster) -

    -

    -

    Plugin defines Jenkins plugin

    -

    - - - - - - - - - - - - - - - - - -
    FieldDescription
    -name
    - -string - -
    -

    Name is the name of Jenkins plugin

    -
    -version
    - -string - -
    -

    Version is the version of Jenkins plugin

    -
    -

    Restore -

    -

    -(Appears on: -JenkinsSpec) -

    -

    -

    Restore defines configuration of Jenkins backup restore operation

    -

    - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -containerName
    - -string - -
    -

    ContainerName is the container name responsible for restore backup operation

    -
    -action
    - - -Handler - - -
    -

    Action defines action which performs restore backup in restore container sidecar

    -
    -recoveryOnce
    - -uint64 - -
    -(Optional) -

    RecoveryOnce if want to restore specific backup set this field and then Jenkins will be restarted and desired backup will be restored

    -
    -

    SecretKeySelector -

    -

    -(Appears on: -Mailgun, -MicrosoftTeams, -Slack) -

    -

    -

    SecretKeySelector selects a key of a Secret.

    -

    - - - - - - - - - - - - - - - - - -
    FieldDescription
    -secret
    - - -Kubernetes core/v1.LocalObjectReference - - -
    -

    The name of the secret in the pod’s namespace to select from.

    -
    -key
    - -string - -
    -

    The key of the secret to select from. Must be a valid secret key.

    -
    -

    SecretRef -

    -

    -(Appears on: -Customization) -

    -

    -

    SecretRef is reference to Kubernetes secret

    -

    - - - - - - - - - - - - - -
    FieldDescription
    -name
    - -string - -
    -
    -

    SeedJob -

    -

    -(Appears on: -JenkinsSpec) -

    -

    -

    SeedJob defines configuration for seed job -More info: https://github.com/jenkinsci/kubernetes-operator/blob/master/docs/getting-started.md#configure-seed-jobs-and-pipelines

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -id
    - -string - -
    -

    ID is the unique seed job name

    -
    -credentialID
    - -string - -
    -

    CredentialID is the Kubernetes secret name which stores repository access credentials

    -
    -description
    - -string - -
    -(Optional) -

    Description is the description of the seed job

    -
    -targets
    - -string - -
    -

    Targets is the repository path where the seed job definitions are

    -
    -repositoryBranch
    - -string - -
    -

    RepositoryBranch is the repository branch where the seed job definitions are

    -
    -repositoryUrl
    - -string - -
    -

    RepositoryURL is the repository access URL. Can be SSH or HTTPS.

    -
    -credentialType
    - - -JenkinsCredentialType - - -
    -(Optional) -

    JenkinsCredentialType is the https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/ credential type

    -
    -githubPushTrigger
    - -bool - -
    -(Optional) -

    GitHubPushTrigger is used for GitHub web hooks

    -
    -buildPeriodically
    - -string - -
    -(Optional) -

    BuildPeriodically is setting for scheduled trigger

    -
    -pollSCM
    - -string - -
    -(Optional) -

    PollSCM is setting for polling changes in SCM

    -
    -ignoreMissingFiles
    - -bool - -
    -(Optional) -

    IgnoreMissingFiles is setting for Job DSL API plugin to ignore files that miss

    -
    -additionalClasspath
    - -string - -
    -(Optional) -

    AdditionalClasspath is setting for Job DSL API plugin to set Additional Classpath

    -
    -failOnMissingPlugin
    - -bool - -
    -(Optional) -

    FailOnMissingPlugin is setting for Job DSL API plugin that fails job if required plugin is missing

    -
    -unstableOnDeprecation
    - -bool - -
    -(Optional) -

    UnstableOnDeprecation is setting for Job DSL API plugin that sets build status as unstable if build using deprecated features

    -
    -

    Service -

    -

    -(Appears on: -JenkinsSpec) -

    -

    -

    Service defines Kubernetes service attributes

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -annotations
    - -map[string]string - -
    -(Optional) -

    Annotations is an unstructured key value map stored with a resource that may be -set by external tools to store and retrieve arbitrary metadata. They are not -queryable and should be preserved when modifying objects. -More info: http://kubernetes.io/docs/user-guide/annotations

    -
    -labels
    - -map[string]string - -
    -

    Route service traffic to pods with label keys and values matching this -selector. If empty or not present, the service is assumed to have an -external process managing its endpoints, which Kubernetes will not -modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. -Ignored if type is ExternalName. -More info: https://kubernetes.io/docs/concepts/services-networking/service/

    -
    -type
    - - -Kubernetes core/v1.ServiceType - - -
    -(Optional) -

    Type determines how the Service is exposed. Defaults to ClusterIP. Valid -options are ExternalName, ClusterIP, NodePort, and LoadBalancer. -“ExternalName” maps to the specified externalName. -“ClusterIP” allocates a cluster-internal IP address for load-balancing to -endpoints. Endpoints are determined by the selector or if that is not -specified, by manual construction of an Endpoints object. If clusterIP is -“None”, no virtual IP is allocated and the endpoints are published as a -set of endpoints rather than a stable IP. -“NodePort” builds on ClusterIP and allocates a port on every node which -routes to the clusterIP. -“LoadBalancer” builds on NodePort and creates an -external load-balancer (if supported in the current cloud) which routes -to the clusterIP. -More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services—service-types

    -
    -port
    - -int32 - -
    -

    The port that is exposed by this service. -More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies

    -
    -nodePort
    - -int32 - -
    -(Optional) -

    The port on each node on which this service is exposed when type=NodePort or LoadBalancer. -Usually assigned by the system. If specified, it will be allocated to the service -if unused, or else creation of the service will fail. -Default is to auto-allocate a port if the ServiceType of this Service requires one. -More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport

    -
    -loadBalancerSourceRanges
    - -[]string - -
    -(Optional) -

    If specified and supported by the platform, this will restrict traffic through the cloud-provider -the load-balancer will be restricted to the specified client IPs. This field will be ignored if the -cloud-provider does not support the feature.” -More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/

    -
    -loadBalancerIP
    - -string - -
    -(Optional) -

    Only applies to Service Type: LoadBalancer -LoadBalancer will get created with the IP specified in this field. -This feature depends on whether the underlying cloud-provider supports specifying -the loadBalancerIP when a load balancer is created. -This field will be ignored if the cloud-provider does not support the feature.

    -
    -

    Slack -

    -

    -(Appears on: -Notification) -

    -

    -

    Slack is handler for Slack notification channel

    -

    - - - - - - - - - - - - - -
    FieldDescription
    -webHookURLSecretKeySelector
    - - -SecretKeySelector - - -
    -

    The web hook URL to Slack App

    -
    -
    -

    -Generated with gen-crd-api-reference-docs -on git commit f4c4235. -

    diff --git a/website/content/en/docs/Getting Started/latest/developer-guide.md b/website/content/en/docs/Getting Started/latest/developer-guide.md deleted file mode 100644 index 056f54ac..00000000 --- a/website/content/en/docs/Getting Started/latest/developer-guide.md +++ /dev/null @@ -1,198 +0,0 @@ ---- -title: "Developer Guide" -linkTitle: "Developer Guide" -weight: 60 -date: 2019-08-05 -description: > - Jenkins Operator for developers ---- - -{{% pageinfo %}} -This document explains how to setup your development environment. -{{% /pageinfo %}} - -## Prerequisites - -- [operator_sdk][operator_sdk] version v0.8.1 -- [git][git_tool] -- [go][go_tool] version v1.12+ -- [goimports, golint, checkmake and staticcheck][install_dev_tools] -- [minikube][minikube] version v1.1.0+ (preferred Hypervisor - [virtualbox][virtualbox]) -- [docker][docker_tool] version 17.03+ - -## Clone repository and download dependencies - -```bash -mkdir -p $GOPATH/src/github.com/jenkinsci -cd $GOPATH/src/github.com/jenkinsci/ -git clone git@github.com:jenkinsci/kubernetes-operator.git -cd kubernetes-operator -make go-dependencies -``` - -## Build and run with a minikube - -Build and run **Jenkins Operator** locally: - -```bash -make build minikube-run EXTRA_ARGS='--minikube --local' -``` - -Once minikube and **Jenkins Operator** are up and running, apply Jenkins custom resource: - -```bash -kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml -kubectl get jenkins -o yaml -kubectl get po -``` - -## Build and run with a remote Kubernetes cluster - -You can also run the controller locally and make it listen to a remote Kubernetes server. - -```bash -make run NAMESPACE=default KUBECTL_CONTEXT=remote-k8s EXTRA_ARGS='--kubeconfig ~/.kube/config' -``` - -Once minikube and **Jenkins Operator** are up and running, apply Jenkins custom resource: - -```bash -kubectl --context remote-k8s --namespace default apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml -kubectl --context remote-k8s --namespace default get jenkins -o yaml -kubectl --context remote-k8s --namespace default get po -``` - -## Testing - -Run unit tests: - -```bash -make test -``` - -### Running E2E tests on Linux - -Run e2e tests with minikube: - -```bash -make minikube-start -eval $(minikube docker-env) -make build e2e -``` - -Run the specific e2e test: - -```bash -make build e2e E2E_TEST_SELECTOR='^TestConfiguration$' -``` - -### Running E2E tests on macOS - -At first, you need to start minikube: -```bash -$ make minikube-start -$ eval $(minikube docker-env) -``` - -Build a Docker image inside the provided Linux container by: -```bash -$ make indocker -``` - -Build **Jenkins Operator** inside a container using: - - -```bash -$ make build -``` - -Then exit the container and run: -``` -make e2e -``` - -## Tips & Tricks - -### Building docker image on minikube (for e2e tests) - -To be able to work with the docker daemon on `minikube` machine run the following command before building an image: - -```bash -eval $(minikube docker-env) -``` - -### When `pkg/apis/jenkinsio/*/jenkins_types.go` has changed - -Run: - -```bash -make deepcopy-gen -``` - -### Getting the Jenkins URL and basic credentials - -```bash -minikube service jenkins-operator-http- --url -kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.user}' | base64 -d -kubectl get secret jenkins-operator-credentials- -o 'jsonpath={.data.password}' | base64 -d -``` - -# Tools - -## Configure environment variables - -```bash -export GOPATH=/home/go # example value -export GOROOT=/usr/lib/go-1.12 # example value -export PATH=$GOPATH/bin:$PATH -``` - -## goimports - -``` -go get golang.org/x/tools/cmd/goimports -cd $GOPATH/src/golang.org/x/tools/cmd/goimports -go build -go install -``` - -## golint - -``` -go get -u golang.org/x/lint/golint -cd $GOPATH/src/golang.org/x/lint/golint -go build -go install -``` - -## checkmake -``` -go get github.com/mrtazz/checkmake -cd $GOPATH/src/github.com/mrtazz/checkmake -go build -go install -``` - -## staticcheck - -``` -mkdir -p $GOPATH/src/github.com/dominikh/ -cd $GOPATH/src/github.com/dominikh/ -git clone https://github.com/dominikh/go-tools.git -cd $GOPATH/src/github.com/dominikh/go-tools/staticcheck -go build -go install -``` - - -[dep_tool]:https://golang.github.io/dep/docs/installation.html -[git_tool]:https://git-scm.com/downloads -[go_tool]:https://golang.org/dl/ -[operator_sdk]:https://github.com/operator-framework/operator-sdk -[fork_guide]:https://help.github.com/articles/fork-a-repo/ -[docker_tool]:https://docs.docker.com/install/ -[kubectl_tool]:https://kubernetes.io/docs/tasks/tools/install-kubectl/ -[minikube]:https://kubernetes.io/docs/tasks/tools/install-minikube/ -[virtualbox]:https://www.virtualbox.org/wiki/Downloads -[jenkins-operator]:../README.md -[install_dev_tools]:install_dev_tools.md