Support for passing operator image as env variable

This commit is contained in:
Martin Montes
2023-12-18 16:13:15 +01:00
parent 955f08a3f9
commit 3ae462383d
20 changed files with 106 additions and 51 deletions

View File

@ -90,6 +90,8 @@ jobs:
make cluster
make install
make net
make docker-build
make docker-load
- name: Test
run: make test

2
.vscode/launch.json vendored
View File

@ -19,6 +19,7 @@
"MARIADB_OPERATOR_NAME": "mariadb-operator",
"MARIADB_OPERATOR_NAMESPACE": "default",
"MARIADB_OPERATOR_SA_PATH": "/tmp/mariadb-operator/token",
"MARIADB_OPERATOR_IMAGE": "ghcr.io/mariadb-operator/mariadb-operator:v0.0.24",
"RELATED_IMAGE_MARIADB": "mariadb:11.2.2",
}
},
@ -63,6 +64,7 @@
"MARIADB_OPERATOR_NAME": "mariadb-operator",
"MARIADB_OPERATOR_NAMESPACE": "default",
"MARIADB_OPERATOR_SA_PATH": "/tmp/mariadb-operator/token",
"MARIADB_OPERATOR_IMAGE": "mariadb/mariadb-operator-enterprise:v0.0.24",
"RELATED_IMAGE_MARIADB": "us-central1-docker.pkg.dev/mariadb-es-docker-registry/enterprise-docker/enterprise-server:10.6",
}
}

View File

@ -12,7 +12,7 @@ endif
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
VERSION ?= 0.0.23
VERSION ?= 0.0.24
IMG ?= ghcr.io/mariadb-operator/mariadb-operator:v$(VERSION)
IMG_ENT ?= mariadb/mariadb-operator-enterprise:v$(VERSION)
RELATED_IMAGE_MARIADB ?= mariadb:11.2.2

View File

@ -280,7 +280,7 @@ metadata:
categories: Database
certified: "true"
containerImage: mariadb/mariadb-operator-enterprise:v0.0.23
createdAt: "2023-12-17T12:06:51Z"
createdAt: "2023-12-18T14:59:40Z"
operators.openshift.io/valid-subscription: '["MariaDB Enterprise Server License"]'
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
@ -291,7 +291,7 @@ metadata:
operatorframework.io/arch.ppc64le: supported
operatorframework.io/arch.s390x: supported
operatorframework.io/os.linux: supported
name: mariadb-operator-enterprise.v0.0.23
name: mariadb-operator-enterprise.v0.0.24
namespace: placeholder
spec:
apiservicedefinitions: {}
@ -602,9 +602,15 @@ spec:
- description: BackupRef is a reference to a Backup object.
displayName: Backup Ref
path: bootstrapFrom.backupRef
- description: FileName is the file within the source to be restored.
displayName: File Name
path: bootstrapFrom.fileName
- description: TargetRecoveryFile is the file within the source to be restored.
If provided, TargetRecoveryFile is ignored.
displayName: Target Recovery File
path: bootstrapFrom.targetRecoveryFile
- description: TargetRecoveryTime is a RFC3339 (1970-01-01T00:00:00Z) date and
time that defines the point in time recovery objective. It is used to determine
the closest restoration source in time.
displayName: Target Recovery Time
path: bootstrapFrom.targetRecoveryTime
- description: Volume is a Kubernetes Volume object that contains a backup.
displayName: Volume
path: bootstrapFrom.volume
@ -1425,9 +1431,6 @@ spec:
- description: BackupRef is a reference to a Backup object.
displayName: Backup Ref
path: backupRef
- description: FileName is the file within the source to be restored.
displayName: File Name
path: fileName
- description: MariaDBRef is a reference to a MariaDB object.
displayName: Maria DBRef
path: mariaDbRef
@ -1446,6 +1449,15 @@ spec:
- description: RestartPolicy to be added to the Backup Job.
displayName: Restart Policy
path: restartPolicy
- description: TargetRecoveryFile is the file within the source to be restored.
If provided, TargetRecoveryFile is ignored.
displayName: Target Recovery File
path: targetRecoveryFile
- description: TargetRecoveryTime is a RFC3339 (1970-01-01T00:00:00Z) date and
time that defines the point in time recovery objective. It is used to determine
the closest restoration source in time.
displayName: Target Recovery Time
path: targetRecoveryTime
- description: Tolerations to be used in the Restore Pod.
displayName: Tolerations
path: tolerations
@ -2001,6 +2013,8 @@ spec:
env:
- name: RELATED_IMAGE_MARIADB
value: us-central1-docker.pkg.dev/mariadb-es-docker-registry/enterprise-docker/enterprise-server:10.6
- name: MARIADB_OPERATOR_IMGE
value: mariadb/mariadb-operator-enterprise:v0.0.24
- name: WATCH_NAMESPACE
valueFrom:
fieldRef:
@ -2015,7 +2029,7 @@ spec:
fieldPath: metadata.namespace
- name: MARIADB_OPERATOR_SA_PATH
value: /var/run/secrets/kubernetes.io/serviceaccount/token
image: mariadb/mariadb-operator-enterprise:v0.0.23
image: mariadb/mariadb-operator-enterprise:v0.0.24
livenessProbe:
httpGet:
path: /healthz
@ -2122,7 +2136,7 @@ spec:
relatedImages:
- image: us-central1-docker.pkg.dev/mariadb-es-docker-registry/enterprise-docker/enterprise-server:10.6
name: mariadb
version: 0.0.23
version: 0.0.24
webhookdefinitions:
- admissionReviewVersions:
- v1

