Skip to content

Commit

Permalink
Merge branch 'main' into K8SPSMDB-1183_bundle_generation
Browse files Browse the repository at this point in the history
  • Loading branch information
nmarukovich authored Feb 3, 2025
2 parents b624e8c + 7149757 commit ad41057
Show file tree
Hide file tree
Showing 68 changed files with 635 additions and 349 deletions.
11 changes: 11 additions & 0 deletions .e2eignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
docs/**
code-of-conduct.md
CONTRIBUTING.md
README.md
.gitattributes
.gitignore
LICENSE
operator.png
kubernetes.svg
release_versions
.github/**
7 changes: 4 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* @hors @egegunes @inelpandzic @pooknull @nmarukovich
/e2e-tests/ @nmarukovich @ptankov @jvpasinatto @eleo007
Jenkinsfile @nmarukovich @ptankov @jvpasinatto @eleo007
* @hors @egegunes @pooknull @nmarukovich @gkech
/e2e-tests/ @ptankov @jvpasinatto @eleo007
Jenkinsfile @ptankov @jvpasinatto @eleo007

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ anaconda-mode/
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# vendor
/vendor/

### Vim ###
# swap
.sw[a-p]
Expand Down
247 changes: 171 additions & 76 deletions Jenkinsfile

Large diffs are not rendered by default.

27 changes: 21 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ uninstall: manifests ## Uninstall CRDs, rbac
deploy: ## Deploy operator
yq eval '(.spec.template.spec.containers[] | select(.name=="percona-server-mongodb-operator")).image = "$(IMAGE)"' $(DEPLOYDIR)/operator.yaml \
| yq eval '(.spec.template.spec.containers[] | select(.name=="percona-server-mongodb-operator").env[] | select(.name=="LOG_LEVEL")).value="DEBUG"' - \
| yq eval '(.spec.template.spec.containers[] | select(.name=="percona-server-mongodb-operator").env[] | select(.name=="DISABLE_TELEMETRY")).value="true"' - \
| kubectl apply -f -

undeploy: ## Undeploy operator
Expand Down Expand Up @@ -99,19 +100,27 @@ swagger: ## Download swagger locally if necessary.
$(call go-get-tool,$(SWAGGER),github.com/go-swagger/go-swagger/cmd/swagger@latest)

# Prepare release
include e2e-tests/release_versions
CERT_MANAGER_VER := $(shell grep -Eo "cert-manager v.*" go.mod|grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")
release: manifests
$(SED) -i "/CERT_MANAGER_VER/s/CERT_MANAGER_VER=\".*/CERT_MANAGER_VER=\"$(CERT_MANAGER_VER)\"/" e2e-tests/functions
$(SED) -i "/Version = \"/s/Version = \".*/Version = \"$(VERSION)\"/" version/version.go
$(SED) -i \
-e "s/crVersion: .*/crVersion: $(VERSION)/" \
-e "/^spec:/,/^ image:/{s#image: .*#image: percona/percona-server-mongodb:@@SET_TAG@@#}" deploy/cr-minimal.yaml
-e "/^spec:/,/^ image:/{s#image: .*#image: $(IMAGE_MONGOD80)#}" deploy/cr-minimal.yaml
$(SED) -i \
-e "s/crVersion: .*/crVersion: $(VERSION)/" \
-e "/^spec:/,/^ image:/{s#image: .*#image: percona/percona-server-mongodb:@@SET_TAG@@#}" \
-e "/^ backup:/,/^ image:/{s#image: .*#image: percona/percona-backup-mongodb:@@SET_TAG@@#}" \
-e "/^spec:/,/^ image:/{s#image: .*#image: $(IMAGE_MONGOD80)#}" \
-e "/^ backup:/,/^ image:/{s#image: .*#image: $(IMAGE_BACKUP)#}" \
-e "s#initImage: .*#initImage: percona/percona-server-mongodb-operator:$(VERSION)#g" \
-e "/^ pmm:/,/^ image:/{s#image: .*#image: percona/pmm-client:@@SET_TAG@@#}" deploy/cr.yaml
-e "/^ pmm:/,/^ image:/{s#image: .*#image: $(IMAGE_PMM_CLIENT)#}" deploy/cr.yaml
$(SED) -i \
-e "s|perconalab/percona-server-mongodb-operator:main-mongod8.0|$(IMAGE_MONGOD80)|g" \
-e "s|perconalab/percona-server-mongodb-operator:main-backup|$(IMAGE_BACKUP)|g" \
-e "s|perconalab/percona-server-mongodb-operator:main|$(IMAGE_OPERATOR)|g" \
pkg/controller/perconaservermongodb/testdata/reconcile-statefulset/*.yaml
$(SED) -i "s|cr.Spec.InitImage = \".*\"|cr.Spec.InitImage = \"${IMAGE_OPERATOR}\"|g" pkg/controller/perconaservermongodb/suite_test.go


# Prepare main branch after release
MAJOR_VER := $(shell grep -oE "crVersion: .*" deploy/cr.yaml|grep -oE "[0-9]+\.[0-9]+\.[0-9]+"|cut -d'.' -f1)
Expand All @@ -121,13 +130,19 @@ after-release: manifests
$(SED) -i "/Version = \"/s/Version = \".*/Version = \"$(NEXT_VER)\"/" version/version.go
$(SED) -i \
-e "s/crVersion: .*/crVersion: $(NEXT_VER)/" \
-e "/^spec:/,/^ image:/{s#image: .*#image: perconalab/percona-server-mongodb-operator:main-mongod7.0#}" deploy/cr-minimal.yaml
-e "/^spec:/,/^ image:/{s#image: .*#image: perconalab/percona-server-mongodb-operator:main-mongod8.0#}" deploy/cr-minimal.yaml
$(SED) -i \
-e "s/crVersion: .*/crVersion: $(NEXT_VER)/" \
-e "/^spec:/,/^ image:/{s#image: .*#image: perconalab/percona-server-mongodb-operator:main-mongod7.0#}" \
-e "/^spec:/,/^ image:/{s#image: .*#image: perconalab/percona-server-mongodb-operator:main-mongod8.0#}" \
-e "/^ backup:/,/^ image:/{s#image: .*#image: perconalab/percona-server-mongodb-operator:main-backup#}" \
-e "s#initImage: .*#initImage: perconalab/percona-server-mongodb-operator:main#g" \
-e "/^ pmm:/,/^ image:/{s#image: .*#image: perconalab/pmm-client:dev-latest#}" deploy/cr.yaml
$(SED) -i \
-e "s|$(IMAGE_MONGOD80)|perconalab/percona-server-mongodb-operator:main-mongod8.0|g" \
-e "s|$(IMAGE_BACKUP)|perconalab/percona-server-mongodb-operator:main-backup|g" \
-e "s|$(IMAGE_OPERATOR)|perconalab/percona-server-mongodb-operator:main|g" \
pkg/controller/perconaservermongodb/testdata/reconcile-statefulset/*.yaml
$(SED) -i "s|cr.Spec.InitImage = \".*\"|cr.Spec.InitImage = \"perconalab/percona-server-mongodb-operator:main\"|g" pkg/controller/perconaservermongodb/suite_test.go

version-service-client: swagger
curl https://raw.githubusercontent.com/Percona-Lab/percona-version-service/$(VS_BRANCH)/api/version.swagger.yaml \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Below is one of the ways to deploy the Operator using `kubectl`.
kubectl apply --server-side -f https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/main/deploy/bundle.yaml
```

2. Deploy the database cluster itself from `deploy/cr.yaml
2. Deploy the database cluster itself from `deploy/cr.yaml`

```sh
kubectl apply -f https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/main/deploy/cr-minimal.yaml
Expand Down
8 changes: 5 additions & 3 deletions config/crd/bases/psmdb.percona.com_perconaservermongodbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18849,14 +18849,16 @@ spec:
initialized:
type: boolean
members:
items:
additionalProperties:
properties:
name:
type: string
version:
state:
type: integer
stateStr:
type: string
type: object
type: array
type: object
message:
type: string
ready:
Expand Down
8 changes: 5 additions & 3 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19545,14 +19545,16 @@ spec:
initialized:
type: boolean
members:
items:
additionalProperties:
properties:
name:
type: string
version:
state:
type: integer
stateStr:
type: string
type: object
type: array
type: object
message:
type: string
ready:
Expand Down
4 changes: 2 additions & 2 deletions deploy/cr-minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ kind: PerconaServerMongoDB
metadata:
name: minimal-cluster
spec:
crVersion: 1.18.0
image: perconalab/percona-server-mongodb-operator:main-mongod7.0
crVersion: 1.20.0
image: perconalab/percona-server-mongodb-operator:main-mongod8.0
unsafeFlags:
replsetSize: true
mongosSize: true
Expand Down
4 changes: 2 additions & 2 deletions deploy/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ spec:
# pause: true
# unmanaged: false
# enableVolumeExpansion: false
crVersion: 1.19.0
image: perconalab/percona-server-mongodb-operator:main-mongod7.0
crVersion: 1.20.0
image: perconalab/percona-server-mongodb-operator:main-mongod8.0
imagePullPolicy: Always
# tls:
# mode: preferTLS
Expand Down
8 changes: 5 additions & 3 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19545,14 +19545,16 @@ spec:
initialized:
type: boolean
members:
items:
additionalProperties:
properties:
name:
type: string
version:
state:
type: integer
stateStr:
type: string
type: object
type: array
type: object
message:
type: string
ready:
Expand Down
8 changes: 5 additions & 3 deletions deploy/cw-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19545,14 +19545,16 @@ spec:
initialized:
type: boolean
members:
items:
additionalProperties:
properties:
name:
type: string
version:
state:
type: integer
stateStr:
type: string
type: object
type: array
type: object
message:
type: string
ready:
Expand Down
30 changes: 20 additions & 10 deletions e2e-tests/default-cr/run
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,34 @@ function start_cluster() {
}

function main() {
create_infra "$namespace"
cluster="my-cluster-name"

desc 'create secrets and start client'
kubectl_bin apply -f $deploy_dir/secrets.yaml
kubectl_bin apply -f $conf_dir/client.yml

desc "create first PSMDB cluster $cluster"
delete_crd
check_crd_for_deletion "${GIT_BRANCH}"
kubectl_bin apply ${OPERATOR_NS:+-n $OPERATOR_NS} --server-side --force-conflicts -f $deploy_dir/crd.yaml

if [ -n "$OPERATOR_NS" ]; then
create_namespace $OPERATOR_NS
create_namespace ${namespace}
apply_rbac cw-rbac
kubectl_bin apply -n ${OPERATOR_NS} -f $deploy_dir/cw-operator.yaml
yq eval '
((.. | select(.[] == "DISABLE_TELEMETRY")) |= .value="true") |
((.. | select(.[] == "LOG_LEVEL")) |= .value="DEBUG")' ${src_dir}/deploy/cw-operator.yaml \
| kubectl_bin apply -n ${OPERATOR_NS} -f -
else
create_namespace ${namespace}
apply_rbac rbac
yq eval '((.. | select(.[] == "DISABLE_TELEMETRY")) |= .value="true")' "$deploy_dir/operator.yaml" \
yq eval '
((.. | select(.[] == "DISABLE_TELEMETRY")) |= .value="true") |
((.. | select(.[] == "LOG_LEVEL")) |= .value="DEBUG")' ${src_dir}/deploy/operator.yaml \
| kubectl_bin apply -f -
fi

cluster="my-cluster-name"

desc 'create secrets and start client'
kubectl_bin apply -f $deploy_dir/secrets.yaml
kubectl_bin apply -f $conf_dir/client.yml

desc "create first PSMDB cluster $cluster"
yq eval '.spec.upgradeOptions.versionServiceEndpoint = "https://check-dev.percona.com" |
.spec.replsets[].affinity.antiAffinityTopologyKey = "none" |
.spec.replsets[].nonvoting.affinity.antiAffinityTopologyKey = "none" |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ spec:
- name: PBM_AGENT_MONGODB_USERNAME
valueFrom:
secretKeyRef:
key: MONGODB_BACKUP_USER
key: MONGODB_BACKUP_USER_ESCAPED
name: internal-some-name-users
optional: false
- name: PBM_AGENT_MONGODB_PASSWORD
valueFrom:
secretKeyRef:
key: MONGODB_BACKUP_PASSWORD
key: MONGODB_BACKUP_PASSWORD_ESCAPED
name: internal-some-name-users
optional: false
- name: PBM_MONGODB_REPLSET
Expand Down
6 changes: 3 additions & 3 deletions e2e-tests/demand-backup-eks-credentials-irsa/run
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ compare_kubectl statefulset/$cluster-rs0

desc "update service accounts for operator and default (our cluster uses this one)"

kubectl_bin annotate serviceaccount default \
kubectl_bin annotate serviceaccount default \
eks.amazonaws.com/role-arn="$role_arn" \
--overwrite

kubectl_bin annotate serviceaccount percona-server-mongodb-operator \
kubectl_bin ${OPERATOR_NS:+-n $OPERATOR_NS} annotate serviceaccount percona-server-mongodb-operator \
eks.amazonaws.com/role-arn="$role_arn" \
--overwrite

desc "restart operator and cluster"
operator_pod=$(get_operator_pod)
kubectl_bin delete pod $operator_pod
kubectl_bin ${OPERATOR_NS:+-n $OPERATOR_NS} delete pod $operator_pod

kubectl_bin delete pod "$cluster-rs0-0"
kubectl_bin delete pod "$cluster-rs0-1"
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/demand-backup-fs/conf/some-name.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
volumeMounts:
- mountPath: /mnt/nfs/
name: backup-nfs
image: perconalab/percona-server-mongodb-operator:main-mongod7.0
image: perconalab/percona-server-mongodb-operator:main-mongod8.0
imagePullPolicy: Always
pmm:
enabled: false
Expand Down
26 changes: 22 additions & 4 deletions e2e-tests/demand-backup-fs/run
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ test_dir=$(realpath $(dirname $0))
. ${test_dir}/../functions
set_debug

if [[ "${OPENSHIFT}" ]]; then
echo "This test is not supported on OpenShift due to nfs privileged. See K8SPSMDB-1262"
exit 0
fi

deploy_nfs_server() {
kubectl_bin create namespace storage
kubectl_bin apply -n storage -f ${test_dir}/conf/nfs-server.yaml
sleep 5 # wait for NFS server pod to be created
local nfsPod=$(kubectl_bin get pod -n storage -l app=nfs-server -o jsonpath={.items[].metadata.name})

local nfsPod=$(kubectl_bin get pod -n storage -l app=nfs-server -o jsonpath={.items[].metadata.name})
until [[ "$(kubectl_bin get pod ${nfsPod} -n storage -o jsonpath={.status.phase})" == "Running" ]]; do
log "Waiting for ${nfsPod} to start Running"
sleep 1
Expand Down Expand Up @@ -50,6 +55,11 @@ create_infra ${namespace}

kubectl_bin delete ns storage || :

if [[ $GKE != 1 ]]; then
sc=$(kubectl_bin get storageclass | tail -1 | awk '{print $1}')
kubectl_bin annotate storageclass ${sc} storageclass.kubernetes.io/is-default-class=true
fi

log "deploying NFS server"
deploy_nfs_server

Expand All @@ -59,13 +69,21 @@ kubectl_bin apply \
-f "${conf_dir}/client.yml"

log "creating PSMDB cluster ${cluster}"
apply_cluster ${test_dir}/conf/${cluster}.yaml
if [[ $GKE != 1 ]]; then
nfs_ip=$(kubectl_bin -n storage get svc nfs-service -o jsonpath={.spec.clusterIP})
sed "s/nfs-service.storage.svc.cluster.local/${nfs_ip}/g" ${test_dir}/conf/${cluster}.yaml \
| kubectl_bin apply -f -
else
apply_cluster ${test_dir}/conf/${cluster}.yaml
fi

log 'wait for all 3 pods to start'
wait_for_running ${cluster}-rs0 3

log 'checking if statefulset created with expected config'
compare_kubectl statefulset/${cluster}-rs0
if [[ $GKE == 1 ]]; then
log 'checking if statefulset created with expected config'
compare_kubectl statefulset/${cluster}-rs0
fi

log 'creating user'
run_mongo \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ spec:
- mountPath: /opt/percona
name: bin
restartPolicy: Always
runtimeClassName: container-rc
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ spec:
- mountPath: /opt/percona
name: bin
restartPolicy: Always
runtimeClassName: container-rc
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ spec:
- mountPath: /opt/percona
name: bin
restartPolicy: Always
runtimeClassName: container-rc
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
Expand Down
5 changes: 2 additions & 3 deletions e2e-tests/functions
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ GIT_BRANCH=${VERSION:-$(git rev-parse --abbrev-ref HEAD | sed -e 's^/^-^g; s^[.]
API="psmdb.percona.com/v1"
OPERATOR_VERSION="$(grep 'crVersion' $(realpath $(dirname ${BASH_SOURCE[0]})/../deploy/cr.yaml) | awk '{print $2}')"
IMAGE=${IMAGE:-"perconalab/percona-server-mongodb-operator:${GIT_BRANCH}"}
IMAGE_MONGOD=${IMAGE_MONGOD:-"perconalab/percona-server-mongodb-operator:main-mongod7.0"}
IMAGE_MONGOD=${IMAGE_MONGOD:-"perconalab/percona-server-mongodb-operator:main-mongod8.0"}
IMAGE_MONGOD_CHAIN=${IMAGE_MONGOD_CHAIN:-$'
perconalab/percona-server-mongodb-operator:main-mongod5.0
perconalab/percona-server-mongodb-operator:main-mongod6.0
perconalab/percona-server-mongodb-operator:main-mongod7.0
perconalab/percona-server-mongodb-operator:main-mongod8.0'}
Expand All @@ -16,7 +15,7 @@ SKIP_BACKUPS_TO_AWS_GCP_AZURE=${SKIP_BACKUPS_TO_AWS_GCP_AZURE:-1}
PMM_SERVER_VER=${PMM_SERVER_VER:-"9.9.9"}
IMAGE_PMM_CLIENT=${IMAGE_PMM_CLIENT:-"perconalab/pmm-client:dev-latest"}
IMAGE_PMM_SERVER=${IMAGE_PMM_SERVER:-"perconalab/pmm-server:dev-latest"}
CERT_MANAGER_VER="1.16.1"
CERT_MANAGER_VER="1.16.2"
tmp_dir=$(mktemp -d)
sed=$(which gsed || which sed)
date=$(which gdate || which date)
Expand Down
Loading

0 comments on commit ad41057

Please sign in to comment.