diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 619d75228130f6f5ca1414f557ec54fba21d98e5..5da8189d82f7b83f7f36c027ad82e22273ada89a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -77,7 +77,6 @@ lint_package: - install_tiller - create_secret - install_external_dns "${DNS_PROVIDER}" "${KUBE_INGRESS_BASE_DOMAIN}" - - if ! crdExists || previousDeployFailed ; then OPERATOR_BOOTSTRAP=true deploy ; fi - deploy - add_license - echo "export QA_ENVIRONMENT_URL=gitlab-$CI_ENVIRONMENT_SLUG.$KUBE_INGRESS_BASE_DOMAIN" >> "${VARIABLES_FILE}" @@ -217,7 +216,6 @@ stop_review_eks: - ensure_namespace - install_tiller - create_secret - - if ! crdExists || previousDeployFailed ; then OPERATOR_BOOTSTRAP=true deploy ; fi - deploy - delete canary - echo "export QA_ENVIRONMENT_URL=gitlab.$KUBE_INGRESS_BASE_DOMAIN" >> "${VARIABLES_FILE}" @@ -428,14 +426,8 @@ check_docs_internal_links: helm repo add gitlab https://charts.gitlab.io/ helm dep update . - # If OPERATOR_BOOTSTRAP is set, we _do not_ want to use --wait / --timeout - WAIT="--wait --timeout 600" - if [ -n "${OPERATOR_BOOTSTRAP}" ]; then - WAIT="" - fi - helm upgrade --install \ - $WAIT \ + --wait --timeout 600 \ --set releaseOverride="$CI_ENVIRONMENT_SLUG" \ --set global.hosts.hostSuffix="$HOST_SUFFIX" \ --set global.hosts.domain="$KUBE_INGRESS_BASE_DOMAIN" \ @@ -450,7 +442,6 @@ check_docs_internal_links: --set redis.resources.requests.cpu=100m \ --set minio.resources.requests.cpu=100m \ --set global.operator.enabled=true \ - --set global.operator.bootstrap=${OPERATOR_BOOTSTRAP-false} \ --namespace="$KUBE_NAMESPACE" \ --version="$CI_PIPELINE_ID-$CI_JOB_ID" \ "$name" \ diff --git a/changelogs/unreleased/1234-hook-gitlab-custom-resource-to-post-install-and-post-upgrade.yml b/changelogs/unreleased/1234-hook-gitlab-custom-resource-to-post-install-and-post-upgrade.yml new file mode 100644 index 0000000000000000000000000000000000000000..062c6796e278fae1c1a5a3270e5a8f923c91f0da --- /dev/null +++ b/changelogs/unreleased/1234-hook-gitlab-custom-resource-to-post-install-and-post-upgrade.yml @@ -0,0 +1,5 @@ +--- +title: Hook GitLab Custom Resource to post-install and post-ugprade +merge_request: 754 +author: +type: changed diff --git a/charts/gitlab/charts/operator/templates/crd.yaml b/charts/gitlab/charts/operator/templates/crd.yaml index 9dfa72d3a7c774db885f7a8cb37415588dff6bc3..cdb76f340526b3b6dee5c38acce57a0d2eb9d6d3 100644 --- a/charts/gitlab/charts/operator/templates/crd.yaml +++ b/charts/gitlab/charts/operator/templates/crd.yaml @@ -5,6 +5,9 @@ metadata: labels: controller-tools.k8s.io: "1.0" name: {{ template "gitlab.operator.crdName" . }} + annotations: + "helm.sh/hook": "pre-install,pre-upgrade" + "helm.sh/hook-delete-policy": "before-hook-creation" spec: group: {{ template "gitlab.operator.groupName" . }} names: diff --git a/charts/gitlab/charts/operator/templates/gitlab.yaml b/charts/gitlab/charts/operator/templates/gitlab.yaml index 1fc8eacb3b45a3503e61d51ef972af1d849e6145..884867d97af115143a99512affb022266e309054 100644 --- a/charts/gitlab/charts/operator/templates/gitlab.yaml +++ b/charts/gitlab/charts/operator/templates/gitlab.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.global.operator.enabled (not .Values.global.operator.bootstrap) }} +{{- if and .Values.global.operator.enabled }} apiVersion: {{ printf "%s/v1beta1" (include "gitlab.operator.groupName" .) }} kind: GitLab metadata: diff --git a/charts/gitlab/charts/operator/templates/operator_deployment.yaml b/charts/gitlab/charts/operator/templates/operator_deployment.yaml index d82cf0d13c3a1b591d56db85c08d55ca46c93f81..bb2fd9ea89670220de874b59362a5cdf2accc54b 100644 --- a/charts/gitlab/charts/operator/templates/operator_deployment.yaml +++ b/charts/gitlab/charts/operator/templates/operator_deployment.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.global.operator.enabled (not .Values.global.operator.bootstrap) }} +{{- if and .Values.global.operator.enabled }} apiVersion: apps/v1beta2 kind: Deployment metadata: diff --git a/doc/installation/operator.md b/doc/installation/operator.md index 125ec67cf79a0f07ba04db4112fce4b8391c78f9..edcd79b66b1eb49782df62032652b98daf1ab8b8 100644 --- a/doc/installation/operator.md +++ b/doc/installation/operator.md @@ -8,15 +8,6 @@ We provide an [operator chart](https://gitlab.com/charts/gitlab/tree/master/char ### Enabling the operator -We provide the flag `global.operator.enabled`, when set to true it enables the operator and allows it to manage resources. +NOTE: **Note**: This requires helm 2.12.3 or newer -## Installing using the operator - -The operator makes use of Kubernetes CustomResourceDefinitions (CRD). Since Helm will be used for the installation, we need to ensure that this CRD is in place prior to attempting to use it. In order to do this, we have to run an additional command prior to use. - -1. `helm upgrade --install . --set global.operator.enabled=true --set global.operator.bootstrap=true ... ` where `...` shall be replaced by the rest of the values you would like to set. -2. `helm upgrade . --set global.operator.enabled=true --set global.operator.bootstrap=false ...`. - -The first command will install only the `CRD` but will not actually attempt to deploy the operator. The second command will deploy the operator itself, now that the CRD is in place. - -**NOTE:** This needs done only the first time you install the operator, further upgrades will follow the normal [upgrade procedures](./upgrade.md) +We provide the flag `global.operator.enabled`, when set to true it enables the operator, installs the necessary CRDs and allows it to manage resources.