View File

@ -894,8 +894,15 @@ spec:
type: string
type: object
x-kubernetes-map-type: atomic
fileName:
description: FileName is the file within the source to be restored.
targetRecoveryFile:
description: TargetRecoveryFile is the file within the source
to be restored. If provided, TargetRecoveryFile is ignored.
type: string
targetRecoveryTime:
description: TargetRecoveryTime is a RFC3339 (1970-01-01T00:00:00Z)
date and time that defines the point in time recovery objective.
It is used to determine the closest restoration source in time.
format: date-time
type: string
volume:
description: Volume is a Kubernetes Volume object that contains

View File

@ -892,9 +892,6 @@ spec:
type: string
type: object
x-kubernetes-map-type: atomic
fileName:
description: FileName is the file within the source to be restored.
type: string
mariaDbRef:
description: MariaDBRef is a reference to a MariaDB object.
properties:
@ -998,6 +995,16 @@ spec:
- OnFailure
- Never
type: string
targetRecoveryFile:
description: TargetRecoveryFile is the file within the source to be
restored. If provided, TargetRecoveryFile is ignored.
type: string
targetRecoveryTime:
description: TargetRecoveryTime is a RFC3339 (1970-01-01T00:00:00Z)
date and time that defines the point in time recovery objective.
It is used to determine the closest restoration source in time.
format: date-time
type: string
tolerations:
description: Tolerations to be used in the Restore Pod.
items:

View File

@ -900,9 +900,9 @@ spec:
to be restored. If provided, TargetRecoveryFile is ignored.
type: string
targetRecoveryTime:
description: TargetRecoveryTime defines the point in time recovery
objective. It is used to determine the closest restoration source
in time.
description: TargetRecoveryTime is a RFC3339 (1970-01-01T00:00:00Z)
date and time that defines the point in time recovery objective.
It is used to determine the closest restoration source in time.
format: date-time
type: string
volume:

View File

@ -1001,9 +1001,9 @@ spec:
restored. If provided, TargetRecoveryFile is ignored.
type: string
targetRecoveryTime:
description: TargetRecoveryTime defines the point in time recovery
objective. It is used to determine the closest restoration source
in time.
description: TargetRecoveryTime is a RFC3339 (1970-01-01T00:00:00Z)
date and time that defines the point in time recovery objective.
It is used to determine the closest restoration source in time.
format: date-time
type: string
tolerations:

View File

@ -6,4 +6,4 @@ kind: Kustomization
images:
- name: controller
newName: mariadb/mariadb-operator-enterprise
newTag: v0.0.23
newTag: v0.0.24

View File

@ -45,6 +45,8 @@ spec:
env:
- name: RELATED_IMAGE_MARIADB
value: us-central1-docker.pkg.dev/mariadb-es-docker-registry/enterprise-docker/enterprise-server:10.6
- name: MARIADB_OPERATOR_IMGE
value: mariadb/mariadb-operator-enterprise:v0.0.24
- name: WATCH_NAMESPACE
valueFrom:
fieldRef:

View File

@ -559,9 +559,15 @@ spec:
- description: BackupRef is a reference to a Backup object.
displayName: Backup Ref
path: bootstrapFrom.backupRef
- description: FileName is the file within the source to be restored.
displayName: File Name
path: bootstrapFrom.fileName
- description: TargetRecoveryFile is the file within the source to be restored.
If provided, TargetRecoveryFile is ignored.
displayName: Target Recovery File
path: bootstrapFrom.targetRecoveryFile
- description: TargetRecoveryTime is a RFC3339 (1970-01-01T00:00:00Z) date and
time that defines the point in time recovery objective. It is used to determine
the closest restoration source in time.
displayName: Target Recovery Time
path: bootstrapFrom.targetRecoveryTime
- description: Volume is a Kubernetes Volume object that contains a backup.
displayName: Volume
path: bootstrapFrom.volume
@ -1382,9 +1388,6 @@ spec:
- description: BackupRef is a reference to a Backup object.
displayName: Backup Ref
path: backupRef
- description: FileName is the file within the source to be restored.
displayName: File Name
path: fileName
- description: MariaDBRef is a reference to a MariaDB object.
displayName: Maria DBRef
path: mariaDbRef
@ -1403,6 +1406,15 @@ spec:
- description: RestartPolicy to be added to the Backup Job.
displayName: Restart Policy
path: restartPolicy
- description: TargetRecoveryFile is the file within the source to be restored.
If provided, TargetRecoveryFile is ignored.
displayName: Target Recovery File
path: targetRecoveryFile
- description: TargetRecoveryTime is a RFC3339 (1970-01-01T00:00:00Z) date and
time that defines the point in time recovery objective. It is used to determine
the closest restoration source in time.
displayName: Target Recovery Time
path: targetRecoveryTime
- description: Tolerations to be used in the Restore Pod.
displayName: Tolerations
path: tolerations

View File

@ -4509,9 +4509,9 @@ spec:
to be restored. If provided, TargetRecoveryFile is ignored.
type: string
targetRecoveryTime:
description: TargetRecoveryTime defines the point in time recovery
objective. It is used to determine the closest restoration source
in time.
description: TargetRecoveryTime is a RFC3339 (1970-01-01T00:00:00Z)
date and time that defines the point in time recovery objective.
It is used to determine the closest restoration source in time.
format: date-time
type: string
volume:
@ -14576,9 +14576,9 @@ spec:
restored. If provided, TargetRecoveryFile is ignored.
type: string
targetRecoveryTime:
description: TargetRecoveryTime defines the point in time recovery
objective. It is used to determine the closest restoration source
in time.
description: TargetRecoveryTime is a RFC3339 (1970-01-01T00:00:00Z)
date and time that defines the point in time recovery objective.
It is used to determine the closest restoration source in time.
format: date-time
type: string
tolerations:

View File

@ -1,7 +1,8 @@
apiVersion: v1
data:
MARIADB_OPERATOR_IMAGE: ghcr.io/mariadb-operator/mariadb-operator:v0.0.24
RELATED_IMAGE_MARIADB: mariadb:11.2.2
kind: ConfigMap
metadata:
creationTimestamp: null
name: mariadb-operator-related-images
name: mariadb-operator-images

View File

@ -62,7 +62,7 @@ spec:
name: metrics
envFrom:
- configMapRef:
name: mariadb-operator-related-images
name: mariadb-operator-images
env:
- name: CLUSTER_NAME
value: {{ .Values.clusterName }}

View File

@ -4509,9 +4509,9 @@ spec:
to be restored. If provided, TargetRecoveryFile is ignored.
type: string
targetRecoveryTime:
description: TargetRecoveryTime defines the point in time recovery
objective. It is used to determine the closest restoration source
in time.
description: TargetRecoveryTime is a RFC3339 (1970-01-01T00:00:00Z)
date and time that defines the point in time recovery objective.
It is used to determine the closest restoration source in time.
format: date-time
type: string
volume:
@ -14576,9 +14576,9 @@ spec:
restored. If provided, TargetRecoveryFile is ignored.
type: string
targetRecoveryTime:
description: TargetRecoveryTime defines the point in time recovery
objective. It is used to determine the closest restoration source
in time.
description: TargetRecoveryTime is a RFC3339 (1970-01-01T00:00:00Z)
date and time that defines the point in time recovery objective.
It is used to determine the closest restoration source in time.
format: date-time
type: string
tolerations:

View File

@ -93,10 +93,12 @@ code: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and Dee
helm-crds: kustomize ## Generate CRDs for Helm chart.
$(KUSTOMIZE) build config/crd > deploy/charts/mariadb-operator/crds/crds.yaml
.PHONY: helm-related-img
helm-related-img: ## Update related image in Helm chart.
$(KUBECTL) create configmap mariadb-operator-related-images \
--from-literal=RELATED_IMAGE_MARIADB=$(RELATED_IMAGE_MARIADB) --dry-run=client -o yaml \
.PHONY: helm-images
helm-images: ## Update images in Helm chart.
$(KUBECTL) create configmap mariadb-operator-images \
--from-literal=RELATED_IMAGE_MARIADB=$(RELATED_IMAGE_MARIADB) \
--from-literal=MARIADB_OPERATOR_IMAGE=$(IMG) \
--dry-run=client -o yaml \
> deploy/charts/mariadb-operator/templates/configmap.yaml
DOCS_IMG ?= jnorwood/helm-docs:v1.11.0
@ -110,7 +112,7 @@ helm-lint: ## Lint Helm charts.
docker run --rm --workdir /repo -v $(shell pwd):/repo $(CT_IMG) ct lint --config .github/config/ct.yml
.PHONY: helm
helm: helm-crds helm-related-img helm-docs ## Generate manifests for Helm chart.
helm: helm-crds helm-images helm-docs ## Generate manifests for Helm chart.
.PHONY: helm-chart-version
helm-chart-version: yq ## Get helm chart version.

View File

@ -29,7 +29,7 @@ cert-from-cluster: ## Get certificate from cluster.
lint: golangci-lint ## Lint.
$(GOLANGCI_LINT) run
TEST_ENV ?= RELATED_IMAGE_MARIADB=$(RELATED_IMAGE_MARIADB) \
TEST_ENV ?= RELATED_IMAGE_MARIADB=$(RELATED_IMAGE_MARIADB) MARIADB_OPERATOR_IMAGE=$(IMG) \
MARIADB_OPERATOR_NAME=$(MARIADB_OPERATOR_NAME) MARIADB_OPERATOR_NAMESPACE=$(MARIADB_OPERATOR_NAMESPACE) MARIADB_OPERATOR_SA_PATH=$(MARIADB_OPERATOR_SA_PATH) \
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)"
.PHONY: test
@ -49,7 +49,7 @@ release: goreleaser ## Test release locally.
WATCH_NAMESPACE ?= ""
RUN_FLAGS ?= --log-dev --log-level=debug --log-time-encoder=iso8601
RUN_ENV ?= RELATED_IMAGE_MARIADB=$(RELATED_IMAGE_MARIADB) WATCH_NAMESPACE=$(WATCH_NAMESPACE)
RUN_ENV ?= RELATED_IMAGE_MARIADB=$(RELATED_IMAGE_MARIADB) MARIADB_OPERATOR_IMAGE=$(IMG) MARIADBWATCH_NAMESPACE=$(WATCH_NAMESPACE)
.PHONY: run
run: lint ## Run a controller from your host.
$(RUN_ENV) go run cmd/controller/*.go $(RUN_FLAGS)
@ -65,7 +65,7 @@ CERT_CONTROLLER_FLAGS ?= --log-dev --log-level=debug --log-time-encoder=iso8601
cert-controller: lint ## Run a cert-controller from your host.
go run cmd/controller/*.go cert-controller $(CERT_CONTROLLER_FLAGS)
RUN_ENT_ENV ?= RELATED_IMAGE_MARIADB=$(RELATED_IMAGE_MARIADB_ENT) WATCH_NAMESPACE=$(WATCH_NAMESPACE)
RUN_ENT_ENV ?= RELATED_IMAGE_MARIADB=$(RELATED_IMAGE_MARIADB_ENT) MARIADB_OPERATOR_IMAGE=$(IMG_ENT) WATCH_NAMESPACE=$(WATCH_NAMESPACE)
.PHONY: run-ent
run-ent: lint cert ## Run a enterprise from your host.
$(RUN_ENT_ENV) go run cmd/enterprise/*.go $(RUN_FLAGS)

View File

@ -43,6 +43,7 @@ bundle: operator-sdk yq kustomize manifests ## Generate bundle manifests and met
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG_ENT)
$(YQ) e -i '.spec.template.spec.containers[0].env[0].value = "$(RELATED_IMAGE_MARIADB_ENT)"' config/manager/manager.yaml
$(YQ) e -i '.spec.template.spec.containers[0].env[1].value = "$(IMG_ENT)"' config/manager/manager.yaml
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
$(YQ) e -i '.metadata.annotations.containerImage = (.spec.relatedImages[] | select(.name == "mariadb-operator-enterprise").image)' bundle/manifests/mariadb-operator-enterprise.clusterserviceversion.yaml
$(MAKE) bundle-validate

View File

@ -12,6 +12,7 @@ type Environment struct {
MariadbOperatorName string `env:"MARIADB_OPERATOR_NAME,required"`
MariadbOperatorNamespace string `env:"MARIADB_OPERATOR_NAMESPACE,required"`
MariadbOperatorSAPath string `env:"MARIADB_OPERATOR_SA_PATH,required"`
MariadbOperatorImage string `env:"MARIADB_OPERATOR_IMAGE,required"`
RelatedMariadbImage string `env:"RELATED_IMAGE_MARIADB,required"`
WatchNamespace string `env:"WATCH_NAMESPACE"`
}

View File

@ -25,6 +25,7 @@ func TestWathcNamespaces(t *testing.T) {
"MARIADB_OPERATOR_NAME": "mariadb-operator",
"MARIADB_OPERATOR_NAMESPACE": "mariadb-operator",
"MARIADB_OPERATOR_SA_PATH": "mariadb-operator",
"MARIADB_OPERATOR_IMAGE": "mariadb-operator",
"RELATED_IMAGE_MARIADB": "mariadb:lts",
},
wantNamespaces: nil,
@ -36,6 +37,7 @@ func TestWathcNamespaces(t *testing.T) {
"MARIADB_OPERATOR_NAME": "mariadb-operator",
"MARIADB_OPERATOR_NAMESPACE": "mariadb-operator",
"MARIADB_OPERATOR_SA_PATH": "mariadb-operator",
"MARIADB_OPERATOR_IMAGE": "mariadb-operator",
"RELATED_IMAGE_MARIADB": "mariadb:lts",
"WATCH_NAMESPACE": "",
},
@ -48,6 +50,7 @@ func TestWathcNamespaces(t *testing.T) {
"MARIADB_OPERATOR_NAME": "mariadb-operator",
"MARIADB_OPERATOR_NAMESPACE": "mariadb-operator",
"MARIADB_OPERATOR_SA_PATH": "mariadb-operator",
"MARIADB_OPERATOR_IMAGE": "mariadb-operator",
"RELATED_IMAGE_MARIADB": "mariadb:lts",
"WATCH_NAMESPACE": "ns1",
},
@ -60,6 +63,7 @@ func TestWathcNamespaces(t *testing.T) {
"MARIADB_OPERATOR_NAME": "mariadb-operator",
"MARIADB_OPERATOR_NAMESPACE": "mariadb-operator",
"MARIADB_OPERATOR_SA_PATH": "mariadb-operator",
"MARIADB_OPERATOR_IMAGE": "mariadb-operator",
"RELATED_IMAGE_MARIADB": "mariadb:lts",
"WATCH_NAMESPACE": "ns1,ns2,ns3",
},