diff --git a/.dockerignore b/.dockerignore index 114f349c0..06e1fa0e9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -53,9 +53,8 @@ tools.go # Kubernetes and operator-related artifacts deploy/ config/manifests/ -helm_chart/templates/ -helm_chart/crds/ public/ +!/public/tools/multicluster/go.mod # Documentation files docs/ diff --git a/.evergreen-functions.yml b/.evergreen-functions.yml index c98e43fdd..a28545282 100644 --- a/.evergreen-functions.yml +++ b/.evergreen-functions.yml @@ -424,6 +424,21 @@ functions: params: file: "src/github.com/10gen/ops-manager-kubernetes/logs/myreport.xml" + upload_e2e_logs_gotest: + - command: s3.put + params: + aws_key: ${enterprise_aws_access_key_id} + aws_secret: ${enterprise_aws_secret_access_key} + local_files_include_filter: + - src/github.com/10gen/ops-manager-kubernetes/logs/* + remote_file: logs/${task_id}/${execution}/ + bucket: operator-e2e-artifacts + permissions: public-read + content_type: text/plain + - command: gotest.parse_files + params: + files: [ "src/github.com/10gen/ops-manager-kubernetes/logs/*.suite" ] + upload_code_snippets_logs: - command: s3.put params: @@ -625,7 +640,7 @@ functions: make test-race - command: gotest.parse_files params: - files: [ "src/github.com/10gen/ops-manager-kubernetes/*.suite", "src/github.com/10gen/ops-manager-kubernetes/public/tools/multicluster/*.suite", "src/github.com/10gen/ops-manager-kubernetes/docker/mongodb-enterprise-init-ops-manager/mmsconfiguration/*.suite" ] + files: [ "src/github.com/10gen/ops-manager-kubernetes/*.suite", "src/github.com/10gen/ops-manager-kubernetes/public/tools/multicluster/*.suite", "src/github.com/10gen/ops-manager-kubernetes/docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/*.suite" ] test_python_unit: - command: shell.exec diff --git a/.evergreen-mco.yml b/.evergreen-mco.yml new file mode 100644 index 000000000..b2f9f7bac --- /dev/null +++ b/.evergreen-mco.yml @@ -0,0 +1,147 @@ +buildvariants: +- display_tasks: + - execution_tasks: [] + name: e2e_mco_tests + name: e2e_mco_tests + tasks: + - name: e2e_mco_task_group +task_groups: +- max_hosts: -1 + name: e2e_mco_task_group + setup_group: + - func: clone + - func: download_kube_tools + - func: setup_building_host + setup_task: + - func: cleanup_exec_environment + - func: configure_docker_auth + - func: setup_kubernetes_environment + tasks: + - feature_compatibility_version + - prometheus + - replica_set + - replica_set_arbiter + - replica_set_change_version + - replica_set_connection_string_options + - replica_set_cross_namespace_deploy + - replica_set_custom_persistent_volume + - replica_set_custom_role + - replica_set_enterprise_upgrade_4_5 + - replica_set_enterprise_upgrade_5_6 + - replica_set_enterprise_upgrade_6_7 + - replica_set_enterprise_upgrade_7_8 + - replica_set_mongod_config + - replica_set_mongod_port_change_with_arbiters + - replica_set_mongod_readiness + - replica_set_mount_connection_string + - replica_set_operator_upgrade + - replica_set_recovery + - replica_set_remove_user + - replica_set_scale + - replica_set_scale_down + - replica_set_tls + - replica_set_tls_recreate_mdbc + - replica_set_tls_rotate + - replica_set_tls_rotate_delete_sts + - replica_set_tls_upgrade + - replica_set_x509 + - statefulset_arbitrary_config + - statefulset_arbitrary_config_update + teardown_group: + - func: prune_docker_resources + - func: run_retry_script + teardown_task: + - func: upload_e2e_logs_gotest + - func: teardown_kubernetes_environment +tasks: +- commands: + - func: e2e_test + name: feature_compatibility_version +- commands: + - func: e2e_test + name: prometheus +- commands: + - func: e2e_test + name: replica_set +- commands: + - func: e2e_test + name: replica_set_arbiter +- commands: + - func: e2e_test + name: replica_set_change_version +- commands: + - func: e2e_test + name: replica_set_connection_string_options +- commands: + - func: e2e_test + name: replica_set_cross_namespace_deploy +- commands: + - func: e2e_test + name: replica_set_custom_persistent_volume +- commands: + - func: e2e_test + name: replica_set_custom_role +- commands: + - func: e2e_test + name: replica_set_enterprise_upgrade_4_5 +- commands: + - func: e2e_test + name: replica_set_enterprise_upgrade_5_6 +- commands: + - func: e2e_test + name: replica_set_enterprise_upgrade_6_7 +- commands: + - func: e2e_test + name: replica_set_enterprise_upgrade_7_8 +- commands: + - func: e2e_test + name: replica_set_mongod_config +- commands: + - func: e2e_test + name: replica_set_mongod_port_change_with_arbiters +- commands: + - func: e2e_test + name: replica_set_mongod_readiness +- commands: + - func: e2e_test + name: replica_set_mount_connection_string +- commands: + - func: e2e_test + name: replica_set_operator_upgrade +- commands: + - func: e2e_test + name: replica_set_recovery +- commands: + - func: e2e_test + name: replica_set_remove_user +- commands: + - func: e2e_test + name: replica_set_scale +- commands: + - func: e2e_test + name: replica_set_scale_down +- commands: + - func: e2e_test + name: replica_set_tls +- commands: + - func: e2e_test + name: replica_set_tls_recreate_mdbc +- commands: + - func: e2e_test + name: replica_set_tls_rotate +- commands: + - func: e2e_test + name: replica_set_tls_rotate_delete_sts +- commands: + - func: e2e_test + name: replica_set_tls_upgrade +- commands: + - func: e2e_test + name: replica_set_x509 +- commands: + - func: e2e_test + name: statefulset_arbitrary_config +- commands: + - func: e2e_test + name: statefulset_arbitrary_config_update + diff --git a/.evergreen-tasks.yml b/.evergreen-tasks.yml index beb8ef3a9..6df9272ea 100644 --- a/.evergreen-tasks.yml +++ b/.evergreen-tasks.yml @@ -89,6 +89,11 @@ tasks: commands: - func: e2e_test + - name: e2e_community_and_meko_replicaset_scale + tags: [ "patch-run" ] + commands: + - func: e2e_test + - name: e2e_standalone_custom_podspec tags: [ "patch-run" ] commands: @@ -181,6 +186,8 @@ tasks: - func: "e2e_test" - name: e2e_olm_operator_upgrade + # TODO: CLOUDP-310820 - After 1.0.0 release we need re-enable this + disable: true tags: [ "patch-run" ] commands: - func: "e2e_test" @@ -192,6 +199,13 @@ tasks: - func: "e2e_test" - name: e2e_olm_operator_upgrade_with_resources + # TODO: CLOUDP-310820 - After 1.0.0 release we need re-enable this + disable: true + tags: [ "patch-run" ] + commands: + - func: "e2e_test" + + - name: e2e_olm_meko_operator_upgrade_with_resources tags: [ "patch-run" ] commands: - func: "e2e_test" @@ -211,6 +225,11 @@ tasks: commands: - func: "e2e_test" + - name: e2e_community_replicaset_scale + tags: ["patch-run"] + commands: + - func: "e2e_test" + - name: e2e_replica_set tags: [ "patch-run" ] commands: diff --git a/.evergreen.yml b/.evergreen.yml index 2d1f0ea1d..618cd3644 100644 --- a/.evergreen.yml +++ b/.evergreen.yml @@ -4,6 +4,7 @@ exec_timeout_secs: 7200 include: - filename: .evergreen-functions.yml - filename: .evergreen-tasks.yml + - filename: .evergreen-mco.yml variables: - &ops_manager_60_latest 6.0.27 # The order/index is important, since these are anchors. Please do not change @@ -54,6 +55,21 @@ variables: - name: build_agent_images_ubi variant: init_test_run + - &community_dependency + depends_on: + - name: build_operator_ubi + variant: init_test_run + - name: build_test_image + variant: init_test_run + - name: build_agent_images_ubi + variant: init_test_run + - name: build_readiness_probe_image + variant: init_test_run + - name: build_upgrade_hook_image + variant: init_test_run + - name: build_mco_test_image + variant: init_test_run + - &setup_group setup_group_can_fail_task: true setup_group: @@ -198,6 +214,8 @@ github_pr_aliases: task_tags: [ "unit_tests" ] - variant_tags: [ "e2e_test_suite" ] task_tags: [ "patch-run" ] + - variant_tags: [ "e2e_mco_test_suite" ] + task: ".*" - variant_tags: [ "auto_bump" ] task_tags: [ "patch-run" ] @@ -213,8 +231,8 @@ git_tag_aliases: variant_tags: [ "release" ] task_tags: [ "image_release", "image_preflight", "openshift_bundles", "code_snippets" ] +# TODO: MCK: have this part of e2e.sh and its expansions tasks: - - name: unit_tests_golang tags: [ "unit_tests" ] commands: @@ -394,6 +412,14 @@ tasks: vars: image_name: test + - name: build_mco_test_image + commands: + - func: clone + - func: setup_building_host + - func: pipeline + vars: + image_name: mco-test + - name: build_operator_ubi commands: - func: clone @@ -452,6 +478,24 @@ tasks: image_name: database skip_tags: ubuntu,release + - name: build_readiness_probe_image + commands: + - func: clone + - func: setup_building_host + - func: pipeline + vars: + image_name: readiness-probe + skip_tags: ubuntu,release + + - name: build_upgrade_hook_image + commands: + - func: clone + - func: setup_building_host + - func: pipeline + vars: + image_name: upgrade-hook + skip_tags: ubuntu,release + - name: prepare_aws priority: 59 commands: @@ -542,7 +586,7 @@ tasks: - func: upload_openshift_bundle vars: # mongoDbOperator expansion is added in update_evergreen_expansions func from release.json - bundle_file_name: "operator-certified-${mongodbOperator}.tgz" + bundle_file_name: "mck-operator-certified-${mongodbOperator}.tgz" - name: run_conditionally_prepare_and_upload_openshift_bundles tags: [ "openshift_bundles" ] @@ -576,6 +620,14 @@ task_groups: - gke_multi_cluster_snippets - gke_multi_cluster_no_mesh_snippets + # Task group for deploying mongodbcommunity resources and testing the (former) MCO + - name: e2e_mdb_community_task_group + max_hosts: -1 + <<: *setup_group + <<: *setup_and_teardown_task + tasks: + - e2e_community_replicaset_scale + # This is the task group that contains all the tests run in the e2e_mdb_kind_ubuntu_cloudqa build variant - name: e2e_mdb_kind_cloudqa_task_group max_hosts: -1 @@ -692,6 +744,7 @@ task_groups: - e2e_replica_set_migration - e2e_replica_set_pv_resize - e2e_sharded_cluster_pv_resize + - e2e_community_and_meko_replicaset_scale <<: *teardown_group # this task group contains just a one task, which is smoke testing whether the operator @@ -1116,6 +1169,7 @@ task_groups: tasks: - e2e_olm_operator_upgrade - e2e_olm_operator_upgrade_with_resources + - e2e_olm_meko_operator_upgrade_with_resources <<: *teardown_group buildvariants: @@ -1139,6 +1193,16 @@ buildvariants: # where is any of ubuntu|ubi # where denotes the OM version tested (e.g. om50, om60, cloudqa) - used only for MDB tests + ## MongoDBCommunity build variant + - name: e2e_mdb_community + display_name: e2e_mdb_community + tags: [ "e2e_test_suite"] + run_on: + - ubuntu2204-large + <<: *community_dependency + tasks: + - name: e2e_mdb_community_task_group + ## MongoDB build variants - name: e2e_mdb_kind_ubi_cloudqa display_name: e2e_mdb_kind_ubi_cloudqa @@ -1306,6 +1370,8 @@ buildvariants: - name: e2e_operator_race_with_telemetry_task_group - name: e2e_smoke + # TODO: CLOUDP-310820 - After 1.0.0 release we need re-enabled this + disable: true display_name: e2e_smoke tags: [ "e2e_test_suite" ] run_on: @@ -1317,6 +1383,8 @@ buildvariants: - name: e2e_smoke_task_group - name: e2e_static_smoke + # TODO: CLOUDP-310820 - After 1.0.0 release we need re-enabled this + disable: true display_name: e2e_static_smoke tags: [ "e2e_test_suite" ] run_on: @@ -1493,6 +1561,14 @@ buildvariants: tasks: - name: e2e_kind_olm_group + # This variants runs the tests from MCO with the MEKO operator binary + - name: e2e_mco_tests + display_name: "e2e_mco_tests" + tags: [ "e2e_mco_test_suite"] + <<: *community_dependency + run_on: + - ubuntu2004-large + ## Manual (patch) E2E tests not run for every PR and commit - name: e2e_operator_perf @@ -1535,11 +1611,14 @@ buildvariants: tasks: - name: build_operator_ubi - name: build_test_image + - name: build_mco_test_image - name: build_init_appdb_images_ubi - name: build_init_om_images_ubi - name: build_init_database_image_ubi - name: build_database_image_ubi - name: build_agent_images_ubi + - name: build_readiness_probe_image + - name: build_upgrade_hook_image - name: prepare_aws - name: init_release_agents_on_ecr @@ -1580,8 +1659,6 @@ buildvariants: variant: init_test_run - name: build_agent_images_ubi variant: init_test_run - - name: release_agents_on_ecr_conditional - variant: init_release_agents_on_ecr run_on: - ubuntu2204-small tasks: diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 84227c765..bc4e1e99f 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -16,6 +16,12 @@ fi mkdir -p "$(go env GOPATH)/bin" +function update_mco_tests() { + echo "Regenerating MCO evergreen tests configuration" + python scripts/evergreen/e2e/mco/create_mco_tests.py > .evergreen-mco.yml + git add .evergreen-mco.yml +} + # Generates a yaml file to install the operator from the helm sources. function generate_standalone_yaml() { HELM_OPTS=$@ @@ -112,6 +118,8 @@ function pre_commit() { generate_standalone_yaml # Run black on python files that have changed python_formatting + # Generate MCO evergreen tests + update_mco_tests source scripts/evergreen/lint_code.sh @@ -180,4 +188,6 @@ elif [[ "${cmd}" == "pre-commit" ]]; then pre_commit elif [[ "${cmd}" == "shellcheck" ]]; then start_shellcheck +elif [[ "${cmd}" == "lint" ]]; then + source scripts/evergreen/lint_code.sh fi diff --git a/mongodb-community-operator/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md similarity index 100% rename from mongodb-community-operator/.github/ISSUE_TEMPLATE/bug_report.md rename to .github/ISSUE_TEMPLATE/bug_report.md diff --git a/mongodb-community-operator/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml similarity index 100% rename from mongodb-community-operator/.github/ISSUE_TEMPLATE/config.yml rename to .github/ISSUE_TEMPLATE/config.yml diff --git a/.gitignore b/.gitignore index 2038ad0b0..55ce9969c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,8 @@ /vendor/ public/tools/multicluster/vendor docker/mongodb-enterprise-operator/content/mongodb-enterprise-operator -docker/mongodb-enterprise-database/content/mongodb-mms-automation-agent-version.properties -docker/mongodb-enterprise-database/content/readinessprobe +docker/mongodb-kubernetes-database/content/mongodb-mms-automation-agent-version.properties +docker/mongodb-kubernetes-database/content/readinessprobe docker/mongodb-enterprise-ops-manager/scripts/mmsconfiguration docker/mongodb-enterprise-tests/public @@ -18,7 +18,6 @@ cache **/__pycache__ **/myenv **/venv*/ -**/env*/ *.bak **/pytest_cache/ tmp/* @@ -46,10 +45,10 @@ public/architectures/**/secrets/* docker/mongodb-enterprise-appdb/content/readinessprobe ops-manager-kubernetes docker/mongodb-enterprise-operator/Dockerfile -docker/mongodb-enterprise-database/Dockerfile +docker/mongodb-kubernetes-database/Dockerfile docker/mongodb-enterprise-ops-manager/Dockerfile -docker/mongodb-enterprise-init-database/Dockerfile -docker/mongodb-enterprise-init-ops-manager/Dockerfile +docker/mongodb-kubernetes-init-database/Dockerfile +docker/mongodb-kubernetes-init-ops-manager/Dockerfile docker/mongodb-enterprise-operator/content/mongodb-enterprise-operator.tar docker/mongodb-enterprise-tests/helm_chart/ docker/mongodb-enterprise-tests/public/ diff --git a/.golangci.yml b/.golangci.yml index 1096d29be..ab4f8c535 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -85,7 +85,7 @@ linters: path: ^pkg\/util\/env - linters: - forbidigo - path: ^main.go$ + path: main.go$ formatters: enable: - gci @@ -102,7 +102,6 @@ formatters: - standard # Standard section: captures all standard packages. - default # Default section: contains all imports that could not be matched to another section type. - prefix(github.com/10gen/ops-manager-kubernetes) # Custom section: groups all imports with the specified Prefix. - - prefix(github.com/mongodb/mongodb-kubernetes-operator) # Custom section: groups all imports with the specified Prefix. - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. - alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled. diff --git a/Makefile b/Makefile index cab715f33..d45ca2ac9 100644 --- a/Makefile +++ b/Makefile @@ -71,6 +71,12 @@ operator: configure-operator build-and-push-operator-image database: aws_login @ scripts/evergreen/run_python.sh pipeline.py --include database +readiness_probe: aws_login + @ scripts/evergreen/run_python.sh pipeline.py --include readiness-probe + +upgrade_hook: aws_login + @ scripts/evergreen/run_python.sh pipeline.py --include upgrade-hook + # ensures cluster is up, cleans Kubernetes + OM, build-push-deploy operator, # push-deploy database, create secrets, config map, resources etc full: build-and-push-images @@ -92,17 +98,30 @@ e2e: build-and-push-test-image fi @ scripts/dev/launch_e2e.sh +mco-e2e: aws_login build-and-push-mco-test-image + @ if [[ -z "$(skip)" ]]; then \ + $(MAKE) reset; \ + fi + @ scripts/dev/launch_e2e.sh + +generate-env-file: ## generates a local-test.env for local testing + mkdir -p .generated + { scripts/evergreen/run_python.sh mongodb-community-operator/scripts/dev/get_e2e_env_vars.py ".generated/config.json" | tee >(cut -d' ' -f2 > .generated/mco-test.env) ;} > .generated/mco-test.export.env + . .generated/mco-test.export.env + +reset-helm-leftovers: ## sometimes you didn't cleanly uninstall a helm release, this cleans the existing helm artifacts + @ scripts/dev/reset_helm.sh + e2e-telepresence: build-and-push-test-image telepresence connect --context $(test_pod_cluster); scripts/dev/launch_e2e.sh; telepresence quit -# deletes and creates a kops e2e cluster -recreate-e2e-kops: - @ scripts/dev/recreate_e2e_kops.sh $(imsure) $(cluster) - # clean all kubernetes cluster resources and OM state -reset: +reset: reset-mco go run scripts/dev/reset.go +reset-mco: ## Cleans up e2e test env + kubectl delete mdbc,all,secrets -l e2e-test=true || true + status: @ scripts/dev/status @@ -139,6 +158,11 @@ build-and-push-test-image: aws_login build-multi-cluster-binary scripts/evergreen/run_python.sh pipeline.py --include test; \ fi +build-and-push-mco-test-image: aws_login + @ if [[ -z "$(local)" ]]; then \ + scripts/evergreen/run_python.sh pipeline.py --include mco-test; \ + fi + build-multi-cluster-binary: scripts/evergreen/build_multi_cluster_kubeconfig_creator.sh @@ -372,7 +396,7 @@ dockerfiles: python scripts/update_supported_dockerfiles.py tar -czvf ./public/dockerfiles-$(VERSION).tgz ./public/dockerfiles -prepare-local-e2e: # prepares the local environment to run a local operator +prepare-local-e2e: reset-mco # prepares the local environment to run a local operator scripts/dev/prepare_local_e2e_run.sh prepare-operator-configmap: # prepares the local environment to run a local operator diff --git a/PROJECT b/PROJECT index c76140b76..585f5b86b 100644 --- a/PROJECT +++ b/PROJECT @@ -1,6 +1,6 @@ domain: mongodb.com layout: go.kubebuilder.io/v3 -projectName: mongodb-enterprise +projectName: mongodb-kubernetes repo: github.com/10gen/ops-manager-kubernetes resources: - api: diff --git a/README.md b/README.md index ad5329877..0e681b1b2 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This is a Kubernetes Operator (https://coreos.com/operators/) to work with Ops Manager and Kubernetes clusters. It allows you to easily add new MongoDB deployments (standalones, replica sets, sharded clusters) to your Kubernetes cluster, configure them (modify, scale up/down, remove) and to manage them from your -Ops Manager installation. This provides the combined power of Kubernetes (native scheduling of applications to nodes, scaling, fault tolerance etc) with Ops Manager capabilities (monitoring, backup, upgrades etc) +Ops Manager installation. This provides the combined power of Kubernetes (native scheduling of applications to nodes, scaling, fault tolerance etc) with Ops Manager capabilities (monitoring, backup, upgrades etc). ## Development diff --git a/api/v1/mdb/mongodb_types.go b/api/v1/mdb/mongodb_types.go index c6ad75425..96ca45804 100644 --- a/api/v1/mdb/mongodb_types.go +++ b/api/v1/mdb/mongodb_types.go @@ -11,10 +11,6 @@ import ( "k8s.io/apimachinery/pkg/labels" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - - mdbcv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -22,6 +18,10 @@ import ( "github.com/10gen/ops-manager-kubernetes/api/v1/status" "github.com/10gen/ops-manager-kubernetes/controllers/operator/connectionstring" "github.com/10gen/ops-manager-kubernetes/controllers/operator/ldap" + mdbcv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/fcv" "github.com/10gen/ops-manager-kubernetes/pkg/kube" @@ -265,7 +265,7 @@ type ClusterSpecItem struct { // +optional MemberConfig []automationconfig.MemberOptions `json:"memberConfig,omitempty"` // +optional - StatefulSetConfiguration *mdbcv1.StatefulSetConfiguration `json:"statefulSet,omitempty"` + StatefulSetConfiguration *common.StatefulSetConfiguration `json:"statefulSet,omitempty"` // +optional PodSpec *MongoDbPodSpec `json:"podSpec,omitempty"` } @@ -287,7 +287,7 @@ type ClusterSpecItemOverride struct { // +optional MemberConfig []automationconfig.MemberOptions `json:"memberConfig,omitempty"` // +optional - StatefulSetConfiguration *mdbcv1.StatefulSetConfiguration `json:"statefulSet,omitempty"` + StatefulSetConfiguration *common.StatefulSetConfiguration `json:"statefulSet,omitempty"` // +optional PodSpec *MongoDbPodSpec `json:"podSpec,omitempty"` } @@ -389,7 +389,7 @@ type DbCommonSpec struct { // StatefulSetConfiguration provides the statefulset override for each of the cluster's statefulset // if "StatefulSetConfiguration" is specified at cluster level under "clusterSpecList" that takes precedence over // the global one - StatefulSetConfiguration *mdbcv1.StatefulSetConfiguration `json:"statefulSet,omitempty"` + StatefulSetConfiguration *common.StatefulSetConfiguration `json:"statefulSet,omitempty"` // AdditionalMongodConfig is additional configuration that can be passed to // each data-bearing mongod at runtime. Uses the same structure as the mongod @@ -983,7 +983,7 @@ type AgentAuthentication struct { AutomationLdapGroupDN string `json:"automationLdapGroupDN"` // +optional // +kubebuilder:pruning:PreserveUnknownFields - ClientCertificateSecretRefWrap ClientCertificateSecretRefWrapper `json:"clientCertificateSecretRef,omitempty"` + ClientCertificateSecretRefWrap common.ClientCertificateSecretRefWrapper `json:"clientCertificateSecretRef,omitempty"` } // IsX509Enabled determines if X509 is to be enabled at the project level @@ -1333,7 +1333,7 @@ type ExternalServiceConfiguration struct { // A wrapper for the Service spec object. // +optional // +kubebuilder:pruning:PreserveUnknownFields - SpecWrapper *ServiceSpecWrapper `json:"spec"` + SpecWrapper *common.ServiceSpecWrapper `json:"spec"` // A map of annotations that shall be added to the externally available Service. // +optional @@ -1352,14 +1352,14 @@ type MongoDbPodSpec struct { ContainerResourceRequirements `json:"-"` // +kubebuilder:pruning:PreserveUnknownFields - PodTemplateWrapper PodTemplateSpecWrapper `json:"podTemplate,omitempty"` + PodTemplateWrapper common.PodTemplateSpecWrapper `json:"podTemplate,omitempty"` // Note, this field is not serialized in the CRD, it's only present here because of the // way we currently set defaults for this field in the operator, similar to "ContainerResourceRequirements" PodAntiAffinityTopologyKey string `json:"-"` // Note, that this field is used by MongoDB resources only, let's keep it here for simplicity - Persistence *Persistence `json:"persistence,omitempty"` + Persistence *common.Persistence `json:"persistence,omitempty"` } func (m *MongoDbPodSpec) IsAgentImageOverridden() bool { @@ -1386,25 +1386,6 @@ type PodSpecWrapper struct { Default MongoDbPodSpec } -type Persistence struct { - SingleConfig *PersistenceConfig `json:"single,omitempty"` - MultipleConfig *MultiplePersistenceConfig `json:"multiple,omitempty"` -} - -type MultiplePersistenceConfig struct { - Data *PersistenceConfig `json:"data,omitempty"` - Journal *PersistenceConfig `json:"journal,omitempty"` - Logs *PersistenceConfig `json:"logs,omitempty"` -} - -type PersistenceConfig struct { - Storage string `json:"storage,omitempty"` - StorageClass *string `json:"storageClass,omitempty"` - - // +kubebuilder:pruning:PreserveUnknownFields - LabelSelector *LabelSelectorWrapper `json:"labelSelector,omitempty"` -} - func (p PodSpecWrapper) GetCpuOrDefault() string { if p.CpuLimit == "" && p.CpuRequests == "" { return p.Default.CpuLimit @@ -1459,7 +1440,7 @@ func (p PodSpecWrapper) SetTopology(topology string) PodSpecWrapper { return p } -func GetStorageOrDefault(config *PersistenceConfig, defaultConfig PersistenceConfig) string { +func GetStorageOrDefault(config *common.PersistenceConfig, defaultConfig common.PersistenceConfig) string { if config == nil || config.Storage == "" { return defaultConfig.Storage } diff --git a/api/v1/mdb/mongodbbuilder.go b/api/v1/mdb/mongodbbuilder.go index 5b0d0118a..2ef97cf7d 100644 --- a/api/v1/mdb/mongodbbuilder.go +++ b/api/v1/mdb/mongodbbuilder.go @@ -5,6 +5,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/10gen/ops-manager-kubernetes/api/v1/status" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" ) // TODO must replace all [Standalone|Replicaset|Cluster]Builder classes in 'operator' package @@ -70,7 +71,7 @@ func (b *MongoDBBuilder) ExposedExternally(specOverride *corev1.ServiceSpec, ann b.mdb.Spec.ExternalAccessConfiguration = &ExternalAccessConfiguration{} b.mdb.Spec.ExternalAccessConfiguration.ExternalDomain = externalDomain if specOverride != nil { - b.mdb.Spec.ExternalAccessConfiguration.ExternalService.SpecWrapper = &ServiceSpecWrapper{Spec: *specOverride} + b.mdb.Spec.ExternalAccessConfiguration.ExternalService.SpecWrapper = &common.ServiceSpecWrapper{Spec: *specOverride} } if len(annotationsOverride) > 0 { b.mdb.Spec.ExternalAccessConfiguration.ExternalService.Annotations = annotationsOverride diff --git a/api/v1/mdb/podspecbuilder.go b/api/v1/mdb/podspecbuilder.go index f439b262d..00cad3f7a 100644 --- a/api/v1/mdb/podspecbuilder.go +++ b/api/v1/mdb/podspecbuilder.go @@ -4,6 +4,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" "github.com/10gen/ops-manager-kubernetes/pkg/util" ) @@ -13,7 +14,7 @@ type PodSpecWrapperBuilder struct { } type PersistenceConfigBuilder struct { - config *PersistenceConfig + config *common.PersistenceConfig } // NewPodSpecWrapperBuilder returns the builder with some default values, used in tests mostly @@ -25,7 +26,7 @@ func NewPodSpecWrapperBuilder() *PodSpecWrapperBuilder { MemoryLimit: "500M", MemoryRequests: "400M", }, - PodTemplateWrapper: PodTemplateSpecWrapper{&corev1.PodTemplateSpec{ + PodTemplateWrapper: common.PodTemplateSpecWrapper{PodTemplate: &corev1.PodTemplateSpec{ Spec: corev1.PodSpec{ Affinity: &corev1.Affinity{ PodAffinity: &corev1.PodAffinity{}, @@ -49,10 +50,10 @@ func NewPodSpecWrapperBuilderFromSpec(spec *MongoDbPodSpec) *PodSpecWrapperBuild func NewEmptyPodSpecWrapperBuilder() *PodSpecWrapperBuilder { return &PodSpecWrapperBuilder{spec: PodSpecWrapper{ MongoDbPodSpec: MongoDbPodSpec{ - Persistence: &Persistence{}, + Persistence: &common.Persistence{}, }, Default: MongoDbPodSpec{ - Persistence: &Persistence{SingleConfig: &PersistenceConfig{}}, + Persistence: &common.Persistence{SingleConfig: &common.PersistenceConfig{}}, }, }} } @@ -99,7 +100,7 @@ func (p *PodSpecWrapperBuilder) SetPodTemplate(template *corev1.PodTemplateSpec) func (p *PodSpecWrapperBuilder) SetSinglePersistence(builder *PersistenceConfigBuilder) *PodSpecWrapperBuilder { if p.spec.Persistence == nil { - p.spec.Persistence = &Persistence{} + p.spec.Persistence = &common.Persistence{} } p.spec.Persistence.SingleConfig = builder.config return p @@ -107,9 +108,9 @@ func (p *PodSpecWrapperBuilder) SetSinglePersistence(builder *PersistenceConfigB func (p *PodSpecWrapperBuilder) SetMultiplePersistence(dataBuilder, journalBuilder, logsBuilder *PersistenceConfigBuilder) *PodSpecWrapperBuilder { if p.spec.Persistence == nil { - p.spec.Persistence = &Persistence{} + p.spec.Persistence = &common.Persistence{} } - p.spec.Persistence.MultipleConfig = &MultiplePersistenceConfig{} + p.spec.Persistence.MultipleConfig = &common.MultiplePersistenceConfig{} if dataBuilder != nil { p.spec.Persistence.MultipleConfig.Data = dataBuilder.config } @@ -132,7 +133,7 @@ func (p *PodSpecWrapperBuilder) Build() *PodSpecWrapper { } func NewPersistenceBuilder(size string) *PersistenceConfigBuilder { - return &PersistenceConfigBuilder{config: &PersistenceConfig{Storage: size}} + return &PersistenceConfigBuilder{config: &common.PersistenceConfig{Storage: size}} } func (p *PersistenceConfigBuilder) SetStorageClass(class string) *PersistenceConfigBuilder { @@ -141,18 +142,18 @@ func (p *PersistenceConfigBuilder) SetStorageClass(class string) *PersistenceCon } func (p *PersistenceConfigBuilder) SetLabelSelector(labels map[string]string) *PersistenceConfigBuilder { - p.config.LabelSelector = &LabelSelectorWrapper{metav1.LabelSelector{MatchLabels: labels}} + p.config.LabelSelector = &common.LabelSelectorWrapper{LabelSelector: metav1.LabelSelector{MatchLabels: labels}} return p } func NewPodSpecWithDefaultValues() MongoDbPodSpec { defaultPodSpec := MongoDbPodSpec{PodAntiAffinityTopologyKey: "kubernetes.io/hostname"} - defaultPodSpec.Persistence = &Persistence{ - SingleConfig: &PersistenceConfig{Storage: "30G"}, - MultipleConfig: &MultiplePersistenceConfig{ - Data: &PersistenceConfig{Storage: util.DefaultMongodStorageSize}, - Journal: &PersistenceConfig{Storage: util.DefaultJournalStorageSize}, - Logs: &PersistenceConfig{Storage: util.DefaultLogsStorageSize}, + defaultPodSpec.Persistence = &common.Persistence{ + SingleConfig: &common.PersistenceConfig{Storage: "30G"}, + MultipleConfig: &common.MultiplePersistenceConfig{ + Data: &common.PersistenceConfig{Storage: util.DefaultMongodStorageSize}, + Journal: &common.PersistenceConfig{Storage: util.DefaultJournalStorageSize}, + Logs: &common.PersistenceConfig{Storage: util.DefaultLogsStorageSize}, }, } defaultPodSpec.PodTemplateWrapper = NewMongoDbPodSpec().PodTemplateWrapper diff --git a/api/v1/mdb/sharded_cluster_validation_test.go b/api/v1/mdb/sharded_cluster_validation_test.go index 9aa763ec1..ec8468e55 100644 --- a/api/v1/mdb/sharded_cluster_validation_test.go +++ b/api/v1/mdb/sharded_cluster_validation_test.go @@ -9,12 +9,11 @@ import ( "github.com/stretchr/testify/require" "k8s.io/utils/ptr" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - - v1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" corev1 "k8s.io/api/core/v1" "github.com/10gen/ops-manager-kubernetes/api/v1/status" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" ) @@ -235,7 +234,7 @@ func TestValidClusterSpecLists(t *testing.T) { func TestNoIgnoredFieldUsed(t *testing.T) { podSpecWithTemplate := &MongoDbPodSpec{ - PodTemplateWrapper: PodTemplateSpecWrapper{PodTemplate: &corev1.PodTemplateSpec{ + PodTemplateWrapper: common.PodTemplateSpecWrapper{PodTemplate: &corev1.PodTemplateSpec{ Spec: corev1.PodSpec{}, }}, } @@ -262,7 +261,7 @@ func TestNoIgnoredFieldUsed(t *testing.T) { shardOverrides: []ShardOverride{ {ShardNames: []string{"foo-0"}, MemberConfig: defaultMemberConfig}, {ShardNames: []string{"foo-1"}, Members: ptr.To(2)}, - {ShardNames: []string{"foo-2"}, StatefulSetConfiguration: &v1.StatefulSetConfiguration{}}, + {ShardNames: []string{"foo-2"}, StatefulSetConfiguration: &common.StatefulSetConfiguration{}}, }, expectWarning: false, expectedWarnings: []status.Warning{}, @@ -334,7 +333,7 @@ func TestNoIgnoredFieldUsed(t *testing.T) { shardOverrides: []ShardOverride{ {ShardNames: []string{"foo-0"}, MemberConfig: defaultMemberConfig}, {ShardNames: []string{"foo-1"}, Members: ptr.To(2)}, - {ShardNames: []string{"foo-2"}, StatefulSetConfiguration: &v1.StatefulSetConfiguration{}}, + {ShardNames: []string{"foo-2"}, StatefulSetConfiguration: &common.StatefulSetConfiguration{}}, { ShardNames: []string{"foo-3"}, PodSpec: podSpecWithTemplate, @@ -401,7 +400,7 @@ func TestNoIgnoredFieldUsed(t *testing.T) { func TestPodSpecTemplatesWarnings(t *testing.T) { sc := NewDefaultMultiShardedClusterBuilder().Build() - mongoPodSpec := &MongoDbPodSpec{PodTemplateWrapper: PodTemplateSpecWrapper{PodTemplate: &corev1.PodTemplateSpec{}}} + mongoPodSpec := &MongoDbPodSpec{PodTemplateWrapper: common.PodTemplateSpecWrapper{PodTemplate: &corev1.PodTemplateSpec{}}} sc.Spec.ShardSpec.ClusterSpecList[0].PodSpec = mongoPodSpec sc.Spec.ConfigSrvSpec.ClusterSpecList[0].PodSpec = mongoPodSpec sc.Spec.MongosSpec.ClusterSpecList[0].PodSpec = mongoPodSpec diff --git a/api/v1/mdb/shardedcluster.go b/api/v1/mdb/shardedcluster.go index 4b3e0c404..4220be935 100644 --- a/api/v1/mdb/shardedcluster.go +++ b/api/v1/mdb/shardedcluster.go @@ -3,9 +3,8 @@ package mdb import ( "fmt" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - - mdbcv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" ) // ShardedClusterSpec is the spec consisting of configuration specific for sharded cluster only. @@ -68,7 +67,7 @@ type ShardOverride struct { MemberConfig []automationconfig.MemberOptions `json:"memberConfig,omitempty"` // Statefulset override for this particular shard. // +optional - StatefulSetConfiguration *mdbcv1.StatefulSetConfiguration `json:"statefulSet,omitempty"` + StatefulSetConfiguration *common.StatefulSetConfiguration `json:"statefulSet,omitempty"` } func (s *ShardedClusterComponentSpec) GetAdditionalMongodConfig() *AdditionalMongodConfig { diff --git a/api/v1/mdb/zz_generated.deepcopy.go b/api/v1/mdb/zz_generated.deepcopy.go index 5b2d3ca53..62fed3010 100644 --- a/api/v1/mdb/zz_generated.deepcopy.go +++ b/api/v1/mdb/zz_generated.deepcopy.go @@ -22,8 +22,9 @@ package mdb import ( "github.com/10gen/ops-manager-kubernetes/api/v1/status" - "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" ) @@ -227,12 +228,6 @@ func (in *BackupStatus) DeepCopy() *BackupStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClientCertificateSecretRefWrapper) DeepCopyInto(out *ClientCertificateSecretRefWrapper) { - clone := in.DeepCopy() - *out = *clone -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterSpecItem) DeepCopyInto(out *ClusterSpecItem) { *out = *in @@ -250,8 +245,7 @@ func (in *ClusterSpecItem) DeepCopyInto(out *ClusterSpecItem) { } if in.StatefulSetConfiguration != nil { in, out := &in.StatefulSetConfiguration, &out.StatefulSetConfiguration - *out = new(v1.StatefulSetConfiguration) - (*in).DeepCopyInto(*out) + *out = (*in).DeepCopy() } if in.PodSpec != nil { in, out := &in.PodSpec, &out.PodSpec @@ -287,8 +281,7 @@ func (in *ClusterSpecItemOverride) DeepCopyInto(out *ClusterSpecItemOverride) { } if in.StatefulSetConfiguration != nil { in, out := &in.StatefulSetConfiguration, &out.StatefulSetConfiguration - *out = new(v1.StatefulSetConfiguration) - (*in).DeepCopyInto(*out) + *out = (*in).DeepCopy() } if in.PodSpec != nil { in, out := &in.PodSpec, &out.PodSpec @@ -431,8 +424,7 @@ func (in *DbCommonSpec) DeepCopyInto(out *DbCommonSpec) { } if in.StatefulSetConfiguration != nil { in, out := &in.StatefulSetConfiguration, &out.StatefulSetConfiguration - *out = new(v1.StatefulSetConfiguration) - (*in).DeepCopyInto(*out) + *out = (*in).DeepCopy() } if in.AdditionalMongodConfig != nil { in, out := &in.AdditionalMongodConfig, &out.AdditionalMongodConfig @@ -574,12 +566,6 @@ func (in *KmipConfig) DeepCopy() *KmipConfig { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LabelSelectorWrapper) DeepCopyInto(out *LabelSelectorWrapper) { - clone := in.DeepCopy() - *out = *clone -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Ldap) DeepCopyInto(out *Ldap) { *out = *in @@ -678,6 +664,27 @@ func (in *MongoDBBuilder) DeepCopy() *MongoDBBuilder { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MongoDBConnectionStringBuilder) DeepCopyInto(out *MongoDBConnectionStringBuilder) { + *out = *in + in.MongoDB.DeepCopyInto(&out.MongoDB) + if in.hostnames != nil { + in, out := &in.hostnames, &out.hostnames + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MongoDBConnectionStringBuilder. +func (in *MongoDBConnectionStringBuilder) DeepCopy() *MongoDBConnectionStringBuilder { + if in == nil { + return nil + } + out := new(MongoDBConnectionStringBuilder) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MongoDBConnectivity) DeepCopyInto(out *MongoDBConnectivity) { *out = *in @@ -766,7 +773,7 @@ func (in *MongoDbPodSpec) DeepCopyInto(out *MongoDbPodSpec) { in.PodTemplateWrapper.DeepCopyInto(&out.PodTemplateWrapper) if in.Persistence != nil { in, out := &in.Persistence, &out.Persistence - *out = new(Persistence) + *out = new(common.Persistence) (*in).DeepCopyInto(*out) } } @@ -941,97 +948,12 @@ func (in *MonitoringAgentConfig) DeepCopy() *MonitoringAgentConfig { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MultiplePersistenceConfig) DeepCopyInto(out *MultiplePersistenceConfig) { - *out = *in - if in.Data != nil { - in, out := &in.Data, &out.Data - *out = new(PersistenceConfig) - (*in).DeepCopyInto(*out) - } - if in.Journal != nil { - in, out := &in.Journal, &out.Journal - *out = new(PersistenceConfig) - (*in).DeepCopyInto(*out) - } - if in.Logs != nil { - in, out := &in.Logs, &out.Logs - *out = new(PersistenceConfig) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MultiplePersistenceConfig. -func (in *MultiplePersistenceConfig) DeepCopy() *MultiplePersistenceConfig { - if in == nil { - return nil - } - out := new(MultiplePersistenceConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NodeAffinityWrapper) DeepCopyInto(out *NodeAffinityWrapper) { - clone := in.DeepCopy() - *out = *clone -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Persistence) DeepCopyInto(out *Persistence) { - *out = *in - if in.SingleConfig != nil { - in, out := &in.SingleConfig, &out.SingleConfig - *out = new(PersistenceConfig) - (*in).DeepCopyInto(*out) - } - if in.MultipleConfig != nil { - in, out := &in.MultipleConfig, &out.MultipleConfig - *out = new(MultiplePersistenceConfig) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Persistence. -func (in *Persistence) DeepCopy() *Persistence { - if in == nil { - return nil - } - out := new(Persistence) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PersistenceConfig) DeepCopyInto(out *PersistenceConfig) { - *out = *in - if in.StorageClass != nil { - in, out := &in.StorageClass, &out.StorageClass - *out = new(string) - **out = **in - } - if in.LabelSelector != nil { - in, out := &in.LabelSelector, &out.LabelSelector - *out = (*in).DeepCopy() - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistenceConfig. -func (in *PersistenceConfig) DeepCopy() *PersistenceConfig { - if in == nil { - return nil - } - out := new(PersistenceConfig) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PersistenceConfigBuilder) DeepCopyInto(out *PersistenceConfigBuilder) { *out = *in if in.config != nil { in, out := &in.config, &out.config - *out = new(PersistenceConfig) + *out = new(common.PersistenceConfig) (*in).DeepCopyInto(*out) } } @@ -1046,12 +968,6 @@ func (in *PersistenceConfigBuilder) DeepCopy() *PersistenceConfigBuilder { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PodAffinityWrapper) DeepCopyInto(out *PodAffinityWrapper) { - clone := in.DeepCopy() - *out = *clone -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PodSpecWrapper) DeepCopyInto(out *PodSpecWrapper) { *out = *in @@ -1085,12 +1001,6 @@ func (in *PodSpecWrapperBuilder) DeepCopy() *PodSpecWrapperBuilder { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PodTemplateSpecWrapper) DeepCopyInto(out *PodTemplateSpecWrapper) { - clone := in.DeepCopy() - *out = *clone -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PrivateCloudConfig) DeepCopyInto(out *PrivateCloudConfig) { *out = *in @@ -1233,12 +1143,6 @@ func (in *Security) DeepCopy() *Security { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ServiceSpecWrapper) DeepCopyInto(out *ServiceSpecWrapper) { - clone := in.DeepCopy() - *out = *clone -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ShardOverride) DeepCopyInto(out *ShardOverride) { *out = *in @@ -1267,8 +1171,7 @@ func (in *ShardOverride) DeepCopyInto(out *ShardOverride) { } if in.StatefulSetConfiguration != nil { in, out := &in.StatefulSetConfiguration, &out.StatefulSetConfiguration - *out = new(v1.StatefulSetConfiguration) - (*in).DeepCopyInto(*out) + *out = (*in).DeepCopy() } } @@ -1510,12 +1413,6 @@ func (in StartupParameters) DeepCopy() StartupParameters { return *out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StatefulSetSpecWrapper) DeepCopyInto(out *StatefulSetSpecWrapper) { - clone := in.DeepCopy() - *out = *clone -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TLSConfig) DeepCopyInto(out *TLSConfig) { *out = *in diff --git a/api/v1/mdbmulti/mongodb_multi_types.go b/api/v1/mdbmulti/mongodb_multi_types.go index c8d4aad28..fb791402e 100644 --- a/api/v1/mdbmulti/mongodb_multi_types.go +++ b/api/v1/mdbmulti/mongodb_multi_types.go @@ -8,9 +8,6 @@ import ( "github.com/blang/semver" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - - mdbc "github.com/mongodb/mongodb-kubernetes-operator/api/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "github.com/10gen/ops-manager-kubernetes/api/v1" @@ -18,6 +15,8 @@ import ( "github.com/10gen/ops-manager-kubernetes/api/v1/status" "github.com/10gen/ops-manager-kubernetes/controllers/operator/connectionstring" "github.com/10gen/ops-manager-kubernetes/controllers/operator/ldap" + mdbc "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/fcv" "github.com/10gen/ops-manager-kubernetes/pkg/kube" diff --git a/api/v1/mdbmulti/mongodbmultibuilder.go b/api/v1/mdbmulti/mongodbmultibuilder.go index 5e11adaaa..5972fca71 100644 --- a/api/v1/mdbmulti/mongodbmultibuilder.go +++ b/api/v1/mdbmulti/mongodbmultibuilder.go @@ -5,12 +5,12 @@ import ( "fmt" "math/big" - v1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" "github.com/10gen/ops-manager-kubernetes/controllers/om" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" "github.com/10gen/ops-manager-kubernetes/pkg/util" ) @@ -117,7 +117,7 @@ func (m *MultiReplicaSetBuilder) SetBackup(backupSpec mdbv1.Backup) *MultiReplic func (m *MultiReplicaSetBuilder) SetPodSpecTemplate(spec corev1.PodTemplateSpec) *MultiReplicaSetBuilder { if m.Spec.StatefulSetConfiguration == nil { - m.Spec.StatefulSetConfiguration = &v1.StatefulSetConfiguration{} + m.Spec.StatefulSetConfiguration = &common.StatefulSetConfiguration{} } m.Spec.StatefulSetConfiguration.SpecWrapper.Spec.Template = spec return m diff --git a/api/v1/om/appdb_types.go b/api/v1/om/appdb_types.go index 71a41d616..a7086b827 100644 --- a/api/v1/om/appdb_types.go +++ b/api/v1/om/appdb_types.go @@ -7,16 +7,15 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - - mdbcv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" appsv1 "k8s.io/api/apps/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" userv1 "github.com/10gen/ops-manager-kubernetes/api/v1/user" "github.com/10gen/ops-manager-kubernetes/controllers/operator/connectionstring" + mdbcv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" diff --git a/api/v1/om/opsmanager_types.go b/api/v1/om/opsmanager_types.go index 0bee32bcf..1da176cf2 100644 --- a/api/v1/om/opsmanager_types.go +++ b/api/v1/om/opsmanager_types.go @@ -12,10 +12,6 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - - mdbc "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -25,6 +21,9 @@ import ( "github.com/10gen/ops-manager-kubernetes/api/v1/status" userv1 "github.com/10gen/ops-manager-kubernetes/api/v1/user" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/fcv" "github.com/10gen/ops-manager-kubernetes/pkg/kube" @@ -158,7 +157,7 @@ type MongoDBOpsManagerSpec struct { // Configure custom StatefulSet configuration // +optional - StatefulSetConfiguration *mdbc.StatefulSetConfiguration `json:"statefulSet,omitempty"` + StatefulSetConfiguration *common.StatefulSetConfiguration `json:"statefulSet,omitempty"` // Topology sets the desired cluster topology of Ops Manager deployment. // It defaults (and if not set) to SingleCluster. If MultiCluster specified, @@ -224,7 +223,7 @@ type ClusterSpecOMItem struct { // If specified (even if provided empty) then this field overrides `spec.externalConnectivity` field entirely. // If not specified, then `spec.externalConnectivity` field is used for the Ops Manager and Backup Daemon instances in this cluster. // +optional - StatefulSetConfiguration *mdbc.StatefulSetConfiguration `json:"statefulSet,omitempty"` + StatefulSetConfiguration *common.StatefulSetConfiguration `json:"statefulSet,omitempty"` // Backup contains settings to override from top-level `spec.backup` for this member cluster. // If the value is not set here, then the value is taken from `spec.backup`. @@ -393,18 +392,18 @@ type MongoDBOpsManagerBackup struct { AssignmentLabels []string `json:"assignmentLabels,omitempty"` // HeadDB specifies configuration options for the HeadDB - HeadDB *mdbv1.PersistenceConfig `json:"headDB,omitempty"` - JVMParams []string `json:"jvmParameters,omitempty"` + HeadDB *common.PersistenceConfig `json:"headDB,omitempty"` + JVMParams []string `json:"jvmParameters,omitempty"` // S3OplogStoreConfigs describes the list of s3 oplog store configs used for backup. S3OplogStoreConfigs []S3Config `json:"s3OpLogStores,omitempty"` // OplogStoreConfigs describes the list of oplog store configs used for backup - OplogStoreConfigs []DataStoreConfig `json:"opLogStores,omitempty"` - BlockStoreConfigs []DataStoreConfig `json:"blockStores,omitempty"` - S3Configs []S3Config `json:"s3Stores,omitempty"` - FileSystemStoreConfigs []FileSystemStoreConfig `json:"fileSystemStores,omitempty"` - StatefulSetConfiguration *mdbc.StatefulSetConfiguration `json:"statefulSet,omitempty"` + OplogStoreConfigs []DataStoreConfig `json:"opLogStores,omitempty"` + BlockStoreConfigs []DataStoreConfig `json:"blockStores,omitempty"` + S3Configs []S3Config `json:"s3Stores,omitempty"` + FileSystemStoreConfigs []FileSystemStoreConfig `json:"fileSystemStores,omitempty"` + StatefulSetConfiguration *common.StatefulSetConfiguration `json:"statefulSet,omitempty"` // QueryableBackupSecretRef references the secret which contains the pem file which is used // for queryable backup. This will be mounted into the Ops Manager pod. @@ -430,12 +429,12 @@ type MongoDBOpsManagerBackupClusterSpecItem struct { AssignmentLabels []string `json:"assignmentLabels,omitempty"` // HeadDB specifies configuration options for the HeadDB - HeadDB *mdbv1.PersistenceConfig `json:"headDB,omitempty"` - JVMParams []string `json:"jvmParameters,omitempty"` + HeadDB *common.PersistenceConfig `json:"headDB,omitempty"` + JVMParams []string `json:"jvmParameters,omitempty"` // StatefulSetConfiguration specified optional overrides for backup datemon statefulset. // +optional - StatefulSetConfiguration *mdbc.StatefulSetConfiguration `json:"statefulSet,omitempty"` + StatefulSetConfiguration *common.StatefulSetConfiguration `json:"statefulSet,omitempty"` } // Encryption contains encryption settings diff --git a/api/v1/om/opsmanagerbuilder.go b/api/v1/om/opsmanagerbuilder.go index 5204d8443..44a2a4f38 100644 --- a/api/v1/om/opsmanagerbuilder.go +++ b/api/v1/om/opsmanagerbuilder.go @@ -3,13 +3,13 @@ package om import ( "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - - mdbc "github.com/mongodb/mongodb-kubernetes-operator/api/v1" appsv1 "k8s.io/api/apps/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" userv1 "github.com/10gen/ops-manager-kubernetes/api/v1/user" + mdbc "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" ) type OpsManagerBuilder struct { @@ -192,7 +192,7 @@ func (b *OpsManagerBuilder) SetAppDbFeatureCompatibility(version string) *OpsMan } func (b *OpsManagerBuilder) SetStatefulSetSpec(customSpec appsv1.StatefulSetSpec) *OpsManagerBuilder { - b.om.Spec.StatefulSetConfiguration = &mdbc.StatefulSetConfiguration{SpecWrapper: mdbc.StatefulSetSpecWrapper{Spec: customSpec}} + b.om.Spec.StatefulSetConfiguration = &common.StatefulSetConfiguration{SpecWrapper: common.StatefulSetSpecWrapper{Spec: customSpec}} return b } diff --git a/api/v1/om/zz_generated.deepcopy.go b/api/v1/om/zz_generated.deepcopy.go index 9b6fcc201..eee230673 100644 --- a/api/v1/om/zz_generated.deepcopy.go +++ b/api/v1/om/zz_generated.deepcopy.go @@ -24,8 +24,9 @@ import ( "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" "github.com/10gen/ops-manager-kubernetes/api/v1/status" "github.com/10gen/ops-manager-kubernetes/api/v1/user" - "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" ) @@ -227,8 +228,7 @@ func (in *ClusterSpecOMItem) DeepCopyInto(out *ClusterSpecOMItem) { } if in.StatefulSetConfiguration != nil { in, out := &in.StatefulSetConfiguration, &out.StatefulSetConfiguration - *out = new(v1.StatefulSetConfiguration) - (*in).DeepCopyInto(*out) + *out = (*in).DeepCopy() } if in.Backup != nil { in, out := &in.Backup, &out.Backup @@ -407,7 +407,7 @@ func (in *MongoDBOpsManagerBackup) DeepCopyInto(out *MongoDBOpsManagerBackup) { } if in.HeadDB != nil { in, out := &in.HeadDB, &out.HeadDB - *out = new(mdb.PersistenceConfig) + *out = new(common.PersistenceConfig) (*in).DeepCopyInto(*out) } if in.JVMParams != nil { @@ -450,8 +450,7 @@ func (in *MongoDBOpsManagerBackup) DeepCopyInto(out *MongoDBOpsManagerBackup) { } if in.StatefulSetConfiguration != nil { in, out := &in.StatefulSetConfiguration, &out.StatefulSetConfiguration - *out = new(v1.StatefulSetConfiguration) - (*in).DeepCopyInto(*out) + *out = (*in).DeepCopy() } out.QueryableBackupSecretRef = in.QueryableBackupSecretRef if in.Encryption != nil { @@ -486,7 +485,7 @@ func (in *MongoDBOpsManagerBackupClusterSpecItem) DeepCopyInto(out *MongoDBOpsMa } if in.HeadDB != nil { in, out := &in.HeadDB, &out.HeadDB - *out = new(mdb.PersistenceConfig) + *out = new(common.PersistenceConfig) (*in).DeepCopyInto(*out) } if in.JVMParams != nil { @@ -496,8 +495,7 @@ func (in *MongoDBOpsManagerBackupClusterSpecItem) DeepCopyInto(out *MongoDBOpsMa } if in.StatefulSetConfiguration != nil { in, out := &in.StatefulSetConfiguration, &out.StatefulSetConfiguration - *out = new(v1.StatefulSetConfiguration) - (*in).DeepCopyInto(*out) + *out = (*in).DeepCopy() } } @@ -629,8 +627,7 @@ func (in *MongoDBOpsManagerSpec) DeepCopyInto(out *MongoDBOpsManagerSpec) { } if in.StatefulSetConfiguration != nil { in, out := &in.StatefulSetConfiguration, &out.StatefulSetConfiguration - *out = new(v1.StatefulSetConfiguration) - (*in).DeepCopyInto(*out) + *out = (*in).DeepCopy() } if in.ClusterSpecList != nil { in, out := &in.ClusterSpecList, &out.ClusterSpecList diff --git a/api/v1/status/scaling_status.go b/api/v1/status/scaling_status.go index 004782cb1..d4e4dbfa3 100644 --- a/api/v1/status/scaling_status.go +++ b/api/v1/status/scaling_status.go @@ -3,9 +3,8 @@ package status import ( "fmt" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale" - "github.com/10gen/ops-manager-kubernetes/controllers/operator/construct/scalers/interfaces" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/scale" ) func MembersOption(replicaSetscaler scale.ReplicaSetScaler) Option { diff --git a/api/v1/user/mongodbuser_types.go b/api/v1/user/mongodbuser_types.go index 56e07938d..c2a0e3c67 100644 --- a/api/v1/user/mongodbuser_types.go +++ b/api/v1/user/mongodbuser_types.go @@ -161,7 +161,7 @@ func (u MongoDBUser) GetConnectionStringSecretName() string { } // normalizeName returns a string that conforms to RFC-1123. -// This logic is duplicated in the community operator in https://github.com/mongodb/mongodb-kubernetes-operator/blob/master/api/v1/mongodbcommunity_types.go. +// This logic is duplicated in the community operator in https://github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/blob/master/api/v1/mongodbcommunity_types.go. // The logic should be reused if/when we unify the user types or observe that the logic needs to be changed for business logic reasons, to avoid modifying it // in separate places in the future. func normalizeName(name string) string { diff --git a/config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml b/config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml new file mode 100644 index 000000000..12207a6bd --- /dev/null +++ b/config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml @@ -0,0 +1,677 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.15.0 + service.binding: path={.metadata.name}-{.spec.users[0].db}-{.spec.users[0].name},objectType=Secret + service.binding/connectionString: path={.metadata.name}-{.spec.users[0].db}-{.spec.users[0].name},objectType=Secret,sourceKey=connectionString.standardSrv + service.binding/password: path={.metadata.name}-{.spec.users[0].db}-{.spec.users[0].name},objectType=Secret,sourceKey=password + service.binding/provider: community + service.binding/type: mongodb + service.binding/username: path={.metadata.name}-{.spec.users[0].db}-{.spec.users[0].name},objectType=Secret,sourceKey=username + name: mongodbcommunity.mongodbcommunity.mongodb.com +spec: + group: mongodbcommunity.mongodb.com + names: + kind: MongoDBCommunity + listKind: MongoDBCommunityList + plural: mongodbcommunity + shortNames: + - mdbc + singular: mongodbcommunity + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: Current state of the MongoDB deployment + jsonPath: .status.phase + name: Phase + type: string + - description: Version of MongoDB server + jsonPath: .status.version + name: Version + type: string + name: v1 + schema: + openAPIV3Schema: + description: MongoDBCommunity is the Schema for the mongodbs API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: MongoDBCommunitySpec defines the desired state of MongoDB + properties: + additionalConnectionStringConfig: + description: Additional options to be appended to the connection string. + These options apply to the entire resource and to each user. + nullable: true + type: object + x-kubernetes-preserve-unknown-fields: true + additionalMongodConfig: + description: |- + AdditionalMongodConfig is additional configuration that can be passed to + each data-bearing mongod at runtime. Uses the same structure as the mongod + configuration file: https://www.mongodb.com/docs/manual/reference/configuration-options/ + nullable: true + type: object + x-kubernetes-preserve-unknown-fields: true + agent: + description: AgentConfiguration sets options for the MongoDB automation + agent + properties: + auditLogRotate: + description: AuditLogRotate if enabled, will enable AuditLogRotate + for all processes. + properties: + includeAuditLogsWithMongoDBLogs: + description: |- + set to 'true' to have the Automation Agent rotate the audit files along + with mongodb log files + type: boolean + numTotal: + description: maximum number of log files to have total + type: integer + numUncompressed: + description: maximum number of log files to leave uncompressed + type: integer + percentOfDiskspace: + description: |- + Maximum percentage of the total disk space these log files should take up. + The string needs to be able to be converted to float64 + type: string + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + The string needs to be able to be converted to float64. + Fractional values of MB are supported. + type: string + timeThresholdHrs: + description: maximum hours for an individual log file before + rotation + type: integer + required: + - sizeThresholdMB + - timeThresholdHrs + type: object + logFile: + type: string + logLevel: + type: string + logRotate: + description: LogRotate if enabled, will enable LogRotate for all + processes. + properties: + includeAuditLogsWithMongoDBLogs: + description: |- + set to 'true' to have the Automation Agent rotate the audit files along + with mongodb log files + type: boolean + numTotal: + description: maximum number of log files to have total + type: integer + numUncompressed: + description: maximum number of log files to leave uncompressed + type: integer + percentOfDiskspace: + description: |- + Maximum percentage of the total disk space these log files should take up. + The string needs to be able to be converted to float64 + type: string + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + The string needs to be able to be converted to float64. + Fractional values of MB are supported. + type: string + timeThresholdHrs: + description: maximum hours for an individual log file before + rotation + type: integer + required: + - sizeThresholdMB + - timeThresholdHrs + type: object + maxLogFileDurationHours: + type: integer + systemLog: + description: SystemLog configures system log of mongod + properties: + destination: + type: string + logAppend: + type: boolean + path: + type: string + required: + - destination + - logAppend + - path + type: object + type: object + arbiters: + description: |- + Arbiters is the number of arbiters to add to the Replica Set. + It is not recommended to have more than one arbiter per Replica Set. + More info: https://www.mongodb.com/docs/manual/tutorial/add-replica-set-arbiter/ + type: integer + automationConfig: + description: |- + AutomationConfigOverride is merged on top of the operator created automation config. Processes are merged + by name. Currently Only the process.disabled field is supported. + properties: + processes: + items: + description: OverrideProcess contains fields that we can override + on the AutomationConfig processes. + properties: + disabled: + type: boolean + logRotate: + description: CrdLogRotate is the crd definition of LogRotate + including fields in strings while the agent supports them + as float64 + properties: + includeAuditLogsWithMongoDBLogs: + description: |- + set to 'true' to have the Automation Agent rotate the audit files along + with mongodb log files + type: boolean + numTotal: + description: maximum number of log files to have total + type: integer + numUncompressed: + description: maximum number of log files to leave uncompressed + type: integer + percentOfDiskspace: + description: |- + Maximum percentage of the total disk space these log files should take up. + The string needs to be able to be converted to float64 + type: string + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + The string needs to be able to be converted to float64. + Fractional values of MB are supported. + type: string + timeThresholdHrs: + description: maximum hours for an individual log file + before rotation + type: integer + required: + - sizeThresholdMB + - timeThresholdHrs + type: object + name: + type: string + required: + - disabled + - name + type: object + type: array + replicaSet: + properties: + id: + description: |- + Id can be used together with additionalMongodConfig.replication.replSetName + to manage clusters where replSetName differs from the MongoDBCommunity resource name + type: string + settings: + description: |- + MapWrapper is a wrapper for a map to be used by other structs. + The CRD generator does not support map[string]interface{} + on the top level and hence we need to work around this with + a wrapping struct. + type: object + x-kubernetes-preserve-unknown-fields: true + type: object + type: object + featureCompatibilityVersion: + description: |- + FeatureCompatibilityVersion configures the feature compatibility version that will + be set for the deployment + type: string + memberConfig: + description: MemberConfig + items: + properties: + priority: + type: string + tags: + additionalProperties: + type: string + type: object + votes: + type: integer + type: object + type: array + members: + description: Members is the number of members in the replica set + type: integer + prometheus: + description: Prometheus configurations. + properties: + metricsPath: + description: Indicates path to the metrics endpoint. + pattern: ^\/[a-z0-9]+$ + type: string + passwordSecretRef: + description: Name of a Secret containing a HTTP Basic Auth Password. + properties: + key: + description: Key is the key in the secret storing this password. + Defaults to "password" + type: string + name: + description: Name is the name of the secret storing this user's + password + type: string + required: + - name + type: object + port: + description: Port where metrics endpoint will bind to. Defaults + to 9216. + type: integer + tlsSecretKeyRef: + description: |- + Name of a Secret (type kubernetes.io/tls) holding the certificates to use in the + Prometheus endpoint. + properties: + key: + description: Key is the key in the secret storing this password. + Defaults to "password" + type: string + name: + description: Name is the name of the secret storing this user's + password + type: string + required: + - name + type: object + username: + description: HTTP Basic Auth Username for metrics endpoint. + type: string + required: + - passwordSecretRef + - username + type: object + replicaSetHorizons: + description: |- + ReplicaSetHorizons Add this parameter and values if you need your database + to be accessed outside of Kubernetes. This setting allows you to + provide different DNS settings within the Kubernetes cluster and + to the Kubernetes cluster. The Kubernetes Operator uses split horizon + DNS for replica set members. This feature allows communication both + within the Kubernetes cluster and from outside Kubernetes. + items: + additionalProperties: + type: string + type: object + type: array + security: + description: Security configures security features, such as TLS, and + authentication settings for a deployment + properties: + authentication: + properties: + agentCertificateSecretRef: + description: |- + AgentCertificateSecret is a reference to a Secret containing the certificate and the key for the automation agent + The secret needs to have available: + - certificate under key: "tls.crt" + - private key under key: "tls.key" + If additionally, tls.pem is present, then it needs to be equal to the concatenation of tls.crt and tls.key + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + type: object + x-kubernetes-map-type: atomic + agentMode: + description: AgentMode contains the authentication mode used + by the automation agent. + enum: + - SCRAM + - SCRAM-SHA-256 + - SCRAM-SHA-1 + - X509 + type: string + ignoreUnknownUsers: + default: true + nullable: true + type: boolean + modes: + description: Modes is an array specifying which authentication + methods should be enabled. + items: + enum: + - SCRAM + - SCRAM-SHA-256 + - SCRAM-SHA-1 + - X509 + type: string + type: array + required: + - modes + type: object + roles: + description: User-specified custom MongoDB roles that should be + configured in the deployment. + items: + description: CustomRole defines a custom MongoDB role. + properties: + authenticationRestrictions: + description: The authentication restrictions the server + enforces on the role. + items: + description: |- + AuthenticationRestriction specifies a list of IP addresses and CIDR ranges users + are allowed to connect to or from. + properties: + clientSource: + items: + type: string + type: array + serverAddress: + items: + type: string + type: array + required: + - clientSource + - serverAddress + type: object + type: array + db: + description: The database of the role. + type: string + privileges: + description: The privileges to grant the role. + items: + description: Privilege defines the actions a role is allowed + to perform on a given resource. + properties: + actions: + items: + type: string + type: array + resource: + description: |- + Resource specifies specifies the resources upon which a privilege permits actions. + See https://www.mongodb.com/docs/manual/reference/resource-document for more. + properties: + anyResource: + type: boolean + cluster: + type: boolean + collection: + type: string + db: + type: string + type: object + required: + - actions + - resource + type: object + type: array + role: + description: The name of the role. + type: string + roles: + description: An array of roles from which this role inherits + privileges. + items: + description: Role is the database role this user should + have + properties: + db: + description: DB is the database the role can act on + type: string + name: + description: Name is the name of the role + type: string + required: + - db + - name + type: object + type: array + required: + - db + - privileges + - role + type: object + type: array + tls: + description: TLS configuration for both client-server and server-server + communication + properties: + caCertificateSecretRef: + description: |- + CaCertificateSecret is a reference to a Secret containing the certificate for the CA which signed the server certificates + The certificate is expected to be available under the key "ca.crt" + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + type: object + x-kubernetes-map-type: atomic + caConfigMapRef: + description: |- + CaConfigMap is a reference to a ConfigMap containing the certificate for the CA which signed the server certificates + The certificate is expected to be available under the key "ca.crt" + This field is ignored when CaCertificateSecretRef is configured + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + type: object + x-kubernetes-map-type: atomic + certificateKeySecretRef: + description: |- + CertificateKeySecret is a reference to a Secret containing a private key and certificate to use for TLS. + The key and cert are expected to be PEM encoded and available at "tls.key" and "tls.crt". + This is the same format used for the standard "kubernetes.io/tls" Secret type, but no specific type is required. + Alternatively, an entry tls.pem, containing the concatenation of cert and key, can be provided. + If all of tls.pem, tls.crt and tls.key are present, the tls.pem one needs to be equal to the concatenation of tls.crt and tls.key + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + type: object + x-kubernetes-map-type: atomic + enabled: + type: boolean + optional: + description: Optional configures if TLS should be required + or optional for connections + type: boolean + required: + - enabled + type: object + type: object + statefulSet: + description: |- + StatefulSetConfiguration holds the optional custom StatefulSet + that should be merged into the operator created one. + properties: + metadata: + description: StatefulSetMetadataWrapper is a wrapper around Labels + and Annotations + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + type: object + spec: + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + type: + description: Type defines which type of MongoDB deployment the resource + should create + enum: + - ReplicaSet + type: string + users: + description: Users specifies the MongoDB users that should be configured + in your deployment + items: + properties: + additionalConnectionStringConfig: + description: |- + Additional options to be appended to the connection string. + These options apply only to this user and will override any existing options in the resource. + nullable: true + type: object + x-kubernetes-preserve-unknown-fields: true + connectionStringSecretName: + description: |- + ConnectionStringSecretName is the name of the secret object created by the operator which exposes the connection strings for the user. + If provided, this secret must be different for each user in a deployment. + type: string + connectionStringSecretNamespace: + description: ConnectionStringSecretNamespace is the namespace + of the secret object created by the operator which exposes + the connection strings for the user. + type: string + db: + default: admin + description: DB is the database the user is stored in. Defaults + to "admin" + type: string + name: + description: Name is the username of the user + type: string + passwordSecretRef: + description: PasswordSecretRef is a reference to the secret + containing this user's password + properties: + key: + description: Key is the key in the secret storing this password. + Defaults to "password" + type: string + name: + description: Name is the name of the secret storing this + user's password + type: string + required: + - name + type: object + roles: + description: Roles is an array of roles assigned to this user + items: + description: Role is the database role this user should have + properties: + db: + description: DB is the database the role can act on + type: string + name: + description: Name is the name of the role + type: string + required: + - db + - name + type: object + type: array + scramCredentialsSecretName: + description: |- + ScramCredentialsSecretName appended by string "scram-credentials" is the name of the secret object created by the mongoDB operator for storing SCRAM credentials + These secrets names must be different for each user in a deployment. + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ + type: string + required: + - name + - roles + type: object + type: array + version: + description: Version defines which version of MongoDB will be used + type: string + required: + - security + - type + - users + type: object + status: + description: MongoDBCommunityStatus defines the observed state of MongoDB + properties: + currentMongoDBArbiters: + type: integer + currentMongoDBMembers: + type: integer + currentStatefulSetArbitersReplicas: + type: integer + currentStatefulSetReplicas: + type: integer + message: + type: string + mongoUri: + type: string + phase: + type: string + version: + type: string + required: + - currentMongoDBMembers + - currentStatefulSetReplicas + - mongoUri + - phase + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 4d3100512..ba9817ef8 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -6,6 +6,7 @@ resources: - bases/mongodb.com_mongodbusers.yaml - bases/mongodb.com_opsmanagers.yaml - bases/mongodb.com_mongodbmulticluster.yaml +- bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml # +kubebuilder:scaffold:crdkustomizeresource # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 3055082c0..085431781 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -22,7 +22,7 @@ spec: serviceAccountName: mongodb-enterprise-operator containers: - name: mongodb-enterprise-operator - image: "quay.io/mongodb/mongodb-enterprise-operator-ubi:1.33.0" + image: "quay.io/mongodb/mongodb-enterprise-operator-ubi:0.1.0" imagePullPolicy: Always args: - -watch-resource=mongodb @@ -62,25 +62,25 @@ spec: value: Always # Database - name: MONGODB_ENTERPRISE_DATABASE_IMAGE - value: quay.io/mongodb/mongodb-enterprise-database-ubi + value: quay.io/mongodb/mongodb-kubernetes-database-ubi - name: INIT_DATABASE_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-database-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-database-ubi - name: INIT_DATABASE_VERSION - value: 1.33.0 + value: 0.1.0 - name: DATABASE_VERSION - value: 1.33.0 + value: 0.1.0 # Ops Manager - name: OPS_MANAGER_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-enterprise-ops-manager-ubi - name: INIT_OPS_MANAGER_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-ops-manager-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-ops-manager-ubi - name: INIT_OPS_MANAGER_VERSION - value: 1.33.0 + value: 0.1.0 # AppDB - name: INIT_APPDB_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-appdb-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-appdb-ubi - name: INIT_APPDB_VERSION - value: 1.33.0 + value: 0.1.0 - name: OPS_MANAGER_IMAGE_PULL_POLICY value: Always - name: AGENT_IMAGE @@ -99,14 +99,34 @@ spec: value: "false" - name: MDB_MAX_CONCURRENT_RECONCILES value: "1" - - name: RELATED_IMAGE_MONGODB_ENTERPRISE_DATABASE_IMAGE_1_33_0 - value: "quay.io/mongodb/mongodb-enterprise-database-ubi:1.33.0" - - name: RELATED_IMAGE_INIT_DATABASE_IMAGE_REPOSITORY_1_33_0 - value: "quay.io/mongodb/mongodb-enterprise-init-database-ubi:1.33.0" - - name: RELATED_IMAGE_INIT_OPS_MANAGER_IMAGE_REPOSITORY_1_33_0 - value: "quay.io/mongodb/mongodb-enterprise-init-ops-manager-ubi:1.33.0" - - name: RELATED_IMAGE_INIT_APPDB_IMAGE_REPOSITORY_1_33_0 - value: "quay.io/mongodb/mongodb-enterprise-init-appdb-ubi:1.33.0" + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: OPERATOR_NAME + value: mongodb-enterprise-operator + # Community Env Vars Start + - name: MDB_COMMUNITY_AGENT_IMAGE + value: "quay.io/mongodb/mongodb-agent-ubi:108.0.2.8729-1" + - name: VERSION_UPGRADE_HOOK_IMAGE + value: "quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook:1.0.9" + - name: READINESS_PROBE_IMAGE + value: "quay.io/mongodb/mongodb-kubernetes-readinessprobe:1.0.22" + - name: MDB_COMMUNITY_IMAGE + value: "mongodb-community-server" + - name: MDB_COMMUNITY_REPO_URL + value: "quay.io/mongodb" + - name: MDB_COMMUNITY_IMAGE_TYPE + value: "ubi8" + # Community Env Vars End + - name: RELATED_IMAGE_MONGODB_ENTERPRISE_DATABASE_IMAGE_0_1_0 + value: "quay.io/mongodb/mongodb-kubernetes-database-ubi:0.1.0" + - name: RELATED_IMAGE_INIT_DATABASE_IMAGE_REPOSITORY_0_1_0 + value: "quay.io/mongodb/mongodb-kubernetes-init-database-ubi:0.1.0" + - name: RELATED_IMAGE_INIT_OPS_MANAGER_IMAGE_REPOSITORY_0_1_0 + value: "quay.io/mongodb/mongodb-kubernetes-init-ops-manager-ubi:0.1.0" + - name: RELATED_IMAGE_INIT_APPDB_IMAGE_REPOSITORY_0_1_0 + value: "quay.io/mongodb/mongodb-kubernetes-init-appdb-ubi:0.1.0" - name: RELATED_IMAGE_AGENT_IMAGE_107_0_13_8702_1 value: "quay.io/mongodb/mongodb-agent-ubi:107.0.13.8702-1" - name: RELATED_IMAGE_AGENT_IMAGE_107_0_13_8702_1_1_31_0 diff --git a/config/manifests/bases/mongodb-enterprise.clusterserviceversion.yaml b/config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml similarity index 99% rename from config/manifests/bases/mongodb-enterprise.clusterserviceversion.yaml rename to config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml index 8cf1aa53a..cb3ccc2e2 100644 --- a/config/manifests/bases/mongodb-enterprise.clusterserviceversion.yaml +++ b/config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml @@ -6,7 +6,7 @@ metadata: capabilities: Deep Insights categories: Database certified: "true" - containerImage: quay.io/mongodb/mongodb-enterprise-operator-ubi:1.33.0 + containerImage: quay.io/mongodb/mongodb-enterprise-operator-ubi:0.1.0 createdAt: "" description: The MongoDB Enterprise Kubernetes Operator enables easy deploys of MongoDB into Kubernetes clusters, using our management, monitoring and backup @@ -443,5 +443,5 @@ spec: maturity: stable provider: name: MongoDB, Inc - replaces: mongodb-enterprise.v1.32.0 + replaces: mongodb-enterprise.v1.33.0 version: 0.0.0 diff --git a/config/rbac/operator-roles.yaml b/config/rbac/operator-roles.yaml index 177421e5d..60c3e68dc 100644 --- a/config/rbac/operator-roles.yaml +++ b/config/rbac/operator-roles.yaml @@ -94,6 +94,15 @@ rules: - watch - delete - deletecollection + - apiGroups: + - mongodbcommunity.mongodb.com + resources: + - mongodbcommunity + - mongodbcommunity/status + - mongodbcommunity/spec + - mongodbcommunity/finalizers + verbs: + - '*' - apiGroups: - mongodb.com verbs: diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 75b26fe48..2304b1579 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -13,6 +13,18 @@ rules: - delete - get - update +- apiGroups: + - apps + resources: + - deployments + verbs: + - create + - delete + - get + - list + - patch + - update + - watch - apiGroups: - certificates.k8s.io resources: @@ -22,6 +34,39 @@ rules: - get - list - watch +- apiGroups: + - "" + resources: + - pods + verbs: + - get + - list +- apiGroups: + - mongodbcommunity.mongodb.com + resources: + - mongodbcommunity + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - mongodbcommunity.mongodb.com + resources: + - mongodbcommunity/finalizers + verbs: + - update +- apiGroups: + - mongodbcommunity.mongodb.com + resources: + - mongodbcommunity/status + verbs: + - get + - patch + - update --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role diff --git a/controllers/om/deployment.go b/controllers/om/deployment.go index aabaff472..7864ef7e9 100644 --- a/controllers/om/deployment.go +++ b/controllers/om/deployment.go @@ -12,11 +12,9 @@ import ( "go.uber.org/zap" "golang.org/x/xerrors" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - - mdbcv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" + mdbcv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" "github.com/10gen/ops-manager-kubernetes/pkg/tls" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/util/maputil" diff --git a/controllers/om/deployment_test.go b/controllers/om/deployment_test.go index 569eda9e6..344907a8e 100644 --- a/controllers/om/deployment_test.go +++ b/controllers/om/deployment_test.go @@ -11,9 +11,8 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" "github.com/10gen/ops-manager-kubernetes/pkg/util" ) diff --git a/controllers/om/depshardedcluster_test.go b/controllers/om/depshardedcluster_test.go index d0a317981..e22d8316b 100644 --- a/controllers/om/depshardedcluster_test.go +++ b/controllers/om/depshardedcluster_test.go @@ -7,9 +7,8 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" "github.com/10gen/ops-manager-kubernetes/pkg/util" ) diff --git a/controllers/om/fullreplicaset.go b/controllers/om/fullreplicaset.go index 28eeb2914..098f2eaf3 100644 --- a/controllers/om/fullreplicaset.go +++ b/controllers/om/fullreplicaset.go @@ -3,9 +3,8 @@ package om import ( "strconv" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" ) // ReplicaSetWithProcesses is a wrapper for replica set and processes that match to it diff --git a/controllers/om/fullreplicaset_test.go b/controllers/om/fullreplicaset_test.go index f9dfeeaa1..3fe3b6ec0 100644 --- a/controllers/om/fullreplicaset_test.go +++ b/controllers/om/fullreplicaset_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "k8s.io/utils/ptr" - ac "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" + ac "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" ) func TestDetermineNextProcessIdStartingPoint(t *testing.T) { diff --git a/controllers/om/omclient.go b/controllers/om/omclient.go index 5824ccc57..8c013623e 100644 --- a/controllers/om/omclient.go +++ b/controllers/om/omclient.go @@ -19,14 +19,13 @@ import ( "k8s.io/apimachinery/pkg/api/equality" "k8s.io/utils/ptr" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" "github.com/10gen/ops-manager-kubernetes/controllers/om/api" "github.com/10gen/ops-manager-kubernetes/controllers/om/apierror" "github.com/10gen/ops-manager-kubernetes/controllers/om/backup" "github.com/10gen/ops-manager-kubernetes/controllers/om/host" "github.com/10gen/ops-manager-kubernetes/controllers/operator/controlledfeature" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/util/env" "github.com/10gen/ops-manager-kubernetes/pkg/util/maputil" diff --git a/controllers/om/process.go b/controllers/om/process.go index 0b7f6b20e..c80a22df9 100644 --- a/controllers/om/process.go +++ b/controllers/om/process.go @@ -8,9 +8,8 @@ import ( "github.com/spf13/cast" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" "github.com/10gen/ops-manager-kubernetes/pkg/tls" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/util/architectures" diff --git a/controllers/om/replicaset.go b/controllers/om/replicaset.go index dac3c4ff1..003247a73 100644 --- a/controllers/om/replicaset.go +++ b/controllers/om/replicaset.go @@ -7,9 +7,8 @@ import ( "github.com/spf13/cast" "go.uber.org/zap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" "github.com/10gen/ops-manager-kubernetes/pkg/util" ) diff --git a/controllers/om/replicaset/om_replicaset.go b/controllers/om/replicaset/om_replicaset.go index 42829639b..a475cadae 100644 --- a/controllers/om/replicaset/om_replicaset.go +++ b/controllers/om/replicaset/om_replicaset.go @@ -4,13 +4,12 @@ import ( "go.uber.org/zap" "golang.org/x/xerrors" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale" - appsv1 "k8s.io/api/apps/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" "github.com/10gen/ops-manager-kubernetes/controllers/om" "github.com/10gen/ops-manager-kubernetes/controllers/om/process" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/scale" "github.com/10gen/ops-manager-kubernetes/pkg/dns" ) diff --git a/controllers/om/replicaset_test.go b/controllers/om/replicaset_test.go index f2590d954..5c9f10bb1 100644 --- a/controllers/om/replicaset_test.go +++ b/controllers/om/replicaset_test.go @@ -6,9 +6,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" ) func makeMinimalRsWithProcesses() ReplicaSetWithProcesses { diff --git a/controllers/operator/agents/agents.go b/controllers/operator/agents/agents.go index 8e26ef346..89467525b 100644 --- a/controllers/operator/agents/agents.go +++ b/controllers/operator/agents/agents.go @@ -10,13 +10,12 @@ import ( "go.uber.org/zap" "golang.org/x/xerrors" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - appsv1 "k8s.io/api/apps/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" "github.com/10gen/ops-manager-kubernetes/controllers/om" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/util" diff --git a/controllers/operator/agents/upgrade.go b/controllers/operator/agents/upgrade.go index bcc69d2d3..3edb03f3f 100644 --- a/controllers/operator/agents/upgrade.go +++ b/controllers/operator/agents/upgrade.go @@ -10,9 +10,6 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" corev1 "k8s.io/api/core/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" @@ -20,6 +17,8 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/om" "github.com/10gen/ops-manager-kubernetes/controllers/operator/project" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" "github.com/10gen/ops-manager-kubernetes/pkg/kube" ) diff --git a/controllers/operator/appdbreplicaset_controller.go b/controllers/operator/appdbreplicaset_controller.go index 91d78ba12..56bb8b9b9 100644 --- a/controllers/operator/appdbreplicaset_controller.go +++ b/controllers/operator/appdbreplicaset_controller.go @@ -17,22 +17,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/agent" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/scram" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/service" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/generate" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/result" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale" - - mdbcv1_controllers "github.com/mongodb/mongodb-kubernetes-operator/controllers" - mcoConstruct "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" @@ -55,6 +39,21 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + mdbcv1_controllers "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers" + mcoConstruct "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/agent" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/scram" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/service" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/generate" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/result" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/scale" "github.com/10gen/ops-manager-kubernetes/pkg/agentVersionManagement" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/images" diff --git a/controllers/operator/appdbreplicaset_controller_multi_test.go b/controllers/operator/appdbreplicaset_controller_multi_test.go index 85842c1bc..7a09164cc 100644 --- a/controllers/operator/appdbreplicaset_controller_multi_test.go +++ b/controllers/operator/appdbreplicaset_controller_multi_test.go @@ -15,11 +15,6 @@ import ( "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -33,6 +28,11 @@ import ( enterprisepem "github.com/10gen/ops-manager-kubernetes/controllers/operator/pem" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" @@ -1255,7 +1255,7 @@ func TestAppDBMultiClusterServiceCreation_WithExternalName(t *testing.T) { ClusterName: memberClusterName1, ExternalAccessConfiguration: &mdbv1.ExternalAccessConfiguration{ ExternalService: mdbv1.ExternalServiceConfiguration{ - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "LoadBalancer", Ports: []corev1.ServicePort{ @@ -1439,7 +1439,7 @@ func TestAppDBMultiClusterServiceCreation_WithExternalName(t *testing.T) { ClusterName: memberClusterName1, ExternalAccessConfiguration: &mdbv1.ExternalAccessConfiguration{ ExternalService: mdbv1.ExternalServiceConfiguration{ - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "NodePort", Ports: []corev1.ServicePort{ @@ -1506,7 +1506,7 @@ func TestAppDBMultiClusterServiceCreation_WithExternalName(t *testing.T) { create.PlaceholderClusterName: "{clusterName}", create.PlaceholderClusterIndex: "{clusterIndex}", }, - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "LoadBalancer", Ports: []corev1.ServicePort{ @@ -1537,7 +1537,7 @@ func TestAppDBMultiClusterServiceCreation_WithExternalName(t *testing.T) { create.PlaceholderClusterName: "{clusterName}", create.PlaceholderClusterIndex: "{clusterIndex}", }, - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "LoadBalancer", Ports: []corev1.ServicePort{ diff --git a/controllers/operator/appdbreplicaset_controller_test.go b/controllers/operator/appdbreplicaset_controller_test.go index 7f7442937..06ff86139 100644 --- a/controllers/operator/appdbreplicaset_controller_test.go +++ b/controllers/operator/appdbreplicaset_controller_test.go @@ -19,12 +19,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/interceptor" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - - mdbcv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -40,6 +34,12 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + mdbcv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" "github.com/10gen/ops-manager-kubernetes/pkg/agentVersionManagement" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/kube" @@ -436,7 +436,7 @@ func TestTryConfigureMonitoringInOpsManagerWithCustomTemplate(t *testing.T) { opsManager := builder.Build() appdbScaler := scalers.GetAppDBScaler(opsManager, multicluster.LegacyCentralClusterName, 0, nil) - opsManager.Spec.AppDB.PodSpec.PodTemplateWrapper = mdbv1.PodTemplateSpecWrapper{ + opsManager.Spec.AppDB.PodSpec.PodTemplateWrapper = common.PodTemplateSpecWrapper{ PodTemplate: &corev1.PodTemplateSpec{ Spec: corev1.PodSpec{ Containers: []corev1.Container{ @@ -618,7 +618,7 @@ func TestAppDBServiceCreation_WithExternalName(t *testing.T) { members: 2, externalAccess: &mdbv1.ExternalAccessConfiguration{ ExternalService: mdbv1.ExternalServiceConfiguration{ - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "LoadBalancer", Ports: []corev1.ServicePort{ @@ -781,7 +781,7 @@ func TestAppDBServiceCreation_WithExternalName(t *testing.T) { members: 1, externalAccess: &mdbv1.ExternalAccessConfiguration{ ExternalService: mdbv1.ExternalServiceConfiguration{ - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "NodePort", Ports: []corev1.ServicePort{ @@ -839,7 +839,7 @@ func TestAppDBServiceCreation_WithExternalName(t *testing.T) { create.PlaceholderMongodProcessDomain: "{mongodProcessDomain}", create.PlaceholderMongodProcessFQDN: "{mongodProcessFQDN}", }, - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "LoadBalancer", Ports: []corev1.ServicePort{ @@ -942,7 +942,7 @@ func TestAppDBServiceCreation_WithExternalName(t *testing.T) { create.PlaceholderMongodProcessDomain: "{mongodProcessDomain}", create.PlaceholderMongodProcessFQDN: "{mongodProcessFQDN}", }, - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "LoadBalancer", Ports: []corev1.ServicePort{ diff --git a/controllers/operator/authentication_test.go b/controllers/operator/authentication_test.go index 808610902..f54f77a6e 100644 --- a/controllers/operator/authentication_test.go +++ b/controllers/operator/authentication_test.go @@ -23,9 +23,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" certsv1 "k8s.io/api/certificates/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -37,6 +34,8 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/authentication" "github.com/10gen/ops-manager-kubernetes/controllers/operator/certs" "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" "github.com/10gen/ops-manager-kubernetes/pkg/test" "github.com/10gen/ops-manager-kubernetes/pkg/util" ) diff --git a/controllers/operator/certs/cert_configurations.go b/controllers/operator/certs/cert_configurations.go index 684b7b1d7..9a744739c 100644 --- a/controllers/operator/certs/cert_configurations.go +++ b/controllers/operator/certs/cert_configurations.go @@ -3,8 +3,6 @@ package certs import ( "fmt" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" @@ -13,6 +11,7 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/construct/scalers" "github.com/10gen/ops-manager-kubernetes/controllers/operator/construct/scalers/interfaces" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/scale" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" ) diff --git a/controllers/operator/certs/certificate_test.go b/controllers/operator/certs/certificate_test.go index ad941a18b..a5fc19504 100644 --- a/controllers/operator/certs/certificate_test.go +++ b/controllers/operator/certs/certificate_test.go @@ -8,14 +8,13 @@ import ( "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" "github.com/10gen/ops-manager-kubernetes/pkg/util" ) diff --git a/controllers/operator/certs/certificates.go b/controllers/operator/certs/certificates.go index c69a2aa87..515fb28aa 100644 --- a/controllers/operator/certs/certificates.go +++ b/controllers/operator/certs/certificates.go @@ -11,9 +11,6 @@ import ( "golang.org/x/xerrors" "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - - mdbcv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -21,6 +18,8 @@ import ( enterprisepem "github.com/10gen/ops-manager-kubernetes/controllers/operator/pem" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + mdbcv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/util" diff --git a/controllers/operator/clusterchecks_test.go b/controllers/operator/clusterchecks_test.go index 86daeffc5..4e4b2b6c8 100644 --- a/controllers/operator/clusterchecks_test.go +++ b/controllers/operator/clusterchecks_test.go @@ -10,14 +10,13 @@ import ( "github.com/stretchr/testify/require" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" "github.com/10gen/ops-manager-kubernetes/controllers/operator/create" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/util" ) diff --git a/controllers/operator/common_controller.go b/controllers/operator/common_controller.go index dac27ed5c..416d2d366 100644 --- a/controllers/operator/common_controller.go +++ b/controllers/operator/common_controller.go @@ -19,13 +19,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - - mdbcv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" @@ -42,6 +35,12 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + mdbcv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" "github.com/10gen/ops-manager-kubernetes/pkg/agentVersionManagement" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/passwordhash" diff --git a/controllers/operator/common_controller_test.go b/controllers/operator/common_controller_test.go index 608866258..17d3fefae 100644 --- a/controllers/operator/common_controller_test.go +++ b/controllers/operator/common_controller_test.go @@ -19,7 +19,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" @@ -33,6 +32,7 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/project" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" "github.com/10gen/ops-manager-kubernetes/pkg/agentVersionManagement" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/util" diff --git a/controllers/operator/construct/appdb_construction.go b/controllers/operator/construct/appdb_construction.go index afc012cc3..c88b27a15 100644 --- a/controllers/operator/construct/appdb_construction.go +++ b/controllers/operator/construct/appdb_construction.go @@ -8,13 +8,6 @@ import ( "go.uber.org/zap" - "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/podtemplatespec" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -23,6 +16,13 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/agents" "github.com/10gen/ops-manager-kubernetes/controllers/operator/certs" "github.com/10gen/ops-manager-kubernetes/controllers/operator/construct/scalers/interfaces" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/podtemplatespec" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/scale" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/tls" "github.com/10gen/ops-manager-kubernetes/pkg/util" @@ -298,7 +298,7 @@ func customPersistenceConfig(om *om.MongoDBOpsManager) statefulset.Modification // Two main branches - as the user can either define a single volume for data, logs and journal // or three different volumes if !om.Spec.AppDB.HasSeparateDataAndLogsVolumes() { - var config *mdbv1.PersistenceConfig + var config *common.PersistenceConfig if om.Spec.AppDB.PodSpec.Persistence != nil && om.Spec.AppDB.PodSpec.Persistence.SingleConfig != nil { config = om.Spec.AppDB.PodSpec.Persistence.SingleConfig } diff --git a/controllers/operator/construct/appdb_construction_test.go b/controllers/operator/construct/appdb_construction_test.go index d9c080852..bace54b8e 100644 --- a/controllers/operator/construct/appdb_construction_test.go +++ b/controllers/operator/construct/appdb_construction_test.go @@ -12,6 +12,7 @@ import ( mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" omv1 "github.com/10gen/ops-manager-kubernetes/api/v1/om" "github.com/10gen/ops-manager-kubernetes/controllers/operator/construct/scalers" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" "github.com/10gen/ops-manager-kubernetes/pkg/util/env" ) @@ -49,7 +50,7 @@ func TestResourceRequirements(t *testing.T) { }, } - om.Spec.AppDB.PodSpec.PodTemplateWrapper = mdbv1.PodTemplateSpecWrapper{ + om.Spec.AppDB.PodSpec.PodTemplateWrapper = common.PodTemplateSpecWrapper{ PodTemplate: &corev1.PodTemplateSpec{ Spec: corev1.PodSpec{ Containers: []corev1.Container{ diff --git a/controllers/operator/construct/backup_construction.go b/controllers/operator/construct/backup_construction.go index d40eba5e6..0abb883ec 100644 --- a/controllers/operator/construct/backup_construction.go +++ b/controllers/operator/construct/backup_construction.go @@ -7,20 +7,19 @@ import ( "go.uber.org/zap" "golang.org/x/xerrors" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/lifecycle" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/podtemplatespec" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/probes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" omv1 "github.com/10gen/ops-manager-kubernetes/api/v1/om" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/lifecycle" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/podtemplatespec" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/probes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" "github.com/10gen/ops-manager-kubernetes/pkg/util" @@ -107,7 +106,7 @@ func backupDaemonStatefulSetFunc(opts OpsManagerStatefulSetOptions) statefulset. // PodSecurityContext is added in the backupAndOpsManagerSharedConfiguration _, configureContainerSecurityContext := podtemplatespec.WithDefaultSecurityContextsModifications() - defaultConfig := mdbv1.PersistenceConfig{Storage: util.DefaultHeadDbStorageSize} + defaultConfig := common.PersistenceConfig{Storage: util.DefaultHeadDbStorageSize} pvc := pvcFunc(util.PvcNameHeadDb, opts.HeadDbPersistenceConfig, defaultConfig, opts.Labels) headDbMount := statefulset.CreateVolumeMount(util.PvcNameHeadDb, util.PvcMountPathHeadDb) diff --git a/controllers/operator/construct/backup_construction_test.go b/controllers/operator/construct/backup_construction_test.go index 2b79002ee..c4bc0f6ca 100644 --- a/controllers/operator/construct/backup_construction_test.go +++ b/controllers/operator/construct/backup_construction_test.go @@ -7,11 +7,10 @@ import ( "github.com/stretchr/testify/assert" "go.uber.org/zap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/probes" - omv1 "github.com/10gen/ops-manager-kubernetes/api/v1/om" "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/probes" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/vault" diff --git a/controllers/operator/construct/database_construction.go b/controllers/operator/construct/database_construction.go index 2c511030b..ddcb5afbb 100644 --- a/controllers/operator/construct/database_construction.go +++ b/controllers/operator/construct/database_construction.go @@ -10,15 +10,6 @@ import ( "go.uber.org/zap" "k8s.io/utils/ptr" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/persistentvolumeclaim" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/podtemplatespec" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/probes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale" - - mdbcv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -26,6 +17,15 @@ import ( mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" "github.com/10gen/ops-manager-kubernetes/controllers/operator/agents" "github.com/10gen/ops-manager-kubernetes/controllers/operator/certs" + mdbcv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/persistentvolumeclaim" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/podtemplatespec" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/probes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/scale" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/util/architectures" @@ -537,7 +537,7 @@ func buildPersistentVolumeClaimsFuncs(opts DatabaseStatefulSetOptions) (map[stri if podSpec.Persistence == nil || (podSpec.Persistence.SingleConfig == nil && podSpec.Persistence.MultipleConfig == nil) || podSpec.Persistence.SingleConfig != nil { - var config *mdbv1.PersistenceConfig + var config *common.PersistenceConfig if podSpec.Persistence != nil && podSpec.Persistence.SingleConfig != nil { config = podSpec.Persistence.SingleConfig } diff --git a/controllers/operator/construct/database_construction_test.go b/controllers/operator/construct/database_construction_test.go index e947e263e..e11618044 100644 --- a/controllers/operator/construct/database_construction_test.go +++ b/controllers/operator/construct/database_construction_test.go @@ -11,12 +11,12 @@ import ( "go.uber.org/zap" "k8s.io/utils/ptr" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" corev1 "k8s.io/api/core/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/util/architectures" @@ -30,7 +30,7 @@ func init() { } func Test_buildDatabaseInitContainer(t *testing.T) { - modification := buildDatabaseInitContainer("quay.io/mongodb/mongodb-enterprise-init-database:latest") + modification := buildDatabaseInitContainer("quay.io/mongodb/mongodb-kubernetes-init-database:latest") container := &corev1.Container{} modification(container) expectedVolumeMounts := []corev1.VolumeMount{{ @@ -40,7 +40,7 @@ func Test_buildDatabaseInitContainer(t *testing.T) { }} expectedContainer := &corev1.Container{ Name: InitDatabaseContainerName, - Image: "quay.io/mongodb/mongodb-enterprise-init-database:latest", + Image: "quay.io/mongodb/mongodb-kubernetes-init-database:latest", VolumeMounts: expectedVolumeMounts, SecurityContext: &corev1.SecurityContext{ ReadOnlyRootFilesystem: ptr.To(true), diff --git a/controllers/operator/construct/database_volumes.go b/controllers/operator/construct/database_volumes.go index 8e396f6e1..68ba69995 100644 --- a/controllers/operator/construct/database_volumes.go +++ b/controllers/operator/construct/database_volumes.go @@ -6,12 +6,11 @@ import ( "go.uber.org/zap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - corev1 "k8s.io/api/core/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" "github.com/10gen/ops-manager-kubernetes/controllers/operator/certs" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" "github.com/10gen/ops-manager-kubernetes/pkg/tls" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/vault" diff --git a/controllers/operator/construct/jvm.go b/controllers/operator/construct/jvm.go index 985f8da2c..86977651a 100644 --- a/controllers/operator/construct/jvm.go +++ b/controllers/operator/construct/jvm.go @@ -7,12 +7,11 @@ import ( "golang.org/x/xerrors" "k8s.io/apimachinery/pkg/api/resource" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" omv1 "github.com/10gen/ops-manager-kubernetes/api/v1/om" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" "github.com/10gen/ops-manager-kubernetes/pkg/util" ) diff --git a/controllers/operator/construct/multicluster/multicluster_replicaset.go b/controllers/operator/construct/multicluster/multicluster_replicaset.go index 1585afad1..e9d420eef 100644 --- a/controllers/operator/construct/multicluster/multicluster_replicaset.go +++ b/controllers/operator/construct/multicluster/multicluster_replicaset.go @@ -3,14 +3,13 @@ package multicluster import ( "fmt" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - appsv1 "k8s.io/api/apps/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" mdbmultiv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdbmulti" "github.com/10gen/ops-manager-kubernetes/controllers/operator/certs" "github.com/10gen/ops-manager-kubernetes/controllers/operator/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" "github.com/10gen/ops-manager-kubernetes/pkg/handler" "github.com/10gen/ops-manager-kubernetes/pkg/util" ) diff --git a/controllers/operator/construct/multicluster/multicluster_replicaset_test.go b/controllers/operator/construct/multicluster/multicluster_replicaset_test.go index ea041af98..cd6fdb4fc 100644 --- a/controllers/operator/construct/multicluster/multicluster_replicaset_test.go +++ b/controllers/operator/construct/multicluster/multicluster_replicaset_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/require" "k8s.io/utils/ptr" - mdbc "github.com/mongodb/mongodb-kubernetes-operator/api/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -17,6 +16,7 @@ import ( "github.com/10gen/ops-manager-kubernetes/api/v1/mdbmulti" "github.com/10gen/ops-manager-kubernetes/controllers/operator/construct" "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/util/architectures" ) @@ -73,7 +73,7 @@ func TestMultiClusterStatefulSet(t *testing.T) { }) t.Run("Override provided at clusterSpecList level only", func(t *testing.T) { - singleClusterOverride := &mdbc.StatefulSetConfiguration{SpecWrapper: mdbc.StatefulSetSpecWrapper{ + singleClusterOverride := &common.StatefulSetConfiguration{SpecWrapper: common.StatefulSetSpecWrapper{ Spec: appsv1.StatefulSetSpec{ Replicas: ptr.To(int32(4)), Selector: &metav1.LabelSelector{ @@ -104,8 +104,8 @@ func TestMultiClusterStatefulSet(t *testing.T) { }) t.Run("Override provided only at Spec level", func(t *testing.T) { - stsOverride := &mdbc.StatefulSetConfiguration{ - SpecWrapper: mdbc.StatefulSetSpecWrapper{ + stsOverride := &common.StatefulSetConfiguration{ + SpecWrapper: common.StatefulSetSpecWrapper{ Spec: appsv1.StatefulSetSpec{ Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{"foo": "bar"}, @@ -132,8 +132,8 @@ func TestMultiClusterStatefulSet(t *testing.T) { }) t.Run("Override provided at both Spec and clusterSpecList level", func(t *testing.T) { - stsOverride := &mdbc.StatefulSetConfiguration{ - SpecWrapper: mdbc.StatefulSetSpecWrapper{ + stsOverride := &common.StatefulSetConfiguration{ + SpecWrapper: common.StatefulSetSpecWrapper{ Spec: appsv1.StatefulSetSpec{ Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{"foo": "bar"}, @@ -143,8 +143,8 @@ func TestMultiClusterStatefulSet(t *testing.T) { }, } - singleClusterOverride := &mdbc.StatefulSetConfiguration{ - SpecWrapper: mdbc.StatefulSetSpecWrapper{ + singleClusterOverride := &common.StatefulSetConfiguration{ + SpecWrapper: common.StatefulSetSpecWrapper{ Spec: appsv1.StatefulSetSpec{ ServiceName: "clusteroverrideservice", Replicas: ptr.To(int32(4)), @@ -232,7 +232,7 @@ func TestPVCOverride(t *testing.T) { for _, tt := range tests { mdbm := getMultiClusterMongoDB() - stsOverrideConfiguration := &mdbc.StatefulSetConfiguration{SpecWrapper: mdbc.StatefulSetSpecWrapper{Spec: tt.inp}} + stsOverrideConfiguration := &common.StatefulSetConfiguration{SpecWrapper: common.StatefulSetSpecWrapper{Spec: tt.inp}} opts := MultiClusterReplicaSetOptions( WithClusterNum(0), WithMemberCount(3), diff --git a/controllers/operator/construct/opsmanager_construction.go b/controllers/operator/construct/opsmanager_construction.go index 57a4feceb..0f8e34ae5 100644 --- a/controllers/operator/construct/opsmanager_construction.go +++ b/controllers/operator/construct/opsmanager_construction.go @@ -10,15 +10,6 @@ import ( "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/lifecycle" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/podtemplatespec" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/probes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" @@ -30,6 +21,15 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/certs" enterprisepem "github.com/10gen/ops-manager-kubernetes/controllers/operator/pem" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/lifecycle" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/podtemplatespec" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/probes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" "github.com/10gen/ops-manager-kubernetes/pkg/util" @@ -70,7 +70,7 @@ type OpsManagerStatefulSetOptions struct { kmip *KmipConfiguration DebugPort int32 // backup daemon only - HeadDbPersistenceConfig *mdbv1.PersistenceConfig + HeadDbPersistenceConfig *common.PersistenceConfig Annotations map[string]string LoggingConfiguration *omv1.Logging } diff --git a/controllers/operator/construct/opsmanager_construction_common.go b/controllers/operator/construct/opsmanager_construction_common.go index e409ba4d6..e0ab57995 100644 --- a/controllers/operator/construct/opsmanager_construction_common.go +++ b/controllers/operator/construct/opsmanager_construction_common.go @@ -1,9 +1,9 @@ package construct import ( - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - corev1 "k8s.io/api/core/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" ) const ( diff --git a/controllers/operator/construct/opsmanager_construction_test.go b/controllers/operator/construct/opsmanager_construction_test.go index 44c830e98..83097570b 100644 --- a/controllers/operator/construct/opsmanager_construction_test.go +++ b/controllers/operator/construct/opsmanager_construction_test.go @@ -9,11 +9,6 @@ import ( "k8s.io/apimachinery/pkg/api/resource" "k8s.io/utils/ptr" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/podtemplatespec" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -21,6 +16,10 @@ import ( omv1 "github.com/10gen/ops-manager-kubernetes/api/v1/om" "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/podtemplatespec" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/vault" @@ -338,7 +337,7 @@ func TestOpsManagerPodTemplate_SecurityContext(t *testing.T) { podSpecTemplate := omSts.Spec.Template spec := podSpecTemplate.Spec assert.Len(t, spec.InitContainers, 1) - assert.Equal(t, spec.InitContainers[0].Name, "mongodb-enterprise-init-ops-manager") + assert.Equal(t, spec.InitContainers[0].Name, "mongodb-kubernetes-init-ops-manager") assert.NotNil(t, spec.SecurityContext) assert.Equal(t, util.Int64Ref(util.FsGroup), spec.SecurityContext.FSGroup) diff --git a/controllers/operator/construct/pvc.go b/controllers/operator/construct/pvc.go index 904ce9c70..5c610b855 100644 --- a/controllers/operator/construct/pvc.go +++ b/controllers/operator/construct/pvc.go @@ -1,19 +1,18 @@ package construct import ( - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/persistentvolumeclaim" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - corev1 "k8s.io/api/core/v1" - mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/persistentvolumeclaim" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" "github.com/10gen/ops-manager-kubernetes/pkg/util" ) // pvcFunc convenience function to build a PersistentVolumeClaim. It accepts two config parameters - the one specified by // the customers and the default one configured by the Operator. Putting the default one to the signature ensures the // calling code doesn't forget to think about default values in case the user hasn't provided values. -func pvcFunc(name string, config *mdbv1.PersistenceConfig, defaultConfig mdbv1.PersistenceConfig, labels map[string]string) persistentvolumeclaim.Modification { +func pvcFunc(name string, config *common.PersistenceConfig, defaultConfig common.PersistenceConfig, labels map[string]string) persistentvolumeclaim.Modification { selectorFunc := persistentvolumeclaim.NOOP() storageClassNameFunc := persistentvolumeclaim.NOOP() if config != nil { @@ -34,7 +33,7 @@ func pvcFunc(name string, config *mdbv1.PersistenceConfig, defaultConfig mdbv1.P ) } -func createClaimsAndMountsMultiModeFunc(persistence *mdbv1.Persistence, defaultConfig mdbv1.MultiplePersistenceConfig, labels map[string]string) (map[string]persistentvolumeclaim.Modification, []corev1.VolumeMount) { +func createClaimsAndMountsMultiModeFunc(persistence *common.Persistence, defaultConfig common.MultiplePersistenceConfig, labels map[string]string) (map[string]persistentvolumeclaim.Modification, []corev1.VolumeMount) { mounts := []corev1.VolumeMount{ statefulset.CreateVolumeMount(util.PvcNameData, util.PvcMountPathData), statefulset.CreateVolumeMount(util.PvcNameJournal, util.PvcMountPathJournal), @@ -47,7 +46,7 @@ func createClaimsAndMountsMultiModeFunc(persistence *mdbv1.Persistence, defaultC }, mounts } -func createClaimsAndMountsSingleModeFunc(config *mdbv1.PersistenceConfig, opts DatabaseStatefulSetOptions) (map[string]persistentvolumeclaim.Modification, []corev1.VolumeMount) { +func createClaimsAndMountsSingleModeFunc(config *common.PersistenceConfig, opts DatabaseStatefulSetOptions) (map[string]persistentvolumeclaim.Modification, []corev1.VolumeMount) { mounts := []corev1.VolumeMount{ statefulset.CreateVolumeMount(util.PvcNameData, util.PvcMountPathData, statefulset.WithSubPath(util.PvcNameData)), statefulset.CreateVolumeMount(util.PvcNameData, util.PvcMountPathJournal, statefulset.WithSubPath(util.PvcNameJournal)), diff --git a/controllers/operator/construct/resourcerequirements.go b/controllers/operator/construct/resourcerequirements.go index 166596f2f..0b8bb3703 100644 --- a/controllers/operator/construct/resourcerequirements.go +++ b/controllers/operator/construct/resourcerequirements.go @@ -7,11 +7,12 @@ import ( corev1 "k8s.io/api/core/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" ) // buildStorageRequirements returns a corev1.ResourceList definition for storage requirements. // This is used by the StatefulSet PersistentVolumeClaimTemplate. -func buildStorageRequirements(persistenceConfig *mdbv1.PersistenceConfig, defaultConfig mdbv1.PersistenceConfig) corev1.ResourceList { +func buildStorageRequirements(persistenceConfig *common.PersistenceConfig, defaultConfig common.PersistenceConfig) corev1.ResourceList { res := corev1.ResourceList{} if q := ParseQuantityOrZero(mdbv1.GetStorageOrDefault(persistenceConfig, defaultConfig)); !q.IsZero() { diff --git a/controllers/operator/construct/scalers/appdb_scaler_test.go b/controllers/operator/construct/scalers/appdb_scaler_test.go index bc3db631a..f6116a15e 100644 --- a/controllers/operator/construct/scalers/appdb_scaler_test.go +++ b/controllers/operator/construct/scalers/appdb_scaler_test.go @@ -5,13 +5,12 @@ import ( "github.com/stretchr/testify/assert" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" omv1 "github.com/10gen/ops-manager-kubernetes/api/v1/om" "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/scale" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" ) diff --git a/controllers/operator/construct/scalers/interfaces/interfaces.go b/controllers/operator/construct/scalers/interfaces/interfaces.go index bb9371a6c..7f1a76f65 100644 --- a/controllers/operator/construct/scalers/interfaces/interfaces.go +++ b/controllers/operator/construct/scalers/interfaces/interfaces.go @@ -1,6 +1,6 @@ package interfaces -import "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale" +import "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/scale" type MultiClusterReplicaSetScaler interface { scale.ReplicaSetScaler diff --git a/controllers/operator/construct/scalers/replicaset_scaler.go b/controllers/operator/construct/scalers/replicaset_scaler.go index 5e6e267d6..753baf89a 100644 --- a/controllers/operator/construct/scalers/replicaset_scaler.go +++ b/controllers/operator/construct/scalers/replicaset_scaler.go @@ -3,9 +3,8 @@ package scalers import ( "fmt" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale" - mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/scale" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" ) diff --git a/controllers/operator/create/create.go b/controllers/operator/create/create.go index 42e834f53..cd4fbfaf9 100644 --- a/controllers/operator/create/create.go +++ b/controllers/operator/create/create.go @@ -15,10 +15,6 @@ import ( "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/service" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" @@ -31,6 +27,9 @@ import ( "github.com/10gen/ops-manager-kubernetes/api/v1/status/pvc" "github.com/10gen/ops-manager-kubernetes/controllers/operator/construct" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/service" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/kube" mekoService "github.com/10gen/ops-manager-kubernetes/pkg/kube/service" diff --git a/controllers/operator/create/create_test.go b/controllers/operator/create/create_test.go index f5b60d03c..82f33df2e 100644 --- a/controllers/operator/create/create_test.go +++ b/controllers/operator/create/create_test.go @@ -17,7 +17,6 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/utils/ptr" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -27,6 +26,8 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/construct" "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" "github.com/10gen/ops-manager-kubernetes/pkg/util" @@ -661,7 +662,7 @@ func TestDatabaseInKubernetes_ExternalServicesWithServiceSpecOverrides(t *testin externalAccessConfiguration := mdbv1.ExternalAccessConfiguration{ ExternalDomain: ptr.To("example.com"), ExternalService: mdbv1.ExternalServiceConfiguration{ - SpecWrapper: &mdbv1.ServiceSpecWrapper{Spec: corev1.ServiceSpec{ + SpecWrapper: &common.ServiceSpecWrapper{Spec: corev1.ServiceSpec{ Type: corev1.ServiceTypeNodePort, }}, Annotations: map[string]string{ @@ -702,7 +703,7 @@ func TestDatabaseInKubernetes_ExternalServicesWithPlaceholders(t *testing.T) { service2.Name = "mdb-1-svc-external" externalAccessConfiguration := mdbv1.ExternalAccessConfiguration{ ExternalService: mdbv1.ExternalServiceConfiguration{ - SpecWrapper: &mdbv1.ServiceSpecWrapper{Spec: corev1.ServiceSpec{ + SpecWrapper: &common.ServiceSpecWrapper{Spec: corev1.ServiceSpec{ Type: corev1.ServiceTypeNodePort, }}, Annotations: map[string]string{ @@ -779,7 +780,7 @@ func TestDatabaseInKubernetes_ExternalServicesWithPlaceholders_WithExternalDomai externalAccessConfiguration := mdbv1.ExternalAccessConfiguration{ ExternalDomain: &externalDomain, ExternalService: mdbv1.ExternalServiceConfiguration{ - SpecWrapper: &mdbv1.ServiceSpecWrapper{Spec: corev1.ServiceSpec{ + SpecWrapper: &common.ServiceSpecWrapper{Spec: corev1.ServiceSpec{ Type: corev1.ServiceTypeNodePort, }}, Annotations: map[string]string{ diff --git a/controllers/operator/mock/mockedkubeclient.go b/controllers/operator/mock/mockedkubeclient.go index b62d1144c..30bb91a04 100644 --- a/controllers/operator/mock/mockedkubeclient.go +++ b/controllers/operator/mock/mockedkubeclient.go @@ -13,9 +13,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/client/interceptor" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" certsv1 "k8s.io/api/certificates/v1beta1" corev1 "k8s.io/api/core/v1" @@ -28,6 +25,8 @@ import ( omv1 "github.com/10gen/ops-manager-kubernetes/api/v1/om" "github.com/10gen/ops-manager-kubernetes/api/v1/user" "github.com/10gen/ops-manager-kubernetes/controllers/om" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/handler" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" diff --git a/controllers/operator/mock/test_fixtures.go b/controllers/operator/mock/test_fixtures.go index ad07670d9..221433bd9 100644 --- a/controllers/operator/mock/test_fixtures.go +++ b/controllers/operator/mock/test_fixtures.go @@ -11,9 +11,9 @@ func InitDefaultEnvVariables() { _ = os.Setenv(util.NonStaticDatabaseEnterpriseImage, "mongodb-enterprise-database") _ = os.Setenv(util.AutomationAgentImagePullPolicy, "Never") _ = os.Setenv(util.OpsManagerImageUrl, "quay.io/mongodb/mongodb-enterprise-ops-manager") - _ = os.Setenv(util.InitOpsManagerImageUrl, "quay.io/mongodb/mongodb-enterprise-init-ops-manager") - _ = os.Setenv(util.InitAppdbImageUrlEnv, "quay.io/mongodb/mongodb-enterprise-init-appdb") - _ = os.Setenv(util.InitDatabaseImageUrlEnv, "quay.io/mongodb/mongodb-enterprise-init-database") + _ = os.Setenv(util.InitOpsManagerImageUrl, "quay.io/mongodb/mongodb-kubernetes-init-ops-manager") + _ = os.Setenv(util.InitAppdbImageUrlEnv, "quay.io/mongodb/mongodb-kubernetes-init-appdb") + _ = os.Setenv(util.InitDatabaseImageUrlEnv, "quay.io/mongodb/mongodb-kubernetes-init-database") _ = os.Setenv(util.OpsManagerPullPolicy, "Never") _ = os.Setenv(util.OmOperatorEnv, "test") _ = os.Setenv(util.PodWaitSecondsEnv, "1") diff --git a/controllers/operator/mongodbmultireplicaset_controller.go b/controllers/operator/mongodbmultireplicaset_controller.go index 6f2aa7ed5..459eb4767 100644 --- a/controllers/operator/mongodbmultireplicaset_controller.go +++ b/controllers/operator/mongodbmultireplicaset_controller.go @@ -25,17 +25,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/service" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - - mcoConstruct "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" @@ -60,6 +49,16 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + mcoConstruct "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/service" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" "github.com/10gen/ops-manager-kubernetes/pkg/dns" khandler "github.com/10gen/ops-manager-kubernetes/pkg/handler" "github.com/10gen/ops-manager-kubernetes/pkg/images" diff --git a/controllers/operator/mongodbmultireplicaset_controller_test.go b/controllers/operator/mongodbmultireplicaset_controller_test.go index 0fbd07887..eee401b10 100644 --- a/controllers/operator/mongodbmultireplicaset_controller_test.go +++ b/controllers/operator/mongodbmultireplicaset_controller_test.go @@ -19,9 +19,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/interceptor" "sigs.k8s.io/controller-runtime/pkg/reconcile" - v1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - mcoConstruct "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -35,6 +32,9 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/create" "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + mcoConstruct "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" "github.com/10gen/ops-manager-kubernetes/pkg/agentVersionManagement" "github.com/10gen/ops-manager-kubernetes/pkg/images" "github.com/10gen/ops-manager-kubernetes/pkg/kube" @@ -103,8 +103,8 @@ func TestMultiReplicaSetClusterReconcileContainerImages(t *testing.T) { initDatabaseRelatedImageEnv := fmt.Sprintf("RELATED_IMAGE_%s_2_0_0", util.InitDatabaseImageUrlEnv) imageUrlsMock := images.ImageUrls{ - databaseRelatedImageEnv: "quay.io/mongodb/mongodb-enterprise-database:@sha256:MONGODB_DATABASE", - initDatabaseRelatedImageEnv: "quay.io/mongodb/mongodb-enterprise-init-database:@sha256:MONGODB_INIT_DATABASE", + databaseRelatedImageEnv: "quay.io/mongodb/mongodb-kubernetes-database:@sha256:MONGODB_DATABASE", + initDatabaseRelatedImageEnv: "quay.io/mongodb/mongodb-kubernetes-init-database:@sha256:MONGODB_INIT_DATABASE", } ctx := context.Background() @@ -126,8 +126,8 @@ func TestMultiReplicaSetClusterReconcileContainerImages(t *testing.T) { require.Len(t, sts.Spec.Template.Spec.InitContainers, 1) require.Len(t, sts.Spec.Template.Spec.Containers, 1) - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-database:@sha256:MONGODB_INIT_DATABASE", sts.Spec.Template.Spec.InitContainers[0].Image) - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-database:@sha256:MONGODB_DATABASE", sts.Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-database:@sha256:MONGODB_INIT_DATABASE", sts.Spec.Template.Spec.InitContainers[0].Image) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-database:@sha256:MONGODB_DATABASE", sts.Spec.Template.Spec.Containers[0].Image) }) } } @@ -175,8 +175,8 @@ func TestMultiReplicaSetClusterReconcileContainerImagesWithStaticArchitecture(t func TestReconcilePVCResizeMultiCluster(t *testing.T) { ctx := context.Background() - configuration := v1.StatefulSetConfiguration{ - SpecWrapper: v1.StatefulSetSpecWrapper{ + configuration := common.StatefulSetConfiguration{ + SpecWrapper: common.StatefulSetSpecWrapper{ Spec: appsv1.StatefulSetSpec{ VolumeClaimTemplates: []corev1.PersistentVolumeClaim{ { @@ -796,8 +796,8 @@ func TestScaling(t *testing.T) { }) t.Run("Scale one at a time when scaling up", func(t *testing.T) { - stsWrapper := &v1.StatefulSetConfiguration{ - SpecWrapper: v1.StatefulSetSpecWrapper{ + stsWrapper := &common.StatefulSetConfiguration{ + SpecWrapper: common.StatefulSetSpecWrapper{ Spec: appsv1.StatefulSetSpec{ Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{"a": "b"}, diff --git a/controllers/operator/mongodbopsmanager_controller.go b/controllers/operator/mongodbopsmanager_controller.go index 4ff1953c1..21587d9f1 100644 --- a/controllers/operator/mongodbopsmanager_controller.go +++ b/controllers/operator/mongodbopsmanager_controller.go @@ -26,14 +26,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" @@ -54,6 +46,13 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/images" "github.com/10gen/ops-manager-kubernetes/pkg/kube" diff --git a/controllers/operator/mongodbopsmanager_controller_multi_test.go b/controllers/operator/mongodbopsmanager_controller_multi_test.go index 18a57760f..2bc838eb3 100644 --- a/controllers/operator/mongodbopsmanager_controller_multi_test.go +++ b/controllers/operator/mongodbopsmanager_controller_multi_test.go @@ -11,8 +11,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" @@ -23,6 +21,7 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/om" enterprisepem "github.com/10gen/ops-manager-kubernetes/controllers/operator/pem" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" ) diff --git a/controllers/operator/mongodbopsmanager_controller_test.go b/controllers/operator/mongodbopsmanager_controller_test.go index f5b71f819..328a7bcad 100644 --- a/controllers/operator/mongodbopsmanager_controller_test.go +++ b/controllers/operator/mongodbopsmanager_controller_test.go @@ -17,15 +17,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/interceptor" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/scramcredentials" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - - mcoConstruct "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -44,6 +35,14 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + mcoConstruct "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/scramcredentials" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" "github.com/10gen/ops-manager-kubernetes/pkg/images" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/util" @@ -487,13 +486,13 @@ func TestOpsManagerReconcileContainerImages(t *testing.T) { imageUrlsMock := images.ImageUrls{ // Ops manager & backup deamon images - initOpsManagerRelatedImageEnv: "quay.io/mongodb/mongodb-enterprise-init-ops-manager:@sha256:MONGODB_INIT_APPDB", + initOpsManagerRelatedImageEnv: "quay.io/mongodb/mongodb-kubernetes-init-ops-manager:@sha256:MONGODB_INIT_APPDB", opsManagerRelatedImageEnv: "quay.io/mongodb/mongodb-enterprise-ops-manager:@sha256:MONGODB_OPS_MANAGER", // AppDB images mcoConstruct.AgentImageEnv: "quay.io/mongodb/mongodb-agent@sha256:AGENT_SHA", // In non-static architecture, this env var holds full container image uri mongodbRelatedImageEnv: "quay.io/mongodb/mongodb-enterprise-appdb-database-ubi@sha256:MONGODB_SHA", - initAppdbRelatedImageEnv: "quay.io/mongodb/mongodb-enterprise-init-appdb@sha256:INIT_APPDB_SHA", + initAppdbRelatedImageEnv: "quay.io/mongodb/mongodb-kubernetes-init-appdb@sha256:INIT_APPDB_SHA", } ctx := context.Background() @@ -522,7 +521,7 @@ func TestOpsManagerReconcileContainerImages(t *testing.T) { require.Len(t, sts.Spec.Template.Spec.InitContainers, 1) require.Len(t, sts.Spec.Template.Spec.Containers, 1) - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-ops-manager:@sha256:MONGODB_INIT_APPDB", sts.Spec.Template.Spec.InitContainers[0].Image) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-ops-manager:@sha256:MONGODB_INIT_APPDB", sts.Spec.Template.Spec.InitContainers[0].Image) assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-ops-manager:@sha256:MONGODB_OPS_MANAGER", sts.Spec.Template.Spec.Containers[0].Image) }) } @@ -534,7 +533,7 @@ func TestOpsManagerReconcileContainerImages(t *testing.T) { require.Len(t, appDBSts.Spec.Template.Spec.InitContainers, 1) require.Len(t, appDBSts.Spec.Template.Spec.Containers, 3) - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-appdb@sha256:INIT_APPDB_SHA", appDBSts.Spec.Template.Spec.InitContainers[0].Image) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-appdb@sha256:INIT_APPDB_SHA", appDBSts.Spec.Template.Spec.InitContainers[0].Image) assert.Equal(t, "quay.io/mongodb/mongodb-agent@sha256:AGENT_SHA", appDBSts.Spec.Template.Spec.Containers[0].Image) assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-appdb-database-ubi@sha256:MONGODB_SHA", appDBSts.Spec.Template.Spec.Containers[1].Image) assert.NotContains(t, appDBSts.Spec.Template.Spec.Containers[2].Image, util.OperatorVersion) diff --git a/controllers/operator/mongodbreplicaset_controller.go b/controllers/operator/mongodbreplicaset_controller.go index 08df40e02..93623e5c9 100644 --- a/controllers/operator/mongodbreplicaset_controller.go +++ b/controllers/operator/mongodbreplicaset_controller.go @@ -16,12 +16,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale" - - mcoConstruct "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -44,6 +38,11 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/recovery" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + mcoConstruct "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/scale" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/images" "github.com/10gen/ops-manager-kubernetes/pkg/util" diff --git a/controllers/operator/mongodbreplicaset_controller_test.go b/controllers/operator/mongodbreplicaset_controller_test.go index ca91aead0..a6f5fdd3c 100644 --- a/controllers/operator/mongodbreplicaset_controller_test.go +++ b/controllers/operator/mongodbreplicaset_controller_test.go @@ -18,9 +18,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/interceptor" "sigs.k8s.io/controller-runtime/pkg/reconcile" - mdbcv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - mcoConstruct "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" @@ -40,6 +37,9 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/pem" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + mcoConstruct "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" "github.com/10gen/ops-manager-kubernetes/pkg/images" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/util" @@ -102,8 +102,8 @@ func TestReplicaSetClusterReconcileContainerImages(t *testing.T) { initDatabaseRelatedImageEnv := fmt.Sprintf("RELATED_IMAGE_%s_2_0_0", util.InitDatabaseImageUrlEnv) imageUrlsMock := images.ImageUrls{ - databaseRelatedImageEnv: "quay.io/mongodb/mongodb-enterprise-database:@sha256:MONGODB_DATABASE", - initDatabaseRelatedImageEnv: "quay.io/mongodb/mongodb-enterprise-init-database:@sha256:MONGODB_INIT_DATABASE", + databaseRelatedImageEnv: "quay.io/mongodb/mongodb-kubernetes-database:@sha256:MONGODB_DATABASE", + initDatabaseRelatedImageEnv: "quay.io/mongodb/mongodb-kubernetes-init-database:@sha256:MONGODB_INIT_DATABASE", } ctx := context.Background() @@ -119,8 +119,8 @@ func TestReplicaSetClusterReconcileContainerImages(t *testing.T) { require.Len(t, sts.Spec.Template.Spec.InitContainers, 1) require.Len(t, sts.Spec.Template.Spec.Containers, 1) - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-database:@sha256:MONGODB_INIT_DATABASE", sts.Spec.Template.Spec.InitContainers[0].Image) - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-database:@sha256:MONGODB_DATABASE", sts.Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-database:@sha256:MONGODB_INIT_DATABASE", sts.Spec.Template.Spec.InitContainers[0].Image) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-database:@sha256:MONGODB_DATABASE", sts.Spec.Template.Spec.Containers[0].Image) } func TestReplicaSetClusterReconcileContainerImagesWithStaticArchitecture(t *testing.T) { @@ -165,7 +165,7 @@ func buildReplicaSetWithCustomProjectName(rsName string) (*mdbv1.MongoDB, *corev func TestReplicaSetServiceName(t *testing.T) { ctx := context.Background() rs := DefaultReplicaSetBuilder().SetService("rs-svc").Build() - rs.Spec.StatefulSetConfiguration = &mdbcv1.StatefulSetConfiguration{} + rs.Spec.StatefulSetConfiguration = &common.StatefulSetConfiguration{} rs.Spec.StatefulSetConfiguration.SpecWrapper.Spec.ServiceName = "foo" reconciler, client, _ := defaultReplicaSetReconciler(ctx, nil, "", "", rs) @@ -1172,7 +1172,7 @@ func (b *ReplicaSetBuilder) ExposedExternally(specOverride *corev1.ServiceSpec, b.Spec.ExternalAccessConfiguration = &mdbv1.ExternalAccessConfiguration{} b.Spec.ExternalAccessConfiguration.ExternalDomain = externalDomain if specOverride != nil { - b.Spec.ExternalAccessConfiguration.ExternalService.SpecWrapper = &mdbv1.ServiceSpecWrapper{Spec: *specOverride} + b.Spec.ExternalAccessConfiguration.ExternalService.SpecWrapper = &common.ServiceSpecWrapper{Spec: *specOverride} } if len(annotationsOverride) > 0 { b.Spec.ExternalAccessConfiguration.ExternalService.Annotations = annotationsOverride diff --git a/controllers/operator/mongodbshardedcluster_controller.go b/controllers/operator/mongodbshardedcluster_controller.go index 1ba916b06..d7f268e6f 100644 --- a/controllers/operator/mongodbshardedcluster_controller.go +++ b/controllers/operator/mongodbshardedcluster_controller.go @@ -24,15 +24,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/service" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale" - - mdbcv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - mcoConstruct "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -58,6 +49,14 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/recovery" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + mcoConstruct "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/service" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/scale" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/images" "github.com/10gen/ops-manager-kubernetes/pkg/kube" @@ -370,7 +369,7 @@ func (r *ShardedClusterReconcileHelper) prepareDesiredShardsConfiguration() map[ return shardComponentSpecs } -func getShardTopLevelOverrides(spec *mdbv1.MongoDbSpec, shardIdx int) (*mdbv1.Persistence, *corev1.PodTemplateSpec) { +func getShardTopLevelOverrides(spec *mdbv1.MongoDbSpec, shardIdx int) (*common.Persistence, *corev1.PodTemplateSpec) { topLevelPodSpecOverride, topLevelPersistenceOverride := extractOverridesFromPodSpec(spec.ShardPodSpec) // specific shard level sts and persistence override @@ -390,7 +389,7 @@ func getShardTopLevelOverrides(spec *mdbv1.MongoDbSpec, shardIdx int) (*mdbv1.Pe return topLevelPersistenceOverride, topLevelPodSpecOverride } -func mergeOverrideClusterSpecList(shardOverride mdbv1.ShardOverride, defaultShardConfiguration *mdbv1.ShardedClusterComponentSpec, topLevelPodSpecOverride *corev1.PodTemplateSpec, topLevelPersistenceOverride *mdbv1.Persistence) *mdbv1.ShardedClusterComponentSpec { +func mergeOverrideClusterSpecList(shardOverride mdbv1.ShardOverride, defaultShardConfiguration *mdbv1.ShardedClusterComponentSpec, topLevelPodSpecOverride *corev1.PodTemplateSpec, topLevelPersistenceOverride *common.Persistence) *mdbv1.ShardedClusterComponentSpec { finalShardConfiguration := defaultShardConfiguration.DeepCopy() // We override here all elements of ClusterSpecList, but statefulset overrides if provided here // will be merged on top of previous sts overrides. @@ -403,7 +402,7 @@ func mergeOverrideClusterSpecList(shardOverride mdbv1.ShardOverride, defaultShar // We need to propagate top level specs, from e.g ShardPodSpec or ShardSpecificPodSpec, and apply a merge if foundIdx == -1 { if shardOverrideClusterSpecItem.StatefulSetConfiguration == nil { - shardOverrideClusterSpecItem.StatefulSetConfiguration = &mdbcv1.StatefulSetConfiguration{} + shardOverrideClusterSpecItem.StatefulSetConfiguration = &common.StatefulSetConfiguration{} } // We only need to perform a merge if there is a top level override, otherwise we keep an empty sts configuration if topLevelPodSpecOverride != nil { @@ -488,7 +487,7 @@ func expandShardOverrides(initialOverrides []mdbv1.ShardOverride) []mdbv1.ShardO return expandedShardOverrides } -func processShardOverride(spec *mdbv1.MongoDbSpec, shardOverride mdbv1.ShardOverride, defaultShardConfiguration *mdbv1.ShardedClusterComponentSpec, topLevelPodSpecOverride *corev1.PodTemplateSpec, topLevelPersistenceOverride *mdbv1.Persistence) *mdbv1.ShardedClusterComponentSpec { +func processShardOverride(spec *mdbv1.MongoDbSpec, shardOverride mdbv1.ShardOverride, defaultShardConfiguration *mdbv1.ShardedClusterComponentSpec, topLevelPodSpecOverride *corev1.PodTemplateSpec, topLevelPersistenceOverride *common.Persistence) *mdbv1.ShardedClusterComponentSpec { if shardOverride.Agent != nil { defaultShardConfiguration.Agent = *shardOverride.Agent } @@ -517,7 +516,7 @@ func processShardOverride(spec *mdbv1.MongoDbSpec, shardOverride mdbv1.ShardOver for idx := range defaultShardConfiguration.ClusterSpecList { // Handle case where defaultShardConfiguration.ClusterSpecList[idx].StatefulSetConfiguration is nil if defaultShardConfiguration.ClusterSpecList[idx].StatefulSetConfiguration == nil { - defaultShardConfiguration.ClusterSpecList[idx].StatefulSetConfiguration = &mdbcv1.StatefulSetConfiguration{} + defaultShardConfiguration.ClusterSpecList[idx].StatefulSetConfiguration = &common.StatefulSetConfiguration{} } defaultShardConfiguration.ClusterSpecList[idx].StatefulSetConfiguration.SpecWrapper.Spec = merge.StatefulSetSpecs(defaultShardConfiguration.ClusterSpecList[idx].StatefulSetConfiguration.SpecWrapper.Spec, shardOverride.StatefulSetConfiguration.SpecWrapper.Spec) } @@ -532,9 +531,9 @@ func processShardOverride(spec *mdbv1.MongoDbSpec, shardOverride mdbv1.ShardOver } } -func extractOverridesFromPodSpec(podSpec *mdbv1.MongoDbPodSpec) (*corev1.PodTemplateSpec, *mdbv1.Persistence) { +func extractOverridesFromPodSpec(podSpec *mdbv1.MongoDbPodSpec) (*corev1.PodTemplateSpec, *common.Persistence) { var podTemplateOverride *corev1.PodTemplateSpec - var persistenceOverride *mdbv1.Persistence + var persistenceOverride *common.Persistence if podSpec != nil { if podSpec.PodTemplateWrapper.PodTemplate != nil { podTemplateOverride = podSpec.PodTemplateWrapper.PodTemplate @@ -585,7 +584,7 @@ func (r *ShardedClusterReconcileHelper) prepareDesiredConfigServerConfiguration( func processClusterSpecList( clusterSpecList []mdbv1.ClusterSpecItem, topLevelPodSpecOverride *corev1.PodTemplateSpec, - topLevelPersistenceOverride *mdbv1.Persistence, + topLevelPersistenceOverride *common.Persistence, ) []mdbv1.ClusterSpecItem { for i := range clusterSpecList { // we will store final sts overrides for each cluster in clusterSpecItem.StatefulSetOverride @@ -593,7 +592,7 @@ func processClusterSpecList( // in case higher level overrides are empty, we just use whatever is specified in clusterSpecItem (maybe nothing as well) if topLevelPodSpecOverride != nil { if clusterSpecList[i].StatefulSetConfiguration == nil { - clusterSpecList[i].StatefulSetConfiguration = &mdbcv1.StatefulSetConfiguration{} + clusterSpecList[i].StatefulSetConfiguration = &common.StatefulSetConfiguration{} } clusterSpecList[i].StatefulSetConfiguration.SpecWrapper.Spec.Template = merge.PodTemplateSpecs(*topLevelPodSpecOverride.DeepCopy(), clusterSpecList[i].StatefulSetConfiguration.SpecWrapper.Spec.Template) } diff --git a/controllers/operator/mongodbshardedcluster_controller_multi_test.go b/controllers/operator/mongodbshardedcluster_controller_multi_test.go index 7e329e6cb..f5869573f 100644 --- a/controllers/operator/mongodbshardedcluster_controller_multi_test.go +++ b/controllers/operator/mongodbshardedcluster_controller_multi_test.go @@ -24,9 +24,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -37,6 +34,9 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/agents" "github.com/10gen/ops-manager-kubernetes/controllers/operator/create" "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" "github.com/10gen/ops-manager-kubernetes/pkg/test" "github.com/10gen/ops-manager-kubernetes/pkg/util" @@ -2764,7 +2764,7 @@ func TestMultiClusterShardedServiceCreation_WithExternalName(t *testing.T) { ClusterName: memberClusterName1, ExternalAccessConfiguration: &mdbv1.ExternalAccessConfiguration{ ExternalService: mdbv1.ExternalServiceConfiguration{ - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "LoadBalancer", Ports: []corev1.ServicePort{ @@ -2880,7 +2880,7 @@ func TestMultiClusterShardedServiceCreation_WithExternalName(t *testing.T) { ClusterName: memberClusterName1, ExternalAccessConfiguration: &mdbv1.ExternalAccessConfiguration{ ExternalService: mdbv1.ExternalServiceConfiguration{ - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "NodePort", Ports: []corev1.ServicePort{ @@ -2902,7 +2902,7 @@ func TestMultiClusterShardedServiceCreation_WithExternalName(t *testing.T) { ClusterName: memberClusterName2, ExternalAccessConfiguration: &mdbv1.ExternalAccessConfiguration{ ExternalService: mdbv1.ExternalServiceConfiguration{ - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "NodePort", Ports: []corev1.ServicePort{ @@ -2925,7 +2925,7 @@ func TestMultiClusterShardedServiceCreation_WithExternalName(t *testing.T) { ClusterName: memberClusterName3, ExternalAccessConfiguration: &mdbv1.ExternalAccessConfiguration{ ExternalService: mdbv1.ExternalServiceConfiguration{ - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "NodePort", Ports: []corev1.ServicePort{ @@ -3057,7 +3057,7 @@ func TestMultiClusterShardedServiceCreation_WithExternalName(t *testing.T) { create.PlaceholderClusterName: "{clusterName}", create.PlaceholderClusterIndex: "{clusterIndex}", }, - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "LoadBalancer", Ports: []corev1.ServicePort{ @@ -3092,7 +3092,7 @@ func TestMultiClusterShardedServiceCreation_WithExternalName(t *testing.T) { create.PlaceholderClusterName: "{clusterName}", create.PlaceholderClusterIndex: "{clusterIndex}", }, - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "LoadBalancer", Ports: []corev1.ServicePort{ @@ -3127,7 +3127,7 @@ func TestMultiClusterShardedServiceCreation_WithExternalName(t *testing.T) { create.PlaceholderClusterName: "{clusterName}", create.PlaceholderClusterIndex: "{clusterIndex}", }, - SpecWrapper: &mdbv1.ServiceSpecWrapper{ + SpecWrapper: &common.ServiceSpecWrapper{ Spec: corev1.ServiceSpec{ Type: "LoadBalancer", Ports: []corev1.ServicePort{ diff --git a/controllers/operator/mongodbshardedcluster_controller_test.go b/controllers/operator/mongodbshardedcluster_controller_test.go index 4663f981c..6c2129958 100644 --- a/controllers/operator/mongodbshardedcluster_controller_test.go +++ b/controllers/operator/mongodbshardedcluster_controller_test.go @@ -18,11 +18,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/interceptor" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - - mcoConstruct "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -41,6 +36,11 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + mcoConstruct "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/images" "github.com/10gen/ops-manager-kubernetes/pkg/kube" @@ -254,8 +254,8 @@ func TestShardedClusterReconcileContainerImages(t *testing.T) { initDatabaseRelatedImageEnv := fmt.Sprintf("RELATED_IMAGE_%s_2_0_0", util.InitDatabaseImageUrlEnv) imageUrlsMock := images.ImageUrls{ - databaseRelatedImageEnv: "quay.io/mongodb/mongodb-enterprise-database:@sha256:MONGODB_DATABASE", - initDatabaseRelatedImageEnv: "quay.io/mongodb/mongodb-enterprise-init-database:@sha256:MONGODB_INIT_DATABASE", + databaseRelatedImageEnv: "quay.io/mongodb/mongodb-kubernetes-database:@sha256:MONGODB_DATABASE", + initDatabaseRelatedImageEnv: "quay.io/mongodb/mongodb-kubernetes-init-database:@sha256:MONGODB_INIT_DATABASE", } ctx := context.Background() @@ -279,8 +279,8 @@ func TestShardedClusterReconcileContainerImages(t *testing.T) { require.Len(t, sts.Spec.Template.Spec.InitContainers, 1) require.Len(t, sts.Spec.Template.Spec.Containers, 1) - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-database:@sha256:MONGODB_INIT_DATABASE", sts.Spec.Template.Spec.InitContainers[0].Image) - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-database:@sha256:MONGODB_DATABASE", sts.Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-database:@sha256:MONGODB_INIT_DATABASE", sts.Spec.Template.Spec.InitContainers[0].Image) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-database:@sha256:MONGODB_DATABASE", sts.Spec.Template.Spec.Containers[0].Image) }) } } @@ -332,8 +332,8 @@ func TestReconcilePVCResizeShardedCluster(t *testing.T) { ctx := context.Background() // First creation sc := test.DefaultClusterBuilder().SetShardCountSpec(2).SetShardCountStatus(2).Build() - persistence := mdbv1.Persistence{ - SingleConfig: &mdbv1.PersistenceConfig{ + persistence := common.Persistence{ + SingleConfig: &common.PersistenceConfig{ Storage: "1Gi", }, } diff --git a/controllers/operator/mongodbstandalone_controller.go b/controllers/operator/mongodbstandalone_controller.go index a5291d560..bcb8f80e4 100644 --- a/controllers/operator/mongodbstandalone_controller.go +++ b/controllers/operator/mongodbstandalone_controller.go @@ -16,10 +16,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - - mcoConstruct "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -38,6 +34,9 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/project" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + mcoConstruct "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/images" "github.com/10gen/ops-manager-kubernetes/pkg/util" diff --git a/controllers/operator/mongodbstandalone_controller_test.go b/controllers/operator/mongodbstandalone_controller_test.go index 47c9f1490..c13cd5928 100644 --- a/controllers/operator/mongodbstandalone_controller_test.go +++ b/controllers/operator/mongodbstandalone_controller_test.go @@ -14,8 +14,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/interceptor" "sigs.k8s.io/controller-runtime/pkg/reconcile" - mcoConstruct "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -26,6 +24,8 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/controlledfeature" "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" + mcoConstruct "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" "github.com/10gen/ops-manager-kubernetes/pkg/dns" "github.com/10gen/ops-manager-kubernetes/pkg/images" "github.com/10gen/ops-manager-kubernetes/pkg/kube" @@ -82,8 +82,8 @@ func TestStandaloneClusterReconcileContainerImages(t *testing.T) { initDatabaseRelatedImageEnv := fmt.Sprintf("RELATED_IMAGE_%s_2_0_0", util.InitDatabaseImageUrlEnv) imageUrlsMock := images.ImageUrls{ - databaseRelatedImageEnv: "quay.io/mongodb/mongodb-enterprise-database:@sha256:MONGODB_DATABASE", - initDatabaseRelatedImageEnv: "quay.io/mongodb/mongodb-enterprise-init-database:@sha256:MONGODB_INIT_DATABASE", + databaseRelatedImageEnv: "quay.io/mongodb/mongodb-kubernetes-database:@sha256:MONGODB_DATABASE", + initDatabaseRelatedImageEnv: "quay.io/mongodb/mongodb-kubernetes-init-database:@sha256:MONGODB_INIT_DATABASE", } ctx := context.Background() @@ -99,8 +99,8 @@ func TestStandaloneClusterReconcileContainerImages(t *testing.T) { require.Len(t, sts.Spec.Template.Spec.InitContainers, 1) require.Len(t, sts.Spec.Template.Spec.Containers, 1) - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-database:@sha256:MONGODB_INIT_DATABASE", sts.Spec.Template.Spec.InitContainers[0].Image) - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-database:@sha256:MONGODB_DATABASE", sts.Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-database:@sha256:MONGODB_INIT_DATABASE", sts.Spec.Template.Spec.InitContainers[0].Image) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-database:@sha256:MONGODB_DATABASE", sts.Spec.Template.Spec.Containers[0].Image) } func TestStandaloneClusterReconcileContainerImagesWithStaticArchitecture(t *testing.T) { diff --git a/controllers/operator/mongodbuser_controller.go b/controllers/operator/mongodbuser_controller.go index 614c14695..d47718fd9 100644 --- a/controllers/operator/mongodbuser_controller.go +++ b/controllers/operator/mongodbuser_controller.go @@ -16,10 +16,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" @@ -34,6 +30,9 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" "github.com/10gen/ops-manager-kubernetes/pkg/util" diff --git a/controllers/operator/mongodbuser_controller_test.go b/controllers/operator/mongodbuser_controller_test.go index dd1083943..413faa557 100644 --- a/controllers/operator/mongodbuser_controller_test.go +++ b/controllers/operator/mongodbuser_controller_test.go @@ -11,7 +11,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/reconcile" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -23,6 +22,7 @@ import ( "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" "github.com/10gen/ops-manager-kubernetes/controllers/operator/watch" "github.com/10gen/ops-manager-kubernetes/controllers/operator/workflow" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/test" "github.com/10gen/ops-manager-kubernetes/pkg/util" diff --git a/controllers/operator/project/project.go b/controllers/operator/project/project.go index b12bcc6c5..1ce270088 100644 --- a/controllers/operator/project/project.go +++ b/controllers/operator/project/project.go @@ -8,14 +8,13 @@ import ( "go.uber.org/zap" "golang.org/x/xerrors" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" "github.com/10gen/ops-manager-kubernetes/controllers/om" "github.com/10gen/ops-manager-kubernetes/controllers/om/apierror" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/util" ) diff --git a/controllers/operator/project/projectconfig.go b/controllers/operator/project/projectconfig.go index 66ce5cbb5..45a302b50 100644 --- a/controllers/operator/project/projectconfig.go +++ b/controllers/operator/project/projectconfig.go @@ -7,9 +7,8 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/util/env" ) diff --git a/controllers/operator/project/projectconfig_test.go b/controllers/operator/project/projectconfig_test.go index 517791a09..461d8c093 100644 --- a/controllers/operator/project/projectconfig_test.go +++ b/controllers/operator/project/projectconfig_test.go @@ -6,11 +6,10 @@ import ( "github.com/stretchr/testify/assert" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - corev1 "k8s.io/api/core/v1" "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" "github.com/10gen/ops-manager-kubernetes/pkg/kube" "github.com/10gen/ops-manager-kubernetes/pkg/util" ) diff --git a/controllers/operator/secrets/secrets.go b/controllers/operator/secrets/secrets.go index 2ec6407a7..a1e970386 100644 --- a/controllers/operator/secrets/secrets.go +++ b/controllers/operator/secrets/secrets.go @@ -10,12 +10,11 @@ import ( "golang.org/x/xerrors" "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" "github.com/10gen/ops-manager-kubernetes/pkg/vault" ) diff --git a/controllers/operator/state_store.go b/controllers/operator/state_store.go index 87172735b..842d619df 100644 --- a/controllers/operator/state_store.go +++ b/controllers/operator/state_store.go @@ -10,12 +10,11 @@ import ( "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime/schema" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" corev1 "k8s.io/api/core/v1" - "github.com/10gen/ops-manager-kubernetes/api/v1" + v1 "github.com/10gen/ops-manager-kubernetes/api/v1" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" "github.com/10gen/ops-manager-kubernetes/pkg/kube" ) diff --git a/controllers/operator/workflow/failed.go b/controllers/operator/workflow/failed.go index 8c4583aa4..ff8ef95cf 100644 --- a/controllers/operator/workflow/failed.go +++ b/controllers/operator/workflow/failed.go @@ -7,9 +7,8 @@ import ( "golang.org/x/xerrors" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/apierrors" - "github.com/10gen/ops-manager-kubernetes/api/v1/status" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/apierrors" ) // failedStatus indicates that the reconciliation process must be suspended and CR should get "Pending" status diff --git a/controllers/operator/workflow/status.go b/controllers/operator/workflow/status.go index f7f8d93d1..beb4c9521 100644 --- a/controllers/operator/workflow/status.go +++ b/controllers/operator/workflow/status.go @@ -6,9 +6,8 @@ import ( "go.uber.org/zap" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/apierrors" - "github.com/10gen/ops-manager-kubernetes/api/v1/status" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/apierrors" ) // Status serves as a container holding the status of the custom resource diff --git a/docker/mongodb-agent-non-matrix/Dockerfile.builder b/docker/mongodb-agent-non-matrix/Dockerfile.builder index 369212e3e..ab929133e 100644 --- a/docker/mongodb-agent-non-matrix/Dockerfile.builder +++ b/docker/mongodb-agent-non-matrix/Dockerfile.builder @@ -8,4 +8,4 @@ ARG tools_version ADD https://mciuploads.s3.amazonaws.com/mms-automation/mongodb-mms-build-agent/builds/automation-agent/prod/mongodb-mms-automation-agent-${agent_version}.${agent_distro}.tar.gz /data/mongodb-agent.tar.gz ADD https://downloads.mongodb.org/tools/db/mongodb-database-tools-${tools_distro}-${tools_version}.tgz /data/mongodb-tools.tgz -COPY ./docker/mongodb-enterprise-init-database/content/LICENSE /data/LICENSE +COPY ./docker/mongodb-kubernetes-init-database/content/LICENSE /data/LICENSE diff --git a/docker/mongodb-agent/Dockerfile.builder b/docker/mongodb-agent/Dockerfile.builder index da8f45b2d..b3976c24a 100644 --- a/docker/mongodb-agent/Dockerfile.builder +++ b/docker/mongodb-agent/Dockerfile.builder @@ -16,10 +16,10 @@ FROM public.ecr.aws/docker/library/golang:1.24 as readiness_builder WORKDIR /go/src/github.com/10gen/ops-manager-kubernetes/ COPY --from=dependency_downloader /go/pkg /go/pkg -COPY go.mod go.sum ./ +COPY . /go/src/github.com/10gen/ops-manager-kubernetes -RUN CGO_ENABLED=0 go build -o /readinessprobe github.com/mongodb/mongodb-kubernetes-operator/cmd/readiness -RUN CGO_ENABLED=0 go build -o /version-upgrade-hook github.com/mongodb/mongodb-kubernetes-operator/cmd/versionhook +RUN CGO_ENABLED=0 GOFLAGS=-buildvcs=false go build -o /readinessprobe ./mongodb-community-operator/cmd/readiness/main.go +RUN CGO_ENABLED=0 GOFLAGS=-buildvcs=false go build -o /version-upgrade-hook ./mongodb-community-operator/cmd/versionhook/main.go FROM scratch ARG mongodb_tools_url_ubi diff --git a/docker/mongodb-community-tests/Dockerfile b/docker/mongodb-community-tests/Dockerfile new file mode 100644 index 000000000..b568ff77f --- /dev/null +++ b/docker/mongodb-community-tests/Dockerfile @@ -0,0 +1,29 @@ +# This image is based on latest Python 3.6 release in latest Debian Stretch. +# I had to move away from Alpine as the latest Kubernetes Python module depends +# on `cryptography` which can be installed in Debian but needs to be compiled +# in Alpine, meaning that we would have to install gcc or clang on it, making +# it too slow for the images. +# +# Ref: https://cryptography.io/en/latest/installation/#building-cryptography-on-linux +# +ARG GOLANG_VERSION + +FROM public.ecr.aws/docker/library/golang:${GOLANG_VERSION} as builder + +ENV GO111MODULE=on +ENV GOPATH "" + +WORKDIR /tests + +COPY docker/mongodb-community-tests/testdata/tls/ testdata/tls/ + +RUN curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" \ + && chmod +x ./kubectl \ + && mv ./kubectl /usr/local/bin/kubectl \ + && curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 \ + && chmod +x get_helm.sh && ./get_helm.sh + + +ADD . . + +RUN go mod download && go mod verify diff --git a/mongodb-community-operator/testdata/tls/ca.crt b/docker/mongodb-community-tests/testdata/tls/ca.crt similarity index 100% rename from mongodb-community-operator/testdata/tls/ca.crt rename to docker/mongodb-community-tests/testdata/tls/ca.crt diff --git a/mongodb-community-operator/testdata/tls/ca.key b/docker/mongodb-community-tests/testdata/tls/ca.key similarity index 100% rename from mongodb-community-operator/testdata/tls/ca.key rename to docker/mongodb-community-tests/testdata/tls/ca.key diff --git a/mongodb-community-operator/testdata/tls/server.crt b/docker/mongodb-community-tests/testdata/tls/server.crt similarity index 100% rename from mongodb-community-operator/testdata/tls/server.crt rename to docker/mongodb-community-tests/testdata/tls/server.crt diff --git a/mongodb-community-operator/testdata/tls/server.key b/docker/mongodb-community-tests/testdata/tls/server.key similarity index 100% rename from mongodb-community-operator/testdata/tls/server.key rename to docker/mongodb-community-tests/testdata/tls/server.key diff --git a/mongodb-community-operator/testdata/tls/server.pem b/docker/mongodb-community-tests/testdata/tls/server.pem similarity index 100% rename from mongodb-community-operator/testdata/tls/server.pem rename to docker/mongodb-community-tests/testdata/tls/server.pem diff --git a/mongodb-community-operator/testdata/tls/server_rotated.crt b/docker/mongodb-community-tests/testdata/tls/server_rotated.crt similarity index 100% rename from mongodb-community-operator/testdata/tls/server_rotated.crt rename to docker/mongodb-community-tests/testdata/tls/server_rotated.crt diff --git a/mongodb-community-operator/testdata/tls/server_rotated.key b/docker/mongodb-community-tests/testdata/tls/server_rotated.key similarity index 100% rename from mongodb-community-operator/testdata/tls/server_rotated.key rename to docker/mongodb-community-tests/testdata/tls/server_rotated.key diff --git a/docker/mongodb-enterprise-appdb-database/4.0/ubi/Dockerfile b/docker/mongodb-enterprise-appdb-database/4.0/ubi/Dockerfile deleted file mode 100644 index 1b5d11310..000000000 --- a/docker/mongodb-enterprise-appdb-database/4.0/ubi/Dockerfile +++ /dev/null @@ -1,85 +0,0 @@ -FROM registry.access.redhat.com/ubi8/ubi - -ARG MONGO_VERSION - -LABEL name="MongoDB Enterprise AppDB Database" \ - version=${MONGO_VERSION} \ - summary="MongoDB Enterprise AppDB Database" \ - description="MongoDB Enterprise AppDB Database" \ - vendor="MongoDB" \ - release="1" \ - maintainer="support@mongodb.com" - -ADD licenses /licenses - -# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added -RUN groupadd -r mongodb && useradd -r -g mongodb mongodb - - -RUN set -eux; \ - yum install -y --disableplugin=subscription-manager \ - ca-certificates \ - jq \ - ; \ - if ! command -v ps > /dev/null; then \ - yum install -y --disableplugin=subscription-managers procps; \ - fi; - -# grab gosu for easy step-down from root (https://github.com/tianon/gosu/releases) -ENV GOSU_VERSION 1.14 -# grab "js-yaml" for parsing mongod's YAML config files (https://github.com/nodeca/js-yaml/releases) -ENV JSYAML_VERSION 3.13.1 - -RUN set -ex; \ - \ - yum install -y --disableplugin=subscription-manager \ - wget \ - ; \ - if ! command -v gpg > /dev/null; then \ - yum install -y --disableplugin=subscription-manager gnupg dirmngr; \ - elif gpg --version | grep -q '^gpg (GnuPG) 1\.'; then \ -# "This package provides support for HKPS keyservers." (GnuPG 1.x only) - yum install -y --disableplugin=subscription-manager gnupg-curl; \ - fi; \ - \ - dpkgArch="$(arch| sed 's/x86_64/amd64/')"; \ - wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \ - wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \ - export GNUPGHOME="$(mktemp -d)"; \ - gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ - gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ - command -v gpgconf && gpgconf --kill all || :; \ - rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \ - \ - wget -O /js-yaml.js "https://github.com/nodeca/js-yaml/raw/${JSYAML_VERSION}/dist/js-yaml.js"; \ - chmod +x /usr/local/bin/gosu; \ - gosu --version; \ - gosu nobody true - -RUN mkdir /docker-entrypoint-initdb.d - -# # Allow build-time overrides (eg. to build image with MongoDB Enterprise version) -# # Options for MONGO_PACKAGE: mongodb-org OR mongodb-enterprise -# # Options for MONGO_REPO: repo.mongodb.org OR repo.mongodb.com -# # Example: docker build --build-arg MONGO_PACKAGE=mongodb-enterprise --build-arg MONGO_REPO=repo.mongodb.com . -ARG MONGO_PACKAGE=mongodb-org -ARG MONGO_REPO=repo.mongodb.org -ENV MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO} - -ENV MONGO_MAJOR 4.0 - -COPY 4.0/ubi/mongodb-org-4.0.repo /etc/yum.repos.d/mongodb-org-4.0.repo - - -RUN yum install -y mongodb-enterprise-${MONGO_VERSION} mongodb-enterprise-server-${MONGO_VERSION} mongodb-enterprise-shell-${MONGO_VERSION} mongodb-enterprise-mongos-${MONGO_VERSION} mongodb-enterprise-tools-${MONGO_VERSION} - -RUN echo "exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools" >> /etc/yum.conf -RUN mkdir -p /data/db /data/configdb \ - && chown -R mongodb:mongodb /data/db /data/configdb -VOLUME /data/db /data/configdb - -COPY docker-entrypoint.sh /usr/local/bin/ -ENTRYPOINT ["docker-entrypoint.sh"] - -EXPOSE 27017 -CMD ["mongod"] diff --git a/docker/mongodb-enterprise-appdb-database/4.0/ubi/mongodb-org-4.0.repo b/docker/mongodb-enterprise-appdb-database/4.0/ubi/mongodb-org-4.0.repo deleted file mode 100644 index 18a2fc0e9..000000000 --- a/docker/mongodb-enterprise-appdb-database/4.0/ubi/mongodb-org-4.0.repo +++ /dev/null @@ -1,6 +0,0 @@ -[mongodb-enterprise-4.0] -name=MongoDB Enterprise Repository -baseurl=https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/4.0/$basearch/ -gpgcheck=1 -enabled=1 -gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc diff --git a/docker/mongodb-enterprise-appdb-database/4.2/ubi/Dockerfile b/docker/mongodb-enterprise-appdb-database/4.2/ubi/Dockerfile deleted file mode 100644 index 907d449ce..000000000 --- a/docker/mongodb-enterprise-appdb-database/4.2/ubi/Dockerfile +++ /dev/null @@ -1,87 +0,0 @@ -FROM registry.access.redhat.com/ubi8/ubi - -ARG MONGO_VERSION - -LABEL name="MongoDB Enterprise AppDB Database" \ - version=${MONGO_VERSION} \ - summary="MongoDB Enterprise AppDB Database" \ - description="MongoDB Enterprise AppDB Database" \ - vendor="MongoDB" \ - release="1" \ - maintainer="support@mongodb.com" - -ADD licenses /licenses - -# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added -RUN groupadd -r mongodb && useradd -r -g mongodb mongodb - - -RUN set -eux; \ - yum install -y --disableplugin=subscription-manager \ - ca-certificates \ - jq \ - ; \ - if ! command -v ps > /dev/null; then \ - yum install -y --disableplugin=subscription-managers procps; \ - fi; - -# grab gosu for easy step-down from root (https://github.com/tianon/gosu/releases) -ENV GOSU_VERSION 1.14 -# grab "js-yaml" for parsing mongod's YAML config files (https://github.com/nodeca/js-yaml/releases) -ENV JSYAML_VERSION 3.13.1 - -RUN set -ex; \ - \ - yum install -y --disableplugin=subscription-manager \ - wget \ - ; \ - if ! command -v gpg > /dev/null; then \ - yum install -y --disableplugin=subscription-manager gnupg dirmngr; \ - elif gpg --version | grep -q '^gpg (GnuPG) 1\.'; then \ -# "This package provides support for HKPS keyservers." (GnuPG 1.x only) - yum install -y --disableplugin=subscription-manager gnupg-curl; \ - fi; \ - \ - dpkgArch="$(arch| sed 's/x86_64/amd64/')"; \ - wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \ - wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \ - export GNUPGHOME="$(mktemp -d)"; \ - gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ - gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ - command -v gpgconf && gpgconf --kill all || :; \ - rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \ - \ - wget -O /js-yaml.js "https://github.com/nodeca/js-yaml/raw/${JSYAML_VERSION}/dist/js-yaml.js"; \ - chmod +x /usr/local/bin/gosu; \ - gosu --version; \ - gosu nobody true - - RUN mkdir /docker-entrypoint-initdb.d - -# # Allow build-time overrides (eg. to build image with MongoDB Enterprise version) -# # Options for MONGO_PACKAGE: mongodb-org OR mongodb-enterprise -# # Options for MONGO_REPO: repo.mongodb.org OR repo.mongodb.com -# # Example: docker build --build-arg MONGO_PACKAGE=mongodb-enterprise --build-arg MONGO_REPO=repo.mongodb.com . -ARG MONGO_PACKAGE=mongodb-org -ARG MONGO_REPO=repo.mongodb.org -ENV MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO} - -ENV MONGO_MAJOR 4.2 - -COPY 4.2/ubi/mongodb-org-4.2.repo /etc/yum.repos.d/mongodb-org-4.2.repo - - -RUN cat /etc/yum.repos.d/mongodb-org-4.2.repo - -RUN yum install -y mongodb-enterprise-${MONGO_VERSION} mongodb-enterprise-server-${MONGO_VERSION} mongodb-enterprise-shell-${MONGO_VERSION} mongodb-enterprise-mongos-${MONGO_VERSION} mongodb-enterprise-tools-${MONGO_VERSION} - -RUN echo "exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools" >> /etc/yum.conf -RUN mkdir -p /data/db /data/configdb \ - && chown -R mongodb:mongodb /data/db /data/configdb -VOLUME /data/db /data/configdb - -COPY docker-entrypoint.sh /usr/local/bin/ -ENTRYPOINT ["docker-entrypoint.sh"] - -EXPOSE 27017 -CMD ["mongod"] diff --git a/docker/mongodb-enterprise-appdb-database/4.2/ubi/mongodb-org-4.2.repo b/docker/mongodb-enterprise-appdb-database/4.2/ubi/mongodb-org-4.2.repo deleted file mode 100644 index 836d01f3b..000000000 --- a/docker/mongodb-enterprise-appdb-database/4.2/ubi/mongodb-org-4.2.repo +++ /dev/null @@ -1,6 +0,0 @@ -[mongodb-enterprise-4.2] -name=MongoDB Enterprise Repository -baseurl=https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/4.2/$basearch/ -gpgcheck=1 -enabled=1 -gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc diff --git a/docker/mongodb-enterprise-appdb-database/4.4/ubi/Dockerfile b/docker/mongodb-enterprise-appdb-database/4.4/ubi/Dockerfile deleted file mode 100644 index a93fffc68..000000000 --- a/docker/mongodb-enterprise-appdb-database/4.4/ubi/Dockerfile +++ /dev/null @@ -1,91 +0,0 @@ -FROM registry.access.redhat.com/ubi8/ubi - -ARG MONGO_VERSION - -LABEL name="MongoDB Enterprise AppDB Database" \ - version=${MONGO_VERSION} \ - summary="MongoDB Enterprise AppDB Database" \ - description="MongoDB Enterprise AppDB Database" \ - vendor="MongoDB" \ - release="1" \ - maintainer="support@mongodb.com" - -ADD licenses /licenses - -# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added -RUN groupadd -r mongodb && useradd -r -g mongodb mongodb - -#TODO add numactl - -RUN set -eux; \ - yum install -y --disableplugin=subscription-manager \ - ca-certificates \ - jq \ - ; \ - if ! command -v ps > /dev/null; then \ - yum install -y --disableplugin=subscription-managers procps; \ - fi; - -# grab gosu for easy step-down from root (https://github.com/tianon/gosu/releases) -ENV GOSU_VERSION 1.14 -# grab "js-yaml" for parsing mongod's YAML config files (https://github.com/nodeca/js-yaml/releases) -ENV JSYAML_VERSION 3.13.1 - -RUN set -ex; \ - \ - yum install -y --disableplugin=subscription-manager \ - wget \ - ; \ - if ! command -v gpg > /dev/null; then \ - yum install -y --disableplugin=subscription-manager gnupg dirmngr; \ - elif gpg --version | grep -q '^gpg (GnuPG) 1\.'; then \ -# "This package provides support for HKPS keyservers." (GnuPG 1.x only) - yum install -y --disableplugin=subscription-manager gnupg-curl; \ - fi; \ - \ - dpkgArch="$(arch| sed 's/x86_64/amd64/')"; \ - wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \ - wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \ - export GNUPGHOME="$(mktemp -d)"; \ - gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ - gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ - command -v gpgconf && gpgconf --kill all || :; \ - rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \ - \ - wget -O /js-yaml.js "https://github.com/nodeca/js-yaml/raw/${JSYAML_VERSION}/dist/js-yaml.js"; \ - -# smoke test - chmod +x /usr/local/bin/gosu; \ - gosu --version; \ - gosu nobody true - -RUN mkdir /docker-entrypoint-initdb.d - - -# # Allow build-time overrides (eg. to build image with MongoDB Enterprise version) -# # Options for MONGO_PACKAGE: mongodb-org OR mongodb-enterprise -# # Options for MONGO_REPO: repo.mongodb.org OR repo.mongodb.com -# # Example: docker build --build-arg MONGO_PACKAGE=mongodb-enterprise --build-arg MONGO_REPO=repo.mongodb.com . -ARG MONGO_PACKAGE=mongodb-org -ARG MONGO_REPO=repo.mongodb.org -ENV MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO} - -# TODO put everything in a single dockerfile -ENV MONGO_MAJOR 4.4 - -COPY 4.4/ubi/mongodb-org-4.4.repo /etc/yum.repos.d/mongodb-org-4.4.repo - -RUN cat /etc/yum.repos.d/mongodb-org-4.4.repo - -RUN yum install -y mongodb-enterprise-${MONGO_VERSION} mongodb-enterprise-server-${MONGO_VERSION} mongodb-enterprise-shell-${MONGO_VERSION} mongodb-enterprise-mongos-${MONGO_VERSION} mongodb-enterprise-tools-${MONGO_VERSION} - -RUN echo "exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools" >> /etc/yum.conf -RUN mkdir -p /data/db /data/configdb \ - && chown -R mongodb:mongodb /data/db /data/configdb -VOLUME /data/db /data/configdb - -COPY docker-entrypoint.sh /usr/local/bin/ -ENTRYPOINT ["docker-entrypoint.sh"] - -EXPOSE 27017 -CMD ["mongod"] diff --git a/docker/mongodb-enterprise-appdb-database/4.4/ubi/mongodb-org-4.4.repo b/docker/mongodb-enterprise-appdb-database/4.4/ubi/mongodb-org-4.4.repo deleted file mode 100644 index 0a81c4c40..000000000 --- a/docker/mongodb-enterprise-appdb-database/4.4/ubi/mongodb-org-4.4.repo +++ /dev/null @@ -1,6 +0,0 @@ -[mongodb-enterprise-4.4] -name=MongoDB Enterprise Repository -baseurl=https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/4.4/$basearch/ -gpgcheck=1 -enabled=1 -gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc diff --git a/docker/mongodb-enterprise-appdb-database/5.0/ubi/Dockerfile b/docker/mongodb-enterprise-appdb-database/5.0/ubi/Dockerfile deleted file mode 100644 index 066e88709..000000000 --- a/docker/mongodb-enterprise-appdb-database/5.0/ubi/Dockerfile +++ /dev/null @@ -1,85 +0,0 @@ -FROM registry.access.redhat.com/ubi8/ubi - -ARG MONGO_VERSION - -LABEL name="MongoDB Enterprise AppDB Database" \ - version=${MONGO_VERSION} \ - summary="MongoDB Enterprise AppDB Database" \ - description="MongoDB Enterprise AppDB Database" \ - vendor="MongoDB" \ - release="1" \ - maintainer="support@mongodb.com" - -ADD licenses /licenses - -# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added -RUN groupadd -r mongodb && useradd -r -g mongodb mongodb - -RUN set -eux; \ - yum install -y \ - ca-certificates \ - jq \ - ; \ - if ! command -v ps > /dev/null; then \ - yum install -y procps; \ - fi; - -# grab gosu for easy step-down from root (https://github.com/tianon/gosu/releases) -ENV GOSU_VERSION 1.14 -# grab "js-yaml" for parsing mongod's YAML config files (https://github.com/nodeca/js-yaml/releases) -ENV JSYAML_VERSION 3.13.1 - -RUN set -ex; \ - \ - yum install -y \ - wget \ - ; \ - if ! command -v gpg > /dev/null; then \ - yum install -y gnupg dirmngr; \ - elif gpg --version | grep -q '^gpg (GnuPG) 1\.'; then \ -# "This package provides support for HKPS keyservers." (GnuPG 1.x only) - yum install -y gnupg-curl; \ - fi; \ - \ - dpkgArch="$(arch| sed 's/x86_64/amd64/')"; \ - wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \ - wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \ - export GNUPGHOME="$(mktemp -d)"; \ - gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ - gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ - command -v gpgconf && gpgconf --kill all || :; \ - rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \ - \ - wget -O /js-yaml.js "https://github.com/nodeca/js-yaml/raw/${JSYAML_VERSION}/dist/js-yaml.js"; \ -# smoke test - chmod +x /usr/local/bin/gosu; \ - gosu --version; \ - gosu nobody true - -RUN mkdir /docker-entrypoint-initdb.d - -# Allow build-time overrides (eg. to build image with MongoDB Enterprise version) -# Options for MONGO_PACKAGE: mongodb-org OR mongodb-enterprise -# Options for MONGO_REPO: repo.mongodb.org OR repo.mongodb.com -# Example: docker build --build-arg MONGO_PACKAGE=mongodb-enterprise --build-arg MONGO_REPO=repo.mongodb.com . -ARG MONGO_PACKAGE=mongodb-org -ARG MONGO_REPO=repo.mongodb.org -ENV MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO} - -ENV MONGO_MAJOR 5.0 - -COPY 5.0/ubi/mongodb-org-5.0.repo /etc/yum.repos.d/mongodb-org-5.0.repo -# 08/03/2021, https://github.com/mongodb/mongo/tree/6d9ec525e78465dcecadcff99cce953d380fedc8 - -RUN yum install -y mongodb-enterprise-${MONGO_VERSION} mongodb-enterprise-server-${MONGO_VERSION} mongodb-enterprise-shell-${MONGO_VERSION} mongodb-enterprise-mongos-${MONGO_VERSION} mongodb-enterprise-tools-${MONGO_VERSION} - -RUN echo "exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools" >> /etc/yum.conf -RUN mkdir -p /data/db /data/configdb \ - && chown -R mongodb:mongodb /data/db /data/configdb -VOLUME /data/db /data/configdb - -COPY docker-entrypoint.sh /usr/local/bin/ -ENTRYPOINT ["docker-entrypoint.sh"] - -EXPOSE 27017 -CMD ["mongod"] diff --git a/docker/mongodb-enterprise-appdb-database/5.0/ubi/mongodb-org-5.0.repo b/docker/mongodb-enterprise-appdb-database/5.0/ubi/mongodb-org-5.0.repo deleted file mode 100644 index 76946402d..000000000 --- a/docker/mongodb-enterprise-appdb-database/5.0/ubi/mongodb-org-5.0.repo +++ /dev/null @@ -1,6 +0,0 @@ -[mongodb-enterprise-5.0] -name=MongoDB Enterprise Repository -baseurl=https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/5.0/$basearch/ -gpgcheck=1 -enabled=1 -gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc diff --git a/docker/mongodb-enterprise-appdb-database/README.md b/docker/mongodb-enterprise-appdb-database/README.md deleted file mode 100644 index a5f332d2f..000000000 --- a/docker/mongodb-enterprise-appdb-database/README.md +++ /dev/null @@ -1,8 +0,0 @@ -Build enterprise images with - -```bash -docker build -f path/to/dockerfile --build-arg MONGO_PACKAGE=mongodb-enterprise --build-arg MONGO_REPO=repo.mongodb.com --build-arg MONGO_VERSION=4.0.20 . -``` - -within the given directory. - diff --git a/docker/mongodb-enterprise-appdb-database/build_and_push_appdb_database_images.sh b/docker/mongodb-enterprise-appdb-database/build_and_push_appdb_database_images.sh deleted file mode 100755 index 7e3a81565..000000000 --- a/docker/mongodb-enterprise-appdb-database/build_and_push_appdb_database_images.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash -set -Eeou pipefail - -_44_versions=$(jq -rc '.supportedImages."appdb-database".versions[] | select(test("^4.4"))' < ../../release.json | sed 's/-ent//g' | tr '\n' ' ') -_50_versions=$(jq -rc '.supportedImages."appdb-database".versions[] | select(test("^5.0"))' < ../../release.json | sed 's/-ent//g' | tr '\n' ' ') - -echo "4.4 versions: ${_44_versions}" -echo "5.0 versions: ${_50_versions}" - -build_id="b$(date '+%Y%m%dT000000Z')" - -missing_versions="" - -append_missing_version() { - # shellcheck disable=SC2181 - if [ $? -ne 0 ]; then - missing_versions+="${1} on ${2}"$'\n' - fi -} - -for version in ${_44_versions}; do - docker build \ - -f 4.4/ubi/Dockerfile \ - --build-arg MONGO_PACKAGE=mongodb-enterprise \ - --build-arg "MONGO_VERSION=${version}" \ - --build-arg MONGO_REPO=repo.mongodb.com \ - -t "quay.io/mongodb/mongodb-enterprise-appdb-database-ubi:${version}-ent-${build_id}" \ - -t "quay.io/mongodb/mongodb-enterprise-appdb-database-ubi:${version}-ent" . - append_missing_version "${version}" "ubi" - - docker push "quay.io/mongodb/mongodb-enterprise-appdb-database-ubi:${version}-ent-${build_id}" - docker push "quay.io/mongodb/mongodb-enterprise-appdb-database-ubi:${version}-ent" -done - -for version in ${_50_versions}; do - docker build \ - -f 5.0/ubi/Dockerfile \ - --build-arg MONGO_PACKAGE=mongodb-enterprise \ - --build-arg "MONGO_VERSION=${version}" \ - --build-arg MONGO_REPO=repo.mongodb.com \ - -t "quay.io/mongodb/mongodb-enterprise-appdb-database-ubi:${version}-ent-${build_id}" \ - -t "quay.io/mongodb/mongodb-enterprise-appdb-database-ubi:${version}-ent" . - append_missing_version "${version}" "ubi" - - docker push "quay.io/mongodb/mongodb-enterprise-appdb-database-ubi:${version}-ent-${build_id}" - docker push "quay.io/mongodb/mongodb-enterprise-appdb-database-ubi:${version}-ent" -done - -echo "Missing versions" -echo "${missing_versions}" diff --git a/docker/mongodb-enterprise-appdb-database/docker-entrypoint.sh b/docker/mongodb-enterprise-appdb-database/docker-entrypoint.sh deleted file mode 100644 index d3d1c08c7..000000000 --- a/docker/mongodb-enterprise-appdb-database/docker-entrypoint.sh +++ /dev/null @@ -1,386 +0,0 @@ -#!/usr/bin/env bash -set -Eeuo pipefail - -if [ "${1:0:1}" = '-' ]; then - set -- mongod "$@" -fi - -originalArgOne="$1" - -# allow the container to be started with `--user` -# all mongo* commands should be dropped to the correct user -if [[ "$originalArgOne" == mongo* ]] && [ "$(id -u)" = '0' ]; then - if [ "$originalArgOne" = 'mongod' ]; then - find /data/configdb /data/db \! -user mongodb -exec chown mongodb '{}' + - fi - - # make sure we can write to stdout and stderr as "mongodb" - # (for our "initdb" code later; see "--logpath" below) - chown --dereference mongodb "/proc/$$/fd/1" "/proc/$$/fd/2" || : - # ignore errors thanks to https://github.com/docker-library/mongo/issues/149 - - exec gosu mongodb "$BASH_SOURCE" "$@" -fi - - -# you should use numactl to start your mongod instances, including the config servers, mongos instances, and any clients. -# https://docs.mongodb.com/manual/administration/production-notes/#configuring-numa-on-linux -if [[ "$originalArgOne" == mongo* ]]; then - numa='numactl --interleave=all' - if $numa true &> /dev/null; then - set -- $numa "$@" - fi -fi - -# usage: file_env VAR [DEFAULT] -# ie: file_env 'XYZ_DB_PASSWORD' 'example' -# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of -# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) -file_env() { - local var="$1" - local fileVar="${var}_FILE" - local def="${2:-}" - if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then - echo >&2 "error: both $var and $fileVar are set (but are exclusive)" - exit 1 - fi - local val="$def" - if [ "${!var:-}" ]; then - val="${!var}" - elif [ "${!fileVar:-}" ]; then - val="$(< "${!fileVar}")" - fi - export "$var"="$val" - unset "$fileVar" -} - -# see https://github.com/docker-library/mongo/issues/147 (mongod is picky about duplicated arguments) -_mongod_hack_have_arg() { - local checkArg="$1"; shift - local arg - for arg; do - case "$arg" in - "$checkArg"|"$checkArg"=*) - return 0 - ;; - esac - done - return 1 -} -# _mongod_hack_get_arg_val '--some-arg' "$@" -_mongod_hack_get_arg_val() { - local checkArg="$1"; shift - while [ "$#" -gt 0 ]; do - local arg="$1"; shift - case "$arg" in - "$checkArg") - echo "$1" - return 0 - ;; - "$checkArg"=*) - echo "${arg#$checkArg=}" - return 0 - ;; - esac - done - return 1 -} -declare -a mongodHackedArgs -# _mongod_hack_ensure_arg '--some-arg' "$@" -# set -- "${mongodHackedArgs[@]}" -_mongod_hack_ensure_arg() { - local ensureArg="$1"; shift - mongodHackedArgs=( "$@" ) - if ! _mongod_hack_have_arg "$ensureArg" "$@"; then - mongodHackedArgs+=( "$ensureArg" ) - fi -} -# _mongod_hack_ensure_no_arg '--some-unwanted-arg' "$@" -# set -- "${mongodHackedArgs[@]}" -_mongod_hack_ensure_no_arg() { - local ensureNoArg="$1"; shift - mongodHackedArgs=() - while [ "$#" -gt 0 ]; do - local arg="$1"; shift - if [ "$arg" = "$ensureNoArg" ]; then - continue - fi - mongodHackedArgs+=( "$arg" ) - done -} -# _mongod_hack_ensure_no_arg '--some-unwanted-arg' "$@" -# set -- "${mongodHackedArgs[@]}" -_mongod_hack_ensure_no_arg_val() { - local ensureNoArg="$1"; shift - mongodHackedArgs=() - while [ "$#" -gt 0 ]; do - local arg="$1"; shift - case "$arg" in - "$ensureNoArg") - shift # also skip the value - continue - ;; - "$ensureNoArg"=*) - # value is already included - continue - ;; - esac - mongodHackedArgs+=( "$arg" ) - done -} -# _mongod_hack_ensure_arg_val '--some-arg' 'some-val' "$@" -# set -- "${mongodHackedArgs[@]}" -_mongod_hack_ensure_arg_val() { - local ensureArg="$1"; shift - local ensureVal="$1"; shift - _mongod_hack_ensure_no_arg_val "$ensureArg" "$@" - mongodHackedArgs+=( "$ensureArg" "$ensureVal" ) -} - -# _js_escape 'some "string" value' -_js_escape() { - jq --null-input --arg 'str' "$1" '$str' -} - -: "${TMPDIR:=/tmp}" -jsonConfigFile="$TMPDIR/docker-entrypoint-config.json" -tempConfigFile="$TMPDIR/docker-entrypoint-temp-config.json" -_parse_config() { - if [ -s "$tempConfigFile" ]; then - return 0 - fi - - local configPath - if configPath="$(_mongod_hack_get_arg_val --config "$@")" && [ -s "$configPath" ]; then - # if --config is specified, parse it into a JSON file so we can remove a few problematic keys (especially SSL-related keys) - # see https://docs.mongodb.com/manual/reference/configuration-options/ - if grep -vEm1 '^[[:space:]]*(#|$)' "$configPath" | grep -qE '^[[:space:]]*[^=:]+[[:space:]]*='; then - # if the first non-comment/non-blank line of the config file looks like "foo = ...", this is probably the 2.4 and older "ini-style config format" - # https://docs.mongodb.com/v2.4/reference/configuration-options/ - # https://docs.mongodb.com/v2.6/reference/configuration-options/ - # https://github.com/mongodb/mongo/blob/r4.4.2/src/mongo/util/options_parser/options_parser.cpp#L1359-L1375 - # https://stackoverflow.com/a/25518018/433558 - echo >&2 - echo >&2 "WARNING: it appears that '$configPath' is in the older INI-style format (replaced by YAML in MongoDB 2.6)" - echo >&2 ' This script does not parse the older INI-style format, and thus will ignore it.' - echo >&2 - return 1 - fi - mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile" - if [ "$(head -c1 "$jsonConfigFile")" != '{' ] || [ "$(tail -c2 "$jsonConfigFile")" != '}' ]; then - # if the file doesn't start with "{" and end with "}", it's *probably* an error ("uncaught exception: YAMLException: foo" for example), so we should print it out - echo >&2 'error: unexpected "js-yaml.js" output while parsing config:' - cat >&2 "$jsonConfigFile" - exit 1 - fi - jq 'del(.systemLog, .processManagement, .net, .security)' "$jsonConfigFile" > "$tempConfigFile" - return 0 - fi - - return 1 -} -dbPath= -_dbPath() { - if [ -n "$dbPath" ]; then - echo "$dbPath" - return - fi - - if ! dbPath="$(_mongod_hack_get_arg_val --dbpath "$@")"; then - if _parse_config "$@"; then - dbPath="$(jq -r '.storage.dbPath // empty' "$jsonConfigFile")" - fi - fi - - if [ -z "$dbPath" ]; then - if _mongod_hack_have_arg --configsvr "$@" || { - _parse_config "$@" \ - && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \ - && [ "$clusterRole" = 'configsvr' ] - }; then - # if running as config server, then the default dbpath is /data/configdb - # https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr - dbPath=/data/configdb - fi - fi - - : "${dbPath:=/data/db}" - - echo "$dbPath" -} - -if [ "$originalArgOne" = 'mongod' ]; then - file_env 'MONGO_INITDB_ROOT_USERNAME' - file_env 'MONGO_INITDB_ROOT_PASSWORD' - # pre-check a few factors to see if it's even worth bothering with initdb - shouldPerformInitdb= - if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then - # if we have a username/password, let's set "--auth" - _mongod_hack_ensure_arg '--auth' "$@" - set -- "${mongodHackedArgs[@]}" - shouldPerformInitdb='true' - elif [ "$MONGO_INITDB_ROOT_USERNAME" ] || [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then - cat >&2 <<-'EOF' - - error: missing 'MONGO_INITDB_ROOT_USERNAME' or 'MONGO_INITDB_ROOT_PASSWORD' - both must be specified for a user to be created - - EOF - exit 1 - fi - - if [ -z "$shouldPerformInitdb" ]; then - # if we've got any /docker-entrypoint-initdb.d/* files to parse later, we should initdb - for f in /docker-entrypoint-initdb.d/*; do - case "$f" in - *.sh|*.js) # this should match the set of files we check for below - shouldPerformInitdb="$f" - break - ;; - esac - done - fi - - # check for a few known paths (to determine whether we've already initialized and should thus skip our initdb scripts) - if [ -n "$shouldPerformInitdb" ]; then - dbPath="$(_dbPath "$@")" - for path in \ - "$dbPath/WiredTiger" \ - "$dbPath/journal" \ - "$dbPath/local.0" \ - "$dbPath/storage.bson" \ - ; do - if [ -e "$path" ]; then - shouldPerformInitdb= - break - fi - done - fi - - if [ -n "$shouldPerformInitdb" ]; then - mongodHackedArgs=( "$@" ) - if _parse_config "$@"; then - _mongod_hack_ensure_arg_val --config "$tempConfigFile" "${mongodHackedArgs[@]}" - fi - _mongod_hack_ensure_arg_val --bind_ip 127.0.0.1 "${mongodHackedArgs[@]}" - _mongod_hack_ensure_arg_val --port 27017 "${mongodHackedArgs[@]}" - _mongod_hack_ensure_no_arg --bind_ip_all "${mongodHackedArgs[@]}" - - # remove "--auth" and "--replSet" for our initial startup (see https://docs.mongodb.com/manual/tutorial/enable-authentication/#start-mongodb-without-access-control) - # https://github.com/docker-library/mongo/issues/211 - _mongod_hack_ensure_no_arg --auth "${mongodHackedArgs[@]}" - # "keyFile implies security.authorization" - # https://docs.mongodb.com/manual/reference/configuration-options/#mongodb-setting-security.keyFile - _mongod_hack_ensure_no_arg_val --keyFile "${mongodHackedArgs[@]}" - if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then - _mongod_hack_ensure_no_arg_val --replSet "${mongodHackedArgs[@]}" - fi - - # "BadValue: need sslPEMKeyFile when SSL is enabled" vs "BadValue: need to enable SSL via the sslMode flag when using SSL configuration parameters" - tlsMode='disabled' - if _mongod_hack_have_arg '--tlsCertificateKeyFile' "$@"; then - tlsMode='allowTLS' - elif _mongod_hack_have_arg '--sslPEMKeyFile' "$@"; then - tlsMode='allowSSL' - fi - # 4.2 switched all configuration/flag names from "SSL" to "TLS" - if [ "$tlsMode" = 'allowTLS' ] || mongod --help 2>&1 | grep -q -- ' --tlsMode '; then - _mongod_hack_ensure_arg_val --tlsMode "$tlsMode" "${mongodHackedArgs[@]}" - else - _mongod_hack_ensure_arg_val --sslMode "$tlsMode" "${mongodHackedArgs[@]}" - fi - - if stat "/proc/$$/fd/1" > /dev/null && [ -w "/proc/$$/fd/1" ]; then - # https://github.com/mongodb/mongo/blob/38c0eb538d0fd390c6cb9ce9ae9894153f6e8ef5/src/mongo/db/initialize_server_global_state.cpp#L237-L251 - # https://github.com/docker-library/mongo/issues/164#issuecomment-293965668 - _mongod_hack_ensure_arg_val --logpath "/proc/$$/fd/1" "${mongodHackedArgs[@]}" - else - initdbLogPath="$(_dbPath "$@")/docker-initdb.log" - echo >&2 "warning: initdb logs cannot write to '/proc/$$/fd/1', so they are in '$initdbLogPath' instead" - _mongod_hack_ensure_arg_val --logpath "$initdbLogPath" "${mongodHackedArgs[@]}" - fi - _mongod_hack_ensure_arg --logappend "${mongodHackedArgs[@]}" - - pidfile="$TMPDIR/docker-entrypoint-temp-mongod.pid" - rm -f "$pidfile" - _mongod_hack_ensure_arg_val --pidfilepath "$pidfile" "${mongodHackedArgs[@]}" - - "${mongodHackedArgs[@]}" --fork - - mongo=( mongo --host 127.0.0.1 --port 27017 --quiet ) - - # check to see that our "mongod" actually did start up (catches "--help", "--version", MongoDB 3.2 being silly, slow prealloc, etc) - # https://jira.mongodb.org/browse/SERVER-16292 - tries=30 - while true; do - if ! { [ -s "$pidfile" ] && ps "$(< "$pidfile")" &> /dev/null; }; then - # bail ASAP if "mongod" isn't even running - echo >&2 - echo >&2 "error: $originalArgOne does not appear to have stayed running -- perhaps it had an error?" - echo >&2 - exit 1 - fi - if "${mongo[@]}" 'admin' --eval 'quit(0)' &> /dev/null; then - # success! - break - fi - (( tries-- )) - if [ "$tries" -le 0 ]; then - echo >&2 - echo >&2 "error: $originalArgOne does not appear to have accepted connections quickly enough -- perhaps it had an error?" - echo >&2 - exit 1 - fi - sleep 1 - done - - if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then - rootAuthDatabase='admin' - - "${mongo[@]}" "$rootAuthDatabase" <<-EOJS - db.createUser({ - user: $(_js_escape "$MONGO_INITDB_ROOT_USERNAME"), - pwd: $(_js_escape "$MONGO_INITDB_ROOT_PASSWORD"), - roles: [ { role: 'root', db: $(_js_escape "$rootAuthDatabase") } ] - }) - EOJS - fi - - export MONGO_INITDB_DATABASE="${MONGO_INITDB_DATABASE:-test}" - - echo - for f in /docker-entrypoint-initdb.d/*; do - case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; - *.js) echo "$0: running $f"; "${mongo[@]}" "$MONGO_INITDB_DATABASE" "$f"; echo ;; - *) echo "$0: ignoring $f" ;; - esac - echo - done - - "${mongodHackedArgs[@]}" --shutdown - rm -f "$pidfile" - - echo - echo 'MongoDB init process complete; ready for start up.' - echo - fi - - # MongoDB 3.6+ defaults to localhost-only binding - haveBindIp= - if _mongod_hack_have_arg --bind_ip "$@" || _mongod_hack_have_arg --bind_ip_all "$@"; then - haveBindIp=1 - elif _parse_config "$@" && jq --exit-status '.net.bindIp // .net.bindIpAll' "$jsonConfigFile" > /dev/null; then - haveBindIp=1 - fi - if [ -z "$haveBindIp" ]; then - # so if no "--bind_ip" is specified, let's add "--bind_ip_all" - set -- "$@" --bind_ip_all - fi - - unset "${!MONGO_INITDB_@}" -fi - -rm -f "$jsonConfigFile" "$tempConfigFile" - -exec "$@" diff --git a/docker/mongodb-enterprise-init-ops-manager/LICENSE b/docker/mongodb-enterprise-init-ops-manager/LICENSE deleted file mode 100644 index dc71da876..000000000 --- a/docker/mongodb-enterprise-init-ops-manager/LICENSE +++ /dev/null @@ -1,3 +0,0 @@ -Usage of the MongoDB Enterprise Operator for Kubernetes indicates agreement with the MongoDB Customer Agreement. - -* https://www.mongodb.com/customer-agreement/ diff --git a/docker/mongodb-enterprise-operator/Dockerfile.builder b/docker/mongodb-enterprise-operator/Dockerfile.builder index 5df5ebcaa..0bcb843ca 100644 --- a/docker/mongodb-enterprise-operator/Dockerfile.builder +++ b/docker/mongodb-enterprise-operator/Dockerfile.builder @@ -11,6 +11,7 @@ ARG log_automation_config_diff ARG use_race COPY go.sum go.mod /go/src/github.com/10gen/ops-manager-kubernetes/ + WORKDIR /go/src/github.com/10gen/ops-manager-kubernetes RUN go mod download diff --git a/docker/mongodb-enterprise-ops-manager/Dockerfile.builder b/docker/mongodb-enterprise-ops-manager/Dockerfile.builder index ccfb79597..3d46fd5ef 100644 --- a/docker/mongodb-enterprise-ops-manager/Dockerfile.builder +++ b/docker/mongodb-enterprise-ops-manager/Dockerfile.builder @@ -4,8 +4,8 @@ FROM public.ecr.aws/docker/library/golang:1.24 as readiness_builder COPY . /go/src/github.com/10gen/ops-manager-kubernetes WORKDIR /go/src/github.com/10gen/ops-manager-kubernetes -RUN CGO_ENABLED=0 go build -a -buildvcs=false -o /data/scripts/mmsconfiguration ./docker/mongodb-enterprise-init-ops-manager/mmsconfiguration/edit_mms_configuration.go -RUN CGO_ENABLED=0 go build -a -buildvcs=false -o /data/scripts/backup-daemon-readiness-probe ./docker/mongodb-enterprise-init-ops-manager/backupdaemon_readinessprobe/backupdaemon_readiness.go +RUN CGO_ENABLED=0 go build -a -buildvcs=false -o /data/scripts/mmsconfiguration ./docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/edit_mms_configuration.go +RUN CGO_ENABLED=0 go build -a -buildvcs=false -o /data/scripts/backup-daemon-readiness-probe ./docker/mongodb-kubernetes-init-ops-manager/backupdaemon_readinessprobe/backupdaemon_readiness.go # Move binaries and scripts FROM scratch @@ -15,6 +15,6 @@ COPY --from=readiness_builder /data/scripts/backup-daemon-readiness-probe /data/ # After v2.0, when non-Static Agent images will be removed, please ensure to copy those files # into ./docker/mongodb-enterprise-ops-manager directory. Leaving it this way will make the maintenance easier. -COPY ./docker/mongodb-enterprise-init-ops-manager/scripts/docker-entry-point.sh /data/scripts -COPY ./docker/mongodb-enterprise-init-ops-manager/scripts/backup-daemon-liveness-probe.sh /data/scripts -COPY ./docker/mongodb-enterprise-init-ops-manager/LICENSE /data/licenses/mongodb-enterprise-ops-manager +COPY ./docker/mongodb-kubernetes-init-ops-manager/scripts/docker-entry-point.sh /data/scripts +COPY ./docker/mongodb-kubernetes-init-ops-manager/scripts/backup-daemon-liveness-probe.sh /data/scripts +COPY ./docker/mongodb-kubernetes-init-ops-manager/LICENSE /data/licenses/mongodb-enterprise-ops-manager diff --git a/docker/mongodb-enterprise-tests/kubeobject/customobject.py b/docker/mongodb-enterprise-tests/kubeobject/customobject.py index 6dadb942e..d902a0112 100644 --- a/docker/mongodb-enterprise-tests/kubeobject/customobject.py +++ b/docker/mongodb-enterprise-tests/kubeobject/customobject.py @@ -280,10 +280,7 @@ def get_crd_names( api_client: Optional[client.ApiClient] = None, ) -> Optional[Dict]: """Gets the CRD entry that matches all the parameters passed.""" - # - # TODO: Update to `client.ApiextensionsV1Api()` - # - api = client.ApiextensionsV1beta1Api(api_client=api_client) + api = client.ApiextensionsV1Api(api_client=api_client) if plural == kind == group == version is None: return None diff --git a/docker/mongodb-enterprise-tests/kubetester/__init__.py b/docker/mongodb-enterprise-tests/kubetester/__init__.py index fe72c1886..9a7c2ec63 100644 --- a/docker/mongodb-enterprise-tests/kubetester/__init__.py +++ b/docker/mongodb-enterprise-tests/kubetester/__init__.py @@ -12,6 +12,7 @@ # Re-exports from .kubetester import fixture as find_fixture from .mongodb import MongoDB +from .mongodb_community import MongoDBCommunity from .security_context import ( assert_pod_container_security_context, assert_pod_security_context, diff --git a/docker/mongodb-enterprise-tests/kubetester/mongodb.py b/docker/mongodb-enterprise-tests/kubetester/mongodb.py index 78f99bdbc..992a0f412 100644 --- a/docker/mongodb-enterprise-tests/kubetester/mongodb.py +++ b/docker/mongodb-enterprise-tests/kubetester/mongodb.py @@ -77,14 +77,21 @@ def __init__(self, *args, **kwargs): super(MongoDB, self).__init__(*args, **with_defaults) @classmethod - def from_yaml(cls, yaml_file, name=None, namespace=None) -> MongoDB: + def from_yaml(cls, yaml_file, name=None, namespace=None, with_mdb_version_from_env=True) -> MongoDB: resource = super().from_yaml(yaml_file=yaml_file, name=name, namespace=namespace) - custom_mdb_prev_version = os.getenv("CUSTOM_MDB_VERSION") - custom_mdb_version = os.getenv("CUSTOM_MDB_VERSION") - if custom_mdb_prev_version is not None and semver.compare(resource.get_version(), custom_mdb_prev_version) < 0: - resource.set_version(ensure_ent_version(custom_mdb_prev_version)) - elif custom_mdb_version is not None and semver.compare(resource.get_version(), custom_mdb_version) < 0: - resource.set_version(ensure_ent_version(custom_mdb_version)) + # `with_mdb_version_from_env` flag enables to skip the custom version setting for class inheriting from MongoDB + # for example, community must not have an enterprise version set, but we can inherit the from_yaml (itself + # inherited from CustomObject class + if with_mdb_version_from_env: + custom_mdb_prev_version = os.getenv("CUSTOM_MDB_VERSION") + custom_mdb_version = os.getenv("CUSTOM_MDB_VERSION") + if ( + custom_mdb_prev_version is not None + and semver.compare(resource.get_version(), custom_mdb_prev_version) < 0 + ): + resource.set_version(ensure_ent_version(custom_mdb_prev_version)) + elif custom_mdb_version is not None and semver.compare(resource.get_version(), custom_mdb_version) < 0: + resource.set_version(ensure_ent_version(custom_mdb_version)) return resource def assert_state_transition_happens(self, last_transition, timeout=None): diff --git a/docker/mongodb-enterprise-tests/kubetester/mongodb_community.py b/docker/mongodb-enterprise-tests/kubetester/mongodb_community.py new file mode 100644 index 000000000..d9b557fe6 --- /dev/null +++ b/docker/mongodb-enterprise-tests/kubetester/mongodb_community.py @@ -0,0 +1,61 @@ +from __future__ import annotations + +import time + +from kubeobject import CustomObject +from kubetester.mongodb import MongoDB, Phase, in_desired_state +from opentelemetry import trace +from tests import test_logger + +logger = test_logger.get_test_logger(__name__) + + +class MongoDBCommunity(MongoDB, CustomObject): + def __init__(self, *args, **kwargs): + with_defaults = { + "plural": "mongodbcommunity", + "kind": "MongoDBCommunity", + "group": "mongodbcommunity.mongodb.com", + "version": "v1", + } + with_defaults.update(kwargs) + super(MongoDBCommunity, self).__init__(*args, **with_defaults) + + @classmethod + def from_yaml(cls, yaml_file, name=None, namespace=None, with_mdb_version_from_env=False) -> MongoDBCommunity: + resource = super().from_yaml( + yaml_file=yaml_file, name=name, namespace=namespace, with_mdb_version_from_env=False + ) + return resource + + def assert_reaches_phase(self, phase: Phase, msg_regexp=None, timeout=None, ignore_errors=False): + # intermediate_events is a tuple + intermediate_events = ("updating the status",) + + start_time = time.time() + + self.wait_for( + lambda s: in_desired_state( + current_state=self.get_status_phase(), + desired_state=phase, + # TODO: MCK we don't have "observedGeneration" in MongoDBCommunity status + current_generation=1, + observed_generation=1, + current_message=self.get_status_message(), + msg_regexp=msg_regexp, + ignore_errors=ignore_errors, + intermediate_events=intermediate_events, + ), + timeout, + should_raise=True, + ) + + end_time = time.time() + span = trace.get_current_span() + span.set_attribute("meko_resource", self.__class__.__name__) + span.set_attribute("meko_action", "assert_phase") + span.set_attribute("meko_desired_phase", phase.name) + span.set_attribute("meko_time_needed", end_time - start_time) + logger.debug( + f"Reaching phase {phase.name} for resource {self.__class__.__name__} took {end_time - start_time}s" + ) diff --git a/docker/mongodb-enterprise-tests/kubetester/operator.py b/docker/mongodb-enterprise-tests/kubetester/operator.py index 0fe1931bd..ee9d362d6 100644 --- a/docker/mongodb-enterprise-tests/kubetester/operator.py +++ b/docker/mongodb-enterprise-tests/kubetester/operator.py @@ -6,7 +6,7 @@ import requests from kubernetes import client -from kubernetes.client import V1beta1CustomResourceDefinition, V1Deployment, V1Pod +from kubernetes.client import V1CustomResourceDefinition, V1Deployment, V1Pod from kubernetes.client.rest import ApiException from kubetester import wait_for_webhook from kubetester.create_or_replace_from_yaml import create_or_replace_from_yaml @@ -17,6 +17,7 @@ helm_uninstall, helm_upgrade, ) +from tests import test_logger OPERATOR_CRDS = ( "mongodb.mongodb.com", @@ -24,6 +25,8 @@ "opsmanagers.mongodb.com", ) +logger = test_logger.get_test_logger(__name__) + class Operator(object): """Operator is an abstraction over some Operator and relevant resources. It @@ -171,7 +174,7 @@ def _wait_operator_webhook_is_ready(self, retries: int = 10, multi_cluster: bool from tests.conftest import get_central_cluster_name, get_test_pod_cluster_name if multi_cluster and get_central_cluster_name() != get_test_pod_cluster_name(): - print( + logger.info( f"Skipping waiting for the webhook as we cannot call the webhook endpoint from a test_pod_cluster ({get_test_pod_cluster_name()}) " f"to central cluster ({get_central_cluster_name()}); sleeping for 10s instead" ) @@ -179,22 +182,21 @@ def _wait_operator_webhook_is_ready(self, retries: int = 10, multi_cluster: bool time.sleep(10) return - logging.debug("_wait_operator_webhook_is_ready") + logger.debug("_wait_operator_webhook_is_ready") validation_endpoint = "validate-mongodb-com-v1-mongodb" webhook_endpoint = "https://operator-webhook.{}.svc.{}/{}".format( self.namespace, get_cluster_domain(), validation_endpoint ) headers = {"Content-Type": "application/json"} - + logger.debug(f"Webhook_endpoint: {webhook_endpoint}") retry_count = retries + 1 while retry_count > 0: retry_count -= 1 - - logging.debug("Waiting for operator/webhook to be functional") + logger.debug("Waiting for operator/webhook to be functional") try: response = requests.post(webhook_endpoint, headers=headers, verify=False, timeout=2) except Exception as e: - logging.warn(e) + logger.warning(e) time.sleep(2) continue @@ -203,23 +205,22 @@ def _wait_operator_webhook_is_ready(self, retries: int = 10, multi_cluster: bool # is already in place. response.json() except Exception: - logging.warn("Didn't get a json response from webhook") + logger.warning("Didn't get a json response from webhook") else: return - time.sleep(2) raise Exception("Operator webhook didn't start after {} retries".format(retries)) def print_diagnostics(self): - logging.info("Operator Deployment: ") - logging.info(self.read_deployment()) + logger.info("Operator Deployment: ") + logger.info(self.read_deployment()) pods = self.list_operator_pods() if len(pods) > 0: - logging.info("Operator pods: %d", len(pods)) - logging.info("Operator spec: %s", pods[0].spec) - logging.info("Operator status: %s", pods[0].status) + logger.info("Operator pods: %d", len(pods)) + logger.info("Operator spec: %s", pods[0].spec) + logger.info("Operator status: %s", pods[0].status) def wait_for_webhook(self, retries=5, delay=5): return wait_for_webhook(namespace=self.namespace, retries=retries, delay=delay) @@ -269,7 +270,7 @@ def delete_operator_crds(): raise e -def list_operator_crds() -> List[V1beta1CustomResourceDefinition]: +def list_operator_crds() -> List[V1CustomResourceDefinition]: return sorted( [ crd diff --git a/docker/Dockerfile b/docker/mongodb-enterprise-tests/tests/community/__init__.py similarity index 100% rename from docker/Dockerfile rename to docker/mongodb-enterprise-tests/tests/community/__init__.py diff --git a/docker/mongodb-enterprise-tests/tests/community/community_replicaset_scale.py b/docker/mongodb-enterprise-tests/tests/community/community_replicaset_scale.py new file mode 100644 index 000000000..962cf93b4 --- /dev/null +++ b/docker/mongodb-enterprise-tests/tests/community/community_replicaset_scale.py @@ -0,0 +1,57 @@ +from kubetester import create_or_update_secret, try_load +from kubetester.kubetester import fixture as yaml_fixture +from kubetester.mongodb import Phase +from kubetester.mongodb_community import MongoDBCommunity +from kubetester.operator import Operator +from pytest import fixture, mark +from tests import test_logger + +logger = test_logger.get_test_logger(__name__) + + +@fixture(scope="function") +def mdbc(namespace: str) -> MongoDBCommunity: + resource = MongoDBCommunity.from_yaml( + yaml_fixture("community-replicaset-simple.yaml"), + namespace=namespace, + ) + + if try_load(resource): + return resource + + return resource.update() + + +@mark.e2e_community_replicaset_scale +def test_install_operator(community_operator: Operator): + community_operator.assert_is_running() + + +@mark.e2e_community_replicaset_scale +def test_install_secret(namespace: str): + create_or_update_secret(namespace=namespace, name="my-user-password", data={"password": ""}) + + +@mark.e2e_community_replicaset_scale +def test_replicaset_running(mdbc: MongoDBCommunity): + mdbc.assert_reaches_phase(Phase.Running, timeout=300) + + +@mark.e2e_community_replicaset_scale +def test_replicaset_scale_up(mdbc: MongoDBCommunity): + rs = mdbc.load() + rs["spec"]["members"] = 5 + rs.update() + # TODO: MCK As we don't have "observedGeneration" in MongoDBCommunity status, we could be checking the status too early. + # We always need to check for abandoning phase first + mdbc.assert_abandons_phase(Phase.Running, timeout=60) + mdbc.assert_reaches_phase(Phase.Running, timeout=350) + + +@mark.e2e_community_replicaset_scale +def test_replicaset_scale_down(mdbc: MongoDBCommunity): + rs = mdbc.load() + rs["spec"]["members"] = 3 + rs.update() + mdbc.assert_abandons_phase(Phase.Running, timeout=60) + mdbc.assert_reaches_phase(Phase.Running, timeout=350) diff --git a/docker/mongodb-enterprise-tests/tests/community/conftest.py b/docker/mongodb-enterprise-tests/tests/community/conftest.py new file mode 100644 index 000000000..0089f1a1f --- /dev/null +++ b/docker/mongodb-enterprise-tests/tests/community/conftest.py @@ -0,0 +1,3 @@ +from kubetester.operator import Operator +from pytest import fixture +from tests.conftest import get_default_operator, get_operator_installation_config diff --git a/docker/mongodb-enterprise-tests/tests/community/fixtures/community-replicaset-simple.yaml b/docker/mongodb-enterprise-tests/tests/community/fixtures/community-replicaset-simple.yaml new file mode 100644 index 000000000..b94bec159 --- /dev/null +++ b/docker/mongodb-enterprise-tests/tests/community/fixtures/community-replicaset-simple.yaml @@ -0,0 +1,23 @@ +--- +apiVersion: mongodbcommunity.mongodb.com/v1 +kind: MongoDBCommunity +metadata: + name: mongodb-specify-pod-resources +spec: + members: 3 + type: ReplicaSet + version: "6.0.5" + security: + authentication: + modes: ["SCRAM"] + users: + - name: my-user + db: admin + passwordSecretRef: # a reference to the secret that will be used to generate the user's password + name: my-user-password + roles: + - name: clusterAdmin + db: admin + - name: userAdminAnyDatabase + db: admin + scramCredentialsSecretName: my-scram diff --git a/docker/mongodb-enterprise-tests/tests/conftest.py b/docker/mongodb-enterprise-tests/tests/conftest.py index 924a07aa9..3ce809286 100644 --- a/docker/mongodb-enterprise-tests/tests/conftest.py +++ b/docker/mongodb-enterprise-tests/tests/conftest.py @@ -102,7 +102,7 @@ def get_operator_installation_config(namespace): config["customEnvVars"] += "\&OM_DEBUG_HTTP=true" if local_operator(): - config["operator.replicas"] = 0 + config["operator.replicas"] = "0" return config @@ -480,6 +480,16 @@ def default_operator( return get_default_operator(namespace, operator_installation_config) +@fixture(scope="module") +def community_operator(namespace: str) -> Operator: + helm_args = get_operator_installation_config(namespace) + # TODO: MCK We may want to always watch community resources by default with MCK but it implies to always have + # community CRD installed. In that case we wouldn't need this custom install function, we can get rid of it + # once we merge the helm charts + helm_args["operator.watchedResources"] = "{opsmanagers,mongodb,mongodbusers,mongodbcommunity}" + return get_default_operator(namespace, helm_args) + + def get_default_operator( namespace: str, operator_installation_config: Dict[str, str], diff --git a/docker/mongodb-enterprise-tests/tests/multicluster/multi_cluster_backup_restore.py b/docker/mongodb-enterprise-tests/tests/multicluster/multi_cluster_backup_restore.py index 479cc1f3a..f16e717d9 100644 --- a/docker/mongodb-enterprise-tests/tests/multicluster/multi_cluster_backup_restore.py +++ b/docker/mongodb-enterprise-tests/tests/multicluster/multi_cluster_backup_restore.py @@ -477,10 +477,6 @@ def test_add_test_data(self, mongodb_multi_one_collection): def test_mdb_backed_up(self, project_one: OMTester): project_one.wait_until_backup_snapshots_are_ready(expected_count=1) - @mark.e2e_multi_cluster_backup_restore - def test_mongodb_multi_one_running_state(self, mongodb_multi_one: MongoDBMulti): - mongodb_multi_one.assert_reaches_phase(Phase.Running, ignore_errors=True, timeout=1200) - @mark.e2e_multi_cluster_backup_restore def test_change_mdb_data(self, mongodb_multi_one_collection): now_millis = time_to_millis(datetime.datetime.now()) @@ -488,10 +484,6 @@ def test_change_mdb_data(self, mongodb_multi_one_collection): time.sleep(30) mongodb_multi_one_collection.insert_one({"foo": "bar"}) - @mark.e2e_multi_cluster_backup_restore - def test_mongodb_multi_one_running_state(self, mongodb_multi_one: MongoDBMulti): - mongodb_multi_one.assert_reaches_phase(Phase.Running, ignore_errors=True, timeout=1200) - @mark.e2e_multi_cluster_backup_restore def test_pit_restore(self, project_one: OMTester): now_millis = time_to_millis(datetime.datetime.now()) @@ -503,14 +495,6 @@ def test_pit_restore(self, project_one: OMTester): project_one.create_restore_job_pit(pit_millis) - @mark.e2e_multi_cluster_backup_restore - def test_mdb_ready(self, mongodb_multi_one: MongoDBMulti): - # Note: that we are not waiting for the restore jobs to get finished as PIT restore jobs get FINISHED status - # right away. - # But the agent might still do work on the cluster, so we need to wait for that to happen. - mongodb_multi_one.assert_reaches_phase(Phase.Pending, timeout=1200) - mongodb_multi_one.assert_reaches_phase(Phase.Running, timeout=1200) - @mark.e2e_multi_cluster_backup_restore def test_data_got_restored(self, mongodb_multi_one_collection): assert_data_got_restored(TEST_DATA, mongodb_multi_one_collection, timeout=1200) diff --git a/docker/mongodb-enterprise-tests/tests/olm/olm_meko_operator_upgrade_with_resources.py b/docker/mongodb-enterprise-tests/tests/olm/olm_meko_operator_upgrade_with_resources.py new file mode 100644 index 000000000..35e3b1278 --- /dev/null +++ b/docker/mongodb-enterprise-tests/tests/olm/olm_meko_operator_upgrade_with_resources.py @@ -0,0 +1,422 @@ +import kubernetes +import pytest +from kubeobject import CustomObject +from kubetester import ( + MongoDB, + create_or_update_secret, + get_default_storage_class, + try_load, +) +from kubetester.awss3client import AwsS3Client +from kubetester.certs import create_sharded_cluster_certs +from kubetester.kubetester import ensure_ent_version +from kubetester.kubetester import fixture as yaml_fixture +from kubetester.kubetester import get_default_architecture, run_periodically +from kubetester.mongodb import Phase +from kubetester.mongodb_user import MongoDBUser +from kubetester.opsmanager import MongoDBOpsManager +from pytest import fixture +from tests.olm.olm_test_commons import ( + get_catalog_image, + get_catalog_source_resource, + get_current_operator_version, + get_latest_released_operator_version, + get_operator_group_resource, + get_subscription_custom_object, + increment_patch_version, + wait_for_operator_ready, +) +from tests.opsmanager.om_ops_manager_backup import create_aws_secret, create_s3_bucket + +# See docs how to run this locally: https://wiki.corp.mongodb.com/display/MMS/E2E+Tests+Notes#E2ETestsNotes-OLMtests + +# This test performs operator migration from the latest MEKO to MCK while having OM and MongoDB resources deployed. +# It performs the following actions: +# - deploy latest released MEKO operator using OLM +# - deploy OM +# - deploy backup-required MongoDB: oplog, s3, blockstore +# - deploy TLS-enabled sharded MongoDB +# - check everything is running +# - upgrade the operator to the MCK version built from the current branch +# - wait for resources to be rolling-updated due to updated stateful sets by the new operator +# - check everything is running and connectable + + +@fixture +def catalog_source(namespace: str, version_id: str): + current_operator_version = get_current_operator_version() + incremented_operator_version = increment_patch_version(current_operator_version) + + get_operator_group_resource(namespace, namespace).update() + catalog_source_resource = get_catalog_source_resource( + namespace, get_catalog_image(f"{incremented_operator_version}-{version_id}") + ) + catalog_source_resource.update() + + return catalog_source_resource + + +@fixture +def subscription(namespace: str, catalog_source: CustomObject): + """ + Create subscription for the operator. The subscription is first created + with the latest released version of MEKO operator. + Later in the test, it will be updated to MCK. + """ + static_value = get_default_architecture() + return get_subscription_custom_object( + "mongodb-enterprise-operator", + namespace, + { + "channel": "stable", # stable channel contains latest released operator in RedHat's certified repository + "name": "mongodb-enterprise", + "source": catalog_source.name, + "sourceNamespace": namespace, + "installPlanApproval": "Automatic", + # In certified OpenShift bundles we have this enabled, so the operator is not defining security context (it's managed globally by OpenShift). + # In Kind this will result in empty security contexts and problems deployments with filesystem permissions. + "config": { + "env": [ + {"name": "MANAGED_SECURITY_CONTEXT", "value": "false"}, + {"name": "OPERATOR_ENV", "value": "dev"}, + {"name": "MDB_DEFAULT_ARCHITECTURE", "value": static_value}, + {"name": "MDB_OPERATOR_TELEMETRY_SEND_ENABLED", "value": "false"}, + ] + }, + }, + ) + + +@fixture +def latest_released_meko_version(): + return get_latest_released_operator_version("mongodb-enterprise") + + +@pytest.mark.e2e_olm_meko_operator_upgrade_with_resources +def test_meko_install_stable_operator_version( + namespace: str, + version_id: str, + latest_released_meko_version: str, + catalog_source: CustomObject, + subscription: CustomObject, +): + subscription.update() + wait_for_operator_ready( + namespace, "mongodb-enterprise-operator", f"mongodb-enterprise.v{latest_released_meko_version}" + ) + + +# install resources on the latest released version of the operator + + +@fixture(scope="module") +def ops_manager(namespace: str) -> MongoDBOpsManager: + resource: MongoDBOpsManager = MongoDBOpsManager.from_yaml( + yaml_fixture("olm_ops_manager_backup.yaml"), namespace=namespace + ) + + try_load(resource) + return resource + + +@fixture(scope="module") +def s3_bucket(aws_s3_client: AwsS3Client, namespace: str) -> str: + create_aws_secret(aws_s3_client, "my-s3-secret", namespace) + yield from create_s3_bucket(aws_s3_client, "test-bucket-s3") + + +@pytest.mark.e2e_olm_meko_operator_upgrade_with_resources +def test_create_om( + ops_manager: MongoDBOpsManager, + s3_bucket: str, + custom_version: str, + custom_appdb_version: str, +): + try_load(ops_manager) + ops_manager["spec"]["backup"]["s3Stores"][0]["s3BucketName"] = s3_bucket + ops_manager["spec"]["backup"]["headDB"]["storageClass"] = get_default_storage_class() + ops_manager["spec"]["backup"]["members"] = 2 + + ops_manager.set_version(custom_version) + ops_manager.set_appdb_version(custom_appdb_version) + ops_manager.allow_mdb_rc_versions() + + ops_manager.update() + + +def wait_for_om_healthy_response(ops_manager: MongoDBOpsManager): + def wait_for_om_healthy_response_fn(): + status_code, status_response = ops_manager.get_om_tester().check_healthiness() + if status_code == 200: + return True, f"Got healthy status_code=200: {status_response}" + else: + return False, f"Got unhealthy status_code={status_code}: {status_response}" + + run_periodically( + wait_for_om_healthy_response_fn, + timeout=300, + msg=f"OM returning healthy response", + ) + + +@pytest.mark.e2e_olm_meko_operator_upgrade_with_resources +def test_om_connectivity(ops_manager: MongoDBOpsManager): + ops_manager.om_status().assert_reaches_phase(Phase.Running) + ops_manager.appdb_status().assert_reaches_phase(Phase.Running) + ops_manager.backup_status().assert_reaches_phase(Phase.Pending) + + wait_for_om_healthy_response(ops_manager) + + +# sharded mongodb fixtures + + +@fixture(scope="module") +def mdb_sharded_certs(issuer: str, namespace: str): + create_sharded_cluster_certs( + namespace, + "mdb-sharded", + shards=1, + mongod_per_shard=2, + config_servers=1, + mongos=1, + secret_prefix="prefix-", + ) + + +@fixture +def mdb_sharded( + ops_manager: MongoDBOpsManager, + namespace, + custom_mdb_version: str, + issuer_ca_configmap: str, + mdb_sharded_certs, +): + resource = MongoDB.from_yaml( + yaml_fixture("olm_sharded_cluster_for_om.yaml"), + namespace=namespace, + name="mdb-sharded", + ).configure(ops_manager, "mdb-sharded") + resource.set_version(ensure_ent_version(custom_mdb_version)) + resource["spec"]["security"] = { + "tls": { + "ca": issuer_ca_configmap, + }, + } + resource.configure_backup(mode="disabled") + resource.update() + return resource + + +# OpsManager backup-backing databases + + +@fixture(scope="module") +def oplog_replica_set(ops_manager, namespace, custom_mdb_version: str) -> MongoDB: + resource = MongoDB.from_yaml( + yaml_fixture("olm_replica_set_for_om.yaml"), + namespace=namespace, + name="my-mongodb-oplog", + ).configure(ops_manager, "oplog") + resource.set_version(custom_mdb_version) + return resource.update() + + +@fixture(scope="module") +def s3_replica_set(ops_manager, namespace, custom_mdb_version: str) -> MongoDB: + resource = MongoDB.from_yaml( + yaml_fixture("olm_replica_set_for_om.yaml"), + namespace=namespace, + name="my-mongodb-s3", + ).configure(ops_manager, "s3metadata") + resource.set_version(custom_mdb_version) + return resource.update() + + +@fixture(scope="module") +def blockstore_replica_set(ops_manager, namespace, custom_mdb_version: str) -> MongoDB: + resource = MongoDB.from_yaml( + yaml_fixture("olm_replica_set_for_om.yaml"), + namespace=namespace, + name="my-mongodb-blockstore", + ).configure(ops_manager, "blockstore") + resource.set_version(custom_mdb_version) + return resource.update() + + +@fixture(scope="module") +def blockstore_user(namespace, blockstore_replica_set: MongoDB) -> MongoDBUser: + return create_secret_and_user( + namespace, + "blockstore-user", + blockstore_replica_set.name, + "blockstore-user-password-secret", + "Passw0rd.", + ) + + +@fixture(scope="module") +def oplog_user(namespace, oplog_replica_set: MongoDB) -> MongoDBUser: + return create_secret_and_user( + namespace, + "oplog-user", + oplog_replica_set.name, + "oplog-user-password-secret", + "Passw0rd.", + ) + + +def create_secret_and_user( + namespace: str, name: str, replica_set_name: str, secret_name: str, password: str +) -> MongoDBUser: + resource = MongoDBUser.from_yaml( + yaml_fixture("olm_scram_sha_user_backing_db.yaml"), + namespace=namespace, + name=name, + ) + resource["spec"]["mongodbResourceRef"]["name"] = replica_set_name + resource["spec"]["passwordSecretKeyRef"]["name"] = secret_name + create_or_update_secret(namespace, secret_name, {"password": password}) + return resource.update() + + +@pytest.mark.e2e_olm_meko_operator_upgrade_with_resources +def test_resources_created( + oplog_replica_set: MongoDB, + s3_replica_set: MongoDB, + blockstore_replica_set: MongoDB, + mdb_sharded: MongoDB, + blockstore_user: MongoDBUser, + oplog_user: MongoDBUser, +): + """Creates mongodb databases all at once""" + oplog_replica_set.assert_reaches_phase(Phase.Running) + s3_replica_set.assert_reaches_phase(Phase.Running) + blockstore_replica_set.assert_reaches_phase(Phase.Running) + mdb_sharded.assert_reaches_phase(Phase.Running) + + +@pytest.mark.e2e_olm_meko_operator_upgrade_with_resources +def test_set_backup_users( + ops_manager: MongoDBOpsManager, + oplog_user: MongoDBUser, + blockstore_user: MongoDBUser, +): + ops_manager.load() + ops_manager["spec"]["backup"]["opLogStores"][0]["mongodbUserRef"] = {"name": oplog_user.name} + ops_manager["spec"]["backup"]["blockStores"][0]["mongodbUserRef"] = {"name": blockstore_user.name} + ops_manager.update() + + ops_manager.backup_status().assert_reaches_phase(Phase.Running, ignore_errors=True) + + assert ops_manager.backup_status().get_message() is None + + +@pytest.mark.e2e_olm_meko_operator_upgrade_with_resources +def test_om_connectivity_with_backup( + ops_manager: MongoDBOpsManager, + oplog_replica_set: MongoDB, + s3_replica_set: MongoDB, +): + wait_for_om_healthy_response(ops_manager) + + ops_manager.om_status().assert_reaches_phase(Phase.Running) + ops_manager.appdb_status().assert_reaches_phase(Phase.Running) + ops_manager.backup_status().assert_reaches_phase(Phase.Running) + + +@pytest.mark.e2e_olm_meko_operator_upgrade_with_resources +def test_resources_in_running_state_before_upgrade( + ops_manager: MongoDBOpsManager, + oplog_replica_set: MongoDB, + blockstore_replica_set: MongoDB, + s3_replica_set: MongoDB, + mdb_sharded: MongoDB, +): + ops_manager.om_status().assert_reaches_phase(Phase.Running) + ops_manager.appdb_status().assert_reaches_phase(Phase.Running) + ops_manager.backup_status().assert_reaches_phase(Phase.Running) + oplog_replica_set.assert_reaches_phase(Phase.Running) + blockstore_replica_set.assert_reaches_phase(Phase.Running) + s3_replica_set.assert_reaches_phase(Phase.Running) + mdb_sharded.assert_reaches_phase(Phase.Running) + + +# upgrade the operator + + +@pytest.mark.e2e_olm_meko_operator_upgrade_with_resources +def test_meko_operator_upgrade_to_mck( + namespace: str, + version_id: str, + catalog_source: CustomObject, + subscription: CustomObject, +): + current_operator_version = get_current_operator_version() + incremented_operator_version = increment_patch_version(current_operator_version) + + # It is very likely that OLM will be doing a series of status updates during this time. + # It's better to employ a retry mechanism and spin here for a while before failing. + def update_subscription() -> bool: + try: + subscription.load() + # Update MEKO subscription to MCK + subscription["spec"]["name"] = "mongodb-kubernetes" + # Migration channel contains operator build from the current branch, + # with an upgrade path from the latest MEKO release. + subscription["spec"]["channel"] = "migration" + subscription.update() + return True + except kubernetes.client.ApiException as e: + if e.status == 409: + return False + else: + raise e + + run_periodically(update_subscription, timeout=100, msg="Subscription to be updated") + + wait_for_operator_ready( + namespace, "mongodb-enterprise-operator", f"mongodb-kubernetes.v{incremented_operator_version}" + ) + + +@pytest.mark.e2e_olm_meko_operator_upgrade_with_resources +def test_one_resources_not_in_running_state(ops_manager: MongoDBOpsManager, mdb_sharded: MongoDB): + # Wait for the first resource to become reconciling after operator upgrade. + # Only then wait for all to not get a false positive when all resources are ready, + # because the upgraded operator haven't started reconciling + ops_manager.om_status().assert_reaches_phase(Phase.Pending, timeout=600) + + +@pytest.mark.e2e_olm_meko_operator_upgrade_with_resources +def test_resources_in_running_state_after_upgrade( + ops_manager: MongoDBOpsManager, + oplog_replica_set: MongoDB, + blockstore_replica_set: MongoDB, + s3_replica_set: MongoDB, + mdb_sharded: MongoDB, +): + ops_manager.appdb_status().assert_reaches_phase(Phase.Running) + ops_manager.om_status().assert_reaches_phase(Phase.Running) + ops_manager.backup_status().assert_reaches_phase(Phase.Running) + oplog_replica_set.assert_reaches_phase(Phase.Running, timeout=600) + blockstore_replica_set.assert_reaches_phase(Phase.Running, timeout=600) + s3_replica_set.assert_reaches_phase(Phase.Running, timeout=600) + mdb_sharded.assert_reaches_phase(Phase.Running, timeout=600) + + +@pytest.mark.e2e_olm_meko_operator_upgrade_with_resources +def test_resources_connectivity_after_upgrade( + ca_path: str, + ops_manager: MongoDBOpsManager, + oplog_replica_set: MongoDB, + blockstore_replica_set: MongoDB, + s3_replica_set: MongoDB, + mdb_sharded: MongoDB, +): + wait_for_om_healthy_response(ops_manager) + + oplog_replica_set.assert_connectivity() + blockstore_replica_set.assert_connectivity() + s3_replica_set.assert_connectivity() + mdb_sharded.assert_connectivity(ca_path=ca_path) diff --git a/docker/mongodb-enterprise-tests/tests/olm/olm_operator_upgrade.py b/docker/mongodb-enterprise-tests/tests/olm/olm_operator_upgrade.py index 22d7837a4..6706300d7 100644 --- a/docker/mongodb-enterprise-tests/tests/olm/olm_operator_upgrade.py +++ b/docker/mongodb-enterprise-tests/tests/olm/olm_operator_upgrade.py @@ -25,7 +25,7 @@ @pytest.mark.e2e_olm_operator_upgrade def test_upgrade_operator_only(namespace: str, version_id: str): - latest_released_operator_version = get_latest_released_operator_version() + latest_released_operator_version = get_latest_released_operator_version("mongodb-kubernetes") current_operator_version = get_current_operator_version() incremented_operator_version = increment_patch_version(current_operator_version) @@ -37,7 +37,7 @@ def test_upgrade_operator_only(namespace: str, version_id: str): static_value = get_default_architecture() subscription = get_subscription_custom_object( - "mongodb-enterprise-operator", + "mongodb-kubernetes", namespace, { "channel": "stable", # stable channel contains latest released operator in RedHat's certified repository @@ -60,13 +60,13 @@ def test_upgrade_operator_only(namespace: str, version_id: str): subscription.update() - wait_for_operator_ready(namespace, f"mongodb-enterprise.v{latest_released_operator_version}") + wait_for_operator_ready(namespace, "mongodb-kubernetes", f"mongodb-kubernetes.v{latest_released_operator_version}") subscription.load() subscription["spec"]["channel"] = "fast" # fast channel contains operator build from the current branch subscription.update() - wait_for_operator_ready(namespace, f"mongodb-enterprise.v{incremented_operator_version}") + wait_for_operator_ready(namespace, "mongodb-kubernetes", f"mongodb-kubernetes.v{incremented_operator_version}") @pytest.mark.e2e_olm_operator_upgrade diff --git a/docker/mongodb-enterprise-tests/tests/olm/olm_operator_upgrade_with_resources.py b/docker/mongodb-enterprise-tests/tests/olm/olm_operator_upgrade_with_resources.py index 310e9e5e0..d8be5f42a 100644 --- a/docker/mongodb-enterprise-tests/tests/olm/olm_operator_upgrade_with_resources.py +++ b/docker/mongodb-enterprise-tests/tests/olm/olm_operator_upgrade_with_resources.py @@ -64,7 +64,7 @@ def catalog_source(namespace: str, version_id: str): def subscription(namespace: str, catalog_source: CustomObject): static_value = get_default_architecture() return get_subscription_custom_object( - "mongodb-enterprise-operator", + "mongodb-kubernetes", namespace, { "channel": "stable", # stable channel contains latest released operator in RedHat's certified repository @@ -88,7 +88,7 @@ def subscription(namespace: str, catalog_source: CustomObject): @fixture def current_operator_version(): - return get_latest_released_operator_version() + return get_latest_released_operator_version("mongodb-kubernetes") @pytest.mark.e2e_olm_operator_upgrade_with_resources @@ -100,7 +100,7 @@ def test_install_stable_operator_version( subscription: CustomObject, ): subscription.update() - wait_for_operator_ready(namespace, f"mongodb-enterprise.v{current_operator_version}") + wait_for_operator_ready(namespace, "mongodb-kubernetes", f"mongodb-kubernetes.v{current_operator_version}") # install resources on the latest released version of the operator @@ -368,7 +368,7 @@ def update_subscription() -> bool: run_periodically(update_subscription, timeout=100, msg="Subscription to be updated") - wait_for_operator_ready(namespace, f"mongodb-enterprise.v{incremented_operator_version}") + wait_for_operator_ready(namespace, "mongodb-kubernetes", f"mongodb-kubernetes.v{incremented_operator_version}") @pytest.mark.e2e_olm_operator_upgrade_with_resources diff --git a/docker/mongodb-enterprise-tests/tests/olm/olm_test_commons.py b/docker/mongodb-enterprise-tests/tests/olm/olm_test_commons.py index 897dd0115..25e1136c9 100644 --- a/docker/mongodb-enterprise-tests/tests/olm/olm_test_commons.py +++ b/docker/mongodb-enterprise-tests/tests/olm/olm_test_commons.py @@ -6,6 +6,7 @@ from typing import Callable import kubetester +import pytest import requests import yaml from kubeobject import CustomObject @@ -61,17 +62,6 @@ def get_catalog_source_resource(namespace: str, image: str) -> CustomObject: return resource -def get_package_manifest_resource(namespace: str, manifest_name: str = "mongodb-enterprise") -> CustomObject: - return CustomObject( - manifest_name, - namespace, - "PackageManifest", - "packagemanifests", - "packages.operators.coreos.com", - "v1", - ) - - def get_subscription_custom_object(name: str, namespace: str, spec: dict[str, str]) -> CustomObject: resource = CustomObject( name, @@ -94,7 +84,7 @@ def get_registry(): def get_catalog_image(version: str): - return f"{get_registry()}/mongodb-enterprise-operator-certified-catalog:{version}" + return f"{get_registry()}/mongodb-kubernetes-test-catalog:{version}" def list_operator_pods(namespace: str, name: str) -> list[client.V1Pod]: @@ -151,8 +141,10 @@ def get_current_operator_version() -> str: return get_release_json()["mongodbOperator"] -def get_latest_released_operator_version() -> str: - released_operators_url = f"https://api.github.com/repos/redhat-openshift-ecosystem/certified-operators/contents/operators/mongodb-enterprise" +def get_latest_released_operator_version(package_name: str) -> str: + released_operators_url = ( + f"https://api.github.com/repos/redhat-openshift-ecosystem/certified-operators/contents/operators/{package_name}" + ) response = requests.get(released_operators_url, headers={"Accept": "application/vnd.github.v3+json"}) if response.status_code != 200: @@ -181,11 +173,9 @@ def increment_patch_version(version: str): return ".".join([major, minor, str(int(patch) + 1)]) -def wait_for_operator_ready(namespace: str, expected_operator_version: str): +def wait_for_operator_ready(namespace: str, name: str, expected_operator_version: str): def wait_for_operator_ready_fn(): - return check_operator_pod_ready_and_with_condition_version( - namespace, "mongodb-enterprise-operator", expected_operator_version - ) + return check_operator_pod_ready_and_with_condition_version(namespace, name, expected_operator_version) run_periodically( wait_for_operator_ready_fn, diff --git a/docker/mongodb-enterprise-tests/tests/opsmanager/om_ops_manager_backup_manual.py b/docker/mongodb-enterprise-tests/tests/opsmanager/om_ops_manager_backup_manual.py index f01810a9d..26e1c0a31 100644 --- a/docker/mongodb-enterprise-tests/tests/opsmanager/om_ops_manager_backup_manual.py +++ b/docker/mongodb-enterprise-tests/tests/opsmanager/om_ops_manager_backup_manual.py @@ -315,8 +315,8 @@ def mdb_latest(self, ops_manager: MongoDBOpsManager, namespace, custom_mdb_versi ] resource["spec"]["podSpec"]["podTemplate"]["spec"]["initContainers"] = [ { - "name": "mongodb-enterprise-init-database", - "image": "268558157000.dkr.ecr.us-east-1.amazonaws.com/rodrigo/ubuntu/mongodb-enterprise-init-database:latest-fixed-probe", + "name": "mongodb-kubernetes-init-database", + "image": "268558157000.dkr.ecr.us-east-1.amazonaws.com/rodrigo/ubuntu/mongodb-kubernetes-init-database:latest-fixed-probe", } ] @@ -347,8 +347,8 @@ def mdb_non_fixed(self, ops_manager: MongoDBOpsManager, namespace, custom_mdb_ve resource["spec"]["podSpec"]["podTemplate"]["spec"]["initContainers"] = [ { - "name": "mongodb-enterprise-init-database", - "image": "268558157000.dkr.ecr.us-east-1.amazonaws.com/rodrigo/ubuntu/mongodb-enterprise-init-database:non-fixed-probe", + "name": "mongodb-kubernetes-init-database", + "image": "268558157000.dkr.ecr.us-east-1.amazonaws.com/rodrigo/ubuntu/mongodb-kubernetes-init-database:non-fixed-probe", } ] diff --git a/docker/mongodb-enterprise-tests/tests/opsmanager/om_ops_manager_backup_restore.py b/docker/mongodb-enterprise-tests/tests/opsmanager/om_ops_manager_backup_restore.py index 97fd6e49c..75240a65c 100644 --- a/docker/mongodb-enterprise-tests/tests/opsmanager/om_ops_manager_backup_restore.py +++ b/docker/mongodb-enterprise-tests/tests/opsmanager/om_ops_manager_backup_restore.py @@ -22,7 +22,7 @@ from tests.opsmanager.withMonitoredAppDB.conftest import enable_multi_cluster_deployment """ -The test checks the backup for MongoDB 4.0 and 4.2, checks that snapshots are built and PIT restore and +The test checks the backup for MongoDB 4.0 and 4.2, checks that snapshots are built and PIT restore and restore from snapshot are working. """ diff --git a/docker/mongodb-enterprise-tests/tests/opsmanager/withMonitoredAppDB/om_ops_manager_backup_liveness_probe.py b/docker/mongodb-enterprise-tests/tests/opsmanager/withMonitoredAppDB/om_ops_manager_backup_liveness_probe.py index 589e1ac90..b21e9aee3 100644 --- a/docker/mongodb-enterprise-tests/tests/opsmanager/withMonitoredAppDB/om_ops_manager_backup_liveness_probe.py +++ b/docker/mongodb-enterprise-tests/tests/opsmanager/withMonitoredAppDB/om_ops_manager_backup_liveness_probe.py @@ -24,7 +24,7 @@ """ This test checks the backup if no separate S3 Metadata database is created and AppDB is used for this. -Note, that it doesn't check for mongodb backup as it's done in 'e2e_om_ops_manager_backup_restore'" +Note, that it doesn't check for mongodb backup as it's done in 'e2e_om_ops_manager_backup_restore'" """ diff --git a/docker/mongodb-enterprise-tests/tests/replicaset/community_and_meko_replicaset_scale.py b/docker/mongodb-enterprise-tests/tests/replicaset/community_and_meko_replicaset_scale.py new file mode 100644 index 000000000..89921af13 --- /dev/null +++ b/docker/mongodb-enterprise-tests/tests/replicaset/community_and_meko_replicaset_scale.py @@ -0,0 +1,90 @@ +from kubetester import create_or_update_secret, try_load +from kubetester.kubetester import fixture as yaml_fixture +from kubetester.mongodb import MongoDB, Phase +from kubetester.mongodb_community import MongoDBCommunity +from kubetester.operator import Operator +from pytest import fixture, mark +from tests import test_logger + +logger = test_logger.get_test_logger(__name__) + + +@fixture(scope="function") +def mco_replica_set(namespace: str) -> MongoDBCommunity: + resource = MongoDBCommunity.from_yaml( + yaml_fixture("community-replicaset-simple.yaml"), + namespace=namespace, + name="mco-replica-set", + ) + + if try_load(resource): + return resource + + return resource.update() + + +@fixture(scope="module") +def meko_replica_set(namespace: str, custom_mdb_version: str) -> MongoDB: + resource = MongoDB.from_yaml(yaml_fixture("replica-set-basic.yaml"), namespace=namespace, name="meko-replica-set") + resource.set_version(custom_mdb_version) + + if try_load(resource): + return resource + + return resource.update() + + +@mark.e2e_community_and_meko_replicaset_scale +def test_install_operator(community_operator: Operator): + community_operator.assert_is_running() + + +@mark.e2e_community_and_meko_replicaset_scale +def test_install_secret(namespace: str): + create_or_update_secret(namespace=namespace, name="my-user-password", data={"password": ""}) + + +@mark.e2e_community_and_meko_replicaset_scale +def test_replicaset_running(mco_replica_set: MongoDBCommunity): + mco_replica_set.assert_reaches_phase(Phase.Running, timeout=300) + + +@mark.e2e_community_and_meko_replicaset_scale +def test_meko_replicaset_running(meko_replica_set: MongoDB): + meko_replica_set.assert_reaches_phase(Phase.Running, timeout=400) + + +@mark.e2e_community_and_meko_replicaset_scale +def test_replicaset_scale_up(mco_replica_set: MongoDBCommunity): + rs = mco_replica_set.load() + rs["spec"]["members"] = 5 + rs.update() + # TODO: MCK As we don't have "observedGeneration" in MongoDBCommunity status, we could be checking the status too early. + # We always need to check for abandoning phase first + mco_replica_set.assert_abandons_phase(Phase.Running, timeout=60) + mco_replica_set.assert_reaches_phase(Phase.Running, timeout=350) + + +@mark.e2e_community_and_meko_replicaset_scale +def test_replicaset_scale_down(mco_replica_set: MongoDBCommunity): + rs = mco_replica_set.load() + rs["spec"]["members"] = 3 + rs.update() + mco_replica_set.assert_abandons_phase(Phase.Running, timeout=60) + mco_replica_set.assert_reaches_phase(Phase.Running, timeout=350) + + +@mark.e2e_community_and_meko_replicaset_scale +def test_meko_replicaset_scale_up(meko_replica_set: MongoDB): + rs = meko_replica_set.load() + rs["spec"]["members"] = 5 + rs.update() + meko_replica_set.assert_reaches_phase(Phase.Running, timeout=500) + + +@mark.e2e_community_and_meko_replicaset_scale +def test_meko_replicaset_scale_down(meko_replica_set: MongoDB): + rs = meko_replica_set.load() + rs["spec"]["members"] = 3 + rs.update() + meko_replica_set.assert_reaches_phase(Phase.Running, timeout=1000) diff --git a/docker/mongodb-enterprise-tests/tests/replicaset/manual/replica_set_override_agent_launcher_script.py b/docker/mongodb-enterprise-tests/tests/replicaset/manual/replica_set_override_agent_launcher_script.py index 53e3ef108..c87c2e526 100644 --- a/docker/mongodb-enterprise-tests/tests/replicaset/manual/replica_set_override_agent_launcher_script.py +++ b/docker/mongodb-enterprise-tests/tests/replicaset/manual/replica_set_override_agent_launcher_script.py @@ -11,7 +11,7 @@ # # It's for quick iteration on changes to agent-launcher.sh. # It's deploying a replica set with 1 member with the local copy of agent-launcher.sh and agent-launcher-lib.sh scripts -# from docker/mongodb-enterprise-init-database/content. +# from docker/mongodb-kubernetes-init-database/content. # Scripts are injected (mounted) into their standard location in init image and scripts from init-database image are overwritten. # # Thanks to this, it is possible to quickly iterate on the script without the need to build and push init-database image. @@ -58,10 +58,10 @@ def replica_set(ops_manager: str, namespace: str, custom_mdb_version: str) -> Mo def test_replica_set(replica_set: MongoDB): - with open("../mongodb-enterprise-init-database/content/agent-launcher.sh", "rb") as f: + with open("../mongodb-kubernetes-init-database/content/agent-launcher.sh", "rb") as f: agent_launcher = base64.b64encode(f.read()).decode("utf-8") - with open("../mongodb-enterprise-init-database/content/agent-launcher-lib.sh", "rb") as f: + with open("../mongodb-kubernetes-init-database/content/agent-launcher-lib.sh", "rb") as f: agent_launcher_lib = base64.b64encode(f.read()).decode("utf-8") command = f""" diff --git a/docker/mongodb-enterprise-tests/tests/shardedcluster/sharded_cluster_statefulset_status.py b/docker/mongodb-enterprise-tests/tests/shardedcluster/sharded_cluster_statefulset_status.py index b09f0db94..e8658aa23 100644 --- a/docker/mongodb-enterprise-tests/tests/shardedcluster/sharded_cluster_statefulset_status.py +++ b/docker/mongodb-enterprise-tests/tests/shardedcluster/sharded_cluster_statefulset_status.py @@ -13,8 +13,8 @@ ) """ -This test checks the 'status.resourcesNotReady' element during sharded cluster reconciliation. It's expected to -be populated with the information about current StatefulSet pending in the following order: config server, shard 0, +This test checks the 'status.resourcesNotReady' element during sharded cluster reconciliation. It's expected to +be populated with the information about current StatefulSet pending in the following order: config server, shard 0, shard 1, mongos. """ diff --git a/docker/mongodb-enterprise-database/Dockerfile.builder b/docker/mongodb-kubernetes-database/Dockerfile.builder similarity index 100% rename from docker/mongodb-enterprise-database/Dockerfile.builder rename to docker/mongodb-kubernetes-database/Dockerfile.builder diff --git a/docker/mongodb-enterprise-database/Dockerfile.template b/docker/mongodb-kubernetes-database/Dockerfile.template similarity index 100% rename from docker/mongodb-enterprise-database/Dockerfile.template rename to docker/mongodb-kubernetes-database/Dockerfile.template diff --git a/docker/mongodb-enterprise-database/Dockerfile.ubi b/docker/mongodb-kubernetes-database/Dockerfile.ubi similarity index 100% rename from docker/mongodb-enterprise-database/Dockerfile.ubi rename to docker/mongodb-kubernetes-database/Dockerfile.ubi diff --git a/docker/mongodb-enterprise-appdb-database/licenses/LICENSE b/docker/mongodb-kubernetes-database/LICENSE similarity index 100% rename from docker/mongodb-enterprise-appdb-database/licenses/LICENSE rename to docker/mongodb-kubernetes-database/LICENSE diff --git a/docker/mongodb-enterprise-database/README.md b/docker/mongodb-kubernetes-database/README.md similarity index 100% rename from docker/mongodb-enterprise-database/README.md rename to docker/mongodb-kubernetes-database/README.md diff --git a/docker/mongodb-enterprise-init-database/Dockerfile.builder b/docker/mongodb-kubernetes-init-database/Dockerfile.builder similarity index 50% rename from docker/mongodb-enterprise-init-database/Dockerfile.builder rename to docker/mongodb-kubernetes-init-database/Dockerfile.builder index ef340b04f..03513ed7c 100644 --- a/docker/mongodb-enterprise-init-database/Dockerfile.builder +++ b/docker/mongodb-kubernetes-init-database/Dockerfile.builder @@ -3,8 +3,8 @@ FROM public.ecr.aws/docker/library/golang:1.24 as readiness_builder COPY . /go/src/github.com/10gen/ops-manager-kubernetes WORKDIR /go/src/github.com/10gen/ops-manager-kubernetes -RUN CGO_ENABLED=0 go build -o /readinessprobe github.com/mongodb/mongodb-kubernetes-operator/cmd/readiness -RUN CGO_ENABLED=0 go build -o /version-upgrade-hook github.com/mongodb/mongodb-kubernetes-operator/cmd/versionhook +RUN CGO_ENABLED=0 GOFLAGS=-buildvcs=false go build -o /readinessprobe ./mongodb-community-operator/cmd/readiness/main.go +RUN CGO_ENABLED=0 GOFLAGS=-buildvcs=false go build -o /version-upgrade-hook ./mongodb-community-operator/cmd/versionhook/main.go FROM scratch ARG mongodb_tools_url_ubi @@ -14,9 +14,9 @@ COPY --from=readiness_builder /version-upgrade-hook /data/version-upgrade-hook ADD ${mongodb_tools_url_ubi} /data/mongodb_tools_ubi.tgz -COPY ./docker/mongodb-enterprise-init-database/content/probe.sh /data/probe.sh +COPY ./docker/mongodb-kubernetes-init-database/content/probe.sh /data/probe.sh -COPY ./docker/mongodb-enterprise-init-database/content/agent-launcher-lib.sh /data/scripts/ -COPY ./docker/mongodb-enterprise-init-database/content/agent-launcher.sh /data/scripts/ +COPY ./docker/mongodb-kubernetes-init-database/content/agent-launcher-lib.sh /data/scripts/ +COPY ./docker/mongodb-kubernetes-init-database/content/agent-launcher.sh /data/scripts/ -COPY ./docker/mongodb-enterprise-init-database/content/LICENSE /data/licenses/ +COPY ./docker/mongodb-kubernetes-init-database/content/LICENSE /data/licenses/ diff --git a/docker/mongodb-enterprise-init-database/Dockerfile.template b/docker/mongodb-kubernetes-init-database/Dockerfile.template similarity index 100% rename from docker/mongodb-enterprise-init-database/Dockerfile.template rename to docker/mongodb-kubernetes-init-database/Dockerfile.template diff --git a/docker/mongodb-enterprise-init-database/Dockerfile.ubi_minimal b/docker/mongodb-kubernetes-init-database/Dockerfile.ubi_minimal similarity index 100% rename from docker/mongodb-enterprise-init-database/Dockerfile.ubi_minimal rename to docker/mongodb-kubernetes-init-database/Dockerfile.ubi_minimal diff --git a/docker/mongodb-enterprise-database/LICENSE b/docker/mongodb-kubernetes-init-database/content/LICENSE similarity index 100% rename from docker/mongodb-enterprise-database/LICENSE rename to docker/mongodb-kubernetes-init-database/content/LICENSE diff --git a/docker/mongodb-enterprise-init-database/content/agent-launcher-lib.sh b/docker/mongodb-kubernetes-init-database/content/agent-launcher-lib.sh similarity index 100% rename from docker/mongodb-enterprise-init-database/content/agent-launcher-lib.sh rename to docker/mongodb-kubernetes-init-database/content/agent-launcher-lib.sh diff --git a/docker/mongodb-enterprise-init-database/content/agent-launcher.sh b/docker/mongodb-kubernetes-init-database/content/agent-launcher.sh similarity index 100% rename from docker/mongodb-enterprise-init-database/content/agent-launcher.sh rename to docker/mongodb-kubernetes-init-database/content/agent-launcher.sh diff --git a/docker/mongodb-enterprise-init-database/content/probe.sh b/docker/mongodb-kubernetes-init-database/content/probe.sh similarity index 100% rename from docker/mongodb-enterprise-init-database/content/probe.sh rename to docker/mongodb-kubernetes-init-database/content/probe.sh diff --git a/docker/mongodb-enterprise-init-ops-manager/Dockerfile.builder b/docker/mongodb-kubernetes-init-ops-manager/Dockerfile.builder similarity index 100% rename from docker/mongodb-enterprise-init-ops-manager/Dockerfile.builder rename to docker/mongodb-kubernetes-init-ops-manager/Dockerfile.builder diff --git a/docker/mongodb-enterprise-init-ops-manager/Dockerfile.template b/docker/mongodb-kubernetes-init-ops-manager/Dockerfile.template similarity index 100% rename from docker/mongodb-enterprise-init-ops-manager/Dockerfile.template rename to docker/mongodb-kubernetes-init-ops-manager/Dockerfile.template diff --git a/docker/mongodb-enterprise-init-ops-manager/Dockerfile.ubi_minimal b/docker/mongodb-kubernetes-init-ops-manager/Dockerfile.ubi_minimal similarity index 100% rename from docker/mongodb-enterprise-init-ops-manager/Dockerfile.ubi_minimal rename to docker/mongodb-kubernetes-init-ops-manager/Dockerfile.ubi_minimal diff --git a/docker/mongodb-enterprise-init-database/content/LICENSE b/docker/mongodb-kubernetes-init-ops-manager/LICENSE similarity index 100% rename from docker/mongodb-enterprise-init-database/content/LICENSE rename to docker/mongodb-kubernetes-init-ops-manager/LICENSE diff --git a/docker/mongodb-enterprise-init-ops-manager/backupdaemon_readinessprobe/backupdaemon_readiness.go b/docker/mongodb-kubernetes-init-ops-manager/backupdaemon_readinessprobe/backupdaemon_readiness.go similarity index 100% rename from docker/mongodb-enterprise-init-ops-manager/backupdaemon_readinessprobe/backupdaemon_readiness.go rename to docker/mongodb-kubernetes-init-ops-manager/backupdaemon_readinessprobe/backupdaemon_readiness.go diff --git a/docker/mongodb-enterprise-init-ops-manager/backupdaemon_readinessprobe/backupdaemon_readiness_test.go b/docker/mongodb-kubernetes-init-ops-manager/backupdaemon_readinessprobe/backupdaemon_readiness_test.go similarity index 100% rename from docker/mongodb-enterprise-init-ops-manager/backupdaemon_readinessprobe/backupdaemon_readiness_test.go rename to docker/mongodb-kubernetes-init-ops-manager/backupdaemon_readinessprobe/backupdaemon_readiness_test.go diff --git a/docker/mongodb-enterprise-init-ops-manager/go.mod b/docker/mongodb-kubernetes-init-ops-manager/go.mod similarity index 74% rename from docker/mongodb-enterprise-init-ops-manager/go.mod rename to docker/mongodb-kubernetes-init-ops-manager/go.mod index d9f181db4..6e175d199 100644 --- a/docker/mongodb-enterprise-init-ops-manager/go.mod +++ b/docker/mongodb-kubernetes-init-ops-manager/go.mod @@ -1,4 +1,4 @@ -module github.com/10gen/ops-manager-kubernetes/docker/mongodb-enterprise-init-ops-manager +module github.com/10gen/ops-manager-kubernetes/docker/mongodb-kubernetes-init-ops-manager go 1.24.0 diff --git a/docker/mongodb-enterprise-init-ops-manager/go.sum b/docker/mongodb-kubernetes-init-ops-manager/go.sum similarity index 100% rename from docker/mongodb-enterprise-init-ops-manager/go.sum rename to docker/mongodb-kubernetes-init-ops-manager/go.sum diff --git a/docker/mongodb-enterprise-init-ops-manager/mmsconfiguration/edit_mms_configuration.go b/docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/edit_mms_configuration.go similarity index 99% rename from docker/mongodb-enterprise-init-ops-manager/mmsconfiguration/edit_mms_configuration.go rename to docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/edit_mms_configuration.go index ad4d7ae9d..45605e7ab 100755 --- a/docker/mongodb-enterprise-init-ops-manager/mmsconfiguration/edit_mms_configuration.go +++ b/docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/edit_mms_configuration.go @@ -19,7 +19,7 @@ const ( propOverwriteFmt = "%s=\"${%s} %s\"" backupDaemon = "BACKUP_DAEMON" // keep in sync with AppDBConnectionStringPath constant from "github.com/10gen/ops-manager-kubernetes/controllers/operator/construct" package. - // currently we cannot reference code from outside of docker/mongodb-enterprise-init-ops-manager + // currently we cannot reference code from outside of docker/mongodb-kubernetes-init-ops-manager // because this folder is set as the docker build context (configured in inventories/init_om.yaml) appDbConnectionStringPath = "/mongodb-ops-manager/.mongodb-mms-connection-string" appDbConnectionStringFilePath = appDbConnectionStringPath + "/connectionString" diff --git a/docker/mongodb-enterprise-init-ops-manager/mmsconfiguration/edit_mms_configuration_test.go b/docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/edit_mms_configuration_test.go similarity index 100% rename from docker/mongodb-enterprise-init-ops-manager/mmsconfiguration/edit_mms_configuration_test.go rename to docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/edit_mms_configuration_test.go diff --git a/docker/mongodb-enterprise-init-ops-manager/scripts/backup-daemon-liveness-probe.sh b/docker/mongodb-kubernetes-init-ops-manager/scripts/backup-daemon-liveness-probe.sh similarity index 100% rename from docker/mongodb-enterprise-init-ops-manager/scripts/backup-daemon-liveness-probe.sh rename to docker/mongodb-kubernetes-init-ops-manager/scripts/backup-daemon-liveness-probe.sh diff --git a/docker/mongodb-enterprise-init-ops-manager/scripts/docker-entry-point.sh b/docker/mongodb-kubernetes-init-ops-manager/scripts/docker-entry-point.sh similarity index 100% rename from docker/mongodb-enterprise-init-ops-manager/scripts/docker-entry-point.sh rename to docker/mongodb-kubernetes-init-ops-manager/scripts/docker-entry-point.sh diff --git a/docker/mongodb-kubernetes-readinessprobe/Dockerfile b/docker/mongodb-kubernetes-readinessprobe/Dockerfile new file mode 100644 index 000000000..17c590526 --- /dev/null +++ b/docker/mongodb-kubernetes-readinessprobe/Dockerfile @@ -0,0 +1,6 @@ +ARG imagebase +FROM ${imagebase} as base + +FROM registry.access.redhat.com/ubi9/ubi-minimal + +COPY --from=base /probes/readinessprobe /probes/readinessprobe diff --git a/docker/mongodb-kubernetes-readinessprobe/Dockerfile.builder b/docker/mongodb-kubernetes-readinessprobe/Dockerfile.builder new file mode 100644 index 000000000..e538e793e --- /dev/null +++ b/docker/mongodb-kubernetes-readinessprobe/Dockerfile.builder @@ -0,0 +1,11 @@ +FROM public.ecr.aws/docker/library/golang:1.24 as builder +WORKDIR /go/src +ADD . . + +ARG TARGETOS +ARG TARGETARCH +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o /data/scripts/readinessprobe ./mongodb-community-operator/cmd/readiness/main.go + +FROM scratch as final + +COPY --from=builder /data/scripts/readinessprobe /probes/ diff --git a/docker/mongodb-kubernetes-upgrade-hook/Dockerfile b/docker/mongodb-kubernetes-upgrade-hook/Dockerfile new file mode 100644 index 000000000..362831582 --- /dev/null +++ b/docker/mongodb-kubernetes-upgrade-hook/Dockerfile @@ -0,0 +1,6 @@ +ARG imagebase +FROM ${imagebase} as base + +FROM registry.access.redhat.com/ubi9/ubi-minimal + +COPY --from=base /version-upgrade-hook /version-upgrade-hook diff --git a/docker/mongodb-kubernetes-upgrade-hook/Dockerfile.builder b/docker/mongodb-kubernetes-upgrade-hook/Dockerfile.builder new file mode 100644 index 000000000..1aeffa93b --- /dev/null +++ b/docker/mongodb-kubernetes-upgrade-hook/Dockerfile.builder @@ -0,0 +1,11 @@ +FROM public.ecr.aws/docker/library/golang:1.24 as builder +WORKDIR /go/src +ADD . . + +ARG TARGETOS +ARG TARGETARCH +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o /data/scripts/version-upgrade-hook ./mongodb-community-operator/cmd/versionhook/main.go + +FROM scratch as final + +COPY --from=builder /data/scripts/version-upgrade-hook / diff --git a/go.mod b/go.mod index 466176c81..12ffbc2fa 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ module github.com/10gen/ops-manager-kubernetes require ( github.com/blang/semver v3.5.1+incompatible github.com/ghodss/yaml v1.0.0 + github.com/go-logr/logr v1.4.2 github.com/go-logr/zapr v1.3.0 github.com/google/go-cmp v0.6.0 github.com/google/uuid v1.6.0 @@ -12,7 +13,6 @@ require ( github.com/hashicorp/go-retryablehttp v0.7.7 github.com/hashicorp/vault/api v1.16.0 github.com/imdario/mergo v0.3.15 - github.com/mongodb/mongodb-kubernetes-operator v0.13.0 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.21.0 github.com/r3labs/diff/v3 v3.0.1 @@ -22,6 +22,7 @@ require ( github.com/xdg/stringprep v1.0.3 github.com/yudai/gojsondiff v1.0.0 go.mongodb.org/atlas v0.37.0 + go.mongodb.org/mongo-driver v1.16.0 go.uber.org/zap v1.27.0 golang.org/x/crypto v0.37.0 golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e @@ -34,6 +35,7 @@ require ( k8s.io/klog/v2 v2.130.1 k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 sigs.k8s.io/controller-runtime v0.18.7 + sigs.k8s.io/yaml v1.4.0 ) // force pin, until we update the direct dependencies @@ -49,16 +51,17 @@ require ( github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-jose/go-jose/v4 v4.0.5 // indirect - github.com/go-logr/logr v1.4.2 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.3 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect + github.com/golang/snappy v0.0.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect + github.com/gorilla/websocket v1.5.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-rootcerts v1.0.2 // indirect @@ -72,9 +75,12 @@ require ( github.com/mailru/easyjson v0.7.7 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/moby/spdystream v0.2.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/montanaflynn/stats v0.7.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect github.com/onsi/ginkgo v1.16.5 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.6.1 // indirect @@ -85,6 +91,10 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + github.com/xdg-go/pbkdf2 v1.0.0 // indirect + github.com/xdg-go/scram v1.1.2 // indirect + github.com/xdg-go/stringprep v1.0.4 // indirect + github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect github.com/yudai/pp v2.0.1+incompatible // indirect go.uber.org/multierr v1.11.0 // indirect @@ -106,12 +116,6 @@ require ( k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect - sigs.k8s.io/yaml v1.4.0 // indirect ) -// to replace Community Operator to a locally cloned project run: -// go mod edit -replace github.com/mongodb/mongodb-kubernetes-operator=../mongodb-kubernetes-operator -// to replace it to a specific commit run: -// go mod edit -replace github.com/mongodb/mongodb-kubernetes-operator=github.com/mongodb/mongodb-kubernetes-operator@master - go 1.24.0 diff --git a/go.sum b/go.sum index 22036bbda..a71b6081a 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,6 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= @@ -59,6 +61,8 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -77,6 +81,9 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJY github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -138,15 +145,19 @@ github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUb github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= +github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/mongodb/mongodb-kubernetes-operator v0.13.0 h1:tbR6z7f3DZmeQJgPsC+Xp193kdADMzcwFGqlTvO9gh0= -github.com/mongodb/mongodb-kubernetes-operator v0.13.0/go.mod h1:iphBRGSTwDzHCtwXlB9Pd8f2T7t2zvzum1QLH1rSDl4= +github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= +github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -205,8 +216,16 @@ github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9 github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= +github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= +github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= +github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= +github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= +github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= github.com/xdg/stringprep v1.0.3 h1:cmL5Enob4W83ti/ZHuZLuKD/xqJfus4fVPwE+/BDm+4= github.com/xdg/stringprep v1.0.3/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= @@ -215,8 +234,11 @@ github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcm github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.mongodb.org/atlas v0.37.0 h1:zQnO1o5+bVP9IotpAYpres4UjMD2F4nwNEFTZhNL4ck= go.mongodb.org/atlas v0.37.0/go.mod h1:DJYtM+vsEpPEMSkQzJnFHrT0sP7ev6cseZc/GGjJYG8= +go.mongodb.org/mongo-driver v1.16.0 h1:tpRsfBJMROVHKpdGyc1BBEzzjDUWjItxbVSZ8Ls4BQ4= +go.mongodb.org/mongo-driver v1.16.0/go.mod h1:oB6AhJQvFQL4LEHyXi6aJzQJtBiTQHiAd83l0GdFaiw= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -226,12 +248,14 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -240,6 +264,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98= @@ -248,6 +274,7 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -259,13 +286,21 @@ golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o= golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= @@ -275,6 +310,7 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/helm_chart/Chart.yaml b/helm_chart/Chart.yaml index a796a91f3..e5f5b7a79 100644 --- a/helm_chart/Chart.yaml +++ b/helm_chart/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: enterprise-operator description: MongoDB Kubernetes Enterprise Operator -version: 1.33.0 +version: 0.1.0 kubeVersion: '>=1.16-0' type: application keywords: diff --git a/helm_chart/crds/mongodb.com_mongodbmulti.yaml b/helm_chart/crds/mongodb.com_mongodbmulti.yaml new file mode 100644 index 000000000..c58717ec5 --- /dev/null +++ b/helm_chart/crds/mongodb.com_mongodbmulti.yaml @@ -0,0 +1,638 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.10.0 + creationTimestamp: null + name: mongodbmulti.mongodb.com +spec: + group: mongodb.com + names: + kind: MongoDBMulti + listKind: MongoDBMultiList + plural: mongodbmulti + shortNames: + - mdbm + singular: mongodbmulti + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: Current state of the MongoDB deployment. + jsonPath: .status.phase + name: Phase + type: string + - description: The time since the MongoDBMulti resource was created. + jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1 + schema: + openAPIV3Schema: + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + properties: + additionalMongodConfig: + description: 'AdditionalMongodConfig is additional configuration that + can be passed to each data-bearing mongod at runtime. Uses the same + structure as the mongod configuration file: https://docs.mongodb.com/manual/reference/configuration-options/' + type: object + x-kubernetes-preserve-unknown-fields: true + agent: + properties: + startupOptions: + additionalProperties: + type: string + type: object + type: object + backup: + description: Backup contains configuration options for configuring + backup for this MongoDB resource + properties: + assignmentLabels: + description: Assignment Labels set in the Ops Manager + items: + type: string + type: array + autoTerminateOnDeletion: + description: AutoTerminateOnDeletion indicates if the Operator + should stop and terminate the Backup before the cleanup, when + the MongoDB CR is deleted + type: boolean + encryption: + description: Encryption settings + properties: + kmip: + description: Kmip corresponds to the KMIP configuration assigned + to the Ops Manager Project's configuration. + properties: + client: + description: KMIP Client configuration + properties: + clientCertificatePrefix: + description: 'A prefix used to construct KMIP client + certificate (and corresponding password) Secret + names. The names are generated using the following + pattern: KMIP Client Certificate (TLS Secret): --kmip-client KMIP Client Certificate Password: + --kmip-client-password + The expected key inside is called "password".' + type: string + type: object + required: + - client + type: object + type: object + mode: + enum: + - enabled + - disabled + - terminated + type: string + snapshotSchedule: + properties: + clusterCheckpointIntervalMin: + enum: + - 15 + - 30 + - 60 + type: integer + dailySnapshotRetentionDays: + description: Number of days to retain daily snapshots. Setting + 0 will disable this rule. + maximum: 365 + minimum: 0 + type: integer + fullIncrementalDayOfWeek: + description: Day of the week when Ops Manager takes a full + snapshot. This ensures a recent complete backup. Ops Manager + sets the default value to SUNDAY. + enum: + - SUNDAY + - MONDAY + - TUESDAY + - WEDNESDAY + - THURSDAY + - FRIDAY + - SATURDAY + type: string + monthlySnapshotRetentionMonths: + description: Number of months to retain weekly snapshots. + Setting 0 will disable this rule. + maximum: 36 + minimum: 0 + type: integer + pointInTimeWindowHours: + description: Number of hours in the past for which a point-in-time + snapshot can be created. + enum: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 15 + - 30 + - 60 + - 90 + - 120 + - 180 + - 360 + type: integer + referenceHourOfDay: + description: Hour of the day to schedule snapshots using a + 24-hour clock, in UTC. + maximum: 23 + minimum: 0 + type: integer + referenceMinuteOfHour: + description: Minute of the hour to schedule snapshots, in + UTC. + maximum: 59 + minimum: 0 + type: integer + snapshotIntervalHours: + description: Number of hours between snapshots. + enum: + - 6 + - 8 + - 12 + - 24 + type: integer + snapshotRetentionDays: + description: Number of days to keep recent snapshots. + maximum: 365 + minimum: 1 + type: integer + weeklySnapshotRetentionWeeks: + description: Number of weeks to retain weekly snapshots. Setting + 0 will disable this rule + maximum: 365 + minimum: 0 + type: integer + type: object + type: object + cloudManager: + properties: + configMapRef: + properties: + name: + type: string + type: object + type: object + clusterDomain: + format: hostname + type: string + clusterSpecList: + description: ClusterSpecList holds a list with a clusterSpec corresponding + to each cluster + properties: + clusterSpecs: + items: + description: ClusterSpecItem is the mongodb multi-cluster spec + that is specific to a particular Kubernetes cluster, this + maps to the statefulset created in each cluster + properties: + clusterName: + description: ClusterName is name of the cluster where the + MongoDB Statefulset will be scheduled, the name should + have a one on one mapping with the service-account created + in the central cluster to talk to the workload clusters. + type: string + exposedExternally: + description: ExposedExternally determines whether a NodePort + service should be created for the resource + type: boolean + members: + description: Amount of members for this MongoDB Replica + Set + type: integer + service: + description: this is an optional service, it will get the + name "-service" in case not provided + type: string + statefulSet: + description: StatefulSetConfiguration holds the optional + custom StatefulSet that should be merged into the operator + created one. + properties: + spec: + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + required: + - members + type: object + type: array + type: object + connectivity: + properties: + replicaSetHorizons: + items: + additionalProperties: + type: string + description: 'MongoDBHorizonConfig holds a map of horizon names + to the node addresses, e.g. { "internal": "my-rs-2.my-internal-domain.com:31843", "external": + "my-rs-2.my-external-domain.com:21467" } The key of each item + in the map is an arbitrary, user-chosen string that represents + the name of the horizon. The value of the item is the host + and, optionally, the port that this mongod node will be connected + to from.' + type: object + type: array + type: object + credentials: + description: Name of the Secret holding credentials information + type: string + duplicateServiceObjects: + description: 'In few service mesh options for ex: Istio, by default + we would need to duplicate the service objects created per pod in + all the clusters to enable DNS resolution. Users can however configure + their ServiceMesh with DNS proxy(https://istio.io/latest/docs/ops/configuration/traffic-management/dns-proxy/) + enabled in which case the operator doesn''t need to create the service + objects per cluster. This options tells the operator whether it + should create the service objects in all the clusters or not. By + default, if not specified the operator would create the duplicate + svc objects.' + type: boolean + featureCompatibilityVersion: + type: string + logLevel: + enum: + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + type: string + opsManager: + properties: + configMapRef: + properties: + name: + type: string + type: object + type: object + persistent: + type: boolean + security: + properties: + authentication: + description: Authentication holds various authentication related + settings that affect this MongoDB resource. + properties: + agents: + description: Agents contains authentication configuration + properties for the agents + properties: + automationLdapGroupDN: + type: string + automationPasswordSecretRef: + description: SecretKeySelector selects a key of a Secret. + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + automationUserName: + type: string + clientCertificateSecretRef: + type: object + x-kubernetes-preserve-unknown-fields: true + mode: + description: Mode is the desired Authentication mode that + the agents will use + type: string + required: + - mode + type: object + enabled: + type: boolean + ignoreUnknownUsers: + description: IgnoreUnknownUsers maps to the inverse of auth.authoritativeSet + type: boolean + internalCluster: + type: string + ldap: + description: LDAP Configuration + properties: + authzQueryTemplate: + type: string + bindQueryPasswordSecretRef: + properties: + name: + type: string + required: + - name + type: object + bindQueryUser: + type: string + caConfigMapRef: + description: Allows to point at a ConfigMap/key with a + CA file to mount on the Pod + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + servers: + items: + type: string + type: array + timeoutMS: + type: integer + transportSecurity: + enum: + - tls + - none + type: string + userCacheInvalidationInterval: + type: integer + userToDNMapping: + type: string + validateLDAPServerConfig: + type: boolean + type: object + modes: + items: + type: string + type: array + requireClientTLSAuthentication: + description: Clients should present valid TLS certificates + type: boolean + required: + - enabled + type: object + certsSecretPrefix: + type: string + roles: + items: + properties: + authenticationRestrictions: + items: + properties: + clientSource: + items: + type: string + type: array + serverAddress: + items: + type: string + type: array + type: object + type: array + db: + type: string + privileges: + items: + properties: + actions: + items: + type: string + type: array + resource: + properties: + cluster: + type: boolean + collection: + type: string + db: + type: string + type: object + required: + - actions + - resource + type: object + type: array + role: + type: string + roles: + items: + properties: + db: + type: string + role: + type: string + required: + - db + - role + type: object + type: array + required: + - db + - role + type: object + type: array + tls: + properties: + additionalCertificateDomains: + items: + type: string + type: array + ca: + description: CA corresponds to a ConfigMap containing an entry + for the CA certificate (ca.pem) used to validate the certificates + created already. + type: string + enabled: + description: DEPRECATED please enable TLS by setting `security.certsSecretPrefix` + or `security.tls.secretRef.prefix`. Enables TLS for this + resource. This will make the operator try to mount a Secret + with a defined name (-cert). This is only + used when enabling TLS on a MongoDB resource, and not on + the AppDB, where TLS is configured by setting `secretRef.Name`. + type: boolean + type: object + type: object + statefulSet: + description: StatefulSetConfiguration provides the statefulset override + for each of the cluster's statefulset if "StatefulSetConfiguration" + is specified at cluster level under "clusterSpecList" that takes + precedence over the global one + properties: + spec: + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + type: + enum: + - ReplicaSet + type: string + version: + pattern: ^[0-9]+.[0-9]+.[0-9]+(-.+)?$|^$ + type: string + required: + - credentials + - type + - version + type: object + status: + properties: + backup: + properties: + statusName: + type: string + required: + - statusName + type: object + clusterStatusList: + description: ClusterStatusList holds a list of clusterStatuses corresponding + to each cluster + properties: + clusterStatuses: + items: + description: ClusterStatusItem is the mongodb multi-cluster + spec that is specific to a particular Kubernetes cluster, + this maps to the statefulset created in each cluster + properties: + clusterName: + description: ClusterName is name of the cluster where the + MongoDB Statefulset will be scheduled, the name should + have a one on one mapping with the service-account created + in the central cluster to talk to the workload clusters. + type: string + lastTransition: + type: string + members: + type: integer + message: + type: string + observedGeneration: + format: int64 + type: integer + phase: + type: string + resourcesNotReady: + items: + description: ResourceNotReady describes the dependent + resource which is not ready yet + properties: + errors: + items: + properties: + message: + type: string + reason: + type: string + type: object + type: array + kind: + description: ResourceKind specifies a kind of a Kubernetes + resource. Used in status of a Custom Resource + type: string + message: + type: string + name: + type: string + required: + - kind + - name + type: object + type: array + warnings: + items: + type: string + type: array + required: + - phase + type: object + type: array + type: object + lastTransition: + type: string + link: + type: string + message: + type: string + observedGeneration: + format: int64 + type: integer + phase: + type: string + resourcesNotReady: + items: + description: ResourceNotReady describes the dependent resource which + is not ready yet + properties: + errors: + items: + properties: + message: + type: string + reason: + type: string + type: object + type: array + kind: + description: ResourceKind specifies a kind of a Kubernetes resource. + Used in status of a Custom Resource + type: string + message: + type: string + name: + type: string + required: + - kind + - name + type: object + type: array + version: + type: string + warnings: + items: + type: string + type: array + required: + - phase + - version + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/helm_chart/crds/mongodbcommunity.mongodb.com_mongodbcommunity.yaml b/helm_chart/crds/mongodbcommunity.mongodb.com_mongodbcommunity.yaml new file mode 100644 index 000000000..12207a6bd --- /dev/null +++ b/helm_chart/crds/mongodbcommunity.mongodb.com_mongodbcommunity.yaml @@ -0,0 +1,677 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.15.0 + service.binding: path={.metadata.name}-{.spec.users[0].db}-{.spec.users[0].name},objectType=Secret + service.binding/connectionString: path={.metadata.name}-{.spec.users[0].db}-{.spec.users[0].name},objectType=Secret,sourceKey=connectionString.standardSrv + service.binding/password: path={.metadata.name}-{.spec.users[0].db}-{.spec.users[0].name},objectType=Secret,sourceKey=password + service.binding/provider: community + service.binding/type: mongodb + service.binding/username: path={.metadata.name}-{.spec.users[0].db}-{.spec.users[0].name},objectType=Secret,sourceKey=username + name: mongodbcommunity.mongodbcommunity.mongodb.com +spec: + group: mongodbcommunity.mongodb.com + names: + kind: MongoDBCommunity + listKind: MongoDBCommunityList + plural: mongodbcommunity + shortNames: + - mdbc + singular: mongodbcommunity + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: Current state of the MongoDB deployment + jsonPath: .status.phase + name: Phase + type: string + - description: Version of MongoDB server + jsonPath: .status.version + name: Version + type: string + name: v1 + schema: + openAPIV3Schema: + description: MongoDBCommunity is the Schema for the mongodbs API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: MongoDBCommunitySpec defines the desired state of MongoDB + properties: + additionalConnectionStringConfig: + description: Additional options to be appended to the connection string. + These options apply to the entire resource and to each user. + nullable: true + type: object + x-kubernetes-preserve-unknown-fields: true + additionalMongodConfig: + description: |- + AdditionalMongodConfig is additional configuration that can be passed to + each data-bearing mongod at runtime. Uses the same structure as the mongod + configuration file: https://www.mongodb.com/docs/manual/reference/configuration-options/ + nullable: true + type: object + x-kubernetes-preserve-unknown-fields: true + agent: + description: AgentConfiguration sets options for the MongoDB automation + agent + properties: + auditLogRotate: + description: AuditLogRotate if enabled, will enable AuditLogRotate + for all processes. + properties: + includeAuditLogsWithMongoDBLogs: + description: |- + set to 'true' to have the Automation Agent rotate the audit files along + with mongodb log files + type: boolean + numTotal: + description: maximum number of log files to have total + type: integer + numUncompressed: + description: maximum number of log files to leave uncompressed + type: integer + percentOfDiskspace: + description: |- + Maximum percentage of the total disk space these log files should take up. + The string needs to be able to be converted to float64 + type: string + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + The string needs to be able to be converted to float64. + Fractional values of MB are supported. + type: string + timeThresholdHrs: + description: maximum hours for an individual log file before + rotation + type: integer + required: + - sizeThresholdMB + - timeThresholdHrs + type: object + logFile: + type: string + logLevel: + type: string + logRotate: + description: LogRotate if enabled, will enable LogRotate for all + processes. + properties: + includeAuditLogsWithMongoDBLogs: + description: |- + set to 'true' to have the Automation Agent rotate the audit files along + with mongodb log files + type: boolean + numTotal: + description: maximum number of log files to have total + type: integer + numUncompressed: + description: maximum number of log files to leave uncompressed + type: integer + percentOfDiskspace: + description: |- + Maximum percentage of the total disk space these log files should take up. + The string needs to be able to be converted to float64 + type: string + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + The string needs to be able to be converted to float64. + Fractional values of MB are supported. + type: string + timeThresholdHrs: + description: maximum hours for an individual log file before + rotation + type: integer + required: + - sizeThresholdMB + - timeThresholdHrs + type: object + maxLogFileDurationHours: + type: integer + systemLog: + description: SystemLog configures system log of mongod + properties: + destination: + type: string + logAppend: + type: boolean + path: + type: string + required: + - destination + - logAppend + - path + type: object + type: object + arbiters: + description: |- + Arbiters is the number of arbiters to add to the Replica Set. + It is not recommended to have more than one arbiter per Replica Set. + More info: https://www.mongodb.com/docs/manual/tutorial/add-replica-set-arbiter/ + type: integer + automationConfig: + description: |- + AutomationConfigOverride is merged on top of the operator created automation config. Processes are merged + by name. Currently Only the process.disabled field is supported. + properties: + processes: + items: + description: OverrideProcess contains fields that we can override + on the AutomationConfig processes. + properties: + disabled: + type: boolean + logRotate: + description: CrdLogRotate is the crd definition of LogRotate + including fields in strings while the agent supports them + as float64 + properties: + includeAuditLogsWithMongoDBLogs: + description: |- + set to 'true' to have the Automation Agent rotate the audit files along + with mongodb log files + type: boolean + numTotal: + description: maximum number of log files to have total + type: integer + numUncompressed: + description: maximum number of log files to leave uncompressed + type: integer + percentOfDiskspace: + description: |- + Maximum percentage of the total disk space these log files should take up. + The string needs to be able to be converted to float64 + type: string + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + The string needs to be able to be converted to float64. + Fractional values of MB are supported. + type: string + timeThresholdHrs: + description: maximum hours for an individual log file + before rotation + type: integer + required: + - sizeThresholdMB + - timeThresholdHrs + type: object + name: + type: string + required: + - disabled + - name + type: object + type: array + replicaSet: + properties: + id: + description: |- + Id can be used together with additionalMongodConfig.replication.replSetName + to manage clusters where replSetName differs from the MongoDBCommunity resource name + type: string + settings: + description: |- + MapWrapper is a wrapper for a map to be used by other structs. + The CRD generator does not support map[string]interface{} + on the top level and hence we need to work around this with + a wrapping struct. + type: object + x-kubernetes-preserve-unknown-fields: true + type: object + type: object + featureCompatibilityVersion: + description: |- + FeatureCompatibilityVersion configures the feature compatibility version that will + be set for the deployment + type: string + memberConfig: + description: MemberConfig + items: + properties: + priority: + type: string + tags: + additionalProperties: + type: string + type: object + votes: + type: integer + type: object + type: array + members: + description: Members is the number of members in the replica set + type: integer + prometheus: + description: Prometheus configurations. + properties: + metricsPath: + description: Indicates path to the metrics endpoint. + pattern: ^\/[a-z0-9]+$ + type: string + passwordSecretRef: + description: Name of a Secret containing a HTTP Basic Auth Password. + properties: + key: + description: Key is the key in the secret storing this password. + Defaults to "password" + type: string + name: + description: Name is the name of the secret storing this user's + password + type: string + required: + - name + type: object + port: + description: Port where metrics endpoint will bind to. Defaults + to 9216. + type: integer + tlsSecretKeyRef: + description: |- + Name of a Secret (type kubernetes.io/tls) holding the certificates to use in the + Prometheus endpoint. + properties: + key: + description: Key is the key in the secret storing this password. + Defaults to "password" + type: string + name: + description: Name is the name of the secret storing this user's + password + type: string + required: + - name + type: object + username: + description: HTTP Basic Auth Username for metrics endpoint. + type: string + required: + - passwordSecretRef + - username + type: object + replicaSetHorizons: + description: |- + ReplicaSetHorizons Add this parameter and values if you need your database + to be accessed outside of Kubernetes. This setting allows you to + provide different DNS settings within the Kubernetes cluster and + to the Kubernetes cluster. The Kubernetes Operator uses split horizon + DNS for replica set members. This feature allows communication both + within the Kubernetes cluster and from outside Kubernetes. + items: + additionalProperties: + type: string + type: object + type: array + security: + description: Security configures security features, such as TLS, and + authentication settings for a deployment + properties: + authentication: + properties: + agentCertificateSecretRef: + description: |- + AgentCertificateSecret is a reference to a Secret containing the certificate and the key for the automation agent + The secret needs to have available: + - certificate under key: "tls.crt" + - private key under key: "tls.key" + If additionally, tls.pem is present, then it needs to be equal to the concatenation of tls.crt and tls.key + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + type: object + x-kubernetes-map-type: atomic + agentMode: + description: AgentMode contains the authentication mode used + by the automation agent. + enum: + - SCRAM + - SCRAM-SHA-256 + - SCRAM-SHA-1 + - X509 + type: string + ignoreUnknownUsers: + default: true + nullable: true + type: boolean + modes: + description: Modes is an array specifying which authentication + methods should be enabled. + items: + enum: + - SCRAM + - SCRAM-SHA-256 + - SCRAM-SHA-1 + - X509 + type: string + type: array + required: + - modes + type: object + roles: + description: User-specified custom MongoDB roles that should be + configured in the deployment. + items: + description: CustomRole defines a custom MongoDB role. + properties: + authenticationRestrictions: + description: The authentication restrictions the server + enforces on the role. + items: + description: |- + AuthenticationRestriction specifies a list of IP addresses and CIDR ranges users + are allowed to connect to or from. + properties: + clientSource: + items: + type: string + type: array + serverAddress: + items: + type: string + type: array + required: + - clientSource + - serverAddress + type: object + type: array + db: + description: The database of the role. + type: string + privileges: + description: The privileges to grant the role. + items: + description: Privilege defines the actions a role is allowed + to perform on a given resource. + properties: + actions: + items: + type: string + type: array + resource: + description: |- + Resource specifies specifies the resources upon which a privilege permits actions. + See https://www.mongodb.com/docs/manual/reference/resource-document for more. + properties: + anyResource: + type: boolean + cluster: + type: boolean + collection: + type: string + db: + type: string + type: object + required: + - actions + - resource + type: object + type: array + role: + description: The name of the role. + type: string + roles: + description: An array of roles from which this role inherits + privileges. + items: + description: Role is the database role this user should + have + properties: + db: + description: DB is the database the role can act on + type: string + name: + description: Name is the name of the role + type: string + required: + - db + - name + type: object + type: array + required: + - db + - privileges + - role + type: object + type: array + tls: + description: TLS configuration for both client-server and server-server + communication + properties: + caCertificateSecretRef: + description: |- + CaCertificateSecret is a reference to a Secret containing the certificate for the CA which signed the server certificates + The certificate is expected to be available under the key "ca.crt" + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + type: object + x-kubernetes-map-type: atomic + caConfigMapRef: + description: |- + CaConfigMap is a reference to a ConfigMap containing the certificate for the CA which signed the server certificates + The certificate is expected to be available under the key "ca.crt" + This field is ignored when CaCertificateSecretRef is configured + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + type: object + x-kubernetes-map-type: atomic + certificateKeySecretRef: + description: |- + CertificateKeySecret is a reference to a Secret containing a private key and certificate to use for TLS. + The key and cert are expected to be PEM encoded and available at "tls.key" and "tls.crt". + This is the same format used for the standard "kubernetes.io/tls" Secret type, but no specific type is required. + Alternatively, an entry tls.pem, containing the concatenation of cert and key, can be provided. + If all of tls.pem, tls.crt and tls.key are present, the tls.pem one needs to be equal to the concatenation of tls.crt and tls.key + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + type: object + x-kubernetes-map-type: atomic + enabled: + type: boolean + optional: + description: Optional configures if TLS should be required + or optional for connections + type: boolean + required: + - enabled + type: object + type: object + statefulSet: + description: |- + StatefulSetConfiguration holds the optional custom StatefulSet + that should be merged into the operator created one. + properties: + metadata: + description: StatefulSetMetadataWrapper is a wrapper around Labels + and Annotations + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + type: object + spec: + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + type: + description: Type defines which type of MongoDB deployment the resource + should create + enum: + - ReplicaSet + type: string + users: + description: Users specifies the MongoDB users that should be configured + in your deployment + items: + properties: + additionalConnectionStringConfig: + description: |- + Additional options to be appended to the connection string. + These options apply only to this user and will override any existing options in the resource. + nullable: true + type: object + x-kubernetes-preserve-unknown-fields: true + connectionStringSecretName: + description: |- + ConnectionStringSecretName is the name of the secret object created by the operator which exposes the connection strings for the user. + If provided, this secret must be different for each user in a deployment. + type: string + connectionStringSecretNamespace: + description: ConnectionStringSecretNamespace is the namespace + of the secret object created by the operator which exposes + the connection strings for the user. + type: string + db: + default: admin + description: DB is the database the user is stored in. Defaults + to "admin" + type: string + name: + description: Name is the username of the user + type: string + passwordSecretRef: + description: PasswordSecretRef is a reference to the secret + containing this user's password + properties: + key: + description: Key is the key in the secret storing this password. + Defaults to "password" + type: string + name: + description: Name is the name of the secret storing this + user's password + type: string + required: + - name + type: object + roles: + description: Roles is an array of roles assigned to this user + items: + description: Role is the database role this user should have + properties: + db: + description: DB is the database the role can act on + type: string + name: + description: Name is the name of the role + type: string + required: + - db + - name + type: object + type: array + scramCredentialsSecretName: + description: |- + ScramCredentialsSecretName appended by string "scram-credentials" is the name of the secret object created by the mongoDB operator for storing SCRAM credentials + These secrets names must be different for each user in a deployment. + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ + type: string + required: + - name + - roles + type: object + type: array + version: + description: Version defines which version of MongoDB will be used + type: string + required: + - security + - type + - users + type: object + status: + description: MongoDBCommunityStatus defines the observed state of MongoDB + properties: + currentMongoDBArbiters: + type: integer + currentMongoDBMembers: + type: integer + currentStatefulSetArbitersReplicas: + type: integer + currentStatefulSetReplicas: + type: integer + message: + type: string + mongoUri: + type: string + phase: + type: string + version: + type: string + required: + - currentMongoDBMembers + - currentStatefulSetReplicas + - mongoUri + - phase + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/helm_chart/templates/mongodbcommunity_cr_with_tls.yaml b/helm_chart/templates/mongodbcommunity_cr_with_tls.yaml new file mode 100644 index 000000000..4e420be15 --- /dev/null +++ b/helm_chart/templates/mongodbcommunity_cr_with_tls.yaml @@ -0,0 +1,153 @@ +{{- if and .Values.community.resource.tls.enabled .Values.community.resource.tls.useCertManager }} +# cert-manager resources +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + name: tls-selfsigned-issuer + namespace: {{ .Values.namespace }} +spec: + selfSigned: {} +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: tls-selfsigned-ca + namespace: {{ .Values.namespace }} +spec: + isCA: true + commonName: "*.{{ .Values.community.resource.name }}-svc.{{ .Values.namespace }}.svc.cluster.local" + dnsNames: + - "*.{{ .Values.community.resource.name }}-svc.{{ .Values.namespace }}.svc.cluster.local" + secretName: {{ .Values.community.resource.tls.caCertificateSecretRef }} + privateKey: + algorithm: ECDSA + size: 256 + issuerRef: + name: tls-selfsigned-issuer + kind: Issuer +--- +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + name: tls-ca-issuer + namespace: {{ .Values.namespace }} +spec: + ca: + secretName: {{ .Values.community.resource.tls.caCertificateSecretRef }} +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: cert-manager-tls-certificate + namespace: {{ .Values.namespace }} +spec: + secretName: {{ .Values.community.resource.tls.certificateKeySecretRef }} + issuerRef: + name: tls-ca-issuer + kind: Issuer + duration: {{ .Values.community.resource.tls.certManager.certDuration | default "8760h" }} # default to 365 days + renewBefore: {{ .Values.community.resource.tls.certManager.renewCertBefore | default "720h" }} # default to 30 days + commonName: "*.{{ .Values.community.resource.name }}-svc.{{ .Values.namespace }}.svc.cluster.local" + dnsNames: + - "*.{{ .Values.community.resource.name }}-svc.{{ .Values.namespace }}.svc.cluster.local" +{{- if .Values.community.resource.tls.useX509 }} +# Agent X509 certs +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: agent-certs + namespace: {{ .Values.namespace }} +spec: + commonName: mms-automation-agent + dnsNames: + - automation + duration: 240h0m0s + issuerRef: + name: tls-ca-issuer + renewBefore: 120h0m0s + secretName: agent-certs + subject: + countries: + - US + localities: + - NY + organizationalUnits: + - a-1635241837-m5yb81lfnrz + organizations: + - cluster.local-agent + provinces: + - NY + usages: + - digital signature + - key encipherment + - client auth +{{- end }} +{{- if .Values.community.resource.tls.sampleX509User }} +# Client certs +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: x509-user-cert + namespace: {{ .Values.namespace }} +spec: + commonName: my-x509-user + duration: 240h0m0s + issuerRef: + name: tls-ca-issuer + renewBefore: 120h0m0s + secretName: my-x509-user-cert + subject: + organizationalUnits: + - organizationalunit + organizations: + - organization + usages: + - digital signature + - client auth +{{- end }} +{{- end }} +{{- if .Values.community.createResource }} +# mongodb resources +--- +apiVersion: mongodbcommunity.mongodb.com/v1 +kind: MongoDBCommunity +metadata: + name: {{ .Values.community.resource.name }} + namespace: {{ .Values.namespace }} +spec: + members: {{ .Values.community.resource.members }} + type: ReplicaSet + version: {{ .Values.community.resource.version }} + security: + tls: + enabled: {{ .Values.community.resource.tls.enabled }} + {{- if .Values.community.resource.tls.enabled }} + certificateKeySecretRef: + name: {{ .Values.community.resource.tls.certificateKeySecretRef }} + caCertificateSecretRef: + name: {{ .Values.community.resource.tls.caCertificateSecretRef }} + {{- end }} + authentication: + {{- if .Values.community.resource.tls.useX509 }} + modes: ["X509"] + {{- else }} + modes: ["SCRAM"] + {{- end }} + {{- if .Values.community.resource.tls.sampleX509User }} + users: + - name: CN=my-x509-user,OU=organizationalunit,O=organization + db: $external + roles: + - name: clusterAdmin + db: admin + - name: userAdminAnyDatabase + db: admin + - name: readWriteAnyDatabase + db: admin + {{- else }} + users: + {{- toYaml .Values.community.resource.users | nindent 4 }} + {{- end}} +{{- end }} diff --git a/helm_chart/templates/operator-roles.yaml b/helm_chart/templates/operator-roles.yaml index 49b18ea78..77a923610 100644 --- a/helm_chart/templates/operator-roles.yaml +++ b/helm_chart/templates/operator-roles.yaml @@ -62,6 +62,15 @@ rules: - watch - delete - deletecollection + - apiGroups: + - mongodbcommunity.mongodb.com + resources: + - mongodbcommunity + - mongodbcommunity/status + - mongodbcommunity/spec + - mongodbcommunity/finalizers + verbs: + - '*' - apiGroups: - mongodb.com verbs: diff --git a/helm_chart/templates/operator.yaml b/helm_chart/templates/operator.yaml index 8cb5a94aa..68464d95c 100644 --- a/helm_chart/templates/operator.yaml +++ b/helm_chart/templates/operator.yaml @@ -207,6 +207,26 @@ spec: - name: MDB_MAX_CONCURRENT_RECONCILES value: "{{ .Values.operator.maxConcurrentReconciles }}" {{- end }} + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: OPERATOR_NAME + value: {{ .Values.operator.name }} + # Community Env Vars Start + - name: MDB_COMMUNITY_AGENT_IMAGE + value: "{{ .Values.community.registry.agent }}/{{ .Values.community.agent.name }}:{{ .Values.community.agent.version }}" + - name: VERSION_UPGRADE_HOOK_IMAGE + value: "{{ .Values.registry.versionUpgradeHook }}/{{ .Values.versionUpgradeHook.name }}:{{ .Values.versionUpgradeHook.version }}" + - name: READINESS_PROBE_IMAGE + value: "{{ .Values.registry.readinessProbe }}/{{ .Values.readinessProbe.name }}:{{ .Values.readinessProbe.version }}" + - name: MDB_COMMUNITY_IMAGE + value: "{{ .Values.community.mongodb.name }}" + - name: MDB_COMMUNITY_REPO_URL + value: "{{ .Values.community.mongodb.repo }}" + - name: MDB_COMMUNITY_IMAGE_TYPE + value: "{{ .Values.community.mongodb.imageType }}" + # Community Env Vars End {{- if .Values.relatedImages }} - name: RELATED_IMAGE_{{ $mongodbEnterpriseDatabaseImageEnv }}_{{ $databaseVersion | replace "." "_" | replace "-" "_" }} value: "{{ .Values.registry.database }}/{{ .Values.database.name }}:{{ $databaseVersion }}" diff --git a/helm_chart/values-openshift.yaml b/helm_chart/values-openshift.yaml index de582a4fe..0f87394bb 100644 --- a/helm_chart/values-openshift.yaml +++ b/helm_chart/values-openshift.yaml @@ -27,7 +27,7 @@ operator: # Environment variables prefixed with RELATED_IMAGE_ are used by operator-sdk to generate relatedImages section # with sha256 digests pinning for the certified operator bundle with disconnected environment feature enabled. # https://docs.openshift.com/container-platform/4.14/operators/operator_sdk/osdk-generating-csvs.html#olm-enabling-operator-for-restricted-network_osdk-generating-csvs - version: 1.33.0 + version: 0.1.0 relatedImages: opsManager: - 6.0.25 diff --git a/helm_chart/values.yaml b/helm_chart/values.yaml index a66195e82..8a2c70eaf 100644 --- a/helm_chart/values.yaml +++ b/helm_chart/values.yaml @@ -20,7 +20,7 @@ operator: deployment_name: mongodb-enterprise-operator # Version of mongodb-enterprise-operator - version: 1.33.0 + version: 0.1.0 # The Custom Resources that will be watched by the Operator. Needs to be changed if only some of the CRDs are installed watchedResources: @@ -113,33 +113,38 @@ operator: ## Database database: - name: mongodb-enterprise-database-ubi - version: 1.33.0 + name: mongodb-kubernetes-database-ubi + version: 0.1.0 initDatabase: - name: mongodb-enterprise-init-database-ubi - version: 1.33.0 + name: mongodb-kubernetes-init-database-ubi + version: 0.1.0 ## Ops Manager opsManager: name: mongodb-enterprise-ops-manager-ubi initOpsManager: - name: mongodb-enterprise-init-ops-manager-ubi - version: 1.33.0 + name: mongodb-kubernetes-init-ops-manager-ubi + version: 0.1.0 ## Application Database initAppDb: - name: mongodb-enterprise-init-appdb-ubi - version: 1.33.0 + name: mongodb-kubernetes-init-appdb-ubi + version: 0.1.0 agent: name: mongodb-agent-ubi version: 108.0.2.8729-1 -mongodbLegacyAppDb: - name: mongodb-enterprise-appdb-database-ubi - repo: quay.io/mongodb +# This is only used by the MongoDBCommunity resource reconciler - START +versionUpgradeHook: + name: mongodb-kubernetes-operator-version-upgrade-post-start-hook + version: 1.0.9 +readinessProbe: + name: mongodb-kubernetes-readinessprobe + version: 1.0.22 +# This is only used by the MongoDBCommunity resource reconciler - END # This is used by AppDB and by static containers to determine the image that the operator uses for databases. mongodb: @@ -162,6 +167,11 @@ registry: appDb: quay.io/mongodb agent: quay.io/mongodb +# This is only used by the MongoDBCommunity resource reconciler - START + versionUpgradeHook: quay.io/mongodb + readinessProbe: quay.io/mongodb +# This is only used by the MongoDBCommunity resource reconciler - END + multiCluster: # Specify if we want to deploy the operator in multi-cluster mode clusters: [] @@ -171,3 +181,33 @@ multiCluster: # Set this to false to disable subresource utilization # It might be required on some versions of Openshift subresourceEnabled: true + +# Resources only for the MongoDBCommunity resource reconciler +community: + mongodb: + repo: quay.io/mongodb + # change this if you want to use a different mongoDB image + name: mongodb-community-server + imageType: ubi8 + agent: + name: mongodb-agent-ubi + version: 108.0.2.8729-1 + registry: + agent: quay.io/mongodb + name: mongodb-database + resource: + name: mongodb-replica-set + version: 4.4.0 + members: 3 + tls: + # when tls.enabled == true and tls.useCertManager == true then Cert Manager's Issuer and Certificate resources will be created + enabled: false + # Installs Cert-Manager in this cluster. + useX509: false + sampleX509User: false + useCertManager: true + certificateKeySecretRef: tls-certificate + caCertificateSecretRef: tls-ca-key-pair + certManager: + certDuration: 8760h # 365 days + renewCertBefore: 720h # 30 days diff --git a/inventories/database.yaml b/inventories/database.yaml index 7f837d12e..8a3441d32 100644 --- a/inventories/database.yaml +++ b/inventories/database.yaml @@ -1,11 +1,11 @@ vars: - quay_registry: quay.io/mongodb/mongodb-enterprise-database + quay_registry: quay.io/mongodb/mongodb-kubernetes-database s3_bucket: s3://enterprise-operator-dockerfiles/dockerfiles/mongodb-enterprise-database images: - name: database vars: - context: docker/mongodb-enterprise-database + context: docker/mongodb-kubernetes-database platform: linux/amd64 stages: diff --git a/inventories/init_appdb.yaml b/inventories/init_appdb.yaml index 0287d8210..acbe04a8d 100644 --- a/inventories/init_appdb.yaml +++ b/inventories/init_appdb.yaml @@ -1,22 +1,22 @@ vars: - quay_registry: quay.io/mongodb/mongodb-enterprise-init-appdb - s3_bucket: s3://enterprise-operator-dockerfiles/dockerfiles/mongodb-enterprise-init-appdb + quay_registry: quay.io/mongodb/mongodb-kubernetes-init-appdb + s3_bucket: s3://enterprise-operator-dockerfiles/dockerfiles/mongodb-kubernetes-init-appdb images: - name: init-appdb vars: context: . - template_context: docker/mongodb-enterprise-init-database + template_context: docker/mongodb-kubernetes-init-database platform: linux/amd64 stages: - name: init-appdb-build-context task_type: docker_build - dockerfile: docker/mongodb-enterprise-init-database/Dockerfile.builder + dockerfile: docker/mongodb-kubernetes-init-database/Dockerfile.builder buildargs: mongodb_tools_url_ubi: $(inputs.params.mongodb_tools_url_ubi) output: - - registry: $(inputs.params.registry)/mongodb-enterprise-init-appdb-context + - registry: $(inputs.params.registry)/mongodb-kubernetes-init-appdb-context tag: $(inputs.params.version_id) - name: init-appdb-template-ubi @@ -33,27 +33,27 @@ images: tags: ["ubi"] buildargs: version: $(inputs.params.version) - imagebase: $(inputs.params.registry)/mongodb-enterprise-init-appdb-context:$(inputs.params.version_id) + imagebase: $(inputs.params.registry)/mongodb-kubernetes-init-appdb-context:$(inputs.params.version_id) dockerfile: $(stages['init-appdb-template-ubi'].outputs[0].dockerfile) output: - - registry: $(inputs.params.registry)/mongodb-enterprise-init-appdb-ubi + - registry: $(inputs.params.registry)/mongodb-kubernetes-init-appdb-ubi tag: $(inputs.params.version_id) - name: master-latest task_type: tag_image tags: [ "master" ] source: - registry: $(inputs.params.registry)/mongodb-enterprise-init-appdb-ubi + registry: $(inputs.params.registry)/mongodb-kubernetes-init-appdb-ubi tag: $(inputs.params.version_id) destination: - - registry: $(inputs.params.registry)/mongodb-enterprise-init-appdb-ubi + - registry: $(inputs.params.registry)/mongodb-kubernetes-init-appdb-ubi tag: latest - name: init-appdb-release-context task_type: tag_image tags: ["release"] source: - registry: $(inputs.params.registry)/mongodb-enterprise-init-appdb-context + registry: $(inputs.params.registry)/mongodb-kubernetes-init-appdb-context tag: $(inputs.params.version_id) destination: - registry: $(inputs.params.quay_registry) diff --git a/inventories/init_database.yaml b/inventories/init_database.yaml index a2f9f2734..15ce0455e 100644 --- a/inventories/init_database.yaml +++ b/inventories/init_database.yaml @@ -1,24 +1,24 @@ vars: - quay_registry: quay.io/mongodb/mongodb-enterprise-init-database - s3_bucket: s3://enterprise-operator-dockerfiles/dockerfiles/mongodb-enterprise-init-database + quay_registry: quay.io/mongodb/mongodb-kubernetes-init-database + s3_bucket: s3://enterprise-operator-dockerfiles/dockerfiles/mongodb-kubernetes-init-database images: - name: init-database vars: context: . - template_context: docker/mongodb-enterprise-init-database + template_context: docker/mongodb-kubernetes-init-database platform: linux/amd64 stages: - name: init-database-build-context task_type: docker_build - dockerfile: docker/mongodb-enterprise-init-database/Dockerfile.builder + dockerfile: docker/mongodb-kubernetes-init-database/Dockerfile.builder buildargs: mongodb_tools_url_ubi: $(inputs.params.mongodb_tools_url_ubi) output: - - registry: $(inputs.params.registry)/mongodb-enterprise-init-database-context + - registry: $(inputs.params.registry)/mongodb-kubernetes-init-database-context tag: $(inputs.params.version_id) - - registry: $(inputs.params.registry)/mongodb-enterprise-init-database-context + - registry: $(inputs.params.registry)/mongodb-kubernetes-init-database-context tag: $(inputs.params.version) - name: init-database-template-ubi @@ -34,32 +34,32 @@ images: task_type: docker_build tags: ["ubi"] buildargs: - imagebase: $(inputs.params.registry)/mongodb-enterprise-init-database-context:$(inputs.params.version_id) + imagebase: $(inputs.params.registry)/mongodb-kubernetes-init-database-context:$(inputs.params.version_id) version: $(inputs.params.version) dockerfile: $(stages['init-database-template-ubi'].outputs[0].dockerfile) inputs: - is_appdb output: - - registry: $(inputs.params.registry)/mongodb-enterprise-init-database-ubi + - registry: $(inputs.params.registry)/mongodb-kubernetes-init-database-ubi tag: $(inputs.params.version_id) - - registry: $(inputs.params.registry)/mongodb-enterprise-init-database-ubi + - registry: $(inputs.params.registry)/mongodb-kubernetes-init-database-ubi tag: $(inputs.params.version) - name: master-latest task_type: tag_image tags: ["master"] source: - registry: $(inputs.params.registry)/mongodb-enterprise-init-database-ubi + registry: $(inputs.params.registry)/mongodb-kubernetes-init-database-ubi tag: $(inputs.params.version_id) destination: - - registry: $(inputs.params.registry)/mongodb-enterprise-init-database-ubi + - registry: $(inputs.params.registry)/mongodb-kubernetes-init-database-ubi tag: latest - name: init-database-release-context task_type: tag_image tags: ["release"] source: - registry: $(inputs.params.registry)/mongodb-enterprise-init-database-context + registry: $(inputs.params.registry)/mongodb-kubernetes-init-database-context tag: $(inputs.params.version_id) destination: - registry: $(inputs.params.quay_registry) diff --git a/inventories/init_om.yaml b/inventories/init_om.yaml index 3df465e22..a8b7168dc 100644 --- a/inventories/init_om.yaml +++ b/inventories/init_om.yaml @@ -1,11 +1,11 @@ vars: - quay_registry: quay.io/mongodb/mongodb-enterprise-init-ops-manager - s3_bucket: s3://enterprise-operator-dockerfiles/dockerfiles/mongodb-enterprise-init-ops-manager + quay_registry: quay.io/mongodb/mongodb-kubernetes-init-ops-manager + s3_bucket: s3://enterprise-operator-dockerfiles/dockerfiles/mongodb-kubernetes-init-ops-manager images: - name: init-ops-manager vars: - context: docker/mongodb-enterprise-init-ops-manager + context: docker/mongodb-kubernetes-init-ops-manager platform: linux/amd64 stages: @@ -13,7 +13,7 @@ images: task_type: docker_build dockerfile: Dockerfile.builder output: - - registry: $(inputs.params.registry)/mongodb-enterprise-init-ops-manager-context + - registry: $(inputs.params.registry)/mongodb-kubernetes-init-ops-manager-context tag: $(inputs.params.version_id) - name: init-ops-manager-template-ubi @@ -30,26 +30,26 @@ images: dockerfile: $(stages['init-ops-manager-template-ubi'].outputs[0].dockerfile) tags: ["ubi"] buildargs: - imagebase: $(inputs.params.registry)/mongodb-enterprise-init-ops-manager-context:$(inputs.params.version_id) + imagebase: $(inputs.params.registry)/mongodb-kubernetes-init-ops-manager-context:$(inputs.params.version_id) output: - - registry: $(inputs.params.registry)/mongodb-enterprise-init-ops-manager-ubi + - registry: $(inputs.params.registry)/mongodb-kubernetes-init-ops-manager-ubi tag: $(inputs.params.version_id) - name: master-latest task_type: tag_image tags: ["master"] source: - registry: $(inputs.params.registry)/mongodb-enterprise-init-ops-manager-ubi + registry: $(inputs.params.registry)/mongodb-kubernetes-init-ops-manager-ubi tag: $(inputs.params.version_id) destination: - - registry: $(inputs.params.registry)/mongodb-enterprise-init-ops-manager-ubi + - registry: $(inputs.params.registry)/mongodb-kubernetes-init-ops-manager-ubi tag: latest - name: init-ops-manager-release-context task_type: tag_image tags: ["release"] source: - registry: $(inputs.params.registry)/mongodb-enterprise-init-ops-manager-context + registry: $(inputs.params.registry)/mongodb-kubernetes-init-ops-manager-context tag: $(inputs.params.version_id) destination: - registry: $(inputs.params.quay_registry) diff --git a/inventories/mco_test.yaml b/inventories/mco_test.yaml new file mode 100644 index 000000000..c926b4069 --- /dev/null +++ b/inventories/mco_test.yaml @@ -0,0 +1,17 @@ +images: +- name: community-operator-e2e + vars: + context: . # we will need the whole root for the go tests + platform: linux/amd64 + + stages: + - name: build + task_type: docker_build + dockerfile: docker/mongodb-community-tests/Dockerfile + buildargs: + GOLANG_VERSION: $(inputs.params.golang_version) + output: + - registry: $(inputs.params.registry)/mongodb-community-tests + tag: latest + - registry: $(inputs.params.registry)/mongodb-community-tests + tag: $(inputs.params.version_id) diff --git a/inventories/readiness_probe.yaml b/inventories/readiness_probe.yaml new file mode 100644 index 000000000..3ca2e5cb7 --- /dev/null +++ b/inventories/readiness_probe.yaml @@ -0,0 +1,62 @@ +vars: + quay_registry: quay.io/mongodb/mongodb-kubernetes-readinessprobe + s3_bucket: s3://enterprise-operator-dockerfiles/dockerfiles/mongodb-kubernetes-readinessprobe + +images: + - name: mongodb-kubernetes-readinessprobe + vars: + context: . + template_context: docker/mongodb-kubernetes-readinessprobe + platform: linux/$(inputs.params.architecture) + + stages: + - name: readiness-probe-build-context + task_type: docker_build + dockerfile: docker/mongodb-kubernetes-readinessprobe/Dockerfile.builder + tags: ["ubi"] + buildargs: + GOLANG_VERSION: $(inputs.params.golang_version) + TARGETOS: linux + TARGETARCH: $(inputs.params.architecture) + + labels: + quay.expires-after: 48h + + output: + - registry: $(inputs.params.registry)/mongodb-kubernetes-readinessprobe + tag: $(inputs.params.version_id)-context-$(inputs.params.architecture) + + - name: readiness-probe-build-context-release + task_type: docker_build + tags: ["release"] + dockerfile: docker/mongodb-kubernetes-readinessprobe/Dockerfile.builder + buildargs: + GOLANG_VERSION: $(inputs.params.golang_version) + TARGETOS: linux + TARGETARCH: $(inputs.params.architecture) + output: + - registry: $(inputs.params.quay_registry) + tag: $(inputs.params.version)-context-$(inputs.params.architecture) + + - name: readiness-probe-build + task_type: docker_build + tags: ["ubi"] + buildargs: + imagebase: $(inputs.params.registry)/mongodb-kubernetes-readinessprobe:$(inputs.params.version_id)-context-$(inputs.params.architecture) + version: $(inputs.params.version) + dockerfile: docker/mongodb-kubernetes-readinessprobe/Dockerfile + + labels: + quay.expires-after: 48h + + output: + - registry: $(inputs.params.registry)/mongodb-kubernetes-readinessprobe + tag: $(inputs.params.version_id)-$(inputs.params.architecture) + - registry: $(inputs.params.registry)/mongodb-kubernetes-readinessprobe + tag: latest-$(inputs.params.architecture) + + - name: readiness-probe-template + task_type: dockerfile_template + tags: ["release"] + output: + - dockerfile: $(inputs.params.s3_bucket)/$(inputs.params.version)/ubi/Dockerfile diff --git a/inventories/upgrade_hook.yaml b/inventories/upgrade_hook.yaml new file mode 100644 index 000000000..9407d0427 --- /dev/null +++ b/inventories/upgrade_hook.yaml @@ -0,0 +1,62 @@ +vars: + quay_registry: quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook + s3_bucket: s3://enterprise-operator-dockerfiles/dockerfiles/mongodb-kubernetes-operator-version-upgrade-post-start-hook + +images: + - name: mongodb-kubernetes-operator-version-upgrade-post-start-hook + vars: + context: . + template_context: docker/mongodb-kubernetes-upgrade-hook + platform: linux/$(inputs.params.architecture) + + stages: + - name: readiness-probe-build-context + task_type: docker_build + dockerfile: docker/mongodb-kubernetes-upgrade-hook/Dockerfile.builder + tags: ["ubi"] + buildargs: + GOLANG_VERSION: $(inputs.params.golang_version) + TARGETOS: linux + TARGETARCH: $(inputs.params.architecture) + + labels: + quay.expires-after: 48h + + output: + - registry: $(inputs.params.registry)/mongodb-kubernetes-operator-version-upgrade-post-start-hook + tag: $(inputs.params.version_id)-context-$(inputs.params.architecture) + + - name: readiness-probe-build-context-release + task_type: docker_build + tags: ["release"] + dockerfile: docker/mongodb-kubernetes-upgrade-hook/Dockerfile.builder + buildargs: + GOLANG_VERSION: $(inputs.params.golang_version) + TARGETOS: linux + TARGETARCH: $(inputs.params.architecture) + output: + - registry: $(inputs.params.quay_registry) + tag: $(inputs.params.version)-context-$(inputs.params.architecture) + + - name: readiness-probe-build + task_type: docker_build + tags: ["ubi"] + buildargs: + imagebase: $(inputs.params.registry)/mongodb-kubernetes-operator-version-upgrade-post-start-hook:$(inputs.params.version_id)-context-$(inputs.params.architecture) + version: $(inputs.params.version) + dockerfile: docker/mongodb-kubernetes-upgrade-hook/Dockerfile + + labels: + quay.expires-after: 48h + + output: + - registry: $(inputs.params.registry)/mongodb-kubernetes-operator-version-upgrade-post-start-hook + tag: $(inputs.params.version_id)-$(inputs.params.architecture) + - registry: $(inputs.params.registry)/mongodb-kubernetes-operator-version-upgrade-post-start-hook + tag: latest-$(inputs.params.architecture) + + - name: readiness-probe-template + task_type: dockerfile_template + tags: ["release"] + output: + - dockerfile: $(inputs.params.s3_bucket)/$(inputs.params.version)/ubi/Dockerfile diff --git a/lib/sonar/.gitignore b/lib/sonar/.gitignore index 340963e85..cd7ec2375 100644 --- a/lib/sonar/.gitignore +++ b/lib/sonar/.gitignore @@ -5,7 +5,6 @@ tmp/ *.py[cod] *.egg -build htmlcov sonar.egg-info/* diff --git a/main.go b/main.go index e0effd91e..cdf5e92d6 100644 --- a/main.go +++ b/main.go @@ -23,7 +23,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/manager/signals" - mcoConstruct "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" corev1 "k8s.io/api/core/v1" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" @@ -40,6 +39,10 @@ import ( omv1 "github.com/10gen/ops-manager-kubernetes/api/v1/om" "github.com/10gen/ops-manager-kubernetes/controllers/operator" "github.com/10gen/ops-manager-kubernetes/controllers/operator/construct" + mcov1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + mcoController "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers" + mcoConstruct "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/envvar" "github.com/10gen/ops-manager-kubernetes/pkg/images" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" "github.com/10gen/ops-manager-kubernetes/pkg/telemetry" @@ -55,6 +58,7 @@ const ( mongoDBUserCRDPlural = "mongodbusers" mongoDBOpsManagerCRDPlural = "opsmanagers" mongoDBMultiClusterCRDPlural = "mongodbmulticluster" + mongoDBCommunityCRDPlural = "mongodbcommunity" ) var ( @@ -74,8 +78,8 @@ var ( func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(apiv1.AddToScheme(scheme)) + utilruntime.Must(mcov1.AddToScheme(scheme)) utilruntime.Must(corev1.AddToScheme(scheme)) - // +kubebuilder:scaffold:scheme flag.Var(&crds, "watch-resource", "A Watch Resource specifies if the Operator should watch the given resource") @@ -97,8 +101,10 @@ func (c *crdsToWatch) String() string { func main() { flag.Parse() // If no CRDs are specified, we set default to non-multicluster CRDs + // TODO MCK: consider not making mongoDBCommunityCRDPlural part of the default list + // what happens if we watch this, but its not installed? if len(crds) == 0 { - crds = crdsToWatch{mongoDBCRDPlural, mongoDBUserCRDPlural, mongoDBOpsManagerCRDPlural} + crds = crdsToWatch{mongoDBCRDPlural, mongoDBUserCRDPlural, mongoDBOpsManagerCRDPlural, mongoDBCommunityCRDPlural} } ctx := context.Background() @@ -236,6 +242,22 @@ func main() { log.Infof("Registered CRD: %s", r) } + if slices.Contains(crds, mongoDBCommunityCRDPlural) { + if err := setupCommunityController( + mgr, + envvar.GetEnvOrDefault(mcoConstruct.MongodbCommunityRepoUrlEnv, "quay.io/mongodb"), + // when running MCO resource -> mongodb-community-server + // when running appdb -> mongodb-enterprise-server + env.ReadOrPanic(mcoConstruct.MongodbCommunityImageEnv), + envvar.GetEnvOrDefault(mcoConstruct.MongoDBCommunityImageTypeEnv, mcoConstruct.DefaultImageType), + os.Getenv(util.MongodbCommunityAgentImageEnv), + os.Getenv(mcoConstruct.VersionUpgradeHookImageEnv), + os.Getenv(mcoConstruct.ReadinessProbeImageEnv), + ); err != nil { + log.Fatal(err) + } + } + if telemetry.IsTelemetryActivated() { log.Info("Running telemetry component!") telemetryRunnable, err := telemetry.NewLeaderRunnable(mgr, memberClusterObjectsMap, currentNamespace, imageUrls[mcoConstruct.MongodbImageEnv], imageUrls[util.NonStaticDatabaseEnterpriseImage], getOperatorEnv()) @@ -288,6 +310,26 @@ func setupMongoDBMultiClusterCRD(ctx context.Context, mgr manager.Manager, image return ctrl.NewWebhookManagedBy(mgr).For(&mdbmultiv1.MongoDBMultiCluster{}).Complete() } +func setupCommunityController( + mgr manager.Manager, + mongodbRepoURL string, + mongodbImage string, + mongodbImageType string, + agentImage string, + versionUpgradeHookImage string, + readinessProbeImage string, +) error { + return mcoController.NewReconciler( + mgr, + mongodbRepoURL, // + mongodbImage, // defaults to enterprise in appdb, here should be community + mongodbImageType, + agentImage, + versionUpgradeHookImage, + readinessProbeImage, + ).SetupWithManager(mgr) +} + // getMemberClusters retrieves the member clusters from the configmap util.MemberListConfigMapName func getMemberClusters(ctx context.Context, cfg *rest.Config, currentNamespace string) ([]string, error) { c, err := client.New(cfg, client.Options{}) @@ -372,6 +414,7 @@ func initializeEnvironment() { "POD_WAIT_", "OPERATOR_ENV", "WATCH_NAMESPACE", + "NAMESPACE", "MANAGED_SECURITY_CONTEXT", "IMAGE_PULL_SECRETS", "MONGODB_ENTERPRISE_", diff --git a/mongodb-community-operator/.action_templates/e2e-fork-template.yaml b/mongodb-community-operator/.action_templates/e2e-fork-template.yaml deleted file mode 100644 index c6378cceb..000000000 --- a/mongodb-community-operator/.action_templates/e2e-fork-template.yaml +++ /dev/null @@ -1,27 +0,0 @@ -name: Run E2E Fork -jobs: - - template: display-github-context - - template: setup - # dependabot gets a read only github token, and so must use pull_request_target instead of pull_request. - if: contains(github.event.pull_request.labels.*.name, 'dependencies') || contains(github.event.pull_request.labels.*.name, 'safe-to-test') - steps: - - template: cancel-previous - - template: checkout-fork - - template: setup-and-install-python - - template: quay-login - - template: set-up-qemu - - template: build-and-push-development-images - - template: tests - steps: - - template: cancel-previous - - template: checkout-fork - - template: set-run-status - - template: setup-and-install-python - - template: setup-kind-cluster - if: steps.last_run_status.outputs.last_run_status != 'success' - - template: run-test-matrix - - template: save-run-status - - template: dump-and-upload-diagnostics - -events: - - template: pull-request-target diff --git a/mongodb-community-operator/.action_templates/e2e-pr-template.yaml b/mongodb-community-operator/.action_templates/e2e-pr-template.yaml deleted file mode 100644 index 8c4e79d14..000000000 --- a/mongodb-community-operator/.action_templates/e2e-pr-template.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: Run E2E -jobs: - - template: display-github-context - - template: setup - # run on master, or if a PR is being created from a branch, or if it has been manually triggered. - if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') - steps: - - template: cancel-previous - - template: checkout - - template: setup-and-install-python - - template: quay-login - - template: set-up-qemu - - template: build-and-push-development-images - - template: tests - steps: - - template: cancel-previous - - template: checkout - - template: set-run-status - - template: setup-and-install-python - - template: setup-kind-cluster - if: steps.last_run_status.outputs.last_run_status != 'success' - - template: run-test-matrix - - template: save-run-status - - template: dump-and-upload-diagnostics - -events: - - template: on-pull-request-master - - template: on-push-master - - template: workflow-dispatch diff --git a/mongodb-community-operator/.action_templates/e2e-single-template.yaml b/mongodb-community-operator/.action_templates/e2e-single-template.yaml deleted file mode 100644 index 36e586af3..000000000 --- a/mongodb-community-operator/.action_templates/e2e-single-template.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: Run Single E2E -jobs: - - template: display-github-context - - template: setup - steps: - - template: checkout - - template: setup-and-install-python - - template: quay-login - - template: set-up-qemu - - template: build-and-push-development-images - - template: single-test - steps: - - template: checkout - - template: setup-and-install-python - - template: setup-kind-cluster - - template: run-test-single - - template: dump-and-upload-diagnostics-always - -events: - - template: single-e2e-workflow-dispatch diff --git a/mongodb-community-operator/.action_templates/events/on-pull-request-master.yaml b/mongodb-community-operator/.action_templates/events/on-pull-request-master.yaml deleted file mode 100644 index 9107a3d91..000000000 --- a/mongodb-community-operator/.action_templates/events/on-pull-request-master.yaml +++ /dev/null @@ -1,5 +0,0 @@ -pull_request: - branches: - - master - paths-ignore: - - 'docs/**' diff --git a/mongodb-community-operator/.action_templates/events/on-push-master.yaml b/mongodb-community-operator/.action_templates/events/on-push-master.yaml deleted file mode 100644 index 844e045c3..000000000 --- a/mongodb-community-operator/.action_templates/events/on-push-master.yaml +++ /dev/null @@ -1,5 +0,0 @@ -push: - branches: - - master - paths-ignore: - - 'docs/**' diff --git a/mongodb-community-operator/.action_templates/events/pull-request-target.yaml b/mongodb-community-operator/.action_templates/events/pull-request-target.yaml deleted file mode 100644 index 1e7743cd8..000000000 --- a/mongodb-community-operator/.action_templates/events/pull-request-target.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# pull_request_target means that the secrets of this repo will be used. -pull_request_target: - types: [labeled] - branches: - - master - paths-ignore: - - 'docs/**' diff --git a/mongodb-community-operator/.action_templates/events/single-e2e-workflow-dispatch.yaml b/mongodb-community-operator/.action_templates/events/single-e2e-workflow-dispatch.yaml deleted file mode 100644 index 01cc9fcae..000000000 --- a/mongodb-community-operator/.action_templates/events/single-e2e-workflow-dispatch.yaml +++ /dev/null @@ -1,13 +0,0 @@ -workflow_dispatch: - inputs: - distro: - description: 'Distro to run test' - required: true - default: "ubuntu" - test-name: - description: 'Name of test to run' - required: true - cluster-wide: - description: 'Whether or not the test is cluster wide' - required: true - default: "false" diff --git a/mongodb-community-operator/.action_templates/events/workflow-dispatch.yaml b/mongodb-community-operator/.action_templates/events/workflow-dispatch.yaml deleted file mode 100644 index 5de950ef3..000000000 --- a/mongodb-community-operator/.action_templates/events/workflow-dispatch.yaml +++ /dev/null @@ -1 +0,0 @@ -workflow_dispatch: {} diff --git a/mongodb-community-operator/.action_templates/jobs/display-github-context.yaml b/mongodb-community-operator/.action_templates/jobs/display-github-context.yaml deleted file mode 100644 index 37ecb1972..000000000 --- a/mongodb-community-operator/.action_templates/jobs/display-github-context.yaml +++ /dev/null @@ -1,8 +0,0 @@ -action-context: - if: always() - runs-on: ubuntu-latest - steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJSON(github) }} - run: echo "$GITHUB_CONTEXT" diff --git a/mongodb-community-operator/.action_templates/jobs/setup.yaml b/mongodb-community-operator/.action_templates/jobs/setup.yaml deleted file mode 100644 index ad46dc26d..000000000 --- a/mongodb-community-operator/.action_templates/jobs/setup.yaml +++ /dev/null @@ -1,11 +0,0 @@ -setup: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - pipeline-argument: operator - - pipeline-argument: version-upgrade-hook - - pipeline-argument: readiness-probe - - pipeline-argument: agent - - pipeline-argument: e2e diff --git a/mongodb-community-operator/.action_templates/jobs/single-test.yaml b/mongodb-community-operator/.action_templates/jobs/single-test.yaml deleted file mode 100644 index b06a8a918..000000000 --- a/mongodb-community-operator/.action_templates/jobs/single-test.yaml +++ /dev/null @@ -1,3 +0,0 @@ -single-test: - runs-on: ubuntu-latest - needs: [setup] diff --git a/mongodb-community-operator/.action_templates/jobs/tests.yaml b/mongodb-community-operator/.action_templates/jobs/tests.yaml deleted file mode 100644 index f360ee3d6..000000000 --- a/mongodb-community-operator/.action_templates/jobs/tests.yaml +++ /dev/null @@ -1,68 +0,0 @@ -tests: - runs-on: ubuntu-latest - needs: [setup] - strategy: - fail-fast: false - matrix: - include: - - test-name: replica_set - distro: ubi - - test-name: replica_set_enterprise_upgrade_4_5 - distro: ubi - - test-name: replica_set_enterprise_upgrade_5_6 - distro: ubi - - test-name: replica_set_enterprise_upgrade_6_7 - distro: ubi - - test-name: replica_set_enterprise_upgrade_7_8 - distro: ubi - - test-name: replica_set_recovery - distro: ubi - - test-name: replica_set_mongod_readiness - distro: ubi - - test-name: replica_set_scale - distro: ubi - - test-name: replica_set_scale_down - distro: ubi - - test-name: replica_set_change_version - distro: ubi - - test-name: feature_compatibility_version - distro: ubi - - test-name: prometheus - distro: ubi - - test-name: replica_set_tls - distro: ubi - - test-name: replica_set_tls_recreate_mdbc - distro: ubi - - test-name: replica_set_tls_rotate - distro: ubi - - test-name: replica_set_tls_rotate_delete_sts - distro: ubi - - test-name: replica_set_tls_upgrade - distro: ubi - - test-name: statefulset_arbitrary_config - distro: ubi - - test-name: statefulset_arbitrary_config_update - distro: ubi - - test-name: replica_set_mongod_config - distro: ubi - - test-name: replica_set_cross_namespace_deploy - distro: ubi - cluster-wide: true - - test-name: replica_set_custom_role - distro: ubi - - test-name: replica_set_arbiter - distro: ubi - - test-name: replica_set_custom_persistent_volume - distro: ubi - - test-name: replica_set_mount_connection_string - distro: ubi - - test-name: replica_set_mongod_port_change_with_arbiters - distro: ubi - - test-name: replica_set_operator_upgrade - distro: ubi - - test-name: replica_set_connection_string_options - distro: ubi - - test-name: replica_set_x509 - distro: ubi - - test-name: replica_set_remove_user - distro: ubi diff --git a/mongodb-community-operator/.action_templates/steps/build-and-push-development-images.yaml b/mongodb-community-operator/.action_templates/steps/build-and-push-development-images.yaml deleted file mode 100644 index 4fe3df401..000000000 --- a/mongodb-community-operator/.action_templates/steps/build-and-push-development-images.yaml +++ /dev/null @@ -1,6 +0,0 @@ -- name: Build and Push Images - run: | - python pipeline.py --image-name ${{ matrix.pipeline-argument }} --tag ${{ github.run_id }} - env: - MONGODB_COMMUNITY_CONFIG: "${{ github.workspace }}/scripts/ci/config.json" - version_id: "${{ github.run_id }}" diff --git a/mongodb-community-operator/.action_templates/steps/cancel-previous.yaml b/mongodb-community-operator/.action_templates/steps/cancel-previous.yaml deleted file mode 100644 index 301d5af50..000000000 --- a/mongodb-community-operator/.action_templates/steps/cancel-previous.yaml +++ /dev/null @@ -1,4 +0,0 @@ -- name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} diff --git a/mongodb-community-operator/.action_templates/steps/checkout-fork.yaml b/mongodb-community-operator/.action_templates/steps/checkout-fork.yaml deleted file mode 100644 index abd35041c..000000000 --- a/mongodb-community-operator/.action_templates/steps/checkout-fork.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# We checkout the forked repository code. -# Because we are using pull_request_target the Github Secrets will be passed -# So code should be reviewed before labeling as "safe-to-test" -- name: Checkout Code - uses: actions/checkout@v4 - with: - ref: ${{github.event.pull_request.head.sha}} - repository: ${{github.event.pull_request.head.repo.full_name}} - submodules: true diff --git a/mongodb-community-operator/.action_templates/steps/checkout.yaml b/mongodb-community-operator/.action_templates/steps/checkout.yaml deleted file mode 100644 index da02fc2f3..000000000 --- a/mongodb-community-operator/.action_templates/steps/checkout.yaml +++ /dev/null @@ -1,4 +0,0 @@ -- name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: true diff --git a/mongodb-community-operator/.action_templates/steps/dump-and-upload-diagnostics-always.yaml b/mongodb-community-operator/.action_templates/steps/dump-and-upload-diagnostics-always.yaml deleted file mode 100644 index 968ecd9ce..000000000 --- a/mongodb-community-operator/.action_templates/steps/dump-and-upload-diagnostics-always.yaml +++ /dev/null @@ -1,12 +0,0 @@ -- name: Dump Diagnostics - if: always() - continue-on-error: true - run: scripts/ci/dump_diagnostics.sh default # default since kind is running in the default namespace - -- name: Upload Diagnostics - if: always() - uses: actions/upload-artifact@v4 - continue-on-error: true - with: - name: "${{ github.event.inputs.test-name }}-${{ github.event.inputs.distro }}-diagnostics" - path: "${{ github.workspace }}/diagnostics" diff --git a/mongodb-community-operator/.action_templates/steps/dump-and-upload-diagnostics.yaml b/mongodb-community-operator/.action_templates/steps/dump-and-upload-diagnostics.yaml deleted file mode 100644 index 17f5d2688..000000000 --- a/mongodb-community-operator/.action_templates/steps/dump-and-upload-diagnostics.yaml +++ /dev/null @@ -1,13 +0,0 @@ -- name: Dump Diagnostics - id: dump_diagnostics - if: always() && steps.e2e_test.outcome == 'failure' - continue-on-error: true - run: scripts/ci/dump_diagnostics.sh default # default since kind is running in the default namespace - -- name: Upload Diagnostics - if: always() && steps.dump_diagnostics.outcome == 'success' - uses: actions/upload-artifact@v4 - continue-on-error: true - with: - name: "${{ matrix.test-name }}-${{ matrix.distro }}-diagnostics" - path: "${{ github.workspace }}/diagnostics" diff --git a/mongodb-community-operator/.action_templates/steps/quay-login.yaml b/mongodb-community-operator/.action_templates/steps/quay-login.yaml deleted file mode 100644 index 77a8dd06f..000000000 --- a/mongodb-community-operator/.action_templates/steps/quay-login.yaml +++ /dev/null @@ -1,6 +0,0 @@ -- name: Login to Quay.io - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_ROBOT_TOKEN }} diff --git a/mongodb-community-operator/.action_templates/steps/run-test-matrix.yaml b/mongodb-community-operator/.action_templates/steps/run-test-matrix.yaml deleted file mode 100644 index 9c572a89c..000000000 --- a/mongodb-community-operator/.action_templates/steps/run-test-matrix.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- name: Run Test - id: e2e_test - if: steps.last_run_status.outputs.last_run_status != 'success' - run: | - cluster_wide=${{ matrix.cluster-wide }} - if [ -z "$cluster_wide" ]; then - cluster_wide="false" - fi - python3 ./scripts/dev/e2e.py --test ${{ matrix.test-name }} --tag ${{ github.run_id }} --config_file ./scripts/ci/config.json --distro ${{ matrix.distro }} --cluster-wide ${cluster_wide} diff --git a/mongodb-community-operator/.action_templates/steps/run-test-single.yaml b/mongodb-community-operator/.action_templates/steps/run-test-single.yaml deleted file mode 100644 index 453425961..000000000 --- a/mongodb-community-operator/.action_templates/steps/run-test-single.yaml +++ /dev/null @@ -1,3 +0,0 @@ -- name: Run Test Single - run: | - python3 ./scripts/dev/e2e.py --test ${{ github.event.inputs.test-name }} --tag ${{ github.run_id }} --config_file ./scripts/ci/config.json --distro ${{ github.event.inputs.distro }} --cluster-wide ${{ github.event.inputs.cluster-wide }} diff --git a/mongodb-community-operator/.action_templates/steps/save-run-status.yaml b/mongodb-community-operator/.action_templates/steps/save-run-status.yaml deleted file mode 100644 index 84845013b..000000000 --- a/mongodb-community-operator/.action_templates/steps/save-run-status.yaml +++ /dev/null @@ -1,3 +0,0 @@ -- name: Save run status - if: always() - run: echo "::set-output name=last_run_status::${{ steps.e2e_test.outcome }}" > last_run_status diff --git a/mongodb-community-operator/.action_templates/steps/set-run-status.yaml b/mongodb-community-operator/.action_templates/steps/set-run-status.yaml deleted file mode 100644 index 9f4a76541..000000000 --- a/mongodb-community-operator/.action_templates/steps/set-run-status.yaml +++ /dev/null @@ -1,17 +0,0 @@ -- name: Set default run status - run: echo "::set-output name=last_run_status::pending" > last_run_status - - # Tracking of the state of the previous test run is a workaround to the fact that it is not - # possible to re-run a single failed job, only re-running the entire workflow is currently possible. - # This workaround skips jobs if they have already passed. - # see https://github.com/actions/runner/issues/432 -- name: Restore last run status - id: last_run - uses: actions/cache@v4 - with: - path: last_run_status - key: ${{ github.run_id }}-${{ matrix.test-name }}-${{ matrix.distro }} - -- name: Set last run status - id: last_run_status - run: cat last_run_status diff --git a/mongodb-community-operator/.action_templates/steps/set-up-qemu.yaml b/mongodb-community-operator/.action_templates/steps/set-up-qemu.yaml deleted file mode 100644 index c84384bfc..000000000 --- a/mongodb-community-operator/.action_templates/steps/set-up-qemu.yaml +++ /dev/null @@ -1,2 +0,0 @@ -- name: Set up QEMU - uses: docker/setup-qemu-action@v3 diff --git a/mongodb-community-operator/.action_templates/steps/setup-and-install-python.yaml b/mongodb-community-operator/.action_templates/steps/setup-and-install-python.yaml deleted file mode 100644 index b924e01ae..000000000 --- a/mongodb-community-operator/.action_templates/steps/setup-and-install-python.yaml +++ /dev/null @@ -1,11 +0,0 @@ -- name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.10.4' -- name: Cache Dependencies - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ hashFiles('requirements.txt') }} -- name: Install Python Dependencies - run: pip install -r requirements.txt diff --git a/mongodb-community-operator/.action_templates/steps/setup-kind-cluster.yaml b/mongodb-community-operator/.action_templates/steps/setup-kind-cluster.yaml deleted file mode 100644 index b17558382..000000000 --- a/mongodb-community-operator/.action_templates/steps/setup-kind-cluster.yaml +++ /dev/null @@ -1,11 +0,0 @@ -- name: Setup Kind Cluster - run: | - curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64 - chmod +x ./kind - ./kind create cluster -- name: Create Directories - run: | - docker exec kind-control-plane mkdir -p /opt/data/mongo-data-0 /opt/data/mongo-data-1 /opt/data/mongo-data-2 /opt/data/mongo-logs-0 /opt/data/mongo-logs-1 /opt/data/mongo-logs-2 - -- name: Install CRD - run: kubectl apply -f config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml diff --git a/mongodb-community-operator/.github/CODEOWNERS b/mongodb-community-operator/.github/CODEOWNERS deleted file mode 100644 index db61cf612..000000000 --- a/mongodb-community-operator/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @mircea-cosbuc @lsierant @nammn @Julien-Ben @MaciejKaras @lucian-tosa @fealebenpae @m1kola \ No newline at end of file diff --git a/mongodb-community-operator/.github/PULL_REQUEST_TEMPLATE.md b/mongodb-community-operator/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 650880d32..000000000 --- a/mongodb-community-operator/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,15 +0,0 @@ -### Summary: - - -### All Submissions: - -* [ ] Have you opened an Issue before filing this PR? -* [ ] Have you signed our [CLA](https://www.mongodb.com/legal/contributor-agreement)? -* [ ] Have you checked to ensure there aren't other open [Pull Requests](../../../pulls) for the same update/change? -* [ ] Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such). diff --git a/mongodb-community-operator/.github/config_files/config_lint.yaml b/mongodb-community-operator/.github/config_files/config_lint.yaml deleted file mode 100644 index 435bc8a7b..000000000 --- a/mongodb-community-operator/.github/config_files/config_lint.yaml +++ /dev/null @@ -1,14 +0,0 @@ -checks: - addAllBuiltIn: true - -#Reasons to exclude: - # non-existent-service-account because the service account is created in another file - # minimum-three-replicas because the deployment contains only 1 replica of the operator - # no-readiness-probe & no-liveness-probe because for now, it brings nothing to add these probes - # because they will not check whether the operator is actually ready/living - exclude: - - "non-existent-service-account" - - "minimum-three-replicas" - - "no-liveness-probe" - - "no-readiness-probe" - - "use-namespace" diff --git a/mongodb-community-operator/.github/config_files/config_lint_clusterwide.yaml b/mongodb-community-operator/.github/config_files/config_lint_clusterwide.yaml deleted file mode 100644 index b69b5147d..000000000 --- a/mongodb-community-operator/.github/config_files/config_lint_clusterwide.yaml +++ /dev/null @@ -1,18 +0,0 @@ -checks: - addAllBuiltIn: true - -#Reasons to exclude: - # non-existent-service-account because the service account is created in another file - # minimum-three-replicas because the deployment contains only 1 replica of the operator - # no-readiness-probe & no-liveness-probe because for now, it brings nothing to add these probes - # because they will not check whether the operator is actually ready/living. - # When using a clusterwide operator, it is required to be able to create StatefulSets and Secrets - # so we exclude "access-to-secrets" and "access-to-create-pods" - exclude: - - "non-existent-service-account" - - "minimum-three-replicas" - - "no-liveness-probe" - - "no-readiness-probe" - - "use-namespace" - - "access-to-secrets" - - "access-to-create-pods" diff --git a/mongodb-community-operator/.github/config_files/config_lint_openshift.yaml b/mongodb-community-operator/.github/config_files/config_lint_openshift.yaml deleted file mode 100644 index 34ff6e440..000000000 --- a/mongodb-community-operator/.github/config_files/config_lint_openshift.yaml +++ /dev/null @@ -1,17 +0,0 @@ -checks: - addAllBuiltIn: true - - #Reasons to exclude - # non-existent-service-account because the service account is created in another file - # minimum-three-replicas because the deployment contains only 1 replica of the operator - # no-readiness-probe & no-liveness-probe because for now it brings nothing to add theses probes - # because they will not check whether the operator is actually ready/living - # run-as-non-root & no-read-only-root-fs because the security is managed somewhere else - exclude: - - "non-existent-service-account" - - "minimum-three-replicas" - - "no-liveness-probe" - - "no-readiness-probe" - - "run-as-non-root" - - "no-read-only-root-fs" - - "use-namespace" diff --git a/mongodb-community-operator/.github/dependabot.yml b/mongodb-community-operator/.github/dependabot.yml deleted file mode 100644 index eb3084c66..000000000 --- a/mongodb-community-operator/.github/dependabot.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: 2 -updates: - - package-ecosystem: gomod - directory: "/" - schedule: - interval: weekly - day: monday - ignore: - - dependency-name: k8s.io/api - - dependency-name: k8s.io/apimachinery - - dependency-name: k8s.io/client-go - - dependency-name: k8s.io/code-generator - - dependency-name: sigs.k8s.io/controller-runtime - - package-ecosystem: pip - directory: "/" - schedule: - interval: weekly - day: monday diff --git a/mongodb-community-operator/.github/workflows/close-stale-issues.yml b/mongodb-community-operator/.github/workflows/close-stale-issues.yml deleted file mode 100644 index 942020dbd..000000000 --- a/mongodb-community-operator/.github/workflows/close-stale-issues.yml +++ /dev/null @@ -1,25 +0,0 @@ -# -# Docs: https://github.com/marketplace/actions/close-stale-issues -# -name: Close Stale Issues -on: - schedule: - - cron: '30 1 * * *' - -jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v9 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'This issue is being marked stale because it has been open for 60 days with no activity. Please comment if this issue is still affecting you. If there is no change, this issue will be closed in 30 days.' - stale-pr-message: 'This PR is being marked stale because it has been open for 60 days with no activity. Please update the PR or ask for a fresh review.' - close-issue-message: 'This issue was closed because it became stale and did not receive further updates. If the issue is still affecting you, please re-open it, or file a fresh Issue with updated information.' - - days-before-stale: 60 - days-before-close: 30 - days-before-pr-close: -1 # never close PRs - - exempt-issue-labels: 'bug,feature-request' - ascending: true diff --git a/mongodb-community-operator/.github/workflows/code-health.yml b/mongodb-community-operator/.github/workflows/code-health.yml deleted file mode 100644 index 345941c18..000000000 --- a/mongodb-community-operator/.github/workflows/code-health.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Code Health - -on: - pull_request: - branches: [ master ] -jobs: - Black: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Black Check - uses: jpetrucciani/black-check@7f5b2ad20fa5484f1884f07c1937e032ed8cd939 - - Mypy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Mypy linting - uses: jpetrucciani/mypy-check@179fdad632bf3ccf4cabb7ee4307ef25e51d2f96 - with: - path: scripts/*/*.py - - Golangci-lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: stable - - name: golangci-lint - uses: golangci/golangci-lint-action@v6 diff --git a/mongodb-community-operator/.github/workflows/comment-release-pr.yml b/mongodb-community-operator/.github/workflows/comment-release-pr.yml deleted file mode 100644 index 3944aa660..000000000 --- a/mongodb-community-operator/.github/workflows/comment-release-pr.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Link Github Releases -on: - pull_request: - types: [closed] - -jobs: - comment: - # only link releases on release PRs - if: startsWith(github.event.pull_request.title, 'Release MongoDB Kubernetes Operator') - runs-on: ubuntu-latest - steps: - - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: 'Review and publish the release here: https://github.com/mongodb/mongodb-kubernetes-operator/releases' - }) diff --git a/mongodb-community-operator/.github/workflows/e2e-dispatch.yml b/mongodb-community-operator/.github/workflows/e2e-dispatch.yml deleted file mode 100644 index b3522124d..000000000 --- a/mongodb-community-operator/.github/workflows/e2e-dispatch.yml +++ /dev/null @@ -1,134 +0,0 @@ - -################################################################################## -# -# This file is automatically generated using templates. Changes to this file -# should happen through editing the templates under .action_templates/* -# Manual edits will be overwritten. -# -################################################################################## - -name: Run Single E2E -on: - # template: .action_templates/events/single-e2e-workflow-dispatch.yaml - workflow_dispatch: - inputs: - distro: - description: Distro to run test - required: true - default: ubuntu - test-name: - description: Name of test to run - required: true - cluster-wide: - description: Whether or not the test is cluster wide - required: true - default: 'false' -jobs: - # template: .action_templates/jobs/display-github-context.yaml - action-context: - if: always() - runs-on: ubuntu-latest - steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJSON(github) }} - run: echo "$GITHUB_CONTEXT" - # template: .action_templates/jobs/setup.yaml - setup: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - pipeline-argument: operator - - pipeline-argument: version-upgrade-hook - - pipeline-argument: readiness-probe - - pipeline-argument: agent - - pipeline-argument: e2e - steps: - # template: .action_templates/steps/checkout.yaml - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: true - # template: .action_templates/steps/setup-and-install-python.yaml - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: 3.10.4 - - name: Cache Dependencies - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ hashFiles('requirements.txt') }} - - name: Install Python Dependencies - run: pip install -r requirements.txt - # template: .action_templates/steps/quay-login.yaml - - name: Login to Quay.io - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_ROBOT_TOKEN }} - # template: .action_templates/steps/set-up-qemu.yaml - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - # template: .action_templates/steps/build-and-push-development-images.yaml - - name: Build and Push Images - run: | - python pipeline.py --image-name ${{ matrix.pipeline-argument }} --tag ${{ github.run_id }} - env: - MONGODB_COMMUNITY_CONFIG: ${{ github.workspace }}/scripts/ci/config.json - version_id: ${{ github.run_id }} - # template: .action_templates/jobs/single-test.yaml - single-test: - runs-on: ubuntu-latest - needs: [setup] - steps: - # template: .action_templates/steps/checkout.yaml - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: true - # template: .action_templates/steps/setup-and-install-python.yaml - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: 3.10.4 - - name: Cache Dependencies - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ hashFiles('requirements.txt') }} - - name: Install Python Dependencies - run: pip install -r requirements.txt - # template: .action_templates/steps/setup-kind-cluster.yaml - - name: Setup Kind Cluster - run: | - curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64 - chmod +x ./kind - ./kind create cluster - - name: Create Directories - run: | - docker exec kind-control-plane mkdir -p /opt/data/mongo-data-0 /opt/data/mongo-data-1 /opt/data/mongo-data-2 /opt/data/mongo-logs-0 /opt/data/mongo-logs-1 /opt/data/mongo-logs-2 - - - name: Install CRD - run: kubectl apply -f config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml - # template: .action_templates/steps/run-test-single.yaml - - name: Run Test Single - run: | - python3 ./scripts/dev/e2e.py --test ${{ github.event.inputs.test-name }} --tag ${{ github.run_id }} --config_file ./scripts/ci/config.json --distro ${{ github.event.inputs.distro }} --cluster-wide ${{ github.event.inputs.cluster-wide }} - # template: .action_templates/steps/dump-and-upload-diagnostics-always.yaml - - name: Dump Diagnostics - if: always() - continue-on-error: true - run: scripts/ci/dump_diagnostics.sh default # default since kind is running in the default namespace - - - name: Upload Diagnostics - if: always() - uses: actions/upload-artifact@v4 - continue-on-error: true - with: - name: ${{ github.event.inputs.test-name }}-${{ github.event.inputs.distro - }}-diagnostics - path: ${{ github.workspace }}/diagnostics diff --git a/mongodb-community-operator/.github/workflows/e2e-fork.yml b/mongodb-community-operator/.github/workflows/e2e-fork.yml deleted file mode 100644 index a5c3ae53e..000000000 --- a/mongodb-community-operator/.github/workflows/e2e-fork.yml +++ /dev/null @@ -1,240 +0,0 @@ - -################################################################################## -# -# This file is automatically generated using templates. Changes to this file -# should happen through editing the templates under .action_templates/* -# Manual edits will be overwritten. -# -################################################################################## - -name: Run E2E Fork -on: - # template: .action_templates/events/pull-request-target.yaml - pull_request_target: - types: [labeled] - branches: - - master - paths-ignore: - - docs/** -jobs: - # template: .action_templates/jobs/display-github-context.yaml - action-context: - if: always() - runs-on: ubuntu-latest - steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJSON(github) }} - run: echo "$GITHUB_CONTEXT" - # template: .action_templates/jobs/setup.yaml - setup: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - pipeline-argument: operator - - pipeline-argument: version-upgrade-hook - - pipeline-argument: readiness-probe - - pipeline-argument: agent - - pipeline-argument: e2e - if: contains(github.event.pull_request.labels.*.name, 'dependencies') || contains(github.event.pull_request.labels.*.name, - 'safe-to-test') - steps: - # template: .action_templates/steps/cancel-previous.yaml - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - # template: .action_templates/steps/checkout-fork.yaml - - name: Checkout Code - uses: actions/checkout@v4 - with: - ref: ${{github.event.pull_request.head.sha}} - repository: ${{github.event.pull_request.head.repo.full_name}} - submodules: true - # template: .action_templates/steps/setup-and-install-python.yaml - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: 3.10.4 - - name: Cache Dependencies - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ hashFiles('requirements.txt') }} - - name: Install Python Dependencies - run: pip install -r requirements.txt - # template: .action_templates/steps/quay-login.yaml - - name: Login to Quay.io - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_ROBOT_TOKEN }} - # template: .action_templates/steps/set-up-qemu.yaml - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - # template: .action_templates/steps/build-and-push-development-images.yaml - - name: Build and Push Images - run: | - python pipeline.py --image-name ${{ matrix.pipeline-argument }} --tag ${{ github.run_id }} - env: - MONGODB_COMMUNITY_CONFIG: ${{ github.workspace }}/scripts/ci/config.json - version_id: ${{ github.run_id }} - # template: .action_templates/jobs/tests.yaml - tests: - runs-on: ubuntu-latest - needs: [setup] - strategy: - fail-fast: false - matrix: - include: - - test-name: replica_set - distro: ubi - - test-name: replica_set_enterprise_upgrade_4_5 - distro: ubi - - test-name: replica_set_enterprise_upgrade_5_6 - distro: ubi - - test-name: replica_set_enterprise_upgrade_6_7 - distro: ubi - - test-name: replica_set_enterprise_upgrade_7_8 - distro: ubi - - test-name: replica_set_recovery - distro: ubi - - test-name: replica_set_mongod_readiness - distro: ubi - - test-name: replica_set_scale - distro: ubi - - test-name: replica_set_scale_down - distro: ubi - - test-name: replica_set_change_version - distro: ubi - - test-name: feature_compatibility_version - distro: ubi - - test-name: prometheus - distro: ubi - - test-name: replica_set_tls - distro: ubi - - test-name: replica_set_tls_recreate_mdbc - distro: ubi - - test-name: replica_set_tls_rotate - distro: ubi - - test-name: replica_set_tls_rotate_delete_sts - distro: ubi - - test-name: replica_set_tls_upgrade - distro: ubi - - test-name: statefulset_arbitrary_config - distro: ubi - - test-name: statefulset_arbitrary_config_update - distro: ubi - - test-name: replica_set_mongod_config - distro: ubi - - test-name: replica_set_cross_namespace_deploy - distro: ubi - cluster-wide: true - - test-name: replica_set_custom_role - distro: ubi - - test-name: replica_set_arbiter - distro: ubi - - test-name: replica_set_custom_persistent_volume - distro: ubi - - test-name: replica_set_mount_connection_string - distro: ubi - - test-name: replica_set_mongod_port_change_with_arbiters - distro: ubi - - test-name: replica_set_operator_upgrade - distro: ubi - - test-name: replica_set_connection_string_options - distro: ubi - - test-name: replica_set_x509 - distro: ubi - - test-name: replica_set_remove_user - distro: ubi - steps: - # template: .action_templates/steps/cancel-previous.yaml - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - # template: .action_templates/steps/checkout-fork.yaml - - name: Checkout Code - uses: actions/checkout@v4 - with: - ref: ${{github.event.pull_request.head.sha}} - repository: ${{github.event.pull_request.head.repo.full_name}} - submodules: true - # template: .action_templates/steps/set-run-status.yaml - - name: Set default run status - run: echo "::set-output name=last_run_status::pending" > last_run_status - - # Tracking of the state of the previous test run is a workaround to the fact that it is not - # possible to re-run a single failed job, only re-running the entire workflow is currently possible. - # This workaround skips jobs if they have already passed. - # see https://github.com/actions/runner/issues/432 - - name: Restore last run status - id: last_run - uses: actions/cache@v4 - with: - path: last_run_status - key: ${{ github.run_id }}-${{ matrix.test-name }}-${{ matrix.distro }} - - - name: Set last run status - id: last_run_status - run: cat last_run_status - # template: .action_templates/steps/setup-and-install-python.yaml - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: 3.10.4 - - name: Cache Dependencies - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ hashFiles('requirements.txt') }} - - name: Install Python Dependencies - run: pip install -r requirements.txt - # template: .action_templates/steps/setup-kind-cluster.yaml - - name: Setup Kind Cluster - run: | - curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64 - chmod +x ./kind - ./kind create cluster - if: steps.last_run_status.outputs.last_run_status != 'success' - - name: Create Directories - run: | - docker exec kind-control-plane mkdir -p /opt/data/mongo-data-0 /opt/data/mongo-data-1 /opt/data/mongo-data-2 /opt/data/mongo-logs-0 /opt/data/mongo-logs-1 /opt/data/mongo-logs-2 - - if: steps.last_run_status.outputs.last_run_status != 'success' - - name: Install CRD - run: kubectl apply -f config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml - if: steps.last_run_status.outputs.last_run_status != 'success' - # template: .action_templates/steps/run-test-matrix.yaml - - name: Run Test - id: e2e_test - if: steps.last_run_status.outputs.last_run_status != 'success' - run: | - cluster_wide=${{ matrix.cluster-wide }} - if [ -z "$cluster_wide" ]; then - cluster_wide="false" - fi - python3 ./scripts/dev/e2e.py --test ${{ matrix.test-name }} --tag ${{ github.run_id }} --config_file ./scripts/ci/config.json --distro ${{ matrix.distro }} --cluster-wide ${cluster_wide} - # template: .action_templates/steps/save-run-status.yaml - - name: Save run status - if: always() - run: echo "::set-output name=last_run_status::${{ steps.e2e_test.outcome }}" - > last_run_status - # template: .action_templates/steps/dump-and-upload-diagnostics.yaml - - name: Dump Diagnostics - id: dump_diagnostics - if: always() && steps.e2e_test.outcome == 'failure' - continue-on-error: true - run: scripts/ci/dump_diagnostics.sh default # default since kind is running in the default namespace - - - name: Upload Diagnostics - if: always() && steps.dump_diagnostics.outcome == 'success' - uses: actions/upload-artifact@v4 - continue-on-error: true - with: - name: ${{ matrix.test-name }}-${{ matrix.distro }}-diagnostics - path: ${{ github.workspace }}/diagnostics diff --git a/mongodb-community-operator/.github/workflows/e2e.yml b/mongodb-community-operator/.github/workflows/e2e.yml deleted file mode 100644 index 8501431b6..000000000 --- a/mongodb-community-operator/.github/workflows/e2e.yml +++ /dev/null @@ -1,244 +0,0 @@ - -################################################################################## -# -# This file is automatically generated using templates. Changes to this file -# should happen through editing the templates under .action_templates/* -# Manual edits will be overwritten. -# -################################################################################## - -name: Run E2E -on: - # template: .action_templates/events/on-pull-request-master.yaml - pull_request: - branches: - - master - paths-ignore: - - docs/** - # template: .action_templates/events/on-push-master.yaml - push: - branches: - - master - paths-ignore: - - docs/** - # template: .action_templates/events/workflow-dispatch.yaml - workflow_dispatch: {} -jobs: - # template: .action_templates/jobs/display-github-context.yaml - action-context: - if: always() - runs-on: ubuntu-latest - steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJSON(github) }} - run: echo "$GITHUB_CONTEXT" - # template: .action_templates/jobs/setup.yaml - setup: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - pipeline-argument: operator - - pipeline-argument: version-upgrade-hook - - pipeline-argument: readiness-probe - - pipeline-argument: agent - - pipeline-argument: e2e - if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' - || (github.event.pull_request.head.repo.full_name == github.repository && github.actor - != 'dependabot[bot]') - steps: - # template: .action_templates/steps/cancel-previous.yaml - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - # template: .action_templates/steps/checkout.yaml - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: true - # template: .action_templates/steps/setup-and-install-python.yaml - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: 3.10.4 - - name: Cache Dependencies - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ hashFiles('requirements.txt') }} - - name: Install Python Dependencies - run: pip install -r requirements.txt - # template: .action_templates/steps/quay-login.yaml - - name: Login to Quay.io - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_ROBOT_TOKEN }} - # template: .action_templates/steps/set-up-qemu.yaml - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - # template: .action_templates/steps/build-and-push-development-images.yaml - - name: Build and Push Images - run: | - python pipeline.py --image-name ${{ matrix.pipeline-argument }} --tag ${{ github.run_id }} - env: - MONGODB_COMMUNITY_CONFIG: ${{ github.workspace }}/scripts/ci/config.json - version_id: ${{ github.run_id }} - # template: .action_templates/jobs/tests.yaml - tests: - runs-on: ubuntu-latest - needs: [setup] - strategy: - fail-fast: false - matrix: - include: - - test-name: replica_set - distro: ubi - - test-name: replica_set_enterprise_upgrade_4_5 - distro: ubi - - test-name: replica_set_enterprise_upgrade_5_6 - distro: ubi - - test-name: replica_set_enterprise_upgrade_6_7 - distro: ubi - - test-name: replica_set_enterprise_upgrade_7_8 - distro: ubi - - test-name: replica_set_recovery - distro: ubi - - test-name: replica_set_mongod_readiness - distro: ubi - - test-name: replica_set_scale - distro: ubi - - test-name: replica_set_scale_down - distro: ubi - - test-name: replica_set_change_version - distro: ubi - - test-name: feature_compatibility_version - distro: ubi - - test-name: prometheus - distro: ubi - - test-name: replica_set_tls - distro: ubi - - test-name: replica_set_tls_recreate_mdbc - distro: ubi - - test-name: replica_set_tls_rotate - distro: ubi - - test-name: replica_set_tls_rotate_delete_sts - distro: ubi - - test-name: replica_set_tls_upgrade - distro: ubi - - test-name: statefulset_arbitrary_config - distro: ubi - - test-name: statefulset_arbitrary_config_update - distro: ubi - - test-name: replica_set_mongod_config - distro: ubi - - test-name: replica_set_cross_namespace_deploy - distro: ubi - cluster-wide: true - - test-name: replica_set_custom_role - distro: ubi - - test-name: replica_set_arbiter - distro: ubi - - test-name: replica_set_custom_persistent_volume - distro: ubi - - test-name: replica_set_mount_connection_string - distro: ubi - - test-name: replica_set_mongod_port_change_with_arbiters - distro: ubi - - test-name: replica_set_operator_upgrade - distro: ubi - - test-name: replica_set_connection_string_options - distro: ubi - - test-name: replica_set_x509 - distro: ubi - - test-name: replica_set_remove_user - distro: ubi - steps: - # template: .action_templates/steps/cancel-previous.yaml - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - # template: .action_templates/steps/checkout.yaml - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: true - # template: .action_templates/steps/set-run-status.yaml - - name: Set default run status - run: echo "::set-output name=last_run_status::pending" > last_run_status - - # Tracking of the state of the previous test run is a workaround to the fact that it is not - # possible to re-run a single failed job, only re-running the entire workflow is currently possible. - # This workaround skips jobs if they have already passed. - # see https://github.com/actions/runner/issues/432 - - name: Restore last run status - id: last_run - uses: actions/cache@v4 - with: - path: last_run_status - key: ${{ github.run_id }}-${{ matrix.test-name }}-${{ matrix.distro }} - - - name: Set last run status - id: last_run_status - run: cat last_run_status - # template: .action_templates/steps/setup-and-install-python.yaml - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: 3.10.4 - - name: Cache Dependencies - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ hashFiles('requirements.txt') }} - - name: Install Python Dependencies - run: pip install -r requirements.txt - # template: .action_templates/steps/setup-kind-cluster.yaml - - name: Setup Kind Cluster - run: | - curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64 - chmod +x ./kind - ./kind create cluster - if: steps.last_run_status.outputs.last_run_status != 'success' - - name: Create Directories - run: | - docker exec kind-control-plane mkdir -p /opt/data/mongo-data-0 /opt/data/mongo-data-1 /opt/data/mongo-data-2 /opt/data/mongo-logs-0 /opt/data/mongo-logs-1 /opt/data/mongo-logs-2 - - if: steps.last_run_status.outputs.last_run_status != 'success' - - name: Install CRD - run: kubectl apply -f config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml - if: steps.last_run_status.outputs.last_run_status != 'success' - # template: .action_templates/steps/run-test-matrix.yaml - - name: Run Test - id: e2e_test - if: steps.last_run_status.outputs.last_run_status != 'success' - run: | - cluster_wide=${{ matrix.cluster-wide }} - if [ -z "$cluster_wide" ]; then - cluster_wide="false" - fi - python3 ./scripts/dev/e2e.py --test ${{ matrix.test-name }} --tag ${{ github.run_id }} --config_file ./scripts/ci/config.json --distro ${{ matrix.distro }} --cluster-wide ${cluster_wide} - # template: .action_templates/steps/save-run-status.yaml - - name: Save run status - if: always() - run: echo "::set-output name=last_run_status::${{ steps.e2e_test.outcome }}" - > last_run_status - # template: .action_templates/steps/dump-and-upload-diagnostics.yaml - - name: Dump Diagnostics - id: dump_diagnostics - if: always() && steps.e2e_test.outcome == 'failure' - continue-on-error: true - run: scripts/ci/dump_diagnostics.sh default # default since kind is running in the default namespace - - - name: Upload Diagnostics - if: always() && steps.dump_diagnostics.outcome == 'success' - uses: actions/upload-artifact@v4 - continue-on-error: true - with: - name: ${{ matrix.test-name }}-${{ matrix.distro }}-diagnostics - path: ${{ github.workspace }}/diagnostics diff --git a/mongodb-community-operator/.github/workflows/go.yml b/mongodb-community-operator/.github/workflows/go.yml deleted file mode 100644 index ecce33378..000000000 --- a/mongodb-community-operator/.github/workflows/go.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Go - -on: - pull_request: - branches: [master] - -jobs: - - UnitTests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.24' - - - name: Test api - run: go test -v ./api/... - - - name: Test cmd - run: go test -v ./cmd/... - - - name: Test controllers - run: go test -v ./controllers/... - - - name: Test pkg - run: go test -v ./pkg/... - - - name: Test mongotester - run: go test -v ./test/e2e/util/mongotester/... - - - name: Check licenses - run: make check-licenses diff --git a/mongodb-community-operator/.github/workflows/kubelinter-check.yml b/mongodb-community-operator/.github/workflows/kubelinter-check.yml deleted file mode 100644 index 2fcb5b725..000000000 --- a/mongodb-community-operator/.github/workflows/kubelinter-check.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Kubelinter-check - -on: - push: - branches: - - master - paths-ignore: - - docs/** - pull_request: - branches: - - master - workflow_dispatch: {} - -jobs: - Kubelinter-check: - name: Run Kube-linter check - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Scan directory ./deploy/clusterwide/ with kube-linter - uses: stackrox/kube-linter-action@v1.0.3 - with: - directory: deploy/clusterwide - config: ${GITHUB_WORKSPACE}/.github/config_files/config_lint_clusterwide.yaml - version: "48442350" # Note: This is the id for release 0.2.3 returned from api.github.com/repos/stackrox/kube-linter/releases - - - name: Scan directory ./deploy/openshift/ with kube-linter - uses: stackrox/kube-linter-action@v1.0.3 - with: - directory: deploy/openshift - config: ${GITHUB_WORKSPACE}/.github/config_files/config_lint_openshift.yaml - version: "48442350" - - - name: Scan directory ./config/manager/ with kube-linter - uses: stackrox/kube-linter-action@v1.0.3 - with: - directory: config/manager/manager.yaml - config: ${GITHUB_WORKSPACE}/.github/config_files/config_lint.yaml - version: "48442350" - - - name: Scan directory ./config/samples/ with kube-linter - uses: stackrox/kube-linter-action@v1.0.3 - with: - directory: config/samples - config: ${GITHUB_WORKSPACE}/.github/config_files/config_lint.yaml - version: "48442350" diff --git a/mongodb-community-operator/.github/workflows/main.yaml b/mongodb-community-operator/.github/workflows/main.yaml deleted file mode 100644 index 3442f28df..000000000 --- a/mongodb-community-operator/.github/workflows/main.yaml +++ /dev/null @@ -1,53 +0,0 @@ ---- -########################### -########################### -## Linter GitHub Actions ## -########################### -########################### -name: Lint Code Base - -# -# Documentation: -# https://help.github.com/en/articles/workflow-syntax-for-github-actions -# - -############################# -# Start the job on all push # -############################# -on: - pull_request: - branches: [master] - -############### -# Set the Job # -############### -jobs: - build: - # Name the Job - name: Lint Code Base - # Set the agent to run on - runs-on: ubuntu-latest - - ################## - # Load all steps # - ################## - steps: - ########################## - # Checkout the code base # - ########################## - - name: Checkout Code - uses: actions/checkout@v4 - with: - # Make sure we also get the helm-charts submodule! - submodules: true - - - name: Install missing python packages - run: sudo apt-get install -y --no-install-recommends python3-venv python3-setuptools - - - name: Install dependencies with pip + requirements.txt - run: | - python3 -m venv .venv - .venv/bin/pip install -r requirements.txt - - - name: Move the dependencies - run: mv .venv /home/runner/work/_temp/_github_workflow diff --git a/mongodb-community-operator/.github/workflows/release-images.yml b/mongodb-community-operator/.github/workflows/release-images.yml deleted file mode 100644 index 5ced57eae..000000000 --- a/mongodb-community-operator/.github/workflows/release-images.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: Release Images - -on: - pull_request_review: - types: [submitted] - workflow_dispatch: - -jobs: - release-images: - runs-on: ubuntu-latest - if: startsWith(github.event.pull_request.title, 'Release MongoDB Kubernetes Operator') && github.event.review.state == 'approved' - strategy: - matrix: - include: - - pipeline-argument: operator - release-key: operator - - pipeline-argument: version-upgrade-hook - release-key: version-upgrade-hook - - pipeline-argument: readiness-probe - release-key: readiness-probe - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.10.4' - architecture: 'x64' - - - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ hashFiles('requirements.txt') }} - - - name: Install Python Dependencies - run: pip install -r requirements.txt - - name: Determine if release is needed - id: release_status - run: | - OUTPUT=$(scripts/ci/determine_required_releases.py ${{ matrix.release-key }}) - echo "::set-output name=OUTPUT::$OUTPUT" - - - name: Login to Quay.io - uses: docker/login-action@v1 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_ROBOT_TOKEN }} - - # template: .action_templates/steps/set-up-qemu.yaml - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Publish Image To Quay - if: steps.release_status.outputs.OUTPUT == 'unreleased' - run: python pipeline.py --image-name ${{ matrix.pipeline-argument }} --release --sign - env: - MONGODB_COMMUNITY_CONFIG: "${{ github.workspace }}/scripts/ci/config.json" - AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" - AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" - GRS_USERNAME: "${{ vars.GRS_USERNAME }}" - GRS_PASSWORD: "${{ secrets.GRS_PASSWORD }}" - PKCS11_URI: "${{ vars.PKCS11_URI }}" - ARTIFACTORY_USERNAME: "${{ vars.ARTIFACTORY_USERNAME }}" - ARTIFACTORY_PASSWORD: "${{ secrets.ARTIFACTORY_PASSWORD }}" - AWS_DEFAULT_REGION: "${{ vars.AWS_DEFAULT_REGION }}" - - create-draft-release: - runs-on: ubuntu-latest - needs: [release-images] - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - name: Determine Release Tag - id: release_tag - run: | - OUTPUT=$(jq -r '."mongodb-kubernetes-operator"' < $GITHUB_WORKSPACE/release.json) - echo "::set-output name=OUTPUT::$OUTPUT" - - name: Create Github Release - uses: ncipollo/release-action@v1 - with: - tag: "v${{ steps.release_tag.outputs.OUTPUT }}" - name: MongoDB Kubernetes Operator - bodyFile: "${{ github.workspace }}/docs/RELEASE_NOTES.md" - draft: true - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/mongodb-community-operator/.github/workflows/release-single-image.yml b/mongodb-community-operator/.github/workflows/release-single-image.yml deleted file mode 100644 index 162454391..000000000 --- a/mongodb-community-operator/.github/workflows/release-single-image.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Release Single Image -on: - workflow_dispatch: - inputs: - pipeline-argument: - description: 'Argument to pass to pipeline' - required: true - release-key: - description: 'Corresponding release.json key' - required: true -jobs: - release-single-image: - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.10.4' - architecture: 'x64' - - - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ hashFiles('requirements.txt') }} - - - name: Install Python Dependencies - run: pip install -r requirements.txt - - name: Determine if release is needed - id: release_status - run: | - OUTPUT=$(scripts/ci/determine_required_releases.py ${{ github.event.inputs.release-key }}) - echo "::set-output name=OUTPUT::$OUTPUT" - - - name: Login to Quay.io - uses: docker/login-action@v1 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_ROBOT_TOKEN }} - - # template: .action_templates/steps/set-up-qemu.yaml - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Publish Image To Quay - if: steps.release_status.outputs.OUTPUT == 'unreleased' - run: python pipeline.py --image-name ${{ github.event.inputs.pipeline-argument }} --release --sign - env: - MONGODB_COMMUNITY_CONFIG: "${{ github.workspace }}/scripts/ci/config.json" - AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" - AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" - GRS_USERNAME: "${{ vars.GRS_USERNAME }}" - GRS_PASSWORD: "${{ secrets.GRS_PASSWORD }}" - PKCS11_URI: "${{ vars.PKCS11_URI }}" - ARTIFACTORY_USERNAME: "${{ vars.ARTIFACTORY_USERNAME }}" - ARTIFACTORY_PASSWORD: "${{ secrets.ARTIFACTORY_PASSWORD }}" diff --git a/mongodb-community-operator/.github/workflows/remove-label.yml b/mongodb-community-operator/.github/workflows/remove-label.yml deleted file mode 100644 index 60316ff49..000000000 --- a/mongodb-community-operator/.github/workflows/remove-label.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Remove Label -on: [ pull_request ] -jobs: - remove-safe-to-test-label: - runs-on: ubuntu-latest - name: Remove Label - steps: - - name: - uses: buildsville/add-remove-label@v1 - with: - token: ${{secrets.GITHUB_TOKEN}} - label: safe-to-test - type: remove diff --git a/mongodb-community-operator/.gitignore b/mongodb-community-operator/.gitignore index 0229263df..6e988ca8a 100644 --- a/mongodb-community-operator/.gitignore +++ b/mongodb-community-operator/.gitignore @@ -82,7 +82,6 @@ local-config.json .idea vendor __pycache__ -Dockerfile Dockerfile_python_formatting logs/* testbin/bin diff --git a/mongodb-community-operator/.gitmodules b/mongodb-community-operator/.gitmodules deleted file mode 100644 index ba9320f66..000000000 --- a/mongodb-community-operator/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "helm-charts"] - path = mongodb-community-operator/helm-charts - url = git@github.com:mongodb/helm-charts.git diff --git a/mongodb-community-operator/.golangci.yml b/mongodb-community-operator/.golangci.yml deleted file mode 100644 index 795e08728..000000000 --- a/mongodb-community-operator/.golangci.yml +++ /dev/null @@ -1,61 +0,0 @@ ---- -######################### -######################### -## Golang Linter rules ## -######################### -######################### - -# configure golangci-lint -# see https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml -issues: - exclude-rules: - - path: _test\.go - linters: - - dupl - - gosec - - goconst - - golint - text: "underscore" - - path: ^pkg\/util\/envvar - linters: - - forbidigo - - path: ^cmd\/(readiness|versionhook|manager)\/main\.go$ - linters: - - forbidigo -linters: - enable: - - govet - - errcheck - - staticcheck - - unused - - gosimple - - ineffassign - - typecheck - - rowserrcheck - - gosec - - unconvert - - forbidigo -linters-settings: - gosec: - excludes: - - G115 - forbidigo: - forbid: - - p: os\.(Getenv|LookupEnv|Environ|ExpandEnv) - pkg: os - msg: "Reading environemnt variables here is prohibited. Please read environment variables in the main package." - - p: os\.(Clearenv|Unsetenv|Setenv) - msg: "Modifying environemnt variables is prohibited." - pkg: os - - p: envvar\.(Read.*?|MergeWithOverride|GetEnvOrDefault) - pkg: github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar - msg: "Using this envvar package here is prohibited. Please work with environment variables in the main package." - # Rules with the `pkg` depend on it - analyze-types: true - -run: - modules-download-mode: mod - # timeout for analysis, e.g. 30s, 5m, default is 1m - timeout: 5m - # default concurrency is a available CPU number - concurrency: 4 diff --git a/mongodb-community-operator/LICENSE.md b/mongodb-community-operator/LICENSE.md index 9c600b1bc..5463e3426 100644 --- a/mongodb-community-operator/LICENSE.md +++ b/mongodb-community-operator/LICENSE.md @@ -1,5 +1,5 @@ The MongoDB Agent binary in the agent/ directory may be used under the "Free for Commercial Use - Oct 2020" license found in [agent/LICENSE](scripts/dev/templates/agent/LICENSE). -The source code of this Operator, and all other content in this repository are available under the Apache v2 license. The text of this license is available in [APACHE2](APACHE2) +The source code of this Operator, and all other content in this repo are available under the Apache v2 license. The text of this license is available in [APACHE2](APACHE2) To use this Operator, you must agree to both licenses. diff --git a/mongodb-community-operator/Makefile b/mongodb-community-operator/Makefile deleted file mode 100644 index 6f1811c8f..000000000 --- a/mongodb-community-operator/Makefile +++ /dev/null @@ -1,242 +0,0 @@ -SHELL := /bin/bash - -MONGODB_COMMUNITY_CONFIG ?= $(HOME)/.community-operator-dev/config.json - -# Image URL to use all building/pushing image targets -REPO_URL := $(shell jq -r .repo_url < $(MONGODB_COMMUNITY_CONFIG)) -OPERATOR_IMAGE := $(shell jq -r .operator_image < $(MONGODB_COMMUNITY_CONFIG)) -NAMESPACE := $(shell jq -r .namespace < $(MONGODB_COMMUNITY_CONFIG)) -UPGRADE_HOOK_IMG := $(shell jq -r .version_upgrade_hook_image < $(MONGODB_COMMUNITY_CONFIG)) -READINESS_PROBE_IMG := $(shell jq -r .readiness_probe_image < $(MONGODB_COMMUNITY_CONFIG)) -REGISTRY := $(shell jq -r .repo_url < $(MONGODB_COMMUNITY_CONFIG)) -AGENT_IMAGE_NAME := $(shell jq -r .agent_image < $(MONGODB_COMMUNITY_CONFIG)) -HELM_CHART ?= ./helm-charts/charts/community-operator - -STRING_SET_VALUES := --set namespace=$(NAMESPACE),versionUpgradeHook.name=$(UPGRADE_HOOK_IMG),readinessProbe.name=$(READINESS_PROBE_IMG),registry.operator=$(REPO_URL),operator.operatorImageName=$(OPERATOR_IMAGE),operator.version=latest,registry.agent=$(REGISTRY),registry.versionUpgradeHook=$(REGISTRY),registry.readinessProbe=$(REGISTRY),registry.operator=$(REGISTRY),versionUpgradeHook.version=latest,readinessProbe.version=latest,agent.version=latest,agent.name=$(AGENT_IMAGE_NAME) -STRING_SET_VALUES_LOCAL := $(STRING_SET_VALUES) --set operator.replicas=0 - -DOCKERFILE ?= operator -# Produce CRDs that work back to Kubernetes 1.11 (no version conversion) -CRD_OPTIONS ?= "crd:crdVersions=v1" -RELEASE_NAME_HELM ?= mongodb-kubernetes-operator -TEST_NAMESPACE ?= $(NAMESPACE) - -# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) -ifeq (,$(shell go env GOBIN)) -GOBIN=$(shell go env GOPATH)/bin -else -GOBIN=$(shell go env GOBIN) -endif - -BASE_GO_PACKAGE = github.com/mongodb/mongodb-kubernetes-operator -GO_LICENSES = go-licenses -DISALLOWED_LICENSES = restricted # found reciprocal MPL-2.0 - -all: manager - -##@ Development - -fmt: ## Run go fmt against code - go fmt ./... - -vet: ## Run go vet against code - go vet ./... - -generate: controller-gen ## Generate code - $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." - -$(GO_LICENSES): - @if ! which $@ &> /dev/null; then \ - go install github.com/google/go-licenses@latest; \ - fi - -licenses.csv: go.mod $(GO_LICENSES) ## Track licenses in a CSV file - @echo "Tracking licenses into file $@" - @echo "========================================" - GOOS=linux GOARCH=amd64 $(GO_LICENSES) csv --include_tests $(BASE_GO_PACKAGE)/... > $@ - -# We only check that go.mod is NOT newer than licenses.csv because the CI -# tends to generate slightly different results, so content comparison wouldn't work -licenses-tracked: ## Checks license.csv is up to date - @if [ go.mod -nt licenses.csv ]; then \ - echo "License.csv is stale! Please run 'make licenses.csv' and commit"; exit 1; \ - else echo "License.csv OK (up to date)"; fi - -.PHONY: check-licenses-compliance -check-licenses-compliance: licenses.csv ## Check licenses are compliant with our restrictions - @echo "Checking licenses not to be: $(DISALLOWED_LICENSES)" - @echo "============================================" - GOOS=linux GOARCH=amd64 $(GO_LICENSES) check --include_tests $(BASE_GO_PACKAGE)/... \ - --disallowed_types $(DISALLOWED_LICENSES) - @echo "--------------------" - @echo "Licenses check: PASS" - -.PHONY: check-licenses -check-licenses: licenses-tracked check-licenses-compliance ## Check license tracking & compliance - -TEST ?= ./pkg/... ./api/... ./cmd/... ./controllers/... ./test/e2e/util/mongotester/... -test: generate fmt vet manifests ## Run unit tests - go test $(options) $(TEST) -coverprofile cover.out - -manager: generate fmt vet ## Build operator binary - go build -o bin/manager ./cmd/manager/main.go - -run: install ## Run the operator against the configured Kubernetes cluster in ~/.kube/config - eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup)); \ - go run ./cmd/manager/main.go - -debug: install install-rbac ## Run the operator in debug mode with dlv - eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup)); \ - dlv debug ./cmd/manager/main.go - -CONTROLLER_GEN = $(shell pwd)/bin/controller-gen -controller-gen: ## Download controller-gen locally if necessary - $(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0) - -# Try to use already installed helm from PATH -ifeq (ok,$(shell test -f "$$(which helm)" && echo ok)) - HELM=$(shell which helm) -else - HELM=/usr/local/bin/helm -endif - -helm: ## Download helm locally if necessary - $(call install-helm) - -install-prerequisites-macos: ## installs prerequisites for macos development - scripts/dev/install_prerequisites.sh - -##@ Installation/Uninstallation - -install: manifests helm install-crd ## Install CRDs into a cluster - -install-crd: - kubectl apply -f config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml - -install-chart: uninstall-crd - $(HELM) upgrade --install $(STRING_SET_VALUES) $(RELEASE_NAME_HELM) $(HELM_CHART) --namespace $(NAMESPACE) --create-namespace - -install-chart-local-operator: uninstall-crd - $(HELM) upgrade --install $(STRING_SET_VALUES_LOCAL) $(RELEASE_NAME_HELM) $(HELM_CHART) --namespace $(NAMESPACE) --create-namespace - -prepare-local-dev: generate-env-file install-chart-local-operator install-rbac setup-sas - -# patches all sas to use the local-image-registry -setup-sas: - scripts/dev/setup_sa.sh - -install-chart-with-tls-enabled: - $(HELM) upgrade --install --set createResource=true $(STRING_SET_VALUES) $(RELEASE_NAME_HELM) $(HELM_CHART) --namespace $(NAMESPACE) --create-namespace - -install-rbac: - $(HELM) template $(STRING_SET_VALUES) -s templates/database_roles.yaml $(HELM_CHART) | kubectl apply -f - - $(HELM) template $(STRING_SET_VALUES) -s templates/operator_roles.yaml $(HELM_CHART) | kubectl apply -f - - -uninstall-crd: - kubectl delete crd --ignore-not-found mongodbcommunity.mongodbcommunity.mongodb.com - -uninstall-chart: - $(HELM) uninstall $(RELEASE_NAME_HELM) -n $(NAMESPACE) - -uninstall-rbac: - $(HELM) template $(STRING_SET_VALUES) -s templates/database_roles.yaml $(HELM_CHART) | kubectl delete -f - - $(HELM) template $(STRING_SET_VALUES) -s templates/operator_roles.yaml $(HELM_CHART) | kubectl delete -f - - -uninstall: manifests helm uninstall-chart uninstall-crd ## Uninstall CRDs from a cluster - -##@ Deployment - -deploy: manifests helm install-chart install-crd ## Deploy controller in the configured Kubernetes cluster in ~/.kube/config - -undeploy: uninstall-chart uninstall-crd ## UnDeploy controller from the configured Kubernetes cluster in ~/.kube/config - -manifests: controller-gen ## Generate manifests e.g. CRD, RBAC etc. - $(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./..." output:crd:artifacts:config=config/crd/bases - cp config/crd/bases/* $(HELM_CHART)/crds - -##@ E2E - -# Run e2e tests locally using go build while also setting up a proxy in the shell to allow -# the test to run as if it were inside the cluster. This enables mongodb connectivity while running locally. -# "MDB_LOCAL_OPERATOR=true" ensures the operator pod is not spun up while running the e2e test - since you're -# running it locally. -e2e-telepresence: cleanup-e2e install ## Run e2e tests locally using go build while also setting up a proxy e.g. make e2e-telepresence test=replica_set cleanup=true - export MDB_LOCAL_OPERATOR=true; \ - telepresence connect; \ - eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup)); \ - go test -v -timeout=30m -failfast $(options) ./test/e2e/$(test) ; \ - telepresence quit - -e2e-k8s: cleanup-e2e install e2e-image ## Run e2e test by deploying test image in kubernetes, you can provide e2e.py flags e.g. make e2e-k8s test=replica_set e2eflags="--perform-cleanup". - python scripts/dev/e2e.py $(e2eflags) --test $(test) - -e2e: cleanup-e2e install ## Run e2e test locally. e.g. make e2e test=replica_set cleanup=true - eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup)); \ - go test -v -short -timeout=30m -failfast $(options) ./test/e2e/$(test) - -e2e-gh: ## Trigger a Github Action of the given test - scripts/dev/run_e2e_gh.sh $(test) - -cleanup-e2e: ## Cleans up e2e test env - kubectl delete mdbc,all,secrets -l e2e-test=true -n ${TEST_NAMESPACE} || true - # Most of the tests use StatefulSets, which in turn use stable storage. In order to - # avoid interleaving tests with each other, we need to drop them all. - kubectl delete pvc --all -n $(NAMESPACE) || true - kubectl delete pv --all -n $(NAMESPACE) || true - -generate-env-file: ## generates a local-test.env for local testing - mkdir -p .community-operator-dev - { python scripts/dev/get_e2e_env_vars.py | tee >(cut -d' ' -f2 > .community-operator-dev/local-test.env) ;} > .community-operator-dev/local-test.export.env - . .community-operator-dev/local-test.export.env - -##@ Image - -operator-image: ## Build and push the operator image - python pipeline.py --image-name operator $(IMG_BUILD_ARGS) - -e2e-image: ## Build and push e2e test image - python pipeline.py --image-name e2e $(IMG_BUILD_ARGS) - -agent-image: ## Build and push agent image - python pipeline.py --image-name agent $(IMG_BUILD_ARGS) - -readiness-probe-image: ## Build and push readiness probe image - python pipeline.py --image-name readiness-probe $(IMG_BUILD_ARGS) - -version-upgrade-post-start-hook-image: ## Build and push version upgrade post start hook image - python pipeline.py --image-name version-upgrade-hook $(IMG_BUILD_ARGS) - -all-images: operator-image e2e-image agent-image readiness-probe-image version-upgrade-post-start-hook-image ## create all required images - -define install-helm -@[ -f $(HELM) ] || { \ -set -e ;\ -TMP_DIR=$$(mktemp -d) ;\ -cd $$TMP_DIR ;\ -curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 ;\ -chmod 700 get_helm.sh ;\ -./get_helm.sh ;\ -rm -rf $(TMP_DIR) ;\ -} -endef - -# go-install-tool will 'go install' any package $2 and install it to $1. -PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) -define go-install-tool -@[ -f $(1) ] || { \ -set -e ;\ -TMP_DIR=$$(mktemp -d) ;\ -cd $$TMP_DIR ;\ -go mod init tmp ;\ -echo "Downloading $(2)" ;\ -GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\ -rm -rf $$TMP_DIR ;\ -} -endef - -help: ## Show this help screen. - @echo 'Usage: make ... ' - @echo '' - @echo 'Available targets are:' - @echo '' - @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) diff --git a/mongodb-community-operator/api/v1/common/common.go b/mongodb-community-operator/api/v1/common/common.go new file mode 100644 index 000000000..805d0c79a --- /dev/null +++ b/mongodb-community-operator/api/v1/common/common.go @@ -0,0 +1 @@ +package common diff --git a/mongodb-community-operator/api/v1/common/doc.go b/mongodb-community-operator/api/v1/common/doc.go new file mode 100644 index 000000000..a93f0e088 --- /dev/null +++ b/mongodb-community-operator/api/v1/common/doc.go @@ -0,0 +1,4 @@ +package common + +// +k8s:deepcopy-gen=package +// +versionName=v1 diff --git a/mongodb-community-operator/api/v1/common/persistence.go b/mongodb-community-operator/api/v1/common/persistence.go new file mode 100644 index 000000000..1e2d6f271 --- /dev/null +++ b/mongodb-community-operator/api/v1/common/persistence.go @@ -0,0 +1,20 @@ +package common + +type Persistence struct { + SingleConfig *PersistenceConfig `json:"single,omitempty"` + MultipleConfig *MultiplePersistenceConfig `json:"multiple,omitempty"` +} + +type MultiplePersistenceConfig struct { + Data *PersistenceConfig `json:"data,omitempty"` + Journal *PersistenceConfig `json:"journal,omitempty"` + Logs *PersistenceConfig `json:"logs,omitempty"` +} + +type PersistenceConfig struct { + Storage string `json:"storage,omitempty"` + StorageClass *string `json:"storageClass,omitempty"` + + // +kubebuilder:pruning:PreserveUnknownFields + LabelSelector *LabelSelectorWrapper `json:"labelSelector,omitempty"` +} diff --git a/api/v1/mdb/wrap.go b/mongodb-community-operator/api/v1/common/wrap.go similarity index 64% rename from api/v1/mdb/wrap.go rename to mongodb-community-operator/api/v1/common/wrap.go index 6dfe26af2..274f7b241 100644 --- a/api/v1/mdb/wrap.go +++ b/mongodb-community-operator/api/v1/common/wrap.go @@ -1,7 +1,7 @@ // Contains the wrapped types which are needed for generating // CRD yamls using kubebuilder. They prevent each of the fields showing up in CRD yaml thereby // resulting in a relatively smaller file. -package mdb +package common import ( "encoding/json" @@ -116,18 +116,18 @@ type StatefulSetSpecWrapper struct { } // MarshalJSON defers JSON encoding to the wrapped map -func (s *StatefulSetSpecWrapper) MarshalJSON() ([]byte, error) { - return json.Marshal(s.Spec) +func (in *StatefulSetSpecWrapper) MarshalJSON() ([]byte, error) { + return json.Marshal(in.Spec) } // UnmarshalJSON will decode the data into the wrapped map -func (s *StatefulSetSpecWrapper) UnmarshalJSON(data []byte) error { - return json.Unmarshal(data, &s.Spec) +func (in *StatefulSetSpecWrapper) UnmarshalJSON(data []byte) error { + return json.Unmarshal(data, &in.Spec) } -func (s *StatefulSetSpecWrapper) DeepCopy() *StatefulSetSpecWrapper { +func (in *StatefulSetSpecWrapper) DeepCopy() *StatefulSetSpecWrapper { return &StatefulSetSpecWrapper{ - Spec: s.Spec, + Spec: in.Spec, } } @@ -150,3 +150,56 @@ func (s *ServiceSpecWrapper) DeepCopy() *ServiceSpecWrapper { Spec: s.Spec, } } + +// StatefulSetConfiguration holds the optional custom StatefulSet +// that should be merged into the operator created one. +type StatefulSetConfiguration struct { + // +kubebuilder:pruning:PreserveUnknownFields + SpecWrapper StatefulSetSpecWrapper `json:"spec"` + // +optional + MetadataWrapper StatefulSetMetadataWrapper `json:"metadata"` +} + +// StatefulSetMetadataWrapper is a wrapper around Labels and Annotations +type StatefulSetMetadataWrapper struct { + // +optional + Labels map[string]string `json:"labels,omitempty"` + // +optional + Annotations map[string]string `json:"annotations,omitempty"` +} + +func (in *StatefulSetMetadataWrapper) DeepCopy() *StatefulSetMetadataWrapper { + return &StatefulSetMetadataWrapper{ + Labels: in.Labels, + Annotations: in.Annotations, + } +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StatefulSetConfiguration) DeepCopyInto(out *StatefulSetConfiguration) { + *out = *in + in.SpecWrapper.DeepCopyInto(&out.SpecWrapper) + in.MetadataWrapper.DeepCopyInto(&out.MetadataWrapper) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StatefulSetConfiguration. +func (in *StatefulSetConfiguration) DeepCopy() *StatefulSetConfiguration { + if in == nil { + return nil + } + out := new(StatefulSetConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StatefulSetMetadataWrapper) DeepCopyInto(out *StatefulSetMetadataWrapper) { + clone := in.DeepCopy() + *out = *clone +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StatefulSetSpecWrapper) DeepCopyInto(out *StatefulSetSpecWrapper) { + clone := in.DeepCopy() + *out = *clone +} diff --git a/mongodb-community-operator/api/v1/common/zz_generated.deepcopy.go b/mongodb-community-operator/api/v1/common/zz_generated.deepcopy.go new file mode 100644 index 000000000..1e21eb60e --- /dev/null +++ b/mongodb-community-operator/api/v1/common/zz_generated.deepcopy.go @@ -0,0 +1,138 @@ +//go:build !ignore_autogenerated + +/* +Copyright 2021. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package common + +import () + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClientCertificateSecretRefWrapper) DeepCopyInto(out *ClientCertificateSecretRefWrapper) { + clone := in.DeepCopy() + *out = *clone +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LabelSelectorWrapper) DeepCopyInto(out *LabelSelectorWrapper) { + clone := in.DeepCopy() + *out = *clone +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MultiplePersistenceConfig) DeepCopyInto(out *MultiplePersistenceConfig) { + *out = *in + if in.Data != nil { + in, out := &in.Data, &out.Data + *out = new(PersistenceConfig) + (*in).DeepCopyInto(*out) + } + if in.Journal != nil { + in, out := &in.Journal, &out.Journal + *out = new(PersistenceConfig) + (*in).DeepCopyInto(*out) + } + if in.Logs != nil { + in, out := &in.Logs, &out.Logs + *out = new(PersistenceConfig) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MultiplePersistenceConfig. +func (in *MultiplePersistenceConfig) DeepCopy() *MultiplePersistenceConfig { + if in == nil { + return nil + } + out := new(MultiplePersistenceConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeAffinityWrapper) DeepCopyInto(out *NodeAffinityWrapper) { + clone := in.DeepCopy() + *out = *clone +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Persistence) DeepCopyInto(out *Persistence) { + *out = *in + if in.SingleConfig != nil { + in, out := &in.SingleConfig, &out.SingleConfig + *out = new(PersistenceConfig) + (*in).DeepCopyInto(*out) + } + if in.MultipleConfig != nil { + in, out := &in.MultipleConfig, &out.MultipleConfig + *out = new(MultiplePersistenceConfig) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Persistence. +func (in *Persistence) DeepCopy() *Persistence { + if in == nil { + return nil + } + out := new(Persistence) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PersistenceConfig) DeepCopyInto(out *PersistenceConfig) { + *out = *in + if in.StorageClass != nil { + in, out := &in.StorageClass, &out.StorageClass + *out = new(string) + **out = **in + } + if in.LabelSelector != nil { + in, out := &in.LabelSelector, &out.LabelSelector + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistenceConfig. +func (in *PersistenceConfig) DeepCopy() *PersistenceConfig { + if in == nil { + return nil + } + out := new(PersistenceConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodAffinityWrapper) DeepCopyInto(out *PodAffinityWrapper) { + clone := in.DeepCopy() + *out = *clone +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodTemplateSpecWrapper) DeepCopyInto(out *PodTemplateSpecWrapper) { + clone := in.DeepCopy() + *out = *clone +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceSpecWrapper) DeepCopyInto(out *ServiceSpecWrapper) { + clone := in.DeepCopy() + *out = *clone +} diff --git a/mongodb-community-operator/api/v1/mongodbcommunity_types.go b/mongodb-community-operator/api/v1/mongodbcommunity_types.go index 6a5e4bf0c..81970d758 100644 --- a/mongodb-community-operator/api/v1/mongodbcommunity_types.go +++ b/mongodb-community-operator/api/v1/mongodbcommunity_types.go @@ -6,20 +6,22 @@ import ( "regexp" "strings" - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/stretchr/objx" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/validation" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale" - "github.com/stretchr/objx" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/scale" ) type Type string @@ -43,7 +45,7 @@ const ( // SCRAM-SHA-256 and SCRAM-SHA-1 are the supported auth modes. const ( - defaultMode AuthMode = "SCRAM-SHA-256" + defaultMode AuthMode = Scram256AuthMode ) const ( @@ -99,7 +101,7 @@ type MongoDBCommunitySpec struct { Users []MongoDBUser `json:"users"` // +optional - StatefulSetConfiguration StatefulSetConfiguration `json:"statefulSet,omitempty"` + StatefulSetConfiguration common.StatefulSetConfiguration `json:"statefulSet,omitempty"` // AgentConfiguration sets options for the MongoDB automation agent // +optional @@ -346,23 +348,16 @@ type OverrideProcess struct { LogRotate *automationconfig.CrdLogRotate `json:"logRotate,omitempty"` } -// StatefulSetConfiguration holds the optional custom StatefulSet -// that should be merged into the operator created one. -type StatefulSetConfiguration struct { - // +kubebuilder:pruning:PreserveUnknownFields - SpecWrapper StatefulSetSpecWrapper `json:"spec"` - // +optional - MetadataWrapper StatefulSetMetadataWrapper `json:"metadata"` -} - type LogLevel string const ( - LogLevelDebug LogLevel = "DEBUG" - LogLevelInfo LogLevel = "INFO" - LogLevelWarn LogLevel = "WARN" - LogLevelError LogLevel = "ERROR" - LogLevelFatal LogLevel = "FATAL" + LogLevelDebug LogLevel = "DEBUG" + LogLevelInfo LogLevel = "INFO" + LogLevelWarn LogLevel = "WARN" + LogLevelError LogLevel = "ERROR" + LogLevelFatal LogLevel = "FATAL" + X509AuthMode = "X509" + Scram256AuthMode = "SCRAM-SHA-256" ) type AgentConfiguration struct { @@ -383,44 +378,6 @@ type AgentConfiguration struct { SystemLog *automationconfig.SystemLog `json:"systemLog,omitempty"` } -// StatefulSetSpecWrapper is a wrapper around StatefulSetSpec with a custom implementation -// of MarshalJSON and UnmarshalJSON which delegate to the underlying Spec to avoid CRD pollution. - -type StatefulSetSpecWrapper struct { - Spec appsv1.StatefulSetSpec `json:"-"` -} - -// MarshalJSON defers JSON encoding to the wrapped map -func (m *StatefulSetSpecWrapper) MarshalJSON() ([]byte, error) { - return json.Marshal(m.Spec) -} - -// UnmarshalJSON will decode the data into the wrapped map -func (m *StatefulSetSpecWrapper) UnmarshalJSON(data []byte) error { - return json.Unmarshal(data, &m.Spec) -} - -func (m *StatefulSetSpecWrapper) DeepCopy() *StatefulSetSpecWrapper { - return &StatefulSetSpecWrapper{ - Spec: m.Spec, - } -} - -// StatefulSetMetadataWrapper is a wrapper around Labels and Annotations -type StatefulSetMetadataWrapper struct { - // +optional - Labels map[string]string `json:"labels,omitempty"` - // +optional - Annotations map[string]string `json:"annotations,omitempty"` -} - -func (m *StatefulSetMetadataWrapper) DeepCopy() *StatefulSetMetadataWrapper { - return &StatefulSetMetadataWrapper{ - Labels: m.Labels, - Annotations: m.Annotations, - } -} - // MongodConfiguration holds the optional mongod configuration // that should be merged with the operator created one. type MongodConfiguration struct { @@ -658,11 +615,11 @@ func IsAuthPresent(authModes []AuthMode, auth string) bool { // same authentication mode. func ConvertAuthModeToAuthMechanism(authModeLabel AuthMode) string { switch authModeLabel { - case "SCRAM", "SCRAM-SHA-256": + case "SCRAM", Scram256AuthMode: return constants.Sha256 case "SCRAM-SHA-1": return constants.Sha1 - case "X509": + case X509AuthMode: return constants.X509 default: return "" @@ -774,7 +731,6 @@ func (m *MongoDBCommunity) GetAuthUsers() []authtypes.User { for i, u := range m.Spec.Users { roles := make([]authtypes.Role, len(u.Roles)) for j, r := range u.Roles { - roles[j] = authtypes.Role{ Name: r.Name, Database: r.DB, @@ -846,20 +802,20 @@ func (m *MongoDBCommunitySpec) GetAgentAuthMode() AuthMode { } if len(m.Security.Authentication.Modes) == 0 { - return "SCRAM-SHA-256" + return Scram256AuthMode } else if len(m.Security.Authentication.Modes) == 1 { return m.Security.Authentication.Modes[0] } else if len(m.Security.Authentication.Modes) == 2 { - if (IsAuthPresent(m.Security.Authentication.Modes, "SCRAM") || IsAuthPresent(m.Security.Authentication.Modes, "SCRAM-SHA-256")) && + if (IsAuthPresent(m.Security.Authentication.Modes, "SCRAM") || IsAuthPresent(m.Security.Authentication.Modes, Scram256AuthMode)) && IsAuthPresent(m.Security.Authentication.Modes, "SCRAM-SHA-1") { - return "SCRAM-SHA-256" + return Scram256AuthMode } } return "" } func (m *MongoDBCommunitySpec) IsAgentX509() bool { - return m.GetAgentAuthMode() == "X509" + return m.GetAgentAuthMode() == X509AuthMode } // IsStillScaling returns true if this resource is currently scaling, diff --git a/mongodb-community-operator/api/v1/mongodbcommunity_types_test.go b/mongodb-community-operator/api/v1/mongodbcommunity_types_test.go index 19b365527..2fa177129 100644 --- a/mongodb-community-operator/api/v1/mongodbcommunity_types_test.go +++ b/mongodb-community-operator/api/v1/mongodbcommunity_types_test.go @@ -2,16 +2,16 @@ package v1 import ( "encoding/json" - "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" ) type args struct { @@ -112,7 +112,8 @@ func TestMongoDB_MongoURI_With_Options(t *testing.T) { name: "my-rs", namespace: "my-namespace", additionalConnectionStringConfig: map[string]interface{}{ - "readPreference": "primary", "replicaSet": "differentName", "tls": true, "ssl": true}, + "readPreference": "primary", "replicaSet": "differentName", "tls": true, "ssl": true, + }, connectionString: "mongodb://my-rs-0.my-rs-svc.my-namespace.svc.cluster.local:27017,my-rs-1.my-rs-svc.my-namespace.svc.cluster.local:27017/?replicaSet=my-rs&readPreference=primary", }, { @@ -120,7 +121,8 @@ func TestMongoDB_MongoURI_With_Options(t *testing.T) { name: "my-single-rs", namespace: "my-single-namespace", additionalConnectionStringConfig: map[string]interface{}{ - "readPreference": "primary"}, + "readPreference": "primary", + }, connectionString: "mongodb://my-single-rs-0.my-single-rs-svc.my-single-namespace.svc.cluster.local:27017/?replicaSet=my-single-rs&readPreference=primary", }, { @@ -128,7 +130,8 @@ func TestMongoDB_MongoURI_With_Options(t *testing.T) { name: "my-big-rs", namespace: "my-big-namespace", additionalConnectionStringConfig: map[string]interface{}{ - "readPreference": "primary"}, + "readPreference": "primary", + }, connectionString: "mongodb://my-big-rs-0.my-big-rs-svc.my-big-namespace.svc.cluster.local:27017,my-big-rs-1.my-big-rs-svc.my-big-namespace.svc.cluster.local:27017,my-big-rs-2.my-big-rs-svc.my-big-namespace.svc.cluster.local:27017,my-big-rs-3.my-big-rs-svc.my-big-namespace.svc.cluster.local:27017,my-big-rs-4.my-big-rs-svc.my-big-namespace.svc.cluster.local:27017/?replicaSet=my-big-rs&readPreference=primary", }, { @@ -136,7 +139,8 @@ func TestMongoDB_MongoURI_With_Options(t *testing.T) { name: "my-rs", namespace: "my-namespace", additionalConnectionStringConfig: map[string]interface{}{ - "readPreference": "primary"}, + "readPreference": "primary", + }, additionalMongodConfig: map[string]interface{}{ "net.port": 40333., }, @@ -161,13 +165,15 @@ func TestMongoDB_MongoSRVURI(t *testing.T) { func TestMongoDB_MongoSRVURI_With_Options(t *testing.T) { mdb := newReplicaSet(2, "my-rs", "my-namespace") mdb.Spec.AdditionalConnectionStringConfig.Object = map[string]interface{}{ - "readPreference": "primary"} + "readPreference": "primary", + } assert.Equal(t, mdb.MongoSRVURI(""), "mongodb+srv://my-rs-svc.my-namespace.svc.cluster.local/?replicaSet=my-rs&readPreference=primary") assert.Equal(t, mdb.MongoSRVURI("my.cluster"), "mongodb+srv://my-rs-svc.my-namespace.svc.my.cluster/?replicaSet=my-rs&readPreference=primary") mdb = newReplicaSet(2, "my-rs", "my-namespace") mdb.Spec.AdditionalConnectionStringConfig.Object = map[string]interface{}{ - "readPreference": "primary", "replicaSet": "differentName", "tls": true, "ssl": true} + "readPreference": "primary", "replicaSet": "differentName", "tls": true, "ssl": true, + } assert.Equal(t, mdb.MongoSRVURI(""), "mongodb+srv://my-rs-svc.my-namespace.svc.cluster.local/?replicaSet=my-rs&readPreference=primary") assert.Equal(t, mdb.MongoSRVURI("my.cluster"), "mongodb+srv://my-rs-svc.my-namespace.svc.my.cluster/?replicaSet=my-rs&readPreference=primary") } @@ -287,7 +293,6 @@ func TestGetScramCredentialsSecretName(t *testing.T) { for _, tt := range testusers { assert.Equal(t, tt.exp, tt.in.GetScramCredentialsSecretName()) } - } func TestGetConnectionStringSecretName(t *testing.T) { @@ -363,7 +368,8 @@ func TestMongoDBCommunity_MongoAuthUserURI(t *testing.T) { }, { additionalConnectionStringConfig: map[string]interface{}{ - "readPreference": "primary", "replicaSet": "differentName", "tls": true, "ssl": true}, + "readPreference": "primary", "replicaSet": "differentName", "tls": true, "ssl": true, + }, connectionString: "mongodb://testuser:password@my-rs-0.my-rs-svc.my-namespace.svc.cluster.local:27017,my-rs-1.my-rs-svc.my-namespace.svc.cluster.local:27017/admin?replicaSet=my-rs&ssl=false&readPreference=primary", }, { @@ -374,7 +380,8 @@ func TestMongoDBCommunity_MongoAuthUserURI(t *testing.T) { { additionalConnectionStringConfig: map[string]interface{}{"readPreference": "primary"}, userConnectionStringConfig: map[string]interface{}{ - "readPreference": "primary", "replicaSet": "differentName", "tls": true, "ssl": true}, + "readPreference": "primary", "replicaSet": "differentName", "tls": true, "ssl": true, + }, connectionString: "mongodb://testuser:password@my-rs-0.my-rs-svc.my-namespace.svc.cluster.local:27017,my-rs-1.my-rs-svc.my-namespace.svc.cluster.local:27017/admin?replicaSet=my-rs&ssl=false&readPreference=primary", }, { @@ -422,7 +429,8 @@ func TestMongoDBCommunity_MongoAuthUserSRVURI(t *testing.T) { }, { additionalConnectionStringConfig: map[string]interface{}{ - "readPreference": "primary", "replicaSet": "differentName", "tls": true, "ssl": true}, + "readPreference": "primary", "replicaSet": "differentName", "tls": true, "ssl": true, + }, connectionString: "mongodb+srv://testuser:password@my-rs-svc.my-namespace.svc.cluster.local/admin?replicaSet=my-rs&ssl=false&readPreference=primary", }, { @@ -433,7 +441,8 @@ func TestMongoDBCommunity_MongoAuthUserSRVURI(t *testing.T) { { additionalConnectionStringConfig: map[string]interface{}{"readPreference": "primary"}, userConnectionStringConfig: map[string]interface{}{ - "readPreference": "primary", "replicaSet": "differentName", "tls": true, "ssl": true}, + "readPreference": "primary", "replicaSet": "differentName", "tls": true, "ssl": true, + }, connectionString: "mongodb+srv://testuser:password@my-rs-svc.my-namespace.svc.cluster.local/admin?replicaSet=my-rs&ssl=false&readPreference=primary", }, { @@ -613,7 +622,6 @@ func TestMongoDBCommunity_AgentCertificatePemSecretNamespacedName(t *testing.T) m.Spec.Security.Authentication.AgentCertificateSecret = &corev1.LocalObjectReference{Name: "agent-certs-custom"} assert.Equal(t, "agent-certs-custom-pem", m.AgentCertificatePemSecretNamespacedName().Name) - } func TestMongoDBCommunitySpec_GetAgentAuthMode(t *testing.T) { diff --git a/mongodb-community-operator/api/v1/zz_generated.deepcopy.go b/mongodb-community-operator/api/v1/zz_generated.deepcopy.go index df22b4876..cef307f91 100644 --- a/mongodb-community-operator/api/v1/zz_generated.deepcopy.go +++ b/mongodb-community-operator/api/v1/zz_generated.deepcopy.go @@ -21,7 +21,7 @@ limitations under the License. package v1 import ( - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" ) @@ -528,35 +528,6 @@ func (in *Security) DeepCopy() *Security { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StatefulSetConfiguration) DeepCopyInto(out *StatefulSetConfiguration) { - *out = *in - in.SpecWrapper.DeepCopyInto(&out.SpecWrapper) - in.MetadataWrapper.DeepCopyInto(&out.MetadataWrapper) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StatefulSetConfiguration. -func (in *StatefulSetConfiguration) DeepCopy() *StatefulSetConfiguration { - if in == nil { - return nil - } - out := new(StatefulSetConfiguration) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StatefulSetMetadataWrapper) DeepCopyInto(out *StatefulSetMetadataWrapper) { - clone := in.DeepCopy() - *out = *clone -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StatefulSetSpecWrapper) DeepCopyInto(out *StatefulSetSpecWrapper) { - clone := in.DeepCopy() - *out = *clone -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TLS) DeepCopyInto(out *TLS) { *out = *in diff --git a/mongodb-community-operator/build/bin/entrypoint b/mongodb-community-operator/build/bin/entrypoint deleted file mode 100755 index 9dfc7bd5e..000000000 --- a/mongodb-community-operator/build/bin/entrypoint +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -e - -# This is documented here: -# https://docs.openshift.com/container-platform/3.11/creating_images/guidelines.html#openshift-specific-guidelines - -if ! whoami >/dev/null 2>&1; then - if [ -w /etc/passwd ]; then - echo "${USER_NAME:-mongodb-kubernetes-operator}:x:$(id -u):$(id -g):${USER_NAME:-mongodb-kubernetes-operator} user:${HOME}:/sbin/nologin" >> /etc/passwd - fi -fi - -echo "Running ./${OPERATOR}" -"./${OPERATOR}" "$@" diff --git a/mongodb-community-operator/build/bin/user_setup b/mongodb-community-operator/build/bin/user_setup deleted file mode 100755 index 1d741d62e..000000000 --- a/mongodb-community-operator/build/bin/user_setup +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -set -x - -# ensure $HOME exists and is accessible by group 0 (we don't know what the runtime UID will be) -mkdir -p "${HOME}" -chown" ${USER_UID}":0 "${HOME}" -chmod ug+rwx" ${HOME}" - -# runtime user will need to be able to self-insert in /etc/passwd -chmod g+rw /etc/passwd - -# no need for this script to remain in the image after running -rm "$0" diff --git a/mongodb-community-operator/cmd/manager/main.go b/mongodb-community-operator/cmd/manager/main.go deleted file mode 100644 index b8dd5d184..000000000 --- a/mongodb-community-operator/cmd/manager/main.go +++ /dev/null @@ -1,130 +0,0 @@ -package main - -import ( - "fmt" - "os" - - "sigs.k8s.io/controller-runtime/pkg/cache" - - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/controllers" - "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar" - "go.uber.org/zap" - "k8s.io/apimachinery/pkg/runtime" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - clientgoscheme "k8s.io/client-go/kubernetes/scheme" - "sigs.k8s.io/controller-runtime/pkg/client/config" - "sigs.k8s.io/controller-runtime/pkg/manager" - "sigs.k8s.io/controller-runtime/pkg/manager/signals" -) - -var ( - scheme = runtime.NewScheme() -) - -const ( - WatchNamespaceEnv = "WATCH_NAMESPACE" -) - -func init() { - utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - - utilruntime.Must(mdbv1.AddToScheme(scheme)) - // +kubebuilder:scaffold:scheme -} - -func configureLogger() (*zap.Logger, error) { - // TODO: configure non development logger - logger, err := zap.NewDevelopment() - zap.ReplaceGlobals(logger) - return logger, err -} - -func hasRequiredVariables(logger *zap.Logger, envVariables ...string) bool { - allPresent := true - for _, envVariable := range envVariables { - if _, envSpecified := os.LookupEnv(envVariable); !envSpecified { - logger.Error(fmt.Sprintf("required environment variable %s not found", envVariable)) - allPresent = false - } - } - return allPresent -} - -func main() { - log, err := configureLogger() - if err != nil { - log.Sugar().Fatalf("Failed to configure logger: %v", err) - } - - if !hasRequiredVariables( - log, - construct.MongodbRepoUrlEnv, - construct.MongodbImageEnv, - construct.AgentImageEnv, - construct.VersionUpgradeHookImageEnv, - construct.ReadinessProbeImageEnv, - ) { - os.Exit(1) - } - - // Get watch namespace from environment variable. - namespace, nsSpecified := os.LookupEnv(WatchNamespaceEnv) - if !nsSpecified { - log.Sugar().Fatal("No namespace specified to watch") - } - - // If namespace is a wildcard use the empty string to represent all namespaces - watchNamespace := "" - if namespace == "*" { - log.Info("Watching all namespaces") - } else { - watchNamespace = namespace - log.Sugar().Infof("Watching namespace: %s", watchNamespace) - } - - // Get a config to talk to the apiserver - cfg, err := config.GetConfig() - if err != nil { - log.Sugar().Fatalf("Unable to get config: %v", err) - } - - // Create a new Cmd to provide shared dependencies and start components - mgr, err := manager.New(cfg, manager.Options{ - Cache: cache.Options{ - DefaultNamespaces: map[string]cache.Config{watchNamespace: {}}, - }, - }) - if err != nil { - log.Sugar().Fatalf("Unable to create manager: %v", err) - } - - log.Info("Registering Components.") - - // Setup Scheme for all resources - if err := mdbv1.AddToScheme(mgr.GetScheme()); err != nil { - log.Sugar().Fatalf("Unable to add mdbv1 to scheme: %v", err) - } - - // Setup Controller. - if err = controllers.NewReconciler( - mgr, - os.Getenv(construct.MongodbRepoUrlEnv), - os.Getenv(construct.MongodbImageEnv), - envvar.GetEnvOrDefault(construct.MongoDBImageTypeEnv, construct.DefaultImageType), - os.Getenv(construct.AgentImageEnv), - os.Getenv(construct.VersionUpgradeHookImageEnv), - os.Getenv(construct.ReadinessProbeImageEnv), - ).SetupWithManager(mgr); err != nil { - log.Sugar().Fatalf("Unable to create controller: %v", err) - } - // +kubebuilder:scaffold:builder - - log.Info("Starting the Cmd.") - - // Start the Cmd - if err := mgr.Start(signals.SetupSignalHandler()); err != nil { - log.Sugar().Fatalf("Unable to start manager: %v", err) - } -} diff --git a/mongodb-community-operator/cmd/readiness/main.go b/mongodb-community-operator/cmd/readiness/main.go index 6cf9e7804..6e08dc844 100644 --- a/mongodb-community-operator/cmd/readiness/main.go +++ b/mongodb-community-operator/cmd/readiness/main.go @@ -8,16 +8,15 @@ import ( "os" "time" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/readiness/config" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/readiness/headless" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/readiness/health" + "go.uber.org/zap" "go.uber.org/zap/zapcore" "gopkg.in/natefinch/lumberjack.v2" - "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" - "go.uber.org/zap" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/readiness/config" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/readiness/headless" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/readiness/health" ) const ( diff --git a/mongodb-community-operator/cmd/readiness/readiness_test.go b/mongodb-community-operator/cmd/readiness/readiness_test.go index 11222effa..7ee43dd18 100644 --- a/mongodb-community-operator/cmd/readiness/readiness_test.go +++ b/mongodb-community-operator/cmd/readiness/readiness_test.go @@ -9,14 +9,14 @@ import ( "testing" "time" - "github.com/mongodb/mongodb-kubernetes-operator/cmd/readiness/testdata" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/readiness/config" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/readiness/health" + "github.com/stretchr/testify/assert" + "k8s.io/client-go/kubernetes/fake" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/kubernetes/fake" - "github.com/stretchr/testify/assert" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/cmd/readiness/testdata" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/readiness/config" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/readiness/health" ) // TestDeadlockDetection verifies that if the agent is stuck in "WaitAllRsMembersUp" phase (started > 15 seconds ago) diff --git a/mongodb-community-operator/cmd/versionhook/main.go b/mongodb-community-operator/cmd/versionhook/main.go index 6e0d02f95..5564b7827 100644 --- a/mongodb-community-operator/cmd/versionhook/main.go +++ b/mongodb-community-operator/cmd/versionhook/main.go @@ -9,12 +9,14 @@ import ( "strings" "time" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/agent" "go.uber.org/zap" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/agent" ) const ( @@ -69,7 +71,7 @@ func main() { // If the Pod needs to be killed, we'll wait until the Pod // is killed by Kubernetes, bringing the new container image // into play. - var quit = make(chan struct{}) + quit := make(chan struct{}) logger.Info("Pod killed itself, waiting...") <-quit } else { @@ -118,7 +120,6 @@ func waitForAgentHealthStatus() (agent.Health, error) { } } return agent.Health{}, fmt.Errorf("agent health status not ready after waiting %s", pollingDuration.String()) - } // getAgentHealthStatus returns an instance of agent.Health read @@ -128,7 +129,11 @@ func getAgentHealthStatus() (agent.Health, error) { if err != nil { return agent.Health{}, err } - defer f.Close() + defer func() { + if closeErr := f.Close(); closeErr != nil { + zap.S().Warnf("Failed to close agent health file: %v", closeErr) + } + }() h, err := readAgentHealthStatus(f) if err != nil { diff --git a/mongodb-community-operator/config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml b/mongodb-community-operator/config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml index 12207a6bd..42c2258d0 100644 --- a/mongodb-community-operator/config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml +++ b/mongodb-community-operator/config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml @@ -225,11 +225,6 @@ spec: type: array replicaSet: properties: - id: - description: |- - Id can be used together with additionalMongodConfig.replication.replSetName - to manage clusters where replSetName differs from the MongoDBCommunity resource name - type: string settings: description: |- MapWrapper is a wrapper for a map to be used by other structs. diff --git a/mongodb-community-operator/config/manager/manager.yaml b/mongodb-community-operator/config/manager/manager.yaml index 0705e7eae..9013a8451 100644 --- a/mongodb-community-operator/config/manager/manager.yaml +++ b/mongodb-community-operator/config/manager/manager.yaml @@ -45,16 +45,16 @@ spec: - name: OPERATOR_NAME value: mongodb-kubernetes-operator - name: AGENT_IMAGE - value: quay.io/mongodb/mongodb-agent-ubi:108.0.6.8796-1 + value: quay.io/mongodb/mongodb-agent-ubi:108.0.2.8729-1 - name: VERSION_UPGRADE_HOOK_IMAGE - value: quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook:1.0.10 + value: quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook:1.0.9 - name: READINESS_PROBE_IMAGE - value: quay.io/mongodb/mongodb-kubernetes-readinessprobe:1.0.23 + value: quay.io/mongodb/mongodb-kubernetes-readinessprobe:1.0.22 - name: MONGODB_IMAGE value: mongodb-community-server - name: MONGODB_REPO_URL value: quay.io/mongodb - image: quay.io/mongodb/mongodb-kubernetes-operator:0.13.0 + image: quay.io/mongodb/mongodb-kubernetes-operator:0.12.0 imagePullPolicy: Always name: mongodb-kubernetes-operator resources: diff --git a/mongodb-community-operator/controllers/construct/build_statefulset_test.go b/mongodb-community-operator/controllers/construct/build_statefulset_test.go index 791fa5a8b..fa1c846aa 100644 --- a/mongodb-community-operator/controllers/construct/build_statefulset_test.go +++ b/mongodb-community-operator/controllers/construct/build_statefulset_test.go @@ -4,20 +4,18 @@ import ( "reflect" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/podtemplatespec" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/resourcerequirements" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar" - - corev1 "k8s.io/api/core/v1" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/probes" - - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/stretchr/testify/assert" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/podtemplatespec" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/probes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/resourcerequirements" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/envvar" ) func newTestReplicaSet() mdbv1.MongoDBCommunity { diff --git a/mongodb-community-operator/controllers/construct/mongodbstatefulset.go b/mongodb-community-operator/controllers/construct/mongodbstatefulset.go index ec94a6eac..fd24ab618 100644 --- a/mongodb-community-operator/controllers/construct/mongodbstatefulset.go +++ b/mongodb-community-operator/controllers/construct/mongodbstatefulset.go @@ -5,35 +5,40 @@ import ( "os" "strconv" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/readiness/config" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/persistentvolumeclaim" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/podtemplatespec" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/probes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/resourcerequirements" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale" - appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/types" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" -) -var ( - OfficialMongodbRepoUrls = []string{"docker.io/mongodb", "quay.io/mongodb"} + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/persistentvolumeclaim" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/podtemplatespec" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/probes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/resourcerequirements" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/readiness/config" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/scale" ) +var OfficialMongodbRepoUrls = []string{"docker.io/mongodb", "quay.io/mongodb"} + // Environment variables used to configure the MongoDB StatefulSet. const ( - MongodbRepoUrlEnv = "MONGODB_REPO_URL" - MongodbImageEnv = "MONGODB_IMAGE" - MongoDBImageTypeEnv = "MDB_IMAGE_TYPE" - AgentImageEnv = "AGENT_IMAGE" - VersionUpgradeHookImageEnv = "VERSION_UPGRADE_HOOK_IMAGE" - ReadinessProbeImageEnv = "READINESS_PROBE_IMAGE" + MongodbRepoUrlEnv = "MONGODB_REPO_URL" + MongodbImageEnv = "MONGODB_IMAGE" + MongoDBImageTypeEnv = "MDB_IMAGE_TYPE" + AgentImageEnv = "AGENT_IMAGE" +) + +// MCO only +const ( + VersionUpgradeHookImageEnv = "VERSION_UPGRADE_HOOK_IMAGE" + ReadinessProbeImageEnv = "READINESS_PROBE_IMAGE" + MongoDBCommunityImageTypeEnv = "MDB_COMMUNITY_IMAGE_TYPE" + MongodbCommunityImageEnv = "MDB_COMMUNITY_IMAGE" + MongodbCommunityRepoUrlEnv = "MDB_COMMUNITY_REPO_URL" ) const ( @@ -42,12 +47,13 @@ const ( DefaultImageType = "ubi8" - versionUpgradeHookName = "mongod-posthook" - ReadinessProbeContainerName = "mongodb-agent-readinessprobe" - readinessProbePath = "/opt/scripts/readinessprobe" - agentHealthStatusFilePathEnv = "AGENT_STATUS_FILEPATH" - clusterFilePath = "/var/lib/automation/config/cluster-config.json" - mongodbDatabaseServiceAccountName = "mongodb-database" + versionUpgradeHookName = "mongod-posthook" + ReadinessProbeContainerName = "mongodb-agent-readinessprobe" + readinessProbePath = "/opt/scripts/readinessprobe" + agentHealthStatusFilePathEnv = "AGENT_STATUS_FILEPATH" + clusterFilePath = "/var/lib/automation/config/cluster-config.json" + // TODO: MCK create a new one and not just use appdb + mongodbDatabaseServiceAccountName = "mongodb-enterprise-appdb" agentHealthStatusFilePathValue = "/var/log/mongodb-mms-automation/healthstatus/agent-health-status.json" OfficialMongodbEnterpriseServerImageName = "mongodb-enterprise-server" diff --git a/mongodb-community-operator/controllers/construct/mongodbstatefulset_test.go b/mongodb-community-operator/controllers/construct/mongodbstatefulset_test.go index 67d78174b..881df8849 100644 --- a/mongodb-community-operator/controllers/construct/mongodbstatefulset_test.go +++ b/mongodb-community-operator/controllers/construct/mongodbstatefulset_test.go @@ -1,10 +1,13 @@ package construct import ( - "github.com/mongodb/mongodb-kubernetes-operator/pkg/readiness/config" + "testing" + "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" - "testing" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/readiness/config" ) func TestCollectEnvVars(t *testing.T) { diff --git a/mongodb-community-operator/controllers/mongodb_cleanup.go b/mongodb-community-operator/controllers/mongodb_cleanup.go index d13b0426d..e89b7fefb 100644 --- a/mongodb-community-operator/controllers/mongodb_cleanup.go +++ b/mongodb-community-operator/controllers/mongodb_cleanup.go @@ -2,11 +2,13 @@ package controllers import ( "context" - apiErrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/types" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" + apiErrors "k8s.io/apimachinery/pkg/api/errors" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" ) // cleanupPemSecret cleans up the old pem secret generated for the agent certificate. diff --git a/mongodb-community-operator/controllers/mongodb_cleanup_test.go b/mongodb-community-operator/controllers/mongodb_cleanup_test.go index 0123f63ee..686b4c006 100644 --- a/mongodb-community-operator/controllers/mongodb_cleanup_test.go +++ b/mongodb-community-operator/controllers/mongodb_cleanup_test.go @@ -4,11 +4,13 @@ import ( "context" "testing" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - kubeClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + kubeClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" ) func TestReplicaSetReconcilerCleanupScramSecrets(t *testing.T) { @@ -95,8 +97,8 @@ func TestReplicaSetReconcilerCleanupScramSecrets(t *testing.T) { assert.Equal(t, expected, actual) }) - } + func TestReplicaSetReconcilerCleanupPemSecret(t *testing.T) { ctx := context.Background() lastAppliedSpec := mdbv1.MongoDBCommunitySpec{ @@ -238,5 +240,4 @@ func TestReplicaSetReconcilerCleanupConnectionStringSecrets(t *testing.T) { assert.Equal(t, expected, actual) }) - } diff --git a/mongodb-community-operator/controllers/mongodb_status_options.go b/mongodb-community-operator/controllers/mongodb_status_options.go index 5961bdcbd..bd66b3fcf 100644 --- a/mongodb-community-operator/controllers/mongodb_status_options.go +++ b/mongodb-community-operator/controllers/mongodb_status_options.go @@ -1,13 +1,13 @@ package controllers import ( - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/apierrors" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/result" "go.uber.org/zap" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/status" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/apierrors" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/result" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/status" ) // severity indicates the severity level diff --git a/mongodb-community-operator/controllers/mongodb_status_options_test.go b/mongodb-community-operator/controllers/mongodb_status_options_test.go index 9041c8d99..88571a298 100644 --- a/mongodb-community-operator/controllers/mongodb_status_options_test.go +++ b/mongodb-community-operator/controllers/mongodb_status_options_test.go @@ -3,16 +3,16 @@ package controllers import ( "testing" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" + "github.com/stretchr/testify/assert" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/stretchr/testify/assert" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" ) const testVersion string = "4.2.6" func TestMongoUriOption_ApplyOption(t *testing.T) { - mdb := newReplicaSet(3, testVersion, "my-rs", "my-ns") opt := mongoUriOption{ diff --git a/mongodb-community-operator/controllers/mongodb_tls.go b/mongodb-community-operator/controllers/mongodb_tls.go index 56c67642d..16b7afb42 100644 --- a/mongodb-community-operator/controllers/mongodb_tls.go +++ b/mongodb-community-operator/controllers/mongodb_tls.go @@ -6,22 +6,18 @@ import ( "fmt" "strings" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - - "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/podtemplatespec" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" + "k8s.io/apimachinery/pkg/types" apiErrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/podtemplatespec" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" ) const ( @@ -33,6 +29,7 @@ const ( tlsSecretKeyName = "tls.key" tlsSecretPemName = "tls.pem" automationAgentPemMountPath = "/var/lib/mongodb-mms-automation/agent-certs" + X509Auth = "X509" ) // validateTLSConfig will check that the configured ConfigMap and Secret exist and that they have the correct fields. @@ -45,7 +42,6 @@ func (r *ReplicaSetReconciler) validateTLSConfig(ctx context.Context, mdb mdbv1. // Ensure CA cert is configured _, err := getCaCrt(ctx, r.client, r.client, mdb) - if err != nil { if apiErrors.IsNotFound(err) { r.log.Warnf("CA resource not found: %s", err) @@ -228,7 +224,7 @@ func ensureTLSSecret(ctx context.Context, getUpdateCreator secret.GetUpdateCreat } func ensureAgentCertSecret(ctx context.Context, getUpdateCreator secret.GetUpdateCreator, mdb mdbv1.MongoDBCommunity) error { - if mdb.Spec.GetAgentAuthMode() != "X509" { + if mdb.Spec.GetAgentAuthMode() != X509Auth { return nil } @@ -361,7 +357,7 @@ func buildTLSPrometheus(mdb mdbv1.MongoDBCommunity) podtemplatespec.Modification } func buildAgentX509(mdb mdbv1.MongoDBCommunity) podtemplatespec.Modification { - if mdb.Spec.GetAgentAuthMode() != "X509" { + if mdb.Spec.GetAgentAuthMode() != X509Auth { return podtemplatespec.Apply( podtemplatespec.RemoveVolume(constants.AgentPemFile), podtemplatespec.RemoveVolumeMount(construct.AgentName, constants.AgentPemFile), @@ -375,5 +371,4 @@ func buildAgentX509(mdb mdbv1.MongoDBCommunity) podtemplatespec.Modification { podtemplatespec.WithVolume(agentCertVolume), podtemplatespec.WithVolumeMounts(construct.AgentName, agentCertVolumeMount), ) - } diff --git a/mongodb-community-operator/controllers/mongodb_tls_test.go b/mongodb-community-operator/controllers/mongodb_tls_test.go index b4e832778..ea22bdb44 100644 --- a/mongodb-community-operator/controllers/mongodb_tls_test.go +++ b/mongodb-community-operator/controllers/mongodb_tls_test.go @@ -5,22 +5,21 @@ import ( "errors" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - - corev1 "k8s.io/api/core/v1" + "github.com/stretchr/testify/assert" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/reconcile" appsv1 "k8s.io/api/apps/v1" - "k8s.io/apimachinery/pkg/types" + corev1 "k8s.io/api/core/v1" k8sClient "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/x509" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - kubeClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/stretchr/testify/assert" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/x509" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + kubeClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" ) func TestStatefulSetIsCorrectlyConfiguredWithTLS(t *testing.T) { @@ -272,7 +271,7 @@ func TestStatefulSetIsCorrectlyConfiguredWithTLSAfterChangingExistingVolumes(t * // updating sts tls-ca volume directly to simulate changing of underlying volume's secret for i := range sts.Spec.Template.Spec.Volumes { if sts.Spec.Template.Spec.Volumes[i].Name == "tls-ca" { - sts.Spec.Template.Spec.Volumes[i].VolumeSource.Secret.SecretName = changedTLSCAVolumeSecretName + sts.Spec.Template.Spec.Volumes[i].Secret.SecretName = changedTLSCAVolumeSecretName } } @@ -514,19 +513,23 @@ func TestTLSConfigReferencesToCACertAreValidated(t *testing.T) { tests := map[string]args{ "Success if reference to CA cert provided via secret": { caConfigMap: &corev1.LocalObjectReference{ - Name: "certificateKeySecret"}, + Name: "certificateKeySecret", + }, caCertificateSecret: nil, }, "Success if reference to CA cert provided via config map": { caConfigMap: nil, caCertificateSecret: &corev1.LocalObjectReference{ - Name: "caConfigMap"}, + Name: "caConfigMap", + }, }, "Succes if reference to CA cert provided both via secret and configMap": { caConfigMap: &corev1.LocalObjectReference{ - Name: "certificateKeySecret"}, + Name: "certificateKeySecret", + }, caCertificateSecret: &corev1.LocalObjectReference{ - Name: "caConfigMap"}, + Name: "caConfigMap", + }, }, "Failure if reference to CA cert is missing": { caConfigMap: nil, @@ -554,7 +557,6 @@ func TestTLSConfigReferencesToCACertAreValidated(t *testing.T) { } }) } - } func createTLSConfigMap(ctx context.Context, c k8sClient.Client, mdb mdbv1.MongoDBCommunity) error { diff --git a/mongodb-community-operator/controllers/mongodb_users.go b/mongodb-community-operator/controllers/mongodb_users.go index cd99734ba..724fc4f02 100644 --- a/mongodb-community-operator/controllers/mongodb_users.go +++ b/mongodb-community-operator/controllers/mongodb_users.go @@ -4,11 +4,13 @@ import ( "context" "fmt" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - apiErrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" + + apiErrors "k8s.io/apimachinery/pkg/api/errors" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" ) // ensureUserResources will check that the configured user password secrets can be found diff --git a/mongodb-community-operator/controllers/predicates/predicates.go b/mongodb-community-operator/controllers/predicates/predicates.go index 9acc314b6..4e241342f 100644 --- a/mongodb-community-operator/controllers/predicates/predicates.go +++ b/mongodb-community-operator/controllers/predicates/predicates.go @@ -3,9 +3,10 @@ package predicates import ( "reflect" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" ) // OnlyOnSpecChange returns a set of predicates indicating diff --git a/mongodb-community-operator/controllers/prometheus.go b/mongodb-community-operator/controllers/prometheus.go index cebe939fe..4aa9fb1cf 100644 --- a/mongodb-community-operator/controllers/prometheus.go +++ b/mongodb-community-operator/controllers/prometheus.go @@ -4,13 +4,13 @@ import ( "context" "fmt" - corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/types" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" + corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" ) const ( @@ -71,7 +71,7 @@ func getPrometheusModification(ctx context.Context, getUpdateCreator secret.GetU func prometheusPort(mdb mdbv1.MongoDBCommunity) *corev1.ServicePort { if mdb.Spec.Prometheus != nil { return &corev1.ServicePort{ - Port: int32(mdb.Spec.Prometheus.GetPort()), + Port: int32(mdb.Spec.Prometheus.GetPort()), //nolint:gosec Name: "prometheus", } } diff --git a/mongodb-community-operator/controllers/replica_set_controller.go b/mongodb-community-operator/controllers/replica_set_controller.go index cf3e9d526..3ae356e1f 100644 --- a/mongodb-community-operator/controllers/replica_set_controller.go +++ b/mongodb-community-operator/controllers/replica_set_controller.go @@ -9,40 +9,42 @@ import ( "strings" "github.com/imdario/mergo" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - "github.com/mongodb/mongodb-kubernetes-operator/controllers/predicates" - "github.com/mongodb/mongodb-kubernetes-operator/controllers/validation" - "github.com/mongodb/mongodb-kubernetes-operator/controllers/watch" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/agent" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/podtemplatespec" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/service" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/functions" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/result" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/status" "github.com/stretchr/objx" "go.uber.org/zap" - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - apiErrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" - ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" - k8sClient "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + apiErrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + ctrl "sigs.k8s.io/controller-runtime" + k8sClient "sigs.k8s.io/controller-runtime/pkg/client" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/predicates" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/validation" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/watch" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/agent" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/podtemplatespec" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/service" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/functions" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/result" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/scale" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/status" ) const ( @@ -121,7 +123,6 @@ type ReplicaSetReconciler struct { // The Controller will requeue the Request to be processed again if the returned error is non-nil or // Result.Requeue is true, otherwise upon completion it will remove the work from the queue. func (r ReplicaSetReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) { - // TODO: generalize preparation for resource // Fetch the MongoDB instance mdb := mdbv1.MongoDBCommunity{} @@ -697,7 +698,6 @@ func (r ReplicaSetReconciler) buildAutomationConfig(ctx context.Context, mdb mdb prometheusModification, processPortManager.GetPortsModification(), ) - if err != nil { return automationconfig.AutomationConfig{}, fmt.Errorf("could not create an automation config: %s", err) } diff --git a/mongodb-community-operator/controllers/replicaset_controller_test.go b/mongodb-community-operator/controllers/replicaset_controller_test.go index d7f2eb8da..a3e4c2e19 100644 --- a/mongodb-community-operator/controllers/replicaset_controller_test.go +++ b/mongodb-community-operator/controllers/replicaset_controller_test.go @@ -9,41 +9,34 @@ import ( "testing" "time" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/x509" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" + "github.com/stretchr/objx" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - apiErrors "k8s.io/apimachinery/pkg/api/errors" - "sigs.k8s.io/controller-runtime/pkg/manager" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/yaml" - "github.com/stretchr/objx" - - k8sClient "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - - "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/probes" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/resourcerequirements" - "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" + apiErrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/reconcile" + k8sClient "sigs.k8s.io/controller-runtime/pkg/client" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/x509" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/probes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/resourcerequirements" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" ) const ( @@ -251,8 +244,8 @@ func TestGuessEnterprise(t *testing.T) { setArgs: func(t *testing.T) {}, mdb: mdbv1.MongoDBCommunity{ Spec: mdbv1.MongoDBCommunitySpec{ - StatefulSetConfiguration: mdbv1.StatefulSetConfiguration{ - SpecWrapper: mdbv1.StatefulSetSpecWrapper{ + StatefulSetConfiguration: common.StatefulSetConfiguration{ + SpecWrapper: common.StatefulSetSpecWrapper{ Spec: appsv1.StatefulSetSpec{ Template: corev1.PodTemplateSpec{ Spec: corev1.PodSpec{ @@ -276,8 +269,8 @@ func TestGuessEnterprise(t *testing.T) { setArgs: func(t *testing.T) {}, mdb: mdbv1.MongoDBCommunity{ Spec: mdbv1.MongoDBCommunitySpec{ - StatefulSetConfiguration: mdbv1.StatefulSetConfiguration{ - SpecWrapper: mdbv1.StatefulSetSpecWrapper{ + StatefulSetConfiguration: common.StatefulSetConfiguration{ + SpecWrapper: common.StatefulSetSpecWrapper{ Spec: appsv1.StatefulSetSpec{ Template: corev1.PodTemplateSpec{ Spec: corev1.PodSpec{ @@ -846,7 +839,6 @@ func TestAutomationConfigFCVIsNotIncreasedWhenUpgradingMinorVersion(t *testing.T assert.NoError(t, err) assert.Len(t, currentAc.Processes, 3) assert.Equal(t, currentAc.Processes[0].FeatureCompatibilityVersion, "4.2") - } func TestAutomationConfig_CustomMongodConfig(t *testing.T) { @@ -916,7 +908,6 @@ func TestExistingPasswordAndKeyfile_AreUsedWhenTheSecretExists(t *testing.T) { assert.Equal(t, "my-keyfile", currentAc.Auth.Key) assert.NotEmpty(t, currentAc.Auth.KeyFileWindows) assert.Equal(t, "my-pass", currentAc.Auth.AutoPwd) - } func TestScramIsConfigured(t *testing.T) { diff --git a/mongodb-community-operator/controllers/validation/validation.go b/mongodb-community-operator/controllers/validation/validation.go index 3d84cc1c0..593e74281 100644 --- a/mongodb-community-operator/controllers/validation/validation.go +++ b/mongodb-community-operator/controllers/validation/validation.go @@ -7,9 +7,9 @@ import ( "go.uber.org/zap" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" ) // ValidateInitialSpec checks if the resource's initial Spec is valid. @@ -177,10 +177,10 @@ func validateAuthModeSpec(mdb mdbv1.MongoDBCommunity, log *zap.SugaredLogger) er agentMode := mdb.Spec.GetAgentAuthMode() if agentMode == "" && len(allModes) > 1 { - return fmt.Errorf("If spec.security.authentication.modes contains different authentication modes, the agent mode must be specified ") + return fmt.Errorf("if spec.security.authentication.modes contains different authentication modes, the agent mode must be specified ") } if _, present := mapMechanisms[mdbv1.ConvertAuthModeToAuthMechanism(agentMode)]; !present { - return fmt.Errorf("Agent authentication mode: %s must be part of the spec.security.authentication.modes", agentMode) + return fmt.Errorf("agent authentication mode: %s must be part of the spec.security.authentication.modes", agentMode) } return nil @@ -199,7 +199,8 @@ func validateAgentCertSecret(mdb mdbv1.MongoDBCommunity, log *zap.SugaredLogger) func validateStatefulSet(mdb mdbv1.MongoDBCommunity) error { stsReplicas := mdb.Spec.StatefulSetConfiguration.SpecWrapper.Spec.Replicas - if stsReplicas != nil && *stsReplicas != int32(mdb.Spec.Members) { + // TODO: MCK fix all nolint:gosec + if stsReplicas != nil && *stsReplicas != int32(mdb.Spec.Members) { //nolint:gosec return fmt.Errorf("spec.statefulset.spec.replicas has to be equal to spec.members") } diff --git a/mongodb-community-operator/controllers/watch/watch.go b/mongodb-community-operator/controllers/watch/watch.go index 9522c53c3..903b37d4e 100644 --- a/mongodb-community-operator/controllers/watch/watch.go +++ b/mongodb-community-operator/controllers/watch/watch.go @@ -2,13 +2,16 @@ package watch import ( "context" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/contains" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/workqueue" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/contains" ) // ResourceWatcher implements handler.EventHandler and is used to trigger reconciliation when diff --git a/mongodb-community-operator/controllers/watch/watch_test.go b/mongodb-community-operator/controllers/watch/watch_test.go index ab8c522be..6fc596727 100644 --- a/mongodb-community-operator/controllers/watch/watch_test.go +++ b/mongodb-community-operator/controllers/watch/watch_test.go @@ -4,19 +4,16 @@ import ( "context" "testing" - "k8s.io/apimachinery/pkg/types" - - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/stretchr/testify/assert" - + "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/util/workqueue" "sigs.k8s.io/controller-runtime/pkg/controller/controllertest" + "sigs.k8s.io/controller-runtime/pkg/event" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/util/workqueue" - "sigs.k8s.io/controller-runtime/pkg/event" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" ) func TestWatcher(t *testing.T) { diff --git a/mongodb-community-operator/deploy/e2e/role_binding.yaml b/mongodb-community-operator/deploy/e2e/role_binding.yaml index 17a3828b3..dbe528b8a 100644 --- a/mongodb-community-operator/deploy/e2e/role_binding.yaml +++ b/mongodb-community-operator/deploy/e2e/role_binding.yaml @@ -2,11 +2,11 @@ kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: e2e-test +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin subjects: - kind: ServiceAccount name: e2e-test namespace: mongodb -roleRef: - kind: ClusterRole - name: e2e-test - apiGroup: rbac.authorization.k8s.io diff --git a/mongodb-community-operator/deploy/e2e/service_account.yaml b/mongodb-community-operator/deploy/e2e/service_account.yaml index 84fea363b..5c6a17b01 100644 --- a/mongodb-community-operator/deploy/e2e/service_account.yaml +++ b/mongodb-community-operator/deploy/e2e/service_account.yaml @@ -3,3 +3,5 @@ kind: ServiceAccount metadata: name: e2e-test namespace: mongodb +imagePullSecrets: + - name: image-registries-secret diff --git a/mongodb-community-operator/deploy/openshift/operator_openshift.yaml b/mongodb-community-operator/deploy/openshift/operator_openshift.yaml index b7011a1cc..c0f3cf1ce 100644 --- a/mongodb-community-operator/deploy/openshift/operator_openshift.yaml +++ b/mongodb-community-operator/deploy/openshift/operator_openshift.yaml @@ -47,16 +47,16 @@ spec: - name: OPERATOR_NAME value: mongodb-kubernetes-operator - name: AGENT_IMAGE - value: quay.io/mongodb/mongodb-agent-ubi:108.0.6.8796-1 + value: quay.io/mongodb/mongodb-agent-ubi:108.0.2.8729-1 - name: READINESS_PROBE_IMAGE - value: quay.io/mongodb/mongodb-kubernetes-readinessprobe:1.0.23 + value: quay.io/mongodb/mongodb-kubernetes-readinessprobe:1.0.22 - name: VERSION_UPGRADE_HOOK_IMAGE - value: quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook:1.0.10 + value: quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook:1.0.9 - name: MONGODB_IMAGE value: mongo - name: MONGODB_REPO_URL value: quay.io - image: quay.io/mongodb/mongodb-kubernetes-operator:0.13.0 + image: quay.io/mongodb/mongodb-kubernetes-operator:0.12.0 imagePullPolicy: Always name: mongodb-kubernetes-operator resources: diff --git a/mongodb-community-operator/docs/RELEASE_NOTES.md b/mongodb-community-operator/docs/RELEASE_NOTES.md index 6109fac02..13beb2133 100644 --- a/mongodb-community-operator/docs/RELEASE_NOTES.md +++ b/mongodb-community-operator/docs/RELEASE_NOTES.md @@ -1,18 +1,5 @@ # MongoDB Kubernetes Operator 0.13.0 -## Dependency updates - - Updated kubernetes dependencies to 1.30 - - Bumped Go dependency to 1.24 - - Updated packages `crypto`, `net` and `oauth2` to remediate multiple CVEs - -## MongoDBCommunity Resource - - Added support for overriding the ReplicaSet ID ([#1656](https://github.com/mongodb/mongodb-kubernetes-operator/pull/1656)). - -## Improvements - - Refactored environment variable propagation ([#1676](https://github.com/mongodb/mongodb-kubernetes-operator/pull/1676)). - - Introduced a linter to limit inappropriate usage of environment variables within the codebase ([#1690](https://github.com/mongodb/mongodb-kubernetes-operator/pull/1690)). - -## Security & Dependency Updates - - **CVE Updates**: Updated packages `crypto`, `net` and `oauth2` to remediate multiple CVEs - - Upgraded to Go 1.24 and Kubernetes dependencies to 1.30.x . +## Minor fixes and improvements + - Bumped kube APIs to 1.30 diff --git a/mongodb-community-operator/go.mod b/mongodb-community-operator/go.mod deleted file mode 100644 index 35b8ccebc..000000000 --- a/mongodb-community-operator/go.mod +++ /dev/null @@ -1,90 +0,0 @@ -module github.com/mongodb/mongodb-kubernetes-operator - -go 1.24.0 - -require ( - github.com/blang/semver v3.5.1+incompatible - github.com/go-logr/logr v1.4.2 - github.com/hashicorp/go-multierror v1.1.1 - github.com/imdario/mergo v0.3.15 - github.com/spf13/cast v1.7.1 - github.com/stretchr/objx v0.5.2 - github.com/stretchr/testify v1.10.0 - github.com/xdg/stringprep v1.0.3 - go.mongodb.org/mongo-driver v1.16.0 - go.uber.org/zap v1.27.0 - gopkg.in/natefinch/lumberjack.v2 v2.2.1 - k8s.io/api v0.30.10 - k8s.io/apimachinery v0.30.10 - k8s.io/client-go v0.30.10 - k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 - sigs.k8s.io/controller-runtime v0.18.7 - sigs.k8s.io/yaml v1.4.0 -) - -require google.golang.org/protobuf v1.33.0 // indirect - -require ( - github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/emicklei/go-restful/v3 v3.11.0 // indirect - github.com/evanphx/json-patch v4.12.0+incompatible // indirect - github.com/evanphx/json-patch/v5 v5.9.0 // indirect - github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/go-openapi/jsonpointer v0.19.6 // indirect - github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.22.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.4 // indirect - github.com/golang/snappy v0.0.4 // indirect - github.com/google/gnostic-models v0.6.8 // indirect - github.com/google/go-cmp v0.6.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/gorilla/websocket v1.5.0 // indirect - github.com/hashicorp/errwrap v1.0.0 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.13.6 // indirect - github.com/mailru/easyjson v0.7.7 // indirect - github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect - github.com/moby/spdystream v0.2.0 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/montanaflynn/stats v0.7.1 // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect - github.com/prometheus/client_model v0.5.0 // indirect - github.com/prometheus/common v0.45.0 // indirect - github.com/prometheus/procfs v0.12.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/xdg-go/pbkdf2 v1.0.0 // indirect - github.com/xdg-go/scram v1.1.2 // indirect - github.com/xdg-go/stringprep v1.0.4 // indirect - github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect - go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.37.0 // indirect - golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect - golang.org/x/net v0.39.0 // indirect - golang.org/x/oauth2 v0.29.0 // indirect - golang.org/x/sync v0.13.0 // indirect - golang.org/x/sys v0.32.0 // indirect - golang.org/x/term v0.31.0 // indirect - golang.org/x/text v0.24.0 // indirect - golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.23.0 // indirect - gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.30.1 // indirect - k8s.io/klog/v2 v2.120.1 // indirect - k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect - sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect -) diff --git a/mongodb-community-operator/go.sum b/mongodb-community-operator/go.sum deleted file mode 100644 index 4e2b54c85..000000000 --- a/mongodb-community-operator/go.sum +++ /dev/null @@ -1,247 +0,0 @@ -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= -github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= -github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84= -github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= -github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= -github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= -github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= -github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= -github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= -github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= -github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= -github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= -github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= -github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= -github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= -github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= -github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= -github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= -github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= -github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= -github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8= -github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs= -github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk= -github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= -github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= -github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= -github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= -github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= -github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y= -github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= -github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= -github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= -github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= -github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= -github.com/xdg/stringprep v1.0.3 h1:cmL5Enob4W83ti/ZHuZLuKD/xqJfus4fVPwE+/BDm+4= -github.com/xdg/stringprep v1.0.3/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver v1.16.0 h1:tpRsfBJMROVHKpdGyc1BBEzzjDUWjItxbVSZ8Ls4BQ4= -go.mongodb.org/mongo-driver v1.16.0/go.mod h1:oB6AhJQvFQL4LEHyXi6aJzQJtBiTQHiAd83l0GdFaiw= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= -golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= -golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= -golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= -golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= -golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98= -golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= -golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= -golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o= -golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= -golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= -golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= -golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= -gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= -gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= -gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.30.10 h1:2YvzRF/BELgCvxbQqFKaan5hnj2+y7JOuqu2WpVk3gg= -k8s.io/api v0.30.10/go.mod h1:Hyz3ZuK7jVLJBUFvwzDSGwxHuDdsrGs5RzF16wfHIn4= -k8s.io/apiextensions-apiserver v0.30.1 h1:4fAJZ9985BmpJG6PkoxVRpXv9vmPUOVzl614xarePws= -k8s.io/apiextensions-apiserver v0.30.1/go.mod h1:R4GuSrlhgq43oRY9sF2IToFh7PVlF1JjfWdoG3pixk4= -k8s.io/apimachinery v0.30.10 h1:UflKuJeSSArttm05wjYP0GwpTlvjnMbDKFn6F7rKkKU= -k8s.io/apimachinery v0.30.10/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= -k8s.io/client-go v0.30.10 h1:C0oWM82QMvosIl/IdJhWfTUb7rIxM52rNSutFBknAVY= -k8s.io/client-go v0.30.10/go.mod h1:OfTvt0yuo8VpMViOsgvYQb+tMJQLNWVBqXWkzdFXSq4= -k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= -k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= -k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= -k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 h1:jgGTlFYnhF1PM1Ax/lAlxUPE+KfCIXHaathvJg1C3ak= -k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-runtime v0.18.7 h1:WDnx8LTRY8Fn1j/7B+S/R9MeDjWNAzpDBoaSvMSrQME= -sigs.k8s.io/controller-runtime v0.18.7/go.mod h1:L9r3fUZhID7Q9eK9mseNskpaTg2n11f/tlb8odyzJ4Y= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= -sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= -sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= -sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/mongodb-community-operator/helm-charts b/mongodb-community-operator/helm-charts deleted file mode 160000 index c6b6488a2..000000000 --- a/mongodb-community-operator/helm-charts +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c6b6488a2a84cb806eadac0e286b6060914082d5 diff --git a/mongodb-community-operator/pipeline.py b/mongodb-community-operator/pipeline.py index f288d1a5b..ea3581fc4 100644 --- a/mongodb-community-operator/pipeline.py +++ b/mongodb-community-operator/pipeline.py @@ -3,15 +3,16 @@ import subprocess import sys from typing import Dict, List, Set + +from sonar import process_image + from scripts.ci.base_logger import logger from scripts.ci.images_signing import ( + mongodb_artifactory_login, sign_image, verify_signature, - mongodb_artifactory_login, ) - -from scripts.dev.dev_config import load_config, DevConfig -from sonar.sonar import process_image +from scripts.dev.dev_config import DevConfig, load_config # These image names must correspond to prefixes in release.json, developer configuration and inventories VALID_IMAGE_NAMES = { @@ -128,9 +129,7 @@ def build_and_push_image( if release: registry = args["registry"] + "/" + args["image"] context_tag = args["release_version"] + "-context" - push_manifest( - config, architectures, args["image"], insecure, args["release_version"] - ) + push_manifest(config, architectures, args["image"], insecure, args["release_version"]) push_manifest(config, architectures, args["image"], insecure, context_tag) if sign: sign_and_verify(registry, args["release_version"]) @@ -251,9 +250,7 @@ def main() -> int: image_name = args.image_name if image_name not in VALID_IMAGE_NAMES: - logger.error( - f"Invalid image name: {image_name}. Valid options are: {VALID_IMAGE_NAMES}" - ) + logger.error(f"Invalid image name: {image_name}. Valid options are: {VALID_IMAGE_NAMES}") return 1 # Handle dev config @@ -262,9 +259,7 @@ def main() -> int: # Warn user if trying to release E2E tests if args.release and image_name == "e2e": - logger.warning( - "Warning : releasing E2E test will fail because E2E image has no release version" - ) + logger.warning("Warning : releasing E2E test will fail because E2E image has no release version") # Skipping release tasks by default if not args.release: @@ -284,9 +279,7 @@ def main() -> int: image_args = build_image_args(config, image_name) - build_and_push_image( - image_name, config, image_args, arch_set, args.release, args.sign, args.insecure - ) + build_and_push_image(image_name, config, image_args, arch_set, args.release, args.sign, args.insecure) return 0 diff --git a/mongodb-community-operator/pkg/agent/agent_readiness.go b/mongodb-community-operator/pkg/agent/agent_readiness.go index eefe3a49d..46e45b611 100644 --- a/mongodb-community-operator/pkg/agent/agent_readiness.go +++ b/mongodb-community-operator/pkg/agent/agent_readiness.go @@ -4,13 +4,15 @@ import ( "context" "fmt" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/pod" "github.com/spf13/cast" "go.uber.org/zap" + "k8s.io/apimachinery/pkg/types" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/pod" ) const ( diff --git a/mongodb-community-operator/pkg/agent/agent_readiness_test.go b/mongodb-community-operator/pkg/agent/agent_readiness_test.go index 2f898ad9d..01de37e5a 100644 --- a/mongodb-community-operator/pkg/agent/agent_readiness_test.go +++ b/mongodb-community-operator/pkg/agent/agent_readiness_test.go @@ -5,13 +5,15 @@ import ( "os" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" "github.com/stretchr/testify/assert" "go.uber.org/zap" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" ) func init() { diff --git a/mongodb-community-operator/pkg/agent/agentflags_test.go b/mongodb-community-operator/pkg/agent/agentflags_test.go index e56b67613..448657e4b 100644 --- a/mongodb-community-operator/pkg/agent/agentflags_test.go +++ b/mongodb-community-operator/pkg/agent/agentflags_test.go @@ -21,7 +21,6 @@ func TestAgentFlagIsCorrectlyCreated(t *testing.T) { envVar := StartupParametersToAgentFlag(parameters...) assert.Equal(t, "AGENT_FLAGS", envVar.Name) assert.Equal(t, " -Key1 Value1 -Key2 Value2", envVar.Value) - } func TestAgentFlagEmptyParameters(t *testing.T) { @@ -30,5 +29,4 @@ func TestAgentFlagEmptyParameters(t *testing.T) { envVar := StartupParametersToAgentFlag(parameters...) assert.Equal(t, "AGENT_FLAGS", envVar.Name) assert.Equal(t, "", envVar.Value) - } diff --git a/mongodb-community-operator/pkg/agent/replica_set_port_manager.go b/mongodb-community-operator/pkg/agent/replica_set_port_manager.go index e47e94181..6068d5e0e 100644 --- a/mongodb-community-operator/pkg/agent/replica_set_port_manager.go +++ b/mongodb-community-operator/pkg/agent/replica_set_port_manager.go @@ -1,9 +1,11 @@ package agent import ( - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" "go.uber.org/zap" + corev1 "k8s.io/api/core/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" ) // ReplicaSetPortManager is used to determine which ports should be set in pods (mongod processes) and in the service. @@ -55,18 +57,18 @@ func (r *ReplicaSetPortManager) GetServicePorts() []corev1.ServicePort { if !portChangeRequired || oldPort == r.expectedPort { return []corev1.ServicePort{{ - Port: int32(r.expectedPort), + Port: int32(r.expectedPort), //nolint:gosec Name: "mongodb", }} } servicePorts := []corev1.ServicePort{ { - Port: int32(r.expectedPort), + Port: int32(r.expectedPort), //nolint:gosec Name: "mongodb-new", }, { - Port: int32(oldPort), + Port: int32(oldPort), //nolint:gosec Name: "mongodb", }, } diff --git a/mongodb-community-operator/pkg/agent/replica_set_port_manager_test.go b/mongodb-community-operator/pkg/agent/replica_set_port_manager_test.go index 4a24be9d8..00ba08833 100644 --- a/mongodb-community-operator/pkg/agent/replica_set_port_manager_test.go +++ b/mongodb-community-operator/pkg/agent/replica_set_port_manager_test.go @@ -4,11 +4,12 @@ import ( "fmt" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap" "k8s.io/apimachinery/pkg/types" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" ) func TestReplicaSetPortManagerCalculateExpectedPorts(t *testing.T) { @@ -209,5 +210,4 @@ func TestReplicaSetPortManagerCalculateExpectedPorts(t *testing.T) { assert.Equal(t, tc.expectedOutput, actualOutput) }) } - } diff --git a/mongodb-community-operator/pkg/authentication/authentication.go b/mongodb-community-operator/pkg/authentication/authentication.go index a856bda66..b30ebed69 100644 --- a/mongodb-community-operator/pkg/authentication/authentication.go +++ b/mongodb-community-operator/pkg/authentication/authentication.go @@ -3,16 +3,16 @@ package authentication import ( "context" "fmt" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/scram" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/x509" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/scram" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/x509" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" ) func Enable(ctx context.Context, auth *automationconfig.Auth, secretGetUpdateCreateDeleter secret.GetUpdateCreateDeleter, mdb authtypes.Configurable, agentCertSecret types.NamespacedName) error { diff --git a/mongodb-community-operator/pkg/authentication/authentication_test.go b/mongodb-community-operator/pkg/authentication/authentication_test.go index edfef363d..148ae6efc 100644 --- a/mongodb-community-operator/pkg/authentication/authentication_test.go +++ b/mongodb-community-operator/pkg/authentication/authentication_test.go @@ -2,19 +2,20 @@ package authentication import ( "context" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" "testing" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/mocks" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/x509" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - "github.com/stretchr/testify/assert" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/mocks" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/x509" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" ) func TestEnable(t *testing.T) { @@ -130,7 +131,6 @@ func TestEnable(t *testing.T) { assert.Equal(t, "CN=my-user,OU=organizationalunit,O=organization", auth.Users[1].Username) assert.Equal(t, "CN=mms-automation-agent,OU=ENG,O=MongoDB,C=US", auth.AutoUser) }) - } func TestGetDeletedUsers(t *testing.T) { diff --git a/mongodb-community-operator/pkg/authentication/authtypes/authtypes.go b/mongodb-community-operator/pkg/authentication/authtypes/authtypes.go index 12d7b0cbb..7eb5e6d47 100644 --- a/mongodb-community-operator/pkg/authentication/authtypes/authtypes.go +++ b/mongodb-community-operator/pkg/authentication/authtypes/authtypes.go @@ -4,11 +4,12 @@ import ( "fmt" "net/url" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/contains" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/contains" ) // Options contains a set of values that can be used for more fine-grained configuration of authentication. diff --git a/mongodb-community-operator/pkg/authentication/mocks/mocks.go b/mongodb-community-operator/pkg/authentication/mocks/mocks.go index 627a105be..6ca70ccae 100644 --- a/mongodb-community-operator/pkg/authentication/mocks/mocks.go +++ b/mongodb-community-operator/pkg/authentication/mocks/mocks.go @@ -4,14 +4,15 @@ import ( "context" "fmt" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" ) type MockSecretGetUpdateCreateDeleter struct { @@ -106,7 +107,6 @@ func BuildX509MongoDBUser(name string) authtypes.User { }, }, } - } func BuildScramMongoDBUser(name string) authtypes.User { @@ -136,5 +136,4 @@ func BuildScramMongoDBUser(name string) authtypes.User { PasswordSecretName: fmt.Sprintf("%s-password-secret", name), ScramCredentialsSecretName: fmt.Sprintf("%s-scram", name), } - } diff --git a/mongodb-community-operator/pkg/authentication/scram/scram.go b/mongodb-community-operator/pkg/authentication/scram/scram.go index c21e185f1..c4a99d27b 100644 --- a/mongodb-community-operator/pkg/authentication/scram/scram.go +++ b/mongodb-community-operator/pkg/authentication/scram/scram.go @@ -6,16 +6,16 @@ import ( "fmt" "go.uber.org/zap" + "k8s.io/apimachinery/pkg/types" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/scramcredentials" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/generate" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/scramcredentials" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/generate" ) const ( @@ -78,7 +78,6 @@ func ensureAgent(ctx context.Context, auth *automationconfig.Auth, secretGetUpda // ensureScramCredentials will ensure that the ScramSha1 & ScramSha256 credentials exist and are stored in the credentials // secret corresponding to user of the given MongoDB deployment. func ensureScramCredentials(ctx context.Context, getUpdateCreator secret.GetUpdateCreator, user authtypes.User, mdbNamespacedName types.NamespacedName, ownerRef []metav1.OwnerReference) (scramcredentials.ScramCreds, scramcredentials.ScramCreds, error) { - password, err := secret.ReadKey(ctx, getUpdateCreator, user.PasswordSecretKey, types.NamespacedName{Name: user.PasswordSecretName, Namespace: mdbNamespacedName.Namespace}) if err != nil { // if the password is deleted, that's fine we can read from the stored credentials that were previously generated diff --git a/mongodb-community-operator/pkg/authentication/scram/scram_enabler.go b/mongodb-community-operator/pkg/authentication/scram/scram_enabler.go index d02b03066..62a3d0d9e 100644 --- a/mongodb-community-operator/pkg/authentication/scram/scram_enabler.go +++ b/mongodb-community-operator/pkg/authentication/scram/scram_enabler.go @@ -4,10 +4,11 @@ import ( "errors" "github.com/hashicorp/go-multierror" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/contains" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/contains" ) // enableAgentAuthentication updates the provided auth struct and configures scram authentication based on the provided diff --git a/mongodb-community-operator/pkg/authentication/scram/scram_enabler_test.go b/mongodb-community-operator/pkg/authentication/scram/scram_enabler_test.go index 1930f7aed..e12004d16 100644 --- a/mongodb-community-operator/pkg/authentication/scram/scram_enabler_test.go +++ b/mongodb-community-operator/pkg/authentication/scram/scram_enabler_test.go @@ -3,14 +3,14 @@ package scram import ( "testing" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" "github.com/stretchr/testify/assert" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" ) func TestScramAutomationConfig(t *testing.T) { - // Case 1: Both SHA-256 and SHA-1 auth := automationconfig.Auth{} opts := authtypes.Options{ diff --git a/mongodb-community-operator/pkg/authentication/scram/scram_test.go b/mongodb-community-operator/pkg/authentication/scram/scram_test.go index dd43ffc9c..9d76ef89e 100644 --- a/mongodb-community-operator/pkg/authentication/scram/scram_test.go +++ b/mongodb-community-operator/pkg/authentication/scram/scram_test.go @@ -6,19 +6,20 @@ import ( "reflect" "testing" + "github.com/stretchr/testify/assert" "go.uber.org/zap" + "k8s.io/apimachinery/pkg/types" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/mocks" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/scramcredentials" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/generate" - "github.com/stretchr/testify/assert" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/mocks" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/scramcredentials" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/generate" ) func init() { @@ -222,7 +223,6 @@ func TestConfigureScram(t *testing.T) { assert.True(t, secret.HasAllKeys(ps, constants.AgentPasswordKey)) assert.NotEmpty(t, ps.Data[constants.AgentPasswordKey]) assert.Equal(t, "A21Zv5agv3EKXFfM", string(ps.Data[constants.AgentPasswordKey])) - }) t.Run("Agent Keyfile Secret is used if present", func(t *testing.T) { @@ -243,7 +243,6 @@ func TestConfigureScram(t *testing.T) { assert.NoError(t, err) assert.True(t, secret.HasAllKeys(ks, constants.AgentKeyfileKey)) assert.Equal(t, "RuPeMaIe2g0SNTTa", string(ks.Data[constants.AgentKeyfileKey])) - }) t.Run("Agent Credentials Secret should be created", func(t *testing.T) { diff --git a/mongodb-community-operator/pkg/authentication/scramcredentials/scram_credentials_test.go b/mongodb-community-operator/pkg/authentication/scramcredentials/scram_credentials_test.go index e81234e5b..86d782c77 100644 --- a/mongodb-community-operator/pkg/authentication/scramcredentials/scram_credentials_test.go +++ b/mongodb-community-operator/pkg/authentication/scramcredentials/scram_credentials_test.go @@ -14,6 +14,7 @@ func TestScramSha1SecretsMatch(t *testing.T) { assertSecretsMatch(t, sha1.New, "4d9625b297999b3ca786d4a9622d04f1", 10, "kW9KbCQiCOll5Ljd44cjkQ==", "VJ8fFVHkPltibvT//mG/OWw44Hc=", "ceDRsgj9HezpZ4/vkZX8GZNNN50=") assertSecretsMatch(t, sha1.New, "fd0a78e418dcef39f8c768222810b894", 10, "hhX6xsoID6FeWjXncuNgAg==", "TxgaZJ4cIn+S9EfTcc9IOEG7RGc=", "d6/qjwBs0qkPKfUAjSh5eemsySE=") } + func TestScramSha256SecretsMatch(t *testing.T) { assertSecretsMatch(t, sha256.New, "Gy4ZNMr-SYEsEpAEZv", 15000, "ajdf1E1QTsNAQdBEodB4vzQOFuvcw9K6PmouVg==", "/pBk9XBwSm9UyeQmyJ3LfogfHu9Z/XTjGmRhQDHx/4I=", "Avm8mjtMyg659LAyeD4VmuzQb5lxL5iy3dCuzfscfMc=") assertSecretsMatch(t, sha256.New, "Y9SPYSJYUJB_", 15000, "Oplsu3uju+lYyX4apKb0K6xfHpmFtH99Oyk4Ow==", "oTJhml8KKZUSt9k4tg+tS6D/ygR+a2Xfo8JKjTpQoAI=", "SUfA2+SKL35u665WY5NnJJmA9L5dHu/TnWXX/0nm42Y=") diff --git a/mongodb-community-operator/pkg/authentication/x509/x509.go b/mongodb-community-operator/pkg/authentication/x509/x509.go index 20297e35f..3d5e98b56 100644 --- a/mongodb-community-operator/pkg/authentication/x509/x509.go +++ b/mongodb-community-operator/pkg/authentication/x509/x509.go @@ -18,11 +18,11 @@ import ( "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/generate" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/generate" ) // Enable will configure all of the required Kubernetes resources for X509 to be enabled. @@ -65,7 +65,7 @@ func ensureAgent(ctx context.Context, auth *automationconfig.Auth, secretGetUpda } if !isValidX509Subject(agentSubject) { - return fmt.Errorf("Agent subject: %s is not a valid subject", agentSubject) + return fmt.Errorf("agent subject: %s is not a valid subject", agentSubject) } return enableAgentAuthentication(auth, agentKeyFile, agentSubject, mdb.GetAuthOptions()) diff --git a/mongodb-community-operator/pkg/authentication/x509/x509_enabler.go b/mongodb-community-operator/pkg/authentication/x509/x509_enabler.go index d21227921..cc2314bef 100644 --- a/mongodb-community-operator/pkg/authentication/x509/x509_enabler.go +++ b/mongodb-community-operator/pkg/authentication/x509/x509_enabler.go @@ -4,10 +4,11 @@ import ( "errors" "github.com/hashicorp/go-multierror" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/contains" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/contains" ) // enableAgentAuthentication updates the provided auth struct and configures scram authentication based on the provided diff --git a/mongodb-community-operator/pkg/authentication/x509/x509_enabler_test.go b/mongodb-community-operator/pkg/authentication/x509/x509_enabler_test.go index d0e3a4b33..4d4956dc6 100644 --- a/mongodb-community-operator/pkg/authentication/x509/x509_enabler_test.go +++ b/mongodb-community-operator/pkg/authentication/x509/x509_enabler_test.go @@ -3,10 +3,11 @@ package x509 import ( "testing" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" "github.com/stretchr/testify/assert" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" ) func TestX509AutomationConfig(t *testing.T) { diff --git a/mongodb-community-operator/pkg/authentication/x509/x509_test.go b/mongodb-community-operator/pkg/authentication/x509/x509_test.go index ed4f728fc..0e850e413 100644 --- a/mongodb-community-operator/pkg/authentication/x509/x509_test.go +++ b/mongodb-community-operator/pkg/authentication/x509/x509_test.go @@ -5,15 +5,16 @@ import ( "reflect" "testing" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/mocks" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - "github.com/stretchr/testify/assert" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/mocks" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" ) func TestEnable(t *testing.T) { diff --git a/mongodb-community-operator/pkg/automationconfig/automation_config.go b/mongodb-community-operator/pkg/automationconfig/automation_config.go index 855985108..62bb5eb7e 100644 --- a/mongodb-community-operator/pkg/automationconfig/automation_config.go +++ b/mongodb-community-operator/pkg/automationconfig/automation_config.go @@ -4,10 +4,11 @@ import ( "bytes" "encoding/json" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/scramcredentials" "github.com/spf13/cast" "github.com/stretchr/objx" "go.uber.org/zap" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/scramcredentials" ) const ( @@ -509,5 +510,4 @@ func ConfigureAgentConfiguration(systemLog *SystemLog, logRotate *CrdLogRotate, p.SetLogRotate(logRotate) p.SetAuditLogRotate(auditLR) } - } diff --git a/mongodb-community-operator/pkg/automationconfig/automation_config_builder.go b/mongodb-community-operator/pkg/automationconfig/automation_config_builder.go index 3091734dc..497ed01e3 100644 --- a/mongodb-community-operator/pkg/automationconfig/automation_config_builder.go +++ b/mongodb-community-operator/pkg/automationconfig/automation_config_builder.go @@ -6,9 +6,9 @@ import ( "strings" "github.com/blang/semver" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/versions" - "k8s.io/utils/ptr" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/versions" ) type Topology string @@ -195,13 +195,13 @@ func (b *Builder) SetAuth(auth Auth) *Builder { return b } -func (b *Builder) SetReplicaSetId(id *string) *Builder { - b.replicaSetId = id +func (b *Builder) SetSettings(settings map[string]interface{}) *Builder { + b.settings = settings return b } -func (b *Builder) SetSettings(settings map[string]interface{}) *Builder { - b.settings = settings +func (b *Builder) SetReplicaSetId(id *string) *Builder { + b.replicaSetId = id return b } @@ -270,7 +270,6 @@ func (b *Builder) Build() (AutomationConfig, error) { if b.fcv != "" { _, err := semver.Make(fmt.Sprintf("%s.0", b.fcv)) - if err != nil { return AutomationConfig{}, fmt.Errorf("invalid feature compatibility version: %s", err) } diff --git a/mongodb-community-operator/pkg/automationconfig/automation_config_secret.go b/mongodb-community-operator/pkg/automationconfig/automation_config_secret.go index 9ca6ed469..a3ba94f45 100644 --- a/mongodb-community-operator/pkg/automationconfig/automation_config_secret.go +++ b/mongodb-community-operator/pkg/automationconfig/automation_config_secret.go @@ -4,9 +4,11 @@ import ( "context" "encoding/json" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" ) const ConfigKey = "cluster-config.json" diff --git a/mongodb-community-operator/pkg/automationconfig/automation_config_secret_test.go b/mongodb-community-operator/pkg/automationconfig/automation_config_secret_test.go index ed9a4af77..2810e2ce1 100644 --- a/mongodb-community-operator/pkg/automationconfig/automation_config_secret_test.go +++ b/mongodb-community-operator/pkg/automationconfig/automation_config_secret_test.go @@ -5,13 +5,15 @@ import ( "encoding/json" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" "github.com/stretchr/testify/assert" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" ) func TestEnsureSecret(t *testing.T) { @@ -21,7 +23,6 @@ func TestEnsureSecret(t *testing.T) { assert.NoError(t, err) t.Run("When the secret exists, but does not have the correct key, it is created correctly", func(t *testing.T) { - s := secret.Builder(). SetName(secretNsName.Name). SetNamespace(secretNsName.Namespace). @@ -37,7 +38,6 @@ func TestEnsureSecret(t *testing.T) { assert.NoError(t, err) assert.Contains(t, acSecret.Data, ConfigKey, "The secret of the given name should have been updated with the config.") - }) t.Run("test LogRotate marshal and unmarshal", func(t *testing.T) { @@ -104,7 +104,6 @@ func TestEnsureSecret(t *testing.T) { }) t.Run("When the existing Automation Config is different the Automation Config Changes", func(t *testing.T) { - oldAc, err := newAutomationConfig() assert.NoError(t, err) existingSecret, err := newAutomationConfigSecret(oldAc, secretNsName) @@ -118,10 +117,9 @@ func TestEnsureSecret(t *testing.T) { res, err := EnsureSecret(ctx, secretGetUpdateCreator, secretNsName, []metav1.OwnerReference{}, newAc) assert.NoError(t, err) assert.Equal(t, newAc, res) - }) - } + func newAutomationConfig() (AutomationConfig, error) { return NewBuilder().Build() } @@ -141,7 +139,6 @@ func newAutomationConfigSecret(ac AutomationConfig, nsName types.NamespacedName) SetNamespace(nsName.Namespace). SetField(ConfigKey, string(acBytes)). Build(), nil - } type mockSecretGetUpdateCreator struct { diff --git a/mongodb-community-operator/pkg/automationconfig/automation_config_test.go b/mongodb-community-operator/pkg/automationconfig/automation_config_test.go index 19b3bcfe8..4ab2360b3 100644 --- a/mongodb-community-operator/pkg/automationconfig/automation_config_test.go +++ b/mongodb-community-operator/pkg/automationconfig/automation_config_test.go @@ -5,9 +5,8 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func defaultMongoDbVersion(version string) MongoDbVersionConfig { @@ -396,7 +395,6 @@ func TestModifications(t *testing.T) { } func TestMongoDBVersionsConfig(t *testing.T) { - t.Run("Dummy Config is used when no versions are set", func(t *testing.T) { ac, err := NewBuilder().SetMongoDBVersion("4.4.2").Build() assert.NoError(t, err) @@ -439,14 +437,11 @@ func TestMongoDBVersionsConfig(t *testing.T) { assert.Equal(t, "arch", b.Architecture) assert.Equal(t, "minOs", b.MinOsVersion) assert.Equal(t, "maxOs", b.MaxOsVersion) - }) - } func TestAreEqual(t *testing.T) { t.Run("Automation Configs with same values are equal", func(t *testing.T) { - areEqual, err := AreEqual( createAutomationConfig("name0", "mdbVersion0", "domain0", Options{DownloadBase: "downloadBase0"}, Auth{Disabled: true}, 5, 2), createAutomationConfig("name0", "mdbVersion0", "domain0", Options{DownloadBase: "downloadBase0"}, Auth{Disabled: true}, 5, 2), @@ -457,7 +452,6 @@ func TestAreEqual(t *testing.T) { }) t.Run("Automation Configs with same values but different version are equal", func(t *testing.T) { - areEqual, err := AreEqual( createAutomationConfig("name0", "mdbVersion0", "domain0", Options{DownloadBase: "downloadBase0"}, Auth{Disabled: true}, 5, 2), createAutomationConfig("name0", "mdbVersion0", "domain0", Options{DownloadBase: "downloadBase0"}, Auth{Disabled: true}, 5, 10), @@ -468,7 +462,6 @@ func TestAreEqual(t *testing.T) { }) t.Run("Automation Configs with different values are not equal", func(t *testing.T) { - areEqual, err := AreEqual( createAutomationConfig("name0", "differentVersion", "domain0", Options{DownloadBase: "downloadBase1"}, Auth{Disabled: false}, 2, 2), createAutomationConfig("name0", "mdbVersion0", "domain0", Options{DownloadBase: "downloadBase0"}, Auth{Disabled: true}, 5, 2), @@ -482,11 +475,11 @@ func TestAreEqual(t *testing.T) { votes := 1 priority := "0.0" firstBuilder := NewBuilder().SetName("name0").SetMongoDBVersion("mdbVersion0").SetOptions(Options{DownloadBase: "downloadBase0"}).SetDomain("domain0").SetMembers(2).SetAuth(Auth{Disabled: true}) - firstBuilder.SetMemberOptions([]MemberOptions{MemberOptions{Votes: &votes, Priority: &priority}}) + firstBuilder.SetMemberOptions([]MemberOptions{{Votes: &votes, Priority: &priority}}) firstAc, _ := firstBuilder.Build() firstAc.Version = 2 secondBuilder := NewBuilder().SetName("name0").SetMongoDBVersion("mdbVersion0").SetOptions(Options{DownloadBase: "downloadBase0"}).SetDomain("domain0").SetMembers(2).SetAuth(Auth{Disabled: true}) - secondBuilder.SetMemberOptions([]MemberOptions{MemberOptions{Votes: &votes, Priority: nil}}) + secondBuilder.SetMemberOptions([]MemberOptions{{Votes: &votes, Priority: nil}}) secondAc, _ := secondBuilder.Build() secondAc.Version = 2 @@ -503,34 +496,20 @@ func TestValidateFCV(t *testing.T) { } func TestEnterpriseVersion(t *testing.T) { - //given + // given mongoDBVersion := "6.0.5" expectedVersionInTheAutomationConfig := mongoDBVersion + "-ent" - //when + // when ac, err := NewBuilder().SetMongoDBVersion(mongoDBVersion).SetMembers(1).IsEnterprise(true).Build() - //then + // then assert.NoError(t, err) assert.Equal(t, expectedVersionInTheAutomationConfig, ac.Processes[0].Version) assert.Equal(t, "enterprise", ac.Versions[0].Builds[0].Modules[0]) assert.Equal(t, "enterprise", ac.Versions[0].Builds[1].Modules[0]) } -func createAutomationConfig(name, mongodbVersion, domain string, opts Options, auth Auth, members, acVersion int) AutomationConfig { - ac, _ := NewBuilder(). - SetName(name). - SetMongoDBVersion(mongodbVersion). - SetOptions(opts). - SetDomain(domain). - SetMembers(members). - SetAuth(auth). - Build() - - ac.Version = acVersion - return ac -} - func TestReplicaSetId(t *testing.T) { id := "rs0" ac, err := NewBuilder(). @@ -547,3 +526,17 @@ func TestReplicaSetId(t *testing.T) { rs := ac.ReplicaSets[0] assert.Equal(t, rs.Id, id, "The provided id should be used") } + +func createAutomationConfig(name, mongodbVersion, domain string, opts Options, auth Auth, members, acVersion int) AutomationConfig { + ac, _ := NewBuilder(). + SetName(name). + SetMongoDBVersion(mongodbVersion). + SetOptions(opts). + SetDomain(domain). + SetMembers(members). + SetAuth(auth). + Build() + + ac.Version = acVersion + return ac +} diff --git a/mongodb-community-operator/pkg/helm/helm.go b/mongodb-community-operator/pkg/helm/helm.go index 35392f7f2..3356120db 100644 --- a/mongodb-community-operator/pkg/helm/helm.go +++ b/mongodb-community-operator/pkg/helm/helm.go @@ -3,24 +3,25 @@ package helm import ( "fmt" "os/exec" + "strconv" "strings" + "testing" ) // Uninstall uninstalls a helm chart of the given name. There is no error in the case // of the helm chart not existing. -func Uninstall(chartName string, namespace string) error { +func Uninstall(t *testing.T, chartName string, namespace string) error { helmArgs := []string{"uninstall", chartName, "-n", namespace} - return executeHelmCommand(helmArgs, isNotFoundMessage) -} - -// DependencyUpdate downloads dependencies for a Chart. -func DependencyUpdate(chartPath string) error { - helmArgs := []string{"dependency", "update", chartPath} - return executeHelmCommand(helmArgs, nil) + return executeHelmCommand(t, helmArgs, isNotFoundMessage) } // Install a helm chert at the given path with the given name and the provided set arguments. -func Install(chartPath, chartName string, flags map[string]string, templateValues map[string]string) error { +func Install(t *testing.T, chartPath, chartName string, flags, templateValues map[string]string) error { + // let's ensure we never send telemetry by accident from community + templateValues["operator.env"] = "dev" + templateValues["operator.telemetry.send.enabled"] = strconv.FormatBool(false) + templateValues["operator.telemetry.send.baseUrl"] = "https://cloud-dev.mongodb.com/" + helmArgs := []string{"install"} helmArgs = append(helmArgs, chartName, chartPath) for flagKey, flagValue := range flags { @@ -29,8 +30,9 @@ func Install(chartPath, chartName string, flags map[string]string, templateValue helmArgs = append(helmArgs, flagValue) } } + templateValues["operator.watchedResources"] = "{opsmanagers,mongodb,mongodbusers,mongodbcommunity}" helmArgs = append(helmArgs, mapToHelmValuesArg(templateValues)...) - return executeHelmCommand(helmArgs, nil) + return executeHelmCommand(t, helmArgs, nil) } func isNotFoundMessage(s string) bool { @@ -39,15 +41,18 @@ func isNotFoundMessage(s string) bool { // executeHelmCommand accepts a list of arguments that should be passed to the helm command // and a predicate that when returning true, indicates that the error message should be ignored. -func executeHelmCommand(args []string, messagePredicate func(string) bool) error { +func executeHelmCommand(t *testing.T, args []string, messagePredicate func(string) bool) error { cmd := exec.Command("helm", args...) + t.Logf("cmd: %s", cmd.String()) output, err := cmd.CombinedOutput() + t.Logf("output: %s", output) if err != nil { if messagePredicate != nil && messagePredicate(string(output)) { return nil } return fmt.Errorf("error executing command: %s %s", err, output) } + t.Logf("no error") return nil } diff --git a/mongodb-community-operator/pkg/kube/client/client.go b/mongodb-community-operator/pkg/kube/client/client.go index 640e23373..38b13b293 100644 --- a/mongodb-community-operator/pkg/kube/client/client.go +++ b/mongodb-community-operator/pkg/kube/client/client.go @@ -3,18 +3,18 @@ package client import ( "context" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/pod" + "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/service" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "k8s.io/apimachinery/pkg/types" k8sClient "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/pod" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/service" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" ) func NewClient(c k8sClient.Client) Client { diff --git a/mongodb-community-operator/pkg/kube/client/client_test.go b/mongodb-community-operator/pkg/kube/client/client_test.go index 083df075b..dd3bd01f9 100644 --- a/mongodb-community-operator/pkg/kube/client/client_test.go +++ b/mongodb-community-operator/pkg/kube/client/client_test.go @@ -4,12 +4,13 @@ import ( "context" "testing" + "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" k8sClient "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" ) func TestChangingName_CreatesNewObject(t *testing.T) { diff --git a/mongodb-community-operator/pkg/kube/client/mocked_client.go b/mongodb-community-operator/pkg/kube/client/mocked_client.go index f4a8e499e..627477400 100644 --- a/mongodb-community-operator/pkg/kube/client/mocked_client.go +++ b/mongodb-community-operator/pkg/kube/client/mocked_client.go @@ -4,16 +4,18 @@ import ( "context" "encoding/json" "fmt" - appsv1 "k8s.io/api/apps/v1" + "reflect" + "strings" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" - "reflect" + + appsv1 "k8s.io/api/apps/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8sClient "sigs.k8s.io/controller-runtime/pkg/client" - "strings" ) var ( diff --git a/mongodb-community-operator/pkg/kube/client/mocked_client_test.go b/mongodb-community-operator/pkg/kube/client/mocked_client_test.go index 870b85380..f3fa5355e 100644 --- a/mongodb-community-operator/pkg/kube/client/mocked_client_test.go +++ b/mongodb-community-operator/pkg/kube/client/mocked_client_test.go @@ -4,11 +4,13 @@ import ( "context" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/configmap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/service" "github.com/stretchr/testify/assert" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" + + corev1 "k8s.io/api/core/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/configmap" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/service" ) func TestMockedClient(t *testing.T) { diff --git a/mongodb-community-operator/pkg/kube/client/mocked_manager.go b/mongodb-community-operator/pkg/kube/client/mocked_manager.go index 2f9a3d30c..1a76a74a1 100644 --- a/mongodb-community-operator/pkg/kube/client/mocked_manager.go +++ b/mongodb-community-operator/pkg/kube/client/mocked_manager.go @@ -3,7 +3,6 @@ package client import ( "context" "net/http" - "sigs.k8s.io/controller-runtime/pkg/config" "time" "github.com/go-logr/logr" @@ -12,11 +11,13 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/cache" - k8sClient "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/config" "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + k8sClient "sigs.k8s.io/controller-runtime/pkg/client" ) // MockedManager exists to unit test the reconciliation loops and wrap the mocked client @@ -133,7 +134,7 @@ func (m *MockedManager) GetLogger() logr.Logger { } func (m *MockedManager) GetControllerOptions() config.Controller { - var duration = time.Duration(0) + duration := time.Duration(0) return config.Controller{ CacheSyncTimeout: duration, } diff --git a/mongodb-community-operator/pkg/kube/configmap/configmap.go b/mongodb-community-operator/pkg/kube/configmap/configmap.go index 36f38d469..62afe2481 100644 --- a/mongodb-community-operator/pkg/kube/configmap/configmap.go +++ b/mongodb-community-operator/pkg/kube/configmap/configmap.go @@ -5,10 +5,11 @@ import ( "fmt" "strings" - corev1 "k8s.io/api/core/v1" - apiErrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + + corev1 "k8s.io/api/core/v1" + apiErrors "k8s.io/apimachinery/pkg/api/errors" ) type Getter interface { @@ -133,7 +134,6 @@ func ReadFileLikeField(ctx context.Context, getter Getter, objectKey client.Obje // Exists return whether a configmap with the given namespaced name exists func Exists(ctx context.Context, cmGetter Getter, nsName types.NamespacedName) (bool, error) { _, err := cmGetter.GetConfigMap(ctx, nsName) - if err != nil { if apiErrors.IsNotFound(err) { return false, nil diff --git a/mongodb-community-operator/pkg/kube/configmap/configmap_test.go b/mongodb-community-operator/pkg/kube/configmap/configmap_test.go index 1d731573a..6b46a1d73 100644 --- a/mongodb-community-operator/pkg/kube/configmap/configmap_test.go +++ b/mongodb-community-operator/pkg/kube/configmap/configmap_test.go @@ -5,11 +5,12 @@ import ( "testing" "github.com/stretchr/testify/assert" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) type configMapGetter struct { diff --git a/mongodb-community-operator/pkg/kube/container/container_test.go b/mongodb-community-operator/pkg/kube/container/container_test.go index a61a0be15..44a607519 100644 --- a/mongodb-community-operator/pkg/kube/container/container_test.go +++ b/mongodb-community-operator/pkg/kube/container/container_test.go @@ -4,14 +4,14 @@ import ( "fmt" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/resourcerequirements" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/lifecycle" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/probes" "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/lifecycle" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/probes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/resourcerequirements" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/envvar" ) func TestContainer(t *testing.T) { @@ -218,7 +218,6 @@ func TestWithVolumeMounts(t *testing.T) { assert.Equal(t, fmt.Sprintf("mount-path-%d", i), v.MountPath, "Volumes should be sorted but were not!") assert.Equal(t, fmt.Sprintf("sub-path-%d", i), v.SubPath, "Volumes should be sorted but were not!") } - } func boolRef(b bool) *bool { diff --git a/mongodb-community-operator/pkg/kube/container/containers.go b/mongodb-community-operator/pkg/kube/container/containers.go index 687befc5b..b9e0d3e96 100644 --- a/mongodb-community-operator/pkg/kube/container/containers.go +++ b/mongodb-community-operator/pkg/kube/container/containers.go @@ -4,10 +4,10 @@ import ( "sort" "strings" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/lifecycle" corev1 "k8s.io/api/core/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/lifecycle" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/envvar" ) type Modification func(*corev1.Container) diff --git a/mongodb-community-operator/pkg/kube/pod/pod.go b/mongodb-community-operator/pkg/kube/pod/pod.go index 7b991a694..bbd5aebe2 100644 --- a/mongodb-community-operator/pkg/kube/pod/pod.go +++ b/mongodb-community-operator/pkg/kube/pod/pod.go @@ -2,8 +2,10 @@ package pod import ( "context" - corev1 "k8s.io/api/core/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + + corev1 "k8s.io/api/core/v1" ) type Getter interface { diff --git a/mongodb-community-operator/pkg/kube/podtemplatespec/podspec_template.go b/mongodb-community-operator/pkg/kube/podtemplatespec/podspec_template.go index f908a214a..8224cf7d3 100644 --- a/mongodb-community-operator/pkg/kube/podtemplatespec/podspec_template.go +++ b/mongodb-community-operator/pkg/kube/podtemplatespec/podspec_template.go @@ -1,11 +1,12 @@ package podtemplatespec import ( - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/envvar" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" ) type Modification func(*corev1.PodTemplateSpec) @@ -99,7 +100,7 @@ func WithPodLabels(labels map[string]string) Modification { labels = map[string]string{} } return func(podTemplateSpec *corev1.PodTemplateSpec) { - podTemplateSpec.ObjectMeta.Labels = labels + podTemplateSpec.Labels = labels } } @@ -210,17 +211,16 @@ func WithTopologyKey(topologyKey string, idx int) Modification { // WithAffinity updates the name, antiAffinityLabelKey and weight of the PodTemplateSpec's Affinity func WithAffinity(stsName, antiAffinityLabelKey string, weight int) Modification { return func(podTemplateSpec *corev1.PodTemplateSpec) { - podTemplateSpec.Spec.Affinity = - &corev1.Affinity{ - PodAntiAffinity: &corev1.PodAntiAffinity{ - PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{{ - Weight: int32(weight), - PodAffinityTerm: corev1.PodAffinityTerm{ - LabelSelector: &metav1.LabelSelector{MatchLabels: map[string]string{antiAffinityLabelKey: stsName}}, - }, - }}, - }, - } + podTemplateSpec.Spec.Affinity = &corev1.Affinity{ + PodAntiAffinity: &corev1.PodAntiAffinity{ + PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{{ + Weight: int32(weight), //nolint:gosec + PodAffinityTerm: corev1.PodAffinityTerm{ + LabelSelector: &metav1.LabelSelector{MatchLabels: map[string]string{antiAffinityLabelKey: stsName}}, + }, + }}, + }, + } } } diff --git a/mongodb-community-operator/pkg/kube/podtemplatespec/podspec_template_test.go b/mongodb-community-operator/pkg/kube/podtemplatespec/podspec_template_test.go index 832c2821f..597db3053 100644 --- a/mongodb-community-operator/pkg/kube/podtemplatespec/podspec_template_test.go +++ b/mongodb-community-operator/pkg/kube/podtemplatespec/podspec_template_test.go @@ -3,13 +3,13 @@ package podtemplatespec import ( "testing" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" + "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "github.com/stretchr/testify/assert" - corev1 "k8s.io/api/core/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" ) func TestPodTemplateSpec(t *testing.T) { @@ -476,7 +476,7 @@ func TestMergeVolumes_DoesNotAddDuplicatesWithSameName(t *testing.T) { assert.Len(t, mergedPodSpecTemplate.Spec.Volumes, 3) assert.Equal(t, "new-volume", mergedPodSpecTemplate.Spec.Volumes[0].Name) - assert.Equal(t, "updated-host-path", mergedPodSpecTemplate.Spec.Volumes[0].VolumeSource.HostPath.Path) + assert.Equal(t, "updated-host-path", mergedPodSpecTemplate.Spec.Volumes[0].HostPath.Path) assert.Equal(t, "new-volume-2", mergedPodSpecTemplate.Spec.Volumes[1].Name) assert.Equal(t, "new-volume-3", mergedPodSpecTemplate.Spec.Volumes[2].Name) } @@ -488,7 +488,8 @@ func TestAddVolumes(t *testing.T) { HostPath: &corev1.HostPathVolumeSource{ Path: "old-host-path", }, - }}, + }, + }, ) toAddVolumes := []corev1.Volume{ @@ -511,7 +512,7 @@ func TestAddVolumes(t *testing.T) { assert.Len(t, p.Spec.Volumes, 2) assert.Equal(t, "new-volume", p.Spec.Volumes[0].Name) assert.Equal(t, "new-volume-2", p.Spec.Volumes[1].Name) - assert.Equal(t, "new-host-path", p.Spec.Volumes[0].VolumeSource.HostPath.Path) + assert.Equal(t, "new-host-path", p.Spec.Volumes[0].HostPath.Path) } func int64Ref(i int64) *int64 { diff --git a/mongodb-community-operator/pkg/kube/probes/probes.go b/mongodb-community-operator/pkg/kube/probes/probes.go index 6b11feb8f..f06a0bc11 100644 --- a/mongodb-community-operator/pkg/kube/probes/probes.go +++ b/mongodb-community-operator/pkg/kube/probes/probes.go @@ -22,37 +22,40 @@ func New(funcs ...Modification) corev1.Probe { func WithExecCommand(cmd []string) Modification { return func(probe *corev1.Probe) { - if probe.ProbeHandler.Exec == nil { - probe.ProbeHandler.Exec = &corev1.ExecAction{} + if probe.Exec == nil { + probe.Exec = &corev1.ExecAction{} } - probe.ProbeHandler.Exec.Command = cmd + probe.Exec.Command = cmd } } -func WithFailureThreshold(failureThreshold int) Modification { +func WithFailureThreshold(failureThreshold int32) Modification { return func(probe *corev1.Probe) { - probe.FailureThreshold = int32(failureThreshold) + probe.FailureThreshold = failureThreshold } } -func WithInitialDelaySeconds(initialDelaySeconds int) Modification { +func WithInitialDelaySeconds(initialDelaySeconds int32) Modification { return func(probe *corev1.Probe) { - probe.InitialDelaySeconds = int32(initialDelaySeconds) + probe.InitialDelaySeconds = initialDelaySeconds } } -func WithSuccessThreshold(successThreshold int) Modification { + +func WithSuccessThreshold(successThreshold int32) Modification { return func(probe *corev1.Probe) { - probe.SuccessThreshold = int32(successThreshold) + probe.SuccessThreshold = successThreshold } } -func WithPeriodSeconds(periodSeconds int) Modification { + +func WithPeriodSeconds(periodSeconds int32) Modification { return func(probe *corev1.Probe) { - probe.PeriodSeconds = int32(periodSeconds) + probe.PeriodSeconds = periodSeconds } } -func WithTimeoutSeconds(timeoutSeconds int) Modification { + +func WithTimeoutSeconds(timeoutSeconds int32) Modification { return func(probe *corev1.Probe) { - probe.TimeoutSeconds = int32(timeoutSeconds) + probe.TimeoutSeconds = timeoutSeconds } } diff --git a/mongodb-community-operator/pkg/kube/resourcerequirements/resource_requirements.go b/mongodb-community-operator/pkg/kube/resourcerequirements/resource_requirements.go index 33bc28b04..b35b34f06 100644 --- a/mongodb-community-operator/pkg/kube/resourcerequirements/resource_requirements.go +++ b/mongodb-community-operator/pkg/kube/resourcerequirements/resource_requirements.go @@ -1,8 +1,9 @@ package resourcerequirements import ( - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" + + corev1 "k8s.io/api/core/v1" ) const ( diff --git a/mongodb-community-operator/pkg/kube/secret/secret.go b/mongodb-community-operator/pkg/kube/secret/secret.go index 93f9b64ea..6997e50b5 100644 --- a/mongodb-community-operator/pkg/kube/secret/secret.go +++ b/mongodb-community-operator/pkg/kube/secret/secret.go @@ -6,13 +6,14 @@ import ( "reflect" "strings" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/contains" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/contains" ) type Getter interface { @@ -163,7 +164,6 @@ func CopySecret(ctx context.Context, fromClient Getter, toClient GetUpdateCreato // Exists return whether a secret with the given namespaced name exists func Exists(ctx context.Context, secretGetter Getter, nsName types.NamespacedName) (bool, error) { _, err := secretGetter.GetSecret(ctx, nsName) - if err != nil { if apiErrors.IsNotFound(err) { return false, nil diff --git a/mongodb-community-operator/pkg/kube/secret/secret_builder.go b/mongodb-community-operator/pkg/kube/secret/secret_builder.go index f5c3b4c2b..6700ee9b4 100644 --- a/mongodb-community-operator/pkg/kube/secret/secret_builder.go +++ b/mongodb-community-operator/pkg/kube/secret/secret_builder.go @@ -51,6 +51,7 @@ func (b *builder) SetByteData(stringData map[string][]byte) *builder { b.data = newStringDataBytes return b } + func (b *builder) SetStringMapToData(stringData map[string]string) *builder { newStringDataBytes := make(map[string][]byte, len(stringData)) for k, v := range stringData { diff --git a/mongodb-community-operator/pkg/kube/secret/secret_test.go b/mongodb-community-operator/pkg/kube/secret/secret_test.go index 71810e32d..c1a675bc0 100644 --- a/mongodb-community-operator/pkg/kube/secret/secret_test.go +++ b/mongodb-community-operator/pkg/kube/secret/secret_test.go @@ -5,11 +5,12 @@ import ( "testing" "github.com/stretchr/testify/assert" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) type secretGetter struct { @@ -84,7 +85,6 @@ func TestReadData(t *testing.T) { assert.Equal(t, []byte("value1"), data["key1"]) assert.Equal(t, []byte("value2"), data["key2"]) }) - } func nsName(namespace, name string) types.NamespacedName { @@ -226,11 +226,10 @@ func TestCreateOrUpdateIfNeededEqual(t *testing.T) { } func getDefaultSecret() corev1.Secret { - secret := - Builder(). - SetName("secret"). - SetNamespace("mdb.Namespace"). - SetStringMapToData(map[string]string{"password": "my-password"}). - Build() + secret := Builder(). + SetName("secret"). + SetNamespace("mdb.Namespace"). + SetStringMapToData(map[string]string{"password": "my-password"}). + Build() return secret } diff --git a/mongodb-community-operator/pkg/kube/service/service.go b/mongodb-community-operator/pkg/kube/service/service.go index abb749acf..f4057acec 100644 --- a/mongodb-community-operator/pkg/kube/service/service.go +++ b/mongodb-community-operator/pkg/kube/service/service.go @@ -2,8 +2,10 @@ package service import ( "context" - corev1 "k8s.io/api/core/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + + corev1 "k8s.io/api/core/v1" ) type Getter interface { diff --git a/mongodb-community-operator/pkg/kube/statefulset/merge_statefulset_test.go b/mongodb-community-operator/pkg/kube/statefulset/merge_statefulset_test.go index 7ae2acd53..6e8df85a2 100644 --- a/mongodb-community-operator/pkg/kube/statefulset/merge_statefulset_test.go +++ b/mongodb-community-operator/pkg/kube/statefulset/merge_statefulset_test.go @@ -4,12 +4,12 @@ import ( "reflect" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - "github.com/stretchr/testify/assert" - appsv1 "k8s.io/api/apps/v1" + appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" ) func TestGetLabelSelectorRequirementByKey(t *testing.T) { @@ -45,7 +45,6 @@ func TestGetLabelSelectorRequirementByKey(t *testing.T) { key: "test-key", }, want: &metav1.LabelSelectorRequirement{ - Key: "test-key", }, }, @@ -60,7 +59,6 @@ func TestGetLabelSelectorRequirementByKey(t *testing.T) { } func TestMergeSpec(t *testing.T) { - original := New( WithName("original"), WithServiceName("original-svc-name"), diff --git a/mongodb-community-operator/pkg/kube/statefulset/statefulset.go b/mongodb-community-operator/pkg/kube/statefulset/statefulset.go index d6e7660cb..2c6557a45 100644 --- a/mongodb-community-operator/pkg/kube/statefulset/statefulset.go +++ b/mongodb-community-operator/pkg/kube/statefulset/statefulset.go @@ -2,15 +2,17 @@ package statefulset import ( "context" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - apiErrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" + apiErrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" ) const ( @@ -117,7 +119,6 @@ func CreateVolumeFromSecret(name, sourceName string, options ...func(v *corev1.V option(volumeMount) } return *volumeMount - } func CreateVolumeFromEmptyDir(name string) corev1.Volume { @@ -149,10 +150,10 @@ func NOOP() Modification { func WithSecretDefaultMode(mode *int32) func(*corev1.Volume) { return func(v *corev1.Volume) { - if v.VolumeSource.Secret == nil { - v.VolumeSource.Secret = &corev1.SecretVolumeSource{} + if v.Secret == nil { + v.Secret = &corev1.SecretVolumeSource{} } - v.VolumeSource.Secret.DefaultMode = mode + v.Secret.DefaultMode = mode } } @@ -171,8 +172,8 @@ func WithReadOnly(readonly bool) func(*corev1.VolumeMount) { } func IsReady(sts appsv1.StatefulSet, expectedReplicas int) bool { - allUpdated := int32(expectedReplicas) == sts.Status.UpdatedReplicas - allReady := int32(expectedReplicas) == sts.Status.ReadyReplicas + allUpdated := int32(expectedReplicas) == sts.Status.UpdatedReplicas //nolint:gosec + allReady := int32(expectedReplicas) == sts.Status.ReadyReplicas //nolint:gosec atExpectedGeneration := sts.Generation == sts.Status.ObservedGeneration return allUpdated && allReady && atExpectedGeneration } @@ -233,6 +234,7 @@ func WithMatchLabels(matchLabels map[string]string) Modification { set.Spec.Selector.MatchLabels = copyMap(matchLabels) } } + func WithOwnerReference(ownerRefs []metav1.OwnerReference) Modification { ownerReference := make([]metav1.OwnerReference, len(ownerRefs)) copy(ownerReference, ownerRefs) @@ -242,14 +244,14 @@ func WithOwnerReference(ownerRefs []metav1.OwnerReference) Modification { } func WithReplicas(replicas int) Modification { - stsReplicas := int32(replicas) + stsReplicas := int32(replicas) //nolint:gosec return func(sts *appsv1.StatefulSet) { sts.Spec.Replicas = &stsReplicas } } func WithRevisionHistoryLimit(revisionHistoryLimit int) Modification { - rhl := int32(revisionHistoryLimit) + rhl := int32(revisionHistoryLimit) //nolint:gosec return func(sts *appsv1.StatefulSet) { sts.Spec.RevisionHistoryLimit = &rhl } diff --git a/mongodb-community-operator/pkg/kube/statefulset/statefulset_builder.go b/mongodb-community-operator/pkg/kube/statefulset/statefulset_builder.go index 09a52b75b..2bbcff03c 100644 --- a/mongodb-community-operator/pkg/kube/statefulset/statefulset_builder.go +++ b/mongodb-community-operator/pkg/kube/statefulset/statefulset_builder.go @@ -5,6 +5,7 @@ import ( "sort" "github.com/hashicorp/go-multierror" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -145,7 +146,7 @@ func (s Builder) buildPodTemplateSpec() (corev1.PodTemplateSpec, error) { for _, volumeMount := range volumeMounts { if prevMount, seen := existingVolumeMounts[volumeMount.MountPath]; seen { // Volume with the same path already mounted - errs = multierror.Append(errs, fmt.Errorf("Volume %v already mounted as %v", volumeMount, prevMount)) + errs = multierror.Append(errs, fmt.Errorf("volume %v already mounted as %v", volumeMount, prevMount)) continue } podTemplateSpec.Spec.Containers[idx].VolumeMounts = append(podTemplateSpec.Spec.Containers[idx].VolumeMounts, volumeMount) @@ -191,7 +192,7 @@ func (s Builder) Build() (appsv1.StatefulSet, error) { return appsv1.StatefulSet{}, err } - replicas := int32(s.replicas) + replicas := int32(s.replicas) //nolint:gosec ownerReference := make([]metav1.OwnerReference, len(s.ownerReference)) copy(ownerReference, s.ownerReference) diff --git a/mongodb-community-operator/pkg/kube/statefulset/statefulset_test.go b/mongodb-community-operator/pkg/kube/statefulset/statefulset_test.go index ad67cb3c3..cc6603635 100644 --- a/mongodb-community-operator/pkg/kube/statefulset/statefulset_test.go +++ b/mongodb-community-operator/pkg/kube/statefulset/statefulset_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -75,8 +76,8 @@ func TestAddVolumeAndMount(t *testing.T) { // assert the volumes were added to the podspec template assert.Len(t, sts.Spec.Template.Spec.Volumes, 1) assert.Equal(t, sts.Spec.Template.Spec.Volumes[0].Name, "mount-name") - assert.NotNil(t, sts.Spec.Template.Spec.Volumes[0].VolumeSource.ConfigMap, "volume should have been configured from a config map source") - assert.Nil(t, sts.Spec.Template.Spec.Volumes[0].VolumeSource.Secret, "volume should not have been configured from a secret source") + assert.NotNil(t, sts.Spec.Template.Spec.Volumes[0].ConfigMap, "volume should have been configured from a config map source") + assert.Nil(t, sts.Spec.Template.Spec.Volumes[0].Secret, "volume should not have been configured from a secret source") stsBuilder = defaultStatefulSetBuilder().SetPodTemplateSpec(podTemplateWithContainers([]corev1.Container{{Name: "container-0"}, {Name: "container-1"}})).AddVolumeAndMount(vmd, "container-0") sts, err = stsBuilder.Build() @@ -100,9 +101,8 @@ func TestAddVolumeAndMount(t *testing.T) { assert.Len(t, sts.Spec.Template.Spec.Volumes, 2) assert.Equal(t, "mount-name-secret", sts.Spec.Template.Spec.Volumes[1].Name) assert.Equal(t, int32(416), *sts.Spec.Template.Spec.Volumes[1].Secret.DefaultMode) - assert.Nil(t, sts.Spec.Template.Spec.Volumes[1].VolumeSource.ConfigMap, "volume should not have been configured from a config map source") - assert.NotNil(t, sts.Spec.Template.Spec.Volumes[1].VolumeSource.Secret, "volume should have been configured from a secret source") - + assert.Nil(t, sts.Spec.Template.Spec.Volumes[1].ConfigMap, "volume should not have been configured from a config map source") + assert.NotNil(t, sts.Spec.Template.Spec.Volumes[1].Secret, "volume should have been configured from a secret source") } func TestAddVolumeClaimTemplates(t *testing.T) { @@ -131,15 +131,15 @@ func TestBuildStructImmutable(t *testing.T) { var err error sts, err = stsBuilder.Build() assert.NoError(t, err) - assert.Len(t, sts.ObjectMeta.Labels, 2) + assert.Len(t, sts.Labels, 2) delete(labels, "label_2") // checks that modifying the underlying object did not change the built statefulset - assert.Len(t, sts.ObjectMeta.Labels, 2) + assert.Len(t, sts.Labels, 2) sts, err = stsBuilder.Build() assert.NoError(t, err) - assert.Len(t, sts.ObjectMeta.Labels, 1) + assert.Len(t, sts.Labels, 1) } func defaultStatefulSetBuilder() *Builder { diff --git a/mongodb-community-operator/pkg/readiness/config/config.go b/mongodb-community-operator/pkg/readiness/config/config.go index 7f3e64714..0a879e921 100644 --- a/mongodb-community-operator/pkg/readiness/config/config.go +++ b/mongodb-community-operator/pkg/readiness/config/config.go @@ -8,7 +8,6 @@ import ( "strings" "gopkg.in/natefinch/lumberjack.v2" - "k8s.io/client-go/kubernetes" ) diff --git a/mongodb-community-operator/pkg/readiness/headless/headless.go b/mongodb-community-operator/pkg/readiness/headless/headless.go index 18c28e23f..50f6a9d05 100644 --- a/mongodb-community-operator/pkg/readiness/headless/headless.go +++ b/mongodb-community-operator/pkg/readiness/headless/headless.go @@ -7,11 +7,12 @@ import ( "os" "strconv" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/readiness/config" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/readiness/health" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/readiness/pod" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/readiness/secret" "go.uber.org/zap" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/readiness/config" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/readiness/health" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/readiness/pod" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/readiness/secret" ) const ( @@ -37,7 +38,11 @@ func PerformCheckHeadlessMode(ctx context.Context, health health.Status, conf co if err != nil { return false, err } - defer file.Close() + defer func() { + if closeErr := file.Close(); closeErr != nil { + zap.S().Warnf("Failed to close automation config version file: %v", closeErr) + } + }() data, err := io.ReadAll(file) if err != nil { diff --git a/mongodb-community-operator/pkg/readiness/headless/headless_test.go b/mongodb-community-operator/pkg/readiness/headless/headless_test.go index d6f2f293c..9f91240c2 100644 --- a/mongodb-community-operator/pkg/readiness/headless/headless_test.go +++ b/mongodb-community-operator/pkg/readiness/headless/headless_test.go @@ -4,14 +4,15 @@ import ( "context" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/cmd/readiness/testdata" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/readiness/config" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/readiness/health" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/fake" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/cmd/readiness/testdata" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/readiness/config" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/readiness/health" ) func TestPerformCheckHeadlessMode(t *testing.T) { diff --git a/mongodb-community-operator/pkg/readiness/pod/podannotation.go b/mongodb-community-operator/pkg/readiness/pod/podannotation.go index d36bda37f..044b4fbc8 100644 --- a/mongodb-community-operator/pkg/readiness/pod/podannotation.go +++ b/mongodb-community-operator/pkg/readiness/pod/podannotation.go @@ -6,9 +6,9 @@ import ( "strings" "go.uber.org/zap" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/kubernetes" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const mongodbAgentVersionAnnotation = "agent.mongodb.com/version" @@ -31,7 +31,7 @@ func PatchPodAnnotation(ctx context.Context, podNamespace string, lastVersionAch mdbAgentVersion := strconv.FormatInt(lastVersionAchieved, 10) payload = append(payload, patchValue{ Op: "add", - Path: "/metadata/annotations/" + strings.Replace(mongodbAgentVersionAnnotation, "/", "~1", -1), + Path: "/metadata/annotations/" + strings.ReplaceAll(mongodbAgentVersionAnnotation, "/", "~1"), Value: mdbAgentVersion, }) diff --git a/mongodb-community-operator/pkg/readiness/pod/podannotation_test.go b/mongodb-community-operator/pkg/readiness/pod/podannotation_test.go index b75382421..774c7c9e3 100644 --- a/mongodb-community-operator/pkg/readiness/pod/podannotation_test.go +++ b/mongodb-community-operator/pkg/readiness/pod/podannotation_test.go @@ -5,10 +5,11 @@ import ( "testing" "github.com/stretchr/testify/assert" + "k8s.io/client-go/kubernetes/fake" + v1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/kubernetes/fake" ) // Currently seems like the appending functionality on the library used by the fake diff --git a/mongodb-community-operator/pkg/readiness/pod/podpatcher.go b/mongodb-community-operator/pkg/readiness/pod/podpatcher.go index 5bea91f33..783e78936 100644 --- a/mongodb-community-operator/pkg/readiness/pod/podpatcher.go +++ b/mongodb-community-operator/pkg/readiness/pod/podpatcher.go @@ -4,10 +4,11 @@ import ( "context" "encoding/json" - v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" + + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) type patchValue struct { diff --git a/mongodb-community-operator/pkg/readiness/secret/secretreader.go b/mongodb-community-operator/pkg/readiness/secret/secretreader.go index aecb845e0..06e1ce401 100644 --- a/mongodb-community-operator/pkg/readiness/secret/secretreader.go +++ b/mongodb-community-operator/pkg/readiness/secret/secretreader.go @@ -3,9 +3,10 @@ package secret import ( "context" + "k8s.io/client-go/kubernetes" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/kubernetes" ) type reader struct { diff --git a/mongodb-community-operator/pkg/util/contains/contains.go b/mongodb-community-operator/pkg/util/contains/contains.go index 1b0c8f2ee..0caf3c6a9 100644 --- a/mongodb-community-operator/pkg/util/contains/contains.go +++ b/mongodb-community-operator/pkg/util/contains/contains.go @@ -3,11 +3,12 @@ package contains import ( "reflect" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" + "k8s.io/apimachinery/pkg/types" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" ) func String(slice []string, s string) bool { diff --git a/mongodb-community-operator/pkg/util/envvar/envvars.go b/mongodb-community-operator/pkg/util/envvar/envvars.go index 00f054995..9b8c4e687 100644 --- a/mongodb-community-operator/pkg/util/envvar/envvars.go +++ b/mongodb-community-operator/pkg/util/envvar/envvars.go @@ -30,7 +30,7 @@ func MergeWithOverride(existing, desired []corev1.EnvVar) []corev1.EnvVar { } func GetEnvOrDefault(envVar, defaultValue string) string { - if val, ok := os.LookupEnv(envVar); ok { + if val, ok := os.LookupEnv(envVar); ok { //nolint:forbidigo return val } return defaultValue diff --git a/mongodb-community-operator/pkg/util/generate/generate.go b/mongodb-community-operator/pkg/util/generate/generate.go index 338e0d1b8..9ceba2350 100644 --- a/mongodb-community-operator/pkg/util/generate/generate.go +++ b/mongodb-community-operator/pkg/util/generate/generate.go @@ -8,7 +8,7 @@ import ( "hash" "unicode" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/scramcredentials" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/scramcredentials" ) // final key must be between 6 and at most 1024 characters @@ -62,7 +62,6 @@ func Salts() ([]byte, []byte, error) { func salt(hashConstructor func() hash.Hash) ([]byte, error) { saltSize := hashConstructor().Size() - scramcredentials.RFC5802MandatedSaltSize salt, err := RandomFixedLengthStringOfSize(20) - if err != nil { return nil, err } diff --git a/mongodb-community-operator/pkg/util/merge/merge.go b/mongodb-community-operator/pkg/util/merge/merge.go index df59bab84..065745af8 100644 --- a/mongodb-community-operator/pkg/util/merge/merge.go +++ b/mongodb-community-operator/pkg/util/merge/merge.go @@ -4,8 +4,9 @@ import ( "sort" "strings" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/contains" corev1 "k8s.io/api/core/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/contains" ) // StringSlices accepts two slices of strings, and returns a string slice @@ -78,7 +79,6 @@ func Containers(defaultContainers, overrideContainers []corev1.Container) []core return mergedContainers[i].Name < mergedContainers[j].Name }) return mergedContainers - } func createContainerMap(containers []corev1.Container) map[string]corev1.Container { @@ -563,8 +563,8 @@ func Volume(defaultVolume corev1.Volume, overrideVolume corev1.Volume) corev1.Vo } // - ConfigMap if overrideSource.ConfigMap != nil && defaultSource.ConfigMap != nil { - if overrideSource.ConfigMap.LocalObjectReference.Name != "" { - mergedVolume.ConfigMap.LocalObjectReference.Name = overrideSource.ConfigMap.LocalObjectReference.Name + if overrideSource.ConfigMap.Name != "" { + mergedVolume.ConfigMap.Name = overrideSource.ConfigMap.Name } mergedVolume.ConfigMap.Items = mergeKeyToPathItems(defaultSource.ConfigMap.Items, overrideSource.ConfigMap.Items) if overrideSource.ConfigMap.DefaultMode != nil { diff --git a/mongodb-community-operator/pkg/util/merge/merge_automationconfigs.go b/mongodb-community-operator/pkg/util/merge/merge_automationconfigs.go index 5a6eeb69e..458b8b77c 100644 --- a/mongodb-community-operator/pkg/util/merge/merge_automationconfigs.go +++ b/mongodb-community-operator/pkg/util/merge/merge_automationconfigs.go @@ -1,7 +1,7 @@ package merge import ( - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" ) // AutomationConfigs merges the values in "override" into the "original" Wrapper. diff --git a/mongodb-community-operator/pkg/util/merge/merge_automationconfigs_test.go b/mongodb-community-operator/pkg/util/merge/merge_automationconfigs_test.go index 5e947eed0..ce40aee3c 100644 --- a/mongodb-community-operator/pkg/util/merge/merge_automationconfigs_test.go +++ b/mongodb-community-operator/pkg/util/merge/merge_automationconfigs_test.go @@ -3,8 +3,9 @@ package merge import ( "testing" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" "github.com/stretchr/testify/assert" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" ) func TestMergeAutomationConfigs(t *testing.T) { diff --git a/mongodb-community-operator/pkg/util/merge/merge_ephemeral_container.go b/mongodb-community-operator/pkg/util/merge/merge_ephemeral_container.go index 5853e41cf..790f894d4 100644 --- a/mongodb-community-operator/pkg/util/merge/merge_ephemeral_container.go +++ b/mongodb-community-operator/pkg/util/merge/merge_ephemeral_container.go @@ -34,7 +34,6 @@ func EphemeralContainers(defaultContainers, overrideContainers []corev1.Ephemera return mergedContainers[i].Name < mergedContainers[j].Name }) return mergedContainers - } // EphemeralContainer merges two EphemeralContainers together. diff --git a/mongodb-community-operator/pkg/util/merge/merge_podtemplate_spec.go b/mongodb-community-operator/pkg/util/merge/merge_podtemplate_spec.go index 0e59a4f6e..220539629 100644 --- a/mongodb-community-operator/pkg/util/merge/merge_podtemplate_spec.go +++ b/mongodb-community-operator/pkg/util/merge/merge_podtemplate_spec.go @@ -3,8 +3,9 @@ package merge import ( "sort" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/contains" corev1 "k8s.io/api/core/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/contains" ) func PodTemplateSpecs(original, override corev1.PodTemplateSpec) corev1.PodTemplateSpec { diff --git a/mongodb-community-operator/pkg/util/merge/merge_statefulset.go b/mongodb-community-operator/pkg/util/merge/merge_statefulset.go index a6a9f4879..da9f03aa0 100644 --- a/mongodb-community-operator/pkg/util/merge/merge_statefulset.go +++ b/mongodb-community-operator/pkg/util/merge/merge_statefulset.go @@ -3,11 +3,11 @@ package merge import ( "sort" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/contains" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/contains" ) // StatefulSets merges two StatefulSets together. diff --git a/mongodb-community-operator/pkg/util/merge/merge_test.go b/mongodb-community-operator/pkg/util/merge/merge_test.go index 2d35355ac..661be3a75 100644 --- a/mongodb-community-operator/pkg/util/merge/merge_test.go +++ b/mongodb-community-operator/pkg/util/merge/merge_test.go @@ -4,13 +4,13 @@ import ( "reflect" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/probes" - + "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/api/resource" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/probes" ) func TestMergeStringSlices(t *testing.T) { @@ -381,7 +381,6 @@ func TestMergeContainer(t *testing.T) { assert.Equal(t, "original-sub-path-expr-1", vm1.SubPathExpr) }) }) - }) } @@ -409,7 +408,6 @@ func TestMergeContainerPort(t *testing.T) { assert.Equal(t, override.ContainerPort, mergedPort.ContainerPort) assert.Equal(t, override.HostIP, mergedPort.HostIP) assert.Equal(t, override.ContainerPort, mergedPort.ContainerPort) - }) t.Run("No Override Fields", func(t *testing.T) { @@ -466,7 +464,6 @@ func TestMergeVolumeMount(t *testing.T) { } func TestContainerPortSlicesByName(t *testing.T) { - original := []corev1.ContainerPort{ { Name: "original-port-0", @@ -547,7 +544,6 @@ func TestContainerPortSlicesByName(t *testing.T) { assert.Equal(t, "1.2.3.6", merged[3].HostIP, "The HostIP should have been overridden") assert.Equal(t, corev1.ProtocolTCP, merged[3].Protocol, "The Protocol should remain unchanged") }) - } func TestMergeSecurityContext(t *testing.T) { diff --git a/mongodb-community-operator/pkg/util/scale/scale.go b/mongodb-community-operator/pkg/util/scale/scale.go index afdae1b81..a964f7e9d 100644 --- a/mongodb-community-operator/pkg/util/scale/scale.go +++ b/mongodb-community-operator/pkg/util/scale/scale.go @@ -30,7 +30,6 @@ func ReplicasThisReconciliation(replicaSetScaler ReplicaSetScaler) int { } return replicaSetScaler.CurrentReplicas() + 1 - } func IsStillScaling(replicaSetScaler ReplicaSetScaler) bool { diff --git a/mongodb-community-operator/pkg/util/state/statemachine.go b/mongodb-community-operator/pkg/util/state/statemachine.go index d506e280e..8741dc902 100644 --- a/mongodb-community-operator/pkg/util/state/statemachine.go +++ b/mongodb-community-operator/pkg/util/state/statemachine.go @@ -88,7 +88,6 @@ func NewStateMachine(saver SaveLoader, nsName types.NamespacedName, logger *zap. // Reconcile will reconcile the currently active State. This method should be called // from the controllers. func (m *Machine) Reconcile() (reconcile.Result, error) { - if err := m.determineState(); err != nil { m.logger.Errorf("error initializing starting state: %s", err) return reconcile.Result{}, err diff --git a/mongodb-community-operator/pkg/util/state/statemachine_test.go b/mongodb-community-operator/pkg/util/state/statemachine_test.go index 650749711..8d8c69486 100644 --- a/mongodb-community-operator/pkg/util/state/statemachine_test.go +++ b/mongodb-community-operator/pkg/util/state/statemachine_test.go @@ -6,11 +6,12 @@ import ( "testing" "time" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/result" "github.com/stretchr/testify/assert" "go.uber.org/zap" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/result" ) func init() { @@ -159,7 +160,6 @@ func TestIfStateFails_ItIsRunAgain(t *testing.T) { }) t.Run("When the state passes, the next one will run", func(t *testing.T) { - // the state will now succeed s.states["FailsState"] = newAlwaysCompletingState(fails.Name) @@ -277,7 +277,6 @@ func TestBranchingPath(t *testing.T) { s.AddDirectTransition(right1, right2) t.Run("Left Path", func(t *testing.T) { - _, _ = s.Reconcile() _, _ = s.Reconcile() _, _ = s.Reconcile() @@ -329,7 +328,6 @@ func TestDetermineStartingState_ReadsFromLoader(t *testing.T) { assert.Error(t, err) assert.Nil(t, s.currentState) }) - } // newAlwaysCompletingState returns a State that will always succeed. diff --git a/mongodb-community-operator/pkg/util/status/status.go b/mongodb-community-operator/pkg/util/status/status.go index 21aebfc62..5f26ab3b7 100644 --- a/mongodb-community-operator/pkg/util/status/status.go +++ b/mongodb-community-operator/pkg/util/status/status.go @@ -3,10 +3,10 @@ package status import ( "context" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" ) type Option interface { diff --git a/mongodb-community-operator/pkg/util/status/status_test.go b/mongodb-community-operator/pkg/util/status/status_test.go index c6e5f810d..ba9c21327 100644 --- a/mongodb-community-operator/pkg/util/status/status_test.go +++ b/mongodb-community-operator/pkg/util/status/status_test.go @@ -5,10 +5,10 @@ import ( "testing" "time" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/stretchr/testify/assert" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" ) type errorOption struct{} @@ -36,7 +36,6 @@ func (r retryOption) GetResult() (reconcile.Result, error) { } func TestDetermineReconciliationResult(t *testing.T) { - t.Run("A single error option should result in an error return", func(t *testing.T) { opts := []Option{ errorOption{}, @@ -84,5 +83,4 @@ func TestDetermineReconciliationResult(t *testing.T) { assert.Nil(t, err) assert.Equal(t, true, res.Requeue) }) - } diff --git a/mongodb-community-operator/release.json b/mongodb-community-operator/release.json index 078b90861..88983b5b3 100644 --- a/mongodb-community-operator/release.json +++ b/mongodb-community-operator/release.json @@ -1,8 +1,8 @@ { "golang-builder-image": "golang:1.24", - "operator": "0.13.0", - "version-upgrade-hook": "1.0.10", - "readiness-probe": "1.0.23", - "agent": "108.0.6.8796-1", - "agent-tools-version": "100.11.0" + "operator": "0.12.0", + "version-upgrade-hook": "1.0.9", + "readiness-probe": "1.0.22", + "agent": "108.0.2.8729-1", + "agent-tools-version": "100.10.0" } diff --git a/mongodb-community-operator/requirements.txt b/mongodb-community-operator/requirements.txt deleted file mode 100644 index e264e2e09..000000000 --- a/mongodb-community-operator/requirements.txt +++ /dev/null @@ -1,20 +0,0 @@ -git+https://github.com/mongodb/sonar@bc7bf7732851425421f3cfe2a19cf50b0460e633 -github-action-templates==0.0.4 -docker==7.1.0 -kubernetes==26.1.0 -jinja2==3.1.4 -MarkupSafe==2.0.1 -PyYAML==6.0.1 -black==24.3.0 -mypy==0.961 -tqdm==v4.66.3 -boto3==1.16.21 -pymongo==4.6.3 -dnspython==2.6.1 -requests==2.32.3 -ruamel.yaml==0.17.9 -semver==2.13.0 -rsa>=4.7 # not directly required, pinned by Snyk to avoid a vulnerability -setuptools==78.0.1 # not directly required, pinned by Snyk to avoid a vulnerability -certifi>=2022.12.7 # not directly required, pinned by Snyk to avoid a vulnerability -urllib3<2 # not directly required, pinned by Snyk to avoid a vulnerability diff --git a/mongodb-community-operator/scripts/ci/config.json b/mongodb-community-operator/scripts/ci/config.json index 0260f015f..7bb0fdabb 100644 --- a/mongodb-community-operator/scripts/ci/config.json +++ b/mongodb-community-operator/scripts/ci/config.json @@ -1,16 +1,13 @@ { - "namespace": "default", - "repo_url": "quay.io/mongodb", + "repo_url": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev", + "shared_repo_url": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev", "mongodb_image_repo_url": "quay.io/mongodb", "mongodb_image_name": "mongodb-community-server", - "operator_image": "mongodb-kubernetes-operator", - "operator_image_dev": "community-operator-dev", - "e2e_image": "community-operator-e2e", + "operator_image": "mongodb-enterprise-operator-ubi", + "e2e_image": "mongodb-community-tests", "version_upgrade_hook_image": "mongodb-kubernetes-operator-version-upgrade-post-start-hook", - "version_upgrade_hook_image_dev": "mongodb-kubernetes-operator-version-upgrade-post-start-hook-dev", + "agent_image_dev": "mongodb-agent-ubi", "agent_image": "mongodb-agent-ubi", - "agent_image_dev": "mongodb-agent-ubi-dev", "readiness_probe_image": "mongodb-kubernetes-readinessprobe", - "readiness_probe_image_dev": "mongodb-kubernetes-readinessprobe-dev", "s3_bucket": "s3://enterprise-operator-dockerfiles/dockerfiles" } diff --git a/mongodb-community-operator/scripts/ci/determine_required_releases.py b/mongodb-community-operator/scripts/ci/determine_required_releases.py index f77b9df11..27bccded2 100755 --- a/mongodb-community-operator/scripts/ci/determine_required_releases.py +++ b/mongodb-community-operator/scripts/ci/determine_required_releases.py @@ -5,7 +5,7 @@ import json import sys -from typing import List, Dict +from typing import Dict, List import requests @@ -21,9 +21,7 @@ "version-upgrade-hook": [ "https://quay.io/api/v1/repository/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook" ], - "operator": [ - "https://quay.io/api/v1/repository/mongodb/mongodb-kubernetes-operator" - ], + "operator": ["https://quay.io/api/v1/repository/mongodb/mongodb-kubernetes-operator"], } @@ -72,17 +70,13 @@ def main() -> int: if image_name not in name_to_version_map: raise ValueError( - "Unknown image type [{}], valid values are [{}]".format( - image_name, ",".join(name_to_version_map.keys()) - ) + "Unknown image type [{}], valid values are [{}]".format(image_name, ",".join(name_to_version_map.keys())) ) if image_name not in QUAY_URL_MAP: raise ValueError("No associated image urls for key [{}]".format(image_name)) - if _all_urls_are_released( - QUAY_URL_MAP[image_name], name_to_version_map[image_name] - ): + if _all_urls_are_released(QUAY_URL_MAP[image_name], name_to_version_map[image_name]): print("released") else: print("unreleased") diff --git a/mongodb-community-operator/scripts/ci/images_signing.py b/mongodb-community-operator/scripts/ci/images_signing.py index e2fb4a94e..8ab3c2834 100644 --- a/mongodb-community-operator/scripts/ci/images_signing.py +++ b/mongodb-community-operator/scripts/ci/images_signing.py @@ -84,9 +84,7 @@ def get_image_digest(image_name: str) -> Optional[str]: digest_command.append(f"{transport_protocol}{image_name}") try: - result = subprocess.run( - digest_command, capture_output=True, text=True, check=True - ) + result = subprocess.run(digest_command, capture_output=True, text=True, check=True) digest = result.stdout.strip() return digest except subprocess.CalledProcessError as e: @@ -94,9 +92,7 @@ def get_image_digest(image_name: str) -> Optional[str]: sys.exit(1) -def build_cosign_docker_command( - additional_args: List[str], cosign_command: List[str] -) -> List[str]: +def build_cosign_docker_command(additional_args: List[str], cosign_command: List[str]) -> List[str]: """ Common logic to build a cosign command with the garasign cosign image provided by DevProd. :param additional_args: additional arguments passed to the docker container, e.g mounted volume or env @@ -112,9 +108,7 @@ def build_cosign_docker_command( "--rm", f"--volume={home_dir}/.docker/config.json:/root/.docker/config.json:ro", ] - return ( - base_command + additional_args + [SIGNING_IMAGE_URI, "cosign"] + cosign_command - ) + return base_command + additional_args + [SIGNING_IMAGE_URI, "cosign"] + cosign_command def sign_image(repository: str, tag: str) -> None: diff --git a/mongodb-community-operator/scripts/ci/update_release.py b/mongodb-community-operator/scripts/ci/update_release.py index 96c76746f..ec441863d 100755 --- a/mongodb-community-operator/scripts/ci/update_release.py +++ b/mongodb-community-operator/scripts/ci/update_release.py @@ -2,7 +2,7 @@ import json import sys -from typing import Dict, Callable +from typing import Callable, Dict import ruamel.yaml @@ -45,12 +45,8 @@ def _replace_tag(image: str, new_tag: str) -> str: def update_operator_deployment(operator_deployment: Dict, release: Dict) -> None: - operator_container = operator_deployment["spec"]["template"]["spec"]["containers"][ - 0 - ] - operator_container["image"] = _replace_tag( - operator_container["image"], release["operator"] - ) + operator_container = operator_deployment["spec"]["template"]["spec"]["containers"][0] + operator_container["image"] = _replace_tag(operator_container["image"], release["operator"]) operator_envs = operator_container["env"] for env in operator_envs: if env["name"] == "VERSION_UPGRADE_HOOK_IMAGE": @@ -80,9 +76,7 @@ def update_chart(chart: Dict, release: Dict) -> None: def main() -> int: # Updating local files update_and_write_file(RELATIVE_PATH_TO_MANAGER_YAML, update_operator_deployment) - update_and_write_file( - RELATIVE_PATH_TO_OPENSHIFT_MANAGER_YAML, update_operator_deployment - ) + update_and_write_file(RELATIVE_PATH_TO_OPENSHIFT_MANAGER_YAML, update_operator_deployment) # Updating Helm Chart files update_and_write_file(RELATIVE_PATH_TO_CHART_VALUES, update_chart_values) diff --git a/mongodb-community-operator/scripts/dev/dev_config.py b/mongodb-community-operator/scripts/dev/dev_config.py index 93476b203..23dc45d23 100644 --- a/mongodb-community-operator/scripts/dev/dev_config.py +++ b/mongodb-community-operator/scripts/dev/dev_config.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Dict, Optional, List -from enum import Enum + import json import os +from enum import Enum +from typing import Dict, List, Optional CONFIG_PATH = "~/.community-operator-dev/config.json" FULL_CONFIG_PATH = os.path.expanduser(CONFIG_PATH) @@ -51,6 +52,10 @@ def namespace(self) -> str: def repo_url(self) -> str: return self._config["repo_url"] + @property + def shared_repo_url(self) -> str: + return self._config["shared_repo_url"] + @property def s3_bucket(self) -> str: return self._config["s3_bucket"] @@ -77,9 +82,7 @@ def version_upgrade_hook_image(self) -> str: @property def version_upgrade_hook_image_dev(self) -> str: - return self._get_dev_image( - "version_upgrade_hook_image_dev", "version_upgrade_hook_image" - ) + return self._get_dev_image("version_upgrade_hook_image_dev", "version_upgrade_hook_image") @property def readiness_probe_image(self) -> str: @@ -148,17 +151,16 @@ def _get_dev_image(self, dev_image: str, image: str) -> str: return self._config[image] -def load_config( - config_file_path: Optional[str] = None, distro: Distro = Distro.UBI -) -> DevConfig: +def load_config(config_file_path: Optional[str] = None, distro: Distro = Distro.UBI, namespace: str = "") -> DevConfig: if config_file_path is None: config_file_path = get_config_path() try: with open(config_file_path, "r") as f: - return DevConfig(json.loads(f.read()), distro=distro) + cfg = json.loads(f.read()) + if namespace: + cfg["namespace"] = namespace + return DevConfig(cfg, distro=distro) except FileNotFoundError: - print( - f"No DevConfig found. Please ensure that the configuration file exists at '{config_file_path}'" - ) + print(f"No DevConfig found. Please ensure that the configuration file exists at '{config_file_path}'") raise diff --git a/mongodb-community-operator/scripts/dev/e2e.py b/mongodb-community-operator/scripts/dev/e2e.py old mode 100644 new mode 100755 index 0a8c03df2..9a1a3cf13 --- a/mongodb-community-operator/scripts/dev/e2e.py +++ b/mongodb-community-operator/scripts/dev/e2e.py @@ -1,14 +1,15 @@ #!/usr/bin/env python3 -from kubernetes.client.rest import ApiException - -import k8s_conditions -from typing import Dict -from dev_config import load_config, DevConfig, Distro -from kubernetes import client, config import argparse +import os import sys +from typing import Dict + +import k8s_conditions import yaml +from dev_config import DevConfig, Distro, load_config +from kubernetes import client, config +from kubernetes.client.rest import ApiException TEST_POD_NAME = "e2e-test" TEST_CLUSTER_ROLE_NAME = "e2e-test" @@ -22,18 +23,18 @@ def load_yaml_from_file(path: str) -> Dict: def _load_test_service_account() -> Dict: - return load_yaml_from_file("deploy/e2e/service_account.yaml") + return load_yaml_from_file("mongodb-community-operator/deploy/e2e/service_account.yaml") def _load_test_role() -> Dict: - return load_yaml_from_file("deploy/e2e/role.yaml") + return load_yaml_from_file("mongodb-community-operator/deploy/e2e/role.yaml") def _load_test_role_binding() -> Dict: - return load_yaml_from_file("deploy/e2e/role_binding.yaml") + return load_yaml_from_file("mongodb-community-operator/deploy/e2e/role_binding.yaml") -def _prepare_test_environment(config_file: str) -> None: +def _prepare_test_environment(namespace) -> None: """ _prepare_test_environment ensures that the old test pod is deleted and that namespace, cluster role, cluster role binding and service account @@ -41,59 +42,47 @@ def _prepare_test_environment(config_file: str) -> None: """ rbacv1 = client.RbacAuthorizationV1Api() corev1 = client.CoreV1Api() - dev_config = load_config(config_file) - - _delete_test_pod(config_file) + _delete_test_pod(namespace) print("Creating Namespace") k8s_conditions.ignore_if_already_exists( - lambda: corev1.create_namespace( - client.V1Namespace(metadata=dict(name=dev_config.namespace)) - ) - ) - - print("Creating Cluster Role") - k8s_conditions.ignore_if_already_exists( - lambda: rbacv1.create_cluster_role(_load_test_role()) + lambda: corev1.create_namespace(client.V1Namespace(metadata=dict(name=namespace))) ) - print("Creating Cluster Role Binding") + print("Creating Cluster Role Binding and Service Account for test pod") role_binding = _load_test_role_binding() # set namespace specified in config.json - role_binding["subjects"][0]["namespace"] = dev_config.namespace + role_binding["subjects"][0]["namespace"] = namespace - k8s_conditions.ignore_if_already_exists( - lambda: rbacv1.create_cluster_role_binding(role_binding) - ) + k8s_conditions.ignore_if_already_exists(lambda: rbacv1.create_cluster_role_binding(role_binding)) - print("Creating Service Account") + print("Creating Service Account for test pod") service_account = _load_test_service_account() # set namespace specified in config.json - service_account["metadata"]["namespace"] = dev_config.namespace + service_account["metadata"]["namespace"] = namespace k8s_conditions.ignore_if_already_exists( - lambda: corev1.create_namespaced_service_account( - dev_config.namespace, service_account - ) + lambda: corev1.create_namespaced_service_account(namespace, service_account) ) -def create_test_pod(args: argparse.Namespace, dev_config: DevConfig) -> None: +def create_test_pod(args: argparse.Namespace, namespace: str) -> None: corev1 = client.CoreV1Api() test_pod = { "kind": "Pod", "metadata": { "name": TEST_POD_NAME, - "namespace": dev_config.namespace, + "namespace": namespace, "labels": {"e2e-test": "true"}, }, "spec": { "restartPolicy": "Never", "serviceAccountName": "e2e-test", + "volumes": [{"name": "results", "emptyDir": {}}], "containers": [ { "name": TEST_POD_NAME, - "image": f"{dev_config.repo_url}/{dev_config.e2e_image}:{args.tag}", + "image": f"{os.getenv('BASE_REPO_URL')}/mongodb-community-tests:{os.getenv('VERSION_ID')}", "imagePullPolicy": "Always", "env": [ { @@ -101,32 +90,36 @@ def create_test_pod(args: argparse.Namespace, dev_config: DevConfig) -> None: "value": f"{args.cluster_wide}", }, { - "name": "OPERATOR_IMAGE", - "value": f"{dev_config.repo_url}/{dev_config.operator_image_dev}:{args.tag}", + "name": "VERSION_ID", + "value": f"{os.getenv('VERSION_ID')}", }, { - "name": "AGENT_IMAGE", - "value": f"{dev_config.repo_url}/{dev_config.agent_image_dev}:{args.tag}", + "name": "BASE_REPO_URL", + "value": f"{os.getenv('BASE_REPO_URL')}", }, + # TODO: MCK: when running locally - let's default to /dev and not our own image unless specified + # TODO: MCK: change this to be per patch and not hard coded { - "name": "TEST_NAMESPACE", - "value": dev_config.namespace, + "name": "MDB_COMMUNITY_AGENT_IMAGE", + "value": f"{os.getenv('MDB_COMMUNITY_AGENT_IMAGE')}", }, { - "name": "VERSION_UPGRADE_HOOK_IMAGE", - "value": f"{dev_config.repo_url}/{dev_config.version_upgrade_hook_image_dev}:{args.tag}", + "name": "WATCH_NAMESPACE", + "value": namespace, }, + # TODO: MCK: change this to be per patch and not hard coded { - "name": "READINESS_PROBE_IMAGE", - "value": f"{dev_config.repo_url}/{dev_config.readiness_probe_image_dev}:{args.tag}", + "name": "VERSION_UPGRADE_HOOK_IMAGE", + "value": f"{os.getenv('VERSION_UPGRADE_HOOK_IMAGE')}", }, + # TODO: MCK: change this to be per patch and not hard coded { - "name": "MONGODB_IMAGE", - "value": f"{dev_config.mongodb_image_name}", + "name": "READINESS_PROBE_IMAGE", + "value": f"{os.getenv('READINESS_PROBE_IMAGE')}", }, { - "name": "MONGODB_REPO_URL", - "value": f"{dev_config.mongodb_image_repo_url}", + "name": "MDB_COMMUNITY_IMAGE", + "value": f"{os.getenv('MDB_COMMUNITY_IMAGE')}", }, { "name": "PERFORM_CLEANUP", @@ -134,32 +127,34 @@ def create_test_pod(args: argparse.Namespace, dev_config: DevConfig) -> None: }, ], "command": [ - "go", - "test", - "-v", - "-timeout=45m", - "-failfast", - f"./test/e2e/{args.test}", + "sh", + "-c", + f"go test -v -timeout=45m -failfast ./mongodb-community-operator/test/e2e/{args.test} | tee -a /tmp/results/result.suite", ], - } + "volumeMounts": [{"name": "results", "mountPath": "/tmp/results"}], + }, + { + "name": "keepalive", + "image": "busybox", + "command": ["sh", "-c", "sleep inf"], + "volumeMounts": [{"name": "results", "mountPath": "/tmp/results"}], + }, ], }, } if not k8s_conditions.wait( lambda: corev1.list_namespaced_pod( - dev_config.namespace, + namespace, field_selector=f"metadata.name=={TEST_POD_NAME}", ), lambda pod_list: len(pod_list.items) == 0, timeout=30, sleep_time=0.5, ): - raise Exception( - "Execution timed out while waiting for the existing pod to be deleted" - ) + raise Exception("Execution timed out while waiting for the existing pod to be deleted") if not k8s_conditions.call_eventually_succeeds( - lambda: corev1.create_namespaced_pod(dev_config.namespace, body=test_pod), + lambda: corev1.create_namespaced_pod(namespace, body=test_pod), sleep_time=10, timeout=60, exceptions_to_ignore=ApiException, @@ -167,9 +162,7 @@ def create_test_pod(args: argparse.Namespace, dev_config: DevConfig) -> None: raise Exception("Could not create test pod!") -def wait_for_pod_to_be_running( - corev1: client.CoreV1Api, name: str, namespace: str -) -> None: +def wait_for_pod_to_be_running(corev1: client.CoreV1Api, name: str, namespace: str) -> None: print("Waiting for pod to be running") if not k8s_conditions.wait( lambda: corev1.read_namespaced_pod(name, namespace), @@ -184,55 +177,34 @@ def wait_for_pod_to_be_running( print("Pod is running") -def _delete_test_environment(config_file: str) -> None: +def _delete_test_environment(namespace) -> None: """ _delete_test_environment ensures that the cluster role, cluster role binding and service account for the test pod are deleted. """ rbacv1 = client.RbacAuthorizationV1Api() corev1 = client.CoreV1Api() - dev_config = load_config(config_file) - k8s_conditions.ignore_if_doesnt_exist( - lambda: rbacv1.delete_cluster_role(TEST_CLUSTER_ROLE_NAME) - ) + k8s_conditions.ignore_if_doesnt_exist(lambda: rbacv1.delete_cluster_role(TEST_CLUSTER_ROLE_NAME)) - k8s_conditions.ignore_if_doesnt_exist( - lambda: rbacv1.delete_cluster_role_binding(TEST_CLUSTER_ROLE_BINDING_NAME) - ) + k8s_conditions.ignore_if_doesnt_exist(lambda: rbacv1.delete_cluster_role_binding(TEST_CLUSTER_ROLE_BINDING_NAME)) k8s_conditions.ignore_if_doesnt_exist( - lambda: corev1.delete_namespaced_service_account( - TEST_SERVICE_ACCOUNT_NAME, dev_config.namespace - ) + lambda: corev1.delete_namespaced_service_account(TEST_SERVICE_ACCOUNT_NAME, namespace) ) -def _delete_test_pod(config_file: str) -> None: +def _delete_test_pod(namespace) -> None: """ _delete_test_pod deletes the test pod. """ - dev_config = load_config(config_file) corev1 = client.CoreV1Api() - k8s_conditions.ignore_if_doesnt_exist( - lambda: corev1.delete_namespaced_pod(TEST_POD_NAME, dev_config.namespace) - ) + k8s_conditions.ignore_if_doesnt_exist(lambda: corev1.delete_namespaced_pod(TEST_POD_NAME, namespace)) def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser() parser.add_argument("--test", help="Name of the test to run") - parser.add_argument( - "--tag", - help="Tag for the images, it will be the same for all images", - type=str, - default="latest", - ) - parser.add_argument( - "--skip-dump-diagnostic", - help="Skip the dump of diagnostic information into files", - action="store_true", - ) parser.add_argument( "--perform-cleanup", help="Cleanup the context after executing the tests", @@ -253,41 +225,50 @@ def parse_args() -> argparse.Namespace: return parser.parse_args() -def prepare_and_run_test(args: argparse.Namespace, dev_config: DevConfig) -> None: - _prepare_test_environment(args.config_file) - create_test_pod(args, dev_config) +def prepare_and_run_test(args: argparse.Namespace, namespace: str) -> None: + _prepare_test_environment(namespace) + create_test_pod(args, namespace) corev1 = client.CoreV1Api() wait_for_pod_to_be_running( corev1, TEST_POD_NAME, - dev_config.namespace, + namespace, ) - # stream all of the pod output as the pod is running + print("stream all of the pod output as the pod is running") for line in corev1.read_namespaced_pod_log( - TEST_POD_NAME, dev_config.namespace, follow=True, _preload_content=False + TEST_POD_NAME, namespace, follow=True, _preload_content=False, container="e2e-test" ).stream(): print(line.decode("utf-8").rstrip()) def main() -> int: args = parse_args() - config.load_kube_config() - dev_config = load_config(args.config_file, Distro.from_string(args.distro)) - prepare_and_run_test(args, dev_config) + # TODO: MCK + try: + config.load_kube_config() + except Exception: + config.load_incluster_config() + + namespace = os.getenv("NAMESPACE") + prepare_and_run_test(args, namespace) corev1 = client.CoreV1Api() if not k8s_conditions.wait( - lambda: corev1.read_namespaced_pod(TEST_POD_NAME, dev_config.namespace), - lambda pod: pod.status.phase == "Succeeded", + lambda: corev1.read_namespaced_pod(TEST_POD_NAME, namespace), + lambda pod: any( + container.state.terminated and container.state.terminated.exit_code == 0 + for container in pod.status.container_statuses + if container.name == "e2e-test" + ), sleep_time=5, timeout=60, exceptions_to_ignore=ApiException, ): return 1 - _delete_test_environment(args.config_file) + _delete_test_environment(namespace) return 0 diff --git a/mongodb-community-operator/scripts/dev/generate_github_actions.py b/mongodb-community-operator/scripts/dev/generate_github_actions.py deleted file mode 100755 index 4a5b57edc..000000000 --- a/mongodb-community-operator/scripts/dev/generate_github_actions.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python3 -from typing import Dict - -from ghat.template import template_github_action -import sys -import io -import ruamel.yaml - -yaml = ruamel.yaml.YAML() - -template_mapping = { - ".action_templates/e2e-fork-template.yaml": ".github/workflows/e2e-fork.yml", - ".action_templates/e2e-pr-template.yaml": ".github/workflows/e2e.yml", - ".action_templates/e2e-single-template.yaml": ".github/workflows/e2e-dispatch.yml", -} - - -def _prepend_auto_generated_message(github_action: Dict) -> str: - s = io.StringIO() - yaml.dump(github_action, s) - s.seek(0) - return """ -################################################################################## -# -# This file is automatically generated using templates. Changes to this file -# should happen through editing the templates under .action_templates/* -# Manual edits will be overwritten. -# -################################################################################## - -{}""".format( - s.read() - ) - - -def main() -> int: - for template in template_mapping: - github_action = template_github_action(template) - with open(template_mapping[template], "w+") as f: - f.write(_prepend_auto_generated_message(github_action)) - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/mongodb-community-operator/scripts/dev/get_e2e_env_vars.py b/mongodb-community-operator/scripts/dev/get_e2e_env_vars.py deleted file mode 100755 index cea1ac4e0..000000000 --- a/mongodb-community-operator/scripts/dev/get_e2e_env_vars.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python3 -import sys -from typing import Dict -import os.path - - -from dev_config import load_config, DevConfig, Distro - - -def _get_e2e_test_envs(dev_config: DevConfig) -> Dict[str, str]: - """ - _get_e2e_test_envs returns a dictionary of all the required environment variables - that need to be set in order to run a local e2e test. - - :param dev_config: The local dev config - :return: A diction of env vars to be set - """ - cleanup = False - if len(sys.argv) > 1: - cleanup = sys.argv[1] == "true" - return { - "ROLE_DIR": dev_config.role_dir, - "DEPLOY_DIR": dev_config.deploy_dir, - "OPERATOR_IMAGE": f"{dev_config.repo_url}/{dev_config.operator_image}", - "VERSION_UPGRADE_HOOK_IMAGE": f"{dev_config.repo_url}/{dev_config.version_upgrade_hook_image}", - "AGENT_IMAGE": f"{dev_config.repo_url}/{dev_config.agent_image}", - "TEST_DATA_DIR": dev_config.test_data_dir, - "TEST_NAMESPACE": dev_config.namespace, - "READINESS_PROBE_IMAGE": f"{dev_config.repo_url}/{dev_config.readiness_probe_image}", - "PERFORM_CLEANUP": "true" if cleanup else "false", - "WATCH_NAMESPACE": dev_config.namespace, - "MONGODB_IMAGE": dev_config.mongodb_image_name, - "MONGODB_REPO_URL": dev_config.mongodb_image_repo_url, - "HELM_CHART_PATH": os.path.abspath("./helm-charts/charts/community-operator"), - "MDB_IMAGE_TYPE": dev_config.image_type, - "MDB_LOCAL_OPERATOR": dev_config.local_operator, - "KUBECONFIG": dev_config.kube_config, - } - - -# convert all values in config.json to env vars. -# this can be used to provide configuration for e2e tests. -def main() -> int: - dev_config = load_config(distro=Distro.UBI) - for k, v in _get_e2e_test_envs(dev_config).items(): - print(f"export {k.upper()}={v}") - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/mongodb-community-operator/scripts/dev/k8s_conditions.py b/mongodb-community-operator/scripts/dev/k8s_conditions.py index 207ca3667..5e2927d4e 100644 --- a/mongodb-community-operator/scripts/dev/k8s_conditions.py +++ b/mongodb-community-operator/scripts/dev/k8s_conditions.py @@ -1,5 +1,5 @@ import time -from typing import Callable, Tuple, List, Optional, Any +from typing import Any, Callable, List, Optional, Tuple from kubernetes.client.rest import ApiException @@ -66,7 +66,8 @@ def call_eventually_succeeds( try: fn() return True - except exceptions_to_ignore: # type: ignore + except exceptions_to_ignore as e: + print(e) pass time.sleep(sleep_time) @@ -78,6 +79,7 @@ def _ignore_error_codes(fn: Callable, codes: Optional[List[int]]) -> Any: try: return fn() except ApiException as e: + print(e) if codes is not None and e.status not in codes: raise diff --git a/mongodb-community-operator/scripts/dev/k8s_request_data.py b/mongodb-community-operator/scripts/dev/k8s_request_data.py index 90b6b61cc..204721fce 100644 --- a/mongodb-community-operator/scripts/dev/k8s_request_data.py +++ b/mongodb-community-operator/scripts/dev/k8s_request_data.py @@ -1,7 +1,7 @@ -from kubernetes.client.rest import ApiException -from kubernetes import client +from typing import Dict, List, Optional -from typing import Optional, List, Dict +from kubernetes import client +from kubernetes.client.rest import ApiException def get_crds() -> Optional[Dict]: @@ -91,9 +91,7 @@ def get_pod_namespaced(namespace: str, pod_name: str) -> Optional[client.V1Pod]: return pod -def get_pod_log_namespaced( - namespace: str, pod_name: str, container_name: str -) -> Optional[str]: +def get_pod_log_namespaced(namespace: str, pod_name: str, container_name: str) -> Optional[str]: corev1 = client.CoreV1Api() try: log = corev1.read_namespaced_pod_log( diff --git a/mongodb-community-operator/scripts/dev/run_e2e_gh.sh b/mongodb-community-operator/scripts/dev/run_e2e_gh.sh deleted file mode 100755 index 52297c97e..000000000 --- a/mongodb-community-operator/scripts/dev/run_e2e_gh.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -set -Eeou pipefail - -test_name="${1}" -current_branch="$(git branch --show-current)" - -gh workflow run e2e-dispatch.yml -f "test-name=${test_name}" --ref "${current_branch}" - -echo "Waiting for task to start..." -sleep 2 - -run_id="$(gh run list --workflow=e2e-dispatch.yml | grep workflow_dispatch | grep -Eo "[0-9]{9,11}" | head -n 1)" - -gh run view "${run_id}" --web diff --git a/mongodb-community-operator/scripts/dev/setup_kind_cluster.sh b/mongodb-community-operator/scripts/dev/setup_kind_cluster.sh deleted file mode 100755 index 3178f2878..000000000 --- a/mongodb-community-operator/scripts/dev/setup_kind_cluster.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env bash -set -Eeou pipefail - -#### -# This file is copy-pasted from https://github.com/mongodb/mongodb-kubernetes-operator/blob/master/scripts/dev/setup_kind_cluster.sh -# Do not edit !!! -#### - -function usage() { - echo "Deploy local registry and create kind cluster configured to use this registry. Local Docker registry is deployed at localhost:5000. - -Usage: - setup_kind_cluster.sh [-n ] [-r] - setup_kind_cluster.sh [-h] - setup_kind_cluster.sh [-n ] [-e] [-r] - -Options: - -n (optional) Set kind cluster name to . Creates kubeconfig in ~/.kube/. The default name is 'kind' if not set. - -e (optional) Export newly created kind cluster's credentials to ~/.kube/ and set current kubectl context. - -h (optional) Shows this screen. - -r (optional) Recreate cluster if needed - -p (optional) Network reserved for Pods, e.g. 10.244.0.0/16 - -s (optional) Network reserved for Services, e.g. 10.96.0.0/16 -" - exit 0 -} - -cluster_name=${CLUSTER_NAME:-"kind"} -export_kubeconfig=0 -recreate=0 -pod_network="10.244.0.0/16" -service_network="10.96.0.0/16" -while getopts ':p:s:n:her' opt; do - case $opt in - (n) cluster_name=$OPTARG;; - (e) export_kubeconfig=1;; - (r) recreate=1;; - (p) pod_network=$OPTARG;; - (s) service_network=$OPTARG;; - (h) usage;; - (*) usage;; - esac -done -shift "$((OPTIND-1))" - -kubeconfig_path="$HOME/.kube/${cluster_name}" - -# create the kind network early unless it already exists. -# it would normally be created automatically by kind but we -# need it earlier to get the IP address of our registry. -docker network create kind || true - -# adapted from https://kind.sigs.k8s.io/docs/user/local-registry/ -# create registry container unless it already exists -reg_name='kind-registry' -reg_port='5000' -running="$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" -if [ "${running}" != 'true' ]; then - docker run -d --restart=always -p "127.0.0.1:${reg_port}:5000" --network kind --name "${reg_name}" registry:2 -fi - -if [ "${recreate}" != 0 ]; then - kind delete cluster --name "${cluster_name}" || true -fi - -# create a cluster with the local registry enabled in containerd -cat < /dev/null; then - echo "Installing goimports" - go install golang.org/x/tools/cmd/goimports - fi - - # Formats each file that was changed. - for file in $(git diff --cached --name-only --diff-filter=ACM | grep '\.go$') - do - goimports -w "${file}" - git add "$file" - done - -} - -function generate_crd(){ - echo "Generating CRD" - make manifests - git add config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml -} - -function mypy_check() -{ - local exit_status=0 - # Mypy doesn't support recursive traversal of directories - # So we manually call it on every staged python file - echo "Running mypy on staged python files" - for file in $(git diff --cached --name-only --diff-filter=ACM | grep '\.py$') - do - echo "Analyzing $file ..." - # We ignore missing import otherwise mypy will complain - # about 3rd party libraries not providing type hints - if ! mypy --disallow-untyped-calls --disallow-untyped-defs --disallow-incomplete-defs --ignore-missing-imports "${file}"; then - exit_status=1 - fi - done - return $exit_status -} - -function go_linting() { - dirs_to_analyze=() - for file in $(git diff --cached --name-only --diff-filter=ACM | grep '\.go$') - do - dirs_to_analyze+=("$(dirname "${file}")" ) - done - if [ ${#dirs_to_analyze[@]} -ne 0 ]; then - mapfile -t dirs_to_analyze < <(printf '%s\n' "${dirs_to_analyze[@]}" | sort -u) - echo "Running golangci-lint on staged files" - local exit_status=0 - for file in "${dirs_to_analyze[@]}" - do - if ! golangci-lint run "${file}"; then - exit_status=1 - fi - done - return $exit_status - fi - - return 0 -} - -function black_formatting() -{ - # Black formatting of every python file that was changed - for file in $(git diff --cached --name-only --diff-filter=ACM | grep '\.py$') - do - black -q "$file" - git add "$file" - done -} - -function generate_github_actions(){ - scripts/dev/generate_github_actions.py - git add .github/workflows -} - -generate_github_actions -generate_crd -go_imports -black_formatting -if ! mypy_check; then - echo "MyPy returned some errors, please correct them" - echo "Commit aborted" - # In some cases we might encounter mypy errors that we do not - # actually treat as such. So we provide a link to the dev - # for ignoring them through code annotation - echo "If some of the errors reported are false positives "\ - "and should be ignored, mypy provides a way to silence "\ - "errors: https://mypy.readthedocs.io/en/stable/common_issues.html#spurious-errors-and-locally-silencing-the-checker" - echo "Please use this only for errors that you are sure are"\ - "false positives." - exit 1 -fi -if ! go_linting; then - echo "Golancli-lint returned some errors, please correct them" - echo "Commit aborted" - # In some cases we might encounter mypy errors that we do not - # actually treat as such. So we provide a link to the dev - # for ignoring them through code annotation - echo "If some of the errors reported are false positives "\ - "and should be ignored, golanci-lint provides a way to silence "\ - "errors: https://golangci-lint.run/usage/false-positives/" - echo "Please use this only for errors that you are sure are"\ - "false positives." - exit 1 -fi diff --git a/mongodb-community-operator/scripts/git-hooks/pre-merge-commit b/mongodb-community-operator/scripts/git-hooks/pre-merge-commit deleted file mode 100755 index e69de29bb..000000000 diff --git a/mongodb-community-operator/scripts/git-hooks/pre-push b/mongodb-community-operator/scripts/git-hooks/pre-push deleted file mode 100755 index e69de29bb..000000000 diff --git a/mongodb-community-operator/scripts/git-hooks/pre-rebase b/mongodb-community-operator/scripts/git-hooks/pre-rebase deleted file mode 100755 index e69de29bb..000000000 diff --git a/mongodb-community-operator/scripts/git-hooks/pre-receive b/mongodb-community-operator/scripts/git-hooks/pre-receive deleted file mode 100755 index e69de29bb..000000000 diff --git a/mongodb-community-operator/scripts/git-hooks/prepare-commit-msg b/mongodb-community-operator/scripts/git-hooks/prepare-commit-msg deleted file mode 100755 index e69de29bb..000000000 diff --git a/mongodb-community-operator/scripts/git-hooks/update b/mongodb-community-operator/scripts/git-hooks/update deleted file mode 100755 index e69de29bb..000000000 diff --git a/mongodb-community-operator/test/e2e/client.go b/mongodb-community-operator/test/e2e/client.go index 478e3b81c..3794eaf9d 100644 --- a/mongodb-community-operator/test/e2e/client.go +++ b/mongodb-community-operator/test/e2e/client.go @@ -6,24 +6,24 @@ import ( "fmt" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/generate" - - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" + // Needed for running tests on GCP + "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes/scheme" - corev1client "k8s.io/client-go/kubernetes/typed/core/v1" "k8s.io/client-go/rest" "k8s.io/client-go/tools/remotecommand" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - - // Needed for running tests on GCP - "k8s.io/client-go/dynamic" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" + + corev1 "k8s.io/api/core/v1" + corev1client "k8s.io/client-go/kubernetes/typed/core/v1" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/generate" ) // TestClient is the global client used by e2e tests. diff --git a/mongodb-community-operator/test/e2e/e2eutil.go b/mongodb-community-operator/test/e2e/e2eutil.go index d29fd9abb..f9d558497 100644 --- a/mongodb-community-operator/test/e2e/e2eutil.go +++ b/mongodb-community-operator/test/e2e/e2eutil.go @@ -5,21 +5,19 @@ import ( "fmt" "reflect" - appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/resource" + "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar" - - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" k8sClient "sigs.k8s.io/controller-runtime/pkg/client" -) -const testDataDirEnv = "TEST_DATA_DIR" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" +) // TestLabels should be applied to all resources created by tests. func TestLabels() map[string]string { @@ -35,14 +33,6 @@ func TestAnnotations() map[string]string { } } -func TestDataDir() string { - return envvar.GetEnvOrDefault(testDataDirEnv, "/workspace/testdata") // nolint:forbidigo -} - -func TlsTestDataDir() string { - return fmt.Sprintf("%s/tls", TestDataDir()) -} - // UpdateMongoDBResource applies the provided function to the most recent version of the MongoDB resource // and retries when there are conflicts func UpdateMongoDBResource(ctx context.Context, original *mdbv1.MongoDBCommunity, updateFunc func(*mdbv1.MongoDBCommunity)) error { @@ -111,8 +101,8 @@ func NewTestMongoDB(ctx *TestContext, name string, namespace string) (mdbv1.Mong ScramCredentialsSecretName: fmt.Sprintf("%s-my-scram", name), }, }, - StatefulSetConfiguration: mdbv1.StatefulSetConfiguration{ - SpecWrapper: mdbv1.StatefulSetSpecWrapper{ + StatefulSetConfiguration: common.StatefulSetConfiguration{ + SpecWrapper: common.StatefulSetSpecWrapper{ Spec: appsv1.StatefulSetSpec{ Template: corev1.PodTemplateSpec{ Spec: corev1.PodSpec{ @@ -146,7 +136,8 @@ func NewTestMongoDB(ctx *TestContext, name string, namespace string) (mdbv1.Mong }, }, }, - }}, + }, + }, }, }, } diff --git a/mongodb-community-operator/test/e2e/feature_compatibility_version/feature_compatibility_version_test.go b/mongodb-community-operator/test/e2e/feature_compatibility_version/feature_compatibility_version_test.go index 2cc2db6d9..45e5dbee8 100644 --- a/mongodb-community-operator/test/e2e/feature_compatibility_version/feature_compatibility_version_test.go +++ b/mongodb-community-operator/test/e2e/feature_compatibility_version/feature_compatibility_version_test.go @@ -3,16 +3,17 @@ package feature_compatibility_version import ( "context" "fmt" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - "github.com/stretchr/testify/assert" "os" "testing" "time" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + "github.com/stretchr/testify/assert" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/mongodbtests/mongodbtests.go b/mongodb-community-operator/test/e2e/mongodbtests/mongodbtests.go index a7bbf30df..8f958de8a 100644 --- a/mongodb-community-operator/test/e2e/mongodbtests/mongodbtests.go +++ b/mongodb-community-operator/test/e2e/mongodbtests/mongodbtests.go @@ -9,22 +9,21 @@ import ( "testing" "time" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/authentication/authtypes" - + "github.com/stretchr/testify/assert" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/container" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/wait" - - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/authentication/authtypes" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/container" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/wait" ) // SkipTestIfLocal skips tests locally which tests connectivity to mongodb pods @@ -124,7 +123,6 @@ func StatefulSetHasOwnerReference(ctx context.Context, mdb *mdbv1.MongoDBCommuni stsNamespacedName := types.NamespacedName{Name: mdb.Name, Namespace: mdb.Namespace} sts := appsv1.StatefulSet{} err := e2eutil.TestClient.Get(ctx, stsNamespacedName, &sts) - if err != nil { t.Fatal(err) } @@ -248,6 +246,7 @@ func HasExpectedPersistentVolumes(ctx context.Context, volumes []corev1.Persiste } } } + func HasExpectedMetadata(ctx context.Context, mdb *mdbv1.MongoDBCommunity, expectedLabels map[string]string, expectedAnnotations map[string]string) func(t *testing.T) { return func(t *testing.T) { namespace := mdb.Namespace @@ -544,7 +543,7 @@ func DeletePod(ctx context.Context, mdb *mdbv1.MongoDBCommunity, podNum int) fun t.Fatal(err) } - t.Logf("pod %s/%s deleted", pod.ObjectMeta.Namespace, pod.ObjectMeta.Name) + t.Logf("pod %s/%s deleted", pod.Namespace, pod.Name) } } @@ -561,7 +560,7 @@ func DeleteStatefulSet(ctx context.Context, mdb *mdbv1.MongoDBCommunity) func(*t t.Fatal(err) } - t.Logf("StatefulSet %s/%s deleted", sts.ObjectMeta.Namespace, sts.ObjectMeta.Name) + t.Logf("StatefulSet %s/%s deleted", sts.Namespace, sts.Name) } } @@ -748,7 +747,6 @@ func StatefulSetMessageIsReceived(mdb *mdbv1.MongoDBCommunity, testCtx *e2eutil. if err != nil { t.Fatal(err) } - } } @@ -775,7 +773,6 @@ func RemoveLastUserFromMongoDBCommunity(ctx context.Context, mdb *mdbv1.MongoDBC err := e2eutil.UpdateMongoDBResource(ctx, mdb, func(db *mdbv1.MongoDBCommunity) { db.Spec.Users = db.Spec.Users[:len(db.Spec.Users)-1] }) - if err != nil { t.Fatal(err) } @@ -787,7 +784,6 @@ func EditConnectionStringSecretNameOfLastUser(ctx context.Context, mdb *mdbv1.Mo err := e2eutil.UpdateMongoDBResource(ctx, mdb, func(db *mdbv1.MongoDBCommunity) { db.Spec.Users[len(db.Spec.Users)-1].ConnectionStringSecretName = newSecretName }) - if err != nil { t.Fatal(err) } diff --git a/mongodb-community-operator/test/e2e/prometheus/prometheus_test.go b/mongodb-community-operator/test/e2e/prometheus/prometheus_test.go index 809b9ca9c..baeacb222 100644 --- a/mongodb-community-operator/test/e2e/prometheus/prometheus_test.go +++ b/mongodb-community-operator/test/e2e/prometheus/prometheus_test.go @@ -6,13 +6,13 @@ import ( "os" "testing" - v1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" "github.com/stretchr/testify/assert" + + v1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/replica_set/replica_set_test.go b/mongodb-community-operator/test/e2e/replica_set/replica_set_test.go index 4dfa5327f..cc1667f58 100644 --- a/mongodb-community-operator/test/e2e/replica_set/replica_set_test.go +++ b/mongodb-community-operator/test/e2e/replica_set/replica_set_test.go @@ -6,12 +6,12 @@ import ( "os" "testing" - v1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" + v1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/replica_set_arbiter/replica_set_arbiter_test.go b/mongodb-community-operator/test/e2e/replica_set_arbiter/replica_set_arbiter_test.go index 0906dd900..500187ac5 100644 --- a/mongodb-community-operator/test/e2e/replica_set_arbiter/replica_set_arbiter_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_arbiter/replica_set_arbiter_test.go @@ -6,11 +6,12 @@ import ( "os" "testing" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" "github.com/stretchr/testify/assert" + + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { @@ -22,7 +23,6 @@ func TestMain(m *testing.M) { } func Test(t *testing.T) { - } func TestReplicaSetArbiter(t *testing.T) { diff --git a/mongodb-community-operator/test/e2e/replica_set_authentication/replica_set_authentication_test.go b/mongodb-community-operator/test/e2e/replica_set_authentication/replica_set_authentication_test.go index 38dbcd962..6c7b5c0e5 100644 --- a/mongodb-community-operator/test/e2e/replica_set_authentication/replica_set_authentication_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_authentication/replica_set_authentication_test.go @@ -6,13 +6,13 @@ import ( "os" "testing" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" "go.mongodb.org/mongo-driver/bson/primitive" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { @@ -52,12 +52,14 @@ func withoutSha256() func(*authOptions) { opts.sha256 = false } } + func withLabeledSha256() func(*authOptions) { return func(opts *authOptions) { opts.sha256 = true opts.useLabelForSha256 = true } } + func withSha1() func(*authOptions) { return func(opts *authOptions) { opts.sha1 = true @@ -67,7 +69,6 @@ func withSha1() func(*authOptions) { // testConfigAuthentication run the tests using the auth options to update mdb and then checks that the resources are correctly configured func testConfigAuthentication(ctx context.Context, mdb mdbv1.MongoDBCommunity, user mdbv1.MongoDBUser, pw string, allOptions ...func(*authOptions)) func(t *testing.T) { return func(t *testing.T) { - pickedOpts := authOptions{ sha256: true, } diff --git a/mongodb-community-operator/test/e2e/replica_set_change_version/replica_set_change_version_test.go b/mongodb-community-operator/test/e2e/replica_set_change_version/replica_set_change_version_test.go index 4d022f9d7..2c8ce8ec5 100644 --- a/mongodb-community-operator/test/e2e/replica_set_change_version/replica_set_change_version_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_change_version/replica_set_change_version_test.go @@ -7,13 +7,12 @@ import ( "testing" "time" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" - appsv1 "k8s.io/api/apps/v1" + + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/replica_set_connection_string_options/replica_set_connection_string_options_test.go b/mongodb-community-operator/test/e2e/replica_set_connection_string_options/replica_set_connection_string_options_test.go index 6358f9d3a..d86ba34f9 100644 --- a/mongodb-community-operator/test/e2e/replica_set_connection_string_options/replica_set_connection_string_options_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_connection_string_options/replica_set_connection_string_options_test.go @@ -6,11 +6,10 @@ import ( "os" "testing" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { @@ -107,5 +106,4 @@ func TestReplicaSetWithConnectionString(t *testing.T) { t.Run("Test SRV Connectivity with generated connection string secret", tester.ConnectivityRejected(ctx, WithURI(mongodbtests.GetSrvConnectionStringForUser(ctx, mdb, scramUser)))) }) - } diff --git a/mongodb-community-operator/test/e2e/replica_set_cross_namespace_deploy/replica_set_cross_namespace_deploy_test.go b/mongodb-community-operator/test/e2e/replica_set_cross_namespace_deploy/replica_set_cross_namespace_deploy_test.go index 2bd41ed86..4e5cd94ae 100644 --- a/mongodb-community-operator/test/e2e/replica_set_cross_namespace_deploy/replica_set_cross_namespace_deploy_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_cross_namespace_deploy/replica_set_cross_namespace_deploy_test.go @@ -6,16 +6,16 @@ import ( "os" "testing" - corev1 "k8s.io/api/core/v1" - rbacv1 "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/generate" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" + corev1 "k8s.io/api/core/v1" + rbacv1 "k8s.io/api/rbac/v1" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/generate" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { @@ -70,13 +70,15 @@ func TestCrossNamespaceDeploy(t *testing.T) { // for the database StatefulSet in the other namespace. func createDatabaseServiceAccountRoleAndRoleBinding(ctx context.Context, t *testing.T, namespace string) error { sa := corev1.ServiceAccount{} - err := e2eutil.TestClient.Get(ctx, types.NamespacedName{Name: "mongodb-database", Namespace: e2eutil.OperatorNamespace}, &sa) + // TODO: MCK choose a correct SA name + mckServiceAccountName := "mongodb-enterprise-appdb" + err := e2eutil.TestClient.Get(ctx, types.NamespacedName{Name: mckServiceAccountName, Namespace: e2eutil.OperatorNamespace}, &sa) if err != nil { t.Fatal(err) } sa.Namespace = namespace - sa.ObjectMeta.ResourceVersion = "" + sa.ResourceVersion = "" err = e2eutil.TestClient.Create(ctx, &sa, &e2eutil.CleanupOptions{}) if err != nil { @@ -84,13 +86,13 @@ func createDatabaseServiceAccountRoleAndRoleBinding(ctx context.Context, t *test } role := rbacv1.Role{} - err = e2eutil.TestClient.Get(ctx, types.NamespacedName{Name: "mongodb-database", Namespace: e2eutil.OperatorNamespace}, &role) + err = e2eutil.TestClient.Get(ctx, types.NamespacedName{Name: mckServiceAccountName, Namespace: e2eutil.OperatorNamespace}, &role) if err != nil { t.Fatal(err) } role.Namespace = namespace - role.ObjectMeta.ResourceVersion = "" + role.ResourceVersion = "" err = e2eutil.TestClient.Create(ctx, &role, &e2eutil.CleanupOptions{}) if err != nil { @@ -98,14 +100,21 @@ func createDatabaseServiceAccountRoleAndRoleBinding(ctx context.Context, t *test } rolebinding := rbacv1.RoleBinding{} - err = e2eutil.TestClient.Get(ctx, types.NamespacedName{Name: "mongodb-database", Namespace: e2eutil.OperatorNamespace}, &rolebinding) + err = e2eutil.TestClient.Get(ctx, types.NamespacedName{Name: mckServiceAccountName, Namespace: e2eutil.OperatorNamespace}, &rolebinding) if err != nil { t.Fatal(err) } rolebinding.Namespace = namespace - rolebinding.ObjectMeta.ResourceVersion = "" - + rolebinding.ResourceVersion = "" + + // Update namespace in subjects field + for i := range rolebinding.Subjects { + if rolebinding.Subjects[i].Kind == "ServiceAccount" && + rolebinding.Subjects[i].Name == mckServiceAccountName { + rolebinding.Subjects[i].Namespace = namespace + } + } err = e2eutil.TestClient.Create(ctx, &rolebinding, &e2eutil.CleanupOptions{}) if err != nil { t.Fatal(err) diff --git a/mongodb-community-operator/test/e2e/replica_set_custom_annotations_test/replica_set_custom_annotations_test.go b/mongodb-community-operator/test/e2e/replica_set_custom_annotations_test/replica_set_custom_annotations_test.go index d92d5db1b..419e8cee5 100644 --- a/mongodb-community-operator/test/e2e/replica_set_custom_annotations_test/replica_set_custom_annotations_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_custom_annotations_test/replica_set_custom_annotations_test.go @@ -3,15 +3,17 @@ package replica_set_custom_annotations_test import ( "context" "fmt" - v1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "os" "testing" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { @@ -48,7 +50,7 @@ func TestReplicaSetCustomAnnotations(t *testing.T) { }, }, } - mdb.Spec.StatefulSetConfiguration.MetadataWrapper = v1.StatefulSetMetadataWrapper{ + mdb.Spec.StatefulSetConfiguration.MetadataWrapper = common.StatefulSetMetadataWrapper{ Labels: e2eutil.TestLabels(), Annotations: e2eutil.TestAnnotations(), } diff --git a/mongodb-community-operator/test/e2e/replica_set_custom_persistent_volume/replica_set_custom_persistent_volume_test.go b/mongodb-community-operator/test/e2e/replica_set_custom_persistent_volume/replica_set_custom_persistent_volume_test.go index db16c5ebe..8f095367f 100644 --- a/mongodb-community-operator/test/e2e/replica_set_custom_persistent_volume/replica_set_custom_persistent_volume_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_custom_persistent_volume/replica_set_custom_persistent_volume_test.go @@ -6,17 +6,17 @@ import ( "os" "testing" - v1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" "github.com/stretchr/testify/assert" + "k8s.io/apimachinery/pkg/api/resource" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" corev1 "k8s.io/api/core/v1" - - "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + v1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/replica_set_custom_role/replica_set_custom_role_test.go b/mongodb-community-operator/test/e2e/replica_set_custom_role/replica_set_custom_role_test.go index 54075a71d..1ec4a9176 100644 --- a/mongodb-community-operator/test/e2e/replica_set_custom_role/replica_set_custom_role_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_custom_role/replica_set_custom_role_test.go @@ -6,12 +6,11 @@ import ( "os" "testing" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { @@ -107,5 +106,4 @@ func TestReplicaSetCustomRole(t *testing.T) { roles := mdbv1.ConvertCustomRolesToAutomationConfigCustomRole(mdb.Spec.Security.Roles) t.Run("AutomationConfig has the correct custom role", mongodbtests.AutomationConfigHasTheExpectedCustomRoles(ctx, &mdb, roles)) t.Run("Custom Role was created ", tester.VerifyRoles(roles, 1)) - } diff --git a/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade/replica_set_enterprise_upgrade.go b/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade/replica_set_enterprise_upgrade.go index ff6930252..7b18099cd 100644 --- a/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade/replica_set_enterprise_upgrade.go +++ b/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade/replica_set_enterprise_upgrade.go @@ -6,16 +6,16 @@ import ( "testing" "time" - "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func DeployEnterpriseAndUpgradeTest(ctx context.Context, t *testing.T, versionsToBeTested []string) { - t.Setenv(construct.MongodbRepoUrlEnv, "docker.io/mongodb") - t.Setenv(construct.MongodbImageEnv, "mongodb-enterprise-server") + t.Setenv(construct.MongodbCommunityRepoUrlEnv, "docker.io/mongodb") + t.Setenv(construct.MongodbCommunityImageEnv, "mongodb-enterprise-server") testCtx := setup.Setup(ctx, t) defer testCtx.Teardown() diff --git a/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_4_5/replica_set_enterprise_upgrade_4_5_test.go b/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_4_5/replica_set_enterprise_upgrade_4_5_test.go index 298829059..1234c1f7b 100644 --- a/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_4_5/replica_set_enterprise_upgrade_4_5_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_4_5/replica_set_enterprise_upgrade_4_5_test.go @@ -6,14 +6,11 @@ import ( "os" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/replica_set_enterprise_upgrade" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade" ) -var ( - versionsForUpgrades = []string{"4.4.19", "5.0.15"} -) +var versionsForUpgrades = []string{"4.4.19", "5.0.15"} func TestMain(m *testing.M) { code, err := e2eutil.RunTest(m) diff --git a/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_5_6/replica_set_enterprise_upgrade_5_6_test.go b/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_5_6/replica_set_enterprise_upgrade_5_6_test.go index 0e0eedef5..b42fa6ee9 100644 --- a/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_5_6/replica_set_enterprise_upgrade_5_6_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_5_6/replica_set_enterprise_upgrade_5_6_test.go @@ -6,13 +6,11 @@ import ( "os" "testing" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/replica_set_enterprise_upgrade" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade" ) -var ( - versionsForUpgrades = []string{"5.0.15", "6.0.5"} -) +var versionsForUpgrades = []string{"5.0.15", "6.0.5"} func TestMain(m *testing.M) { code, err := e2eutil.RunTest(m) diff --git a/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_6_7/replica_set_enterprise_upgrade_5_6_test.go b/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_6_7/replica_set_enterprise_upgrade_5_6_test.go index c447ca6c6..939f5048d 100644 --- a/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_6_7/replica_set_enterprise_upgrade_5_6_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_6_7/replica_set_enterprise_upgrade_5_6_test.go @@ -6,13 +6,11 @@ import ( "os" "testing" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/replica_set_enterprise_upgrade" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade" ) -var ( - versionsForUpgrades = []string{"6.0.5", "7.0.2"} -) +var versionsForUpgrades = []string{"6.0.5", "7.0.2"} func TestMain(m *testing.M) { code, err := e2eutil.RunTest(m) diff --git a/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_7_8/replica_set_enterprise_upgrade_5_6_test.go b/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_7_8/replica_set_enterprise_upgrade_5_6_test.go index 00cdf8f10..1995b8462 100644 --- a/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_7_8/replica_set_enterprise_upgrade_5_6_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade_7_8/replica_set_enterprise_upgrade_5_6_test.go @@ -6,13 +6,11 @@ import ( "os" "testing" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/replica_set_enterprise_upgrade" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/replica_set_enterprise_upgrade" ) -var ( - versionsForUpgrades = []string{"7.0.12", "8.0.0"} -) +var versionsForUpgrades = []string{"7.0.12", "8.0.0"} func TestMain(m *testing.M) { code, err := e2eutil.RunTest(m) diff --git a/mongodb-community-operator/test/e2e/replica_set_mongod_config/replica_set_mongod_config_test.go b/mongodb-community-operator/test/e2e/replica_set_mongod_config/replica_set_mongod_config_test.go index 1a009c812..f12a55b45 100644 --- a/mongodb-community-operator/test/e2e/replica_set_mongod_config/replica_set_mongod_config_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_mongod_config/replica_set_mongod_config_test.go @@ -6,12 +6,12 @@ import ( "os" "testing" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" "github.com/stretchr/objx" + + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/replica_set_mongod_port_change_with_arbiters/replica_set_mongod_port_change_with_arbiters_test.go b/mongodb-community-operator/test/e2e/replica_set_mongod_port_change_with_arbiters/replica_set_mongod_port_change_with_arbiters_test.go index f398e36fc..f8d29ffc7 100644 --- a/mongodb-community-operator/test/e2e/replica_set_mongod_port_change_with_arbiters/replica_set_mongod_port_change_with_arbiters_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_mongod_port_change_with_arbiters/replica_set_mongod_port_change_with_arbiters_test.go @@ -6,13 +6,11 @@ import ( "os" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { @@ -49,8 +47,8 @@ func TestReplicaSetMongodPortChangeWithArbiters(t *testing.T) { tester.ConnectivitySucceeds(WithURI(mongodbtests.GetConnectionStringForUser(ctx, mdb, scramUser)))) // FIXME after port change in the service mongodb+srv connection stopped working! - //t.Run("Test SRV Connectivity", tester.ConnectivitySucceeds(WithURI(mdb.MongoSRVURI("")), WithoutTls(), WithReplicaSet(mdb.Name))) - //t.Run("Test SRV Connectivity with generated connection string secret", + // t.Run("Test SRV Connectivity", tester.ConnectivitySucceeds(WithURI(mdb.MongoSRVURI("")), WithoutTls(), WithReplicaSet(mdb.Name))) + // t.Run("Test SRV Connectivity with generated connection string secret", // tester.ConnectivitySucceeds(WithURI(mongodbtests.GetSrvConnectionStringForUser(mdb, scramUser)))) } diff --git a/mongodb-community-operator/test/e2e/replica_set_mongod_readiness/replica_set_mongod_readiness_test.go b/mongodb-community-operator/test/e2e/replica_set_mongod_readiness/replica_set_mongod_readiness_test.go index d82837fb9..25ad9d2e6 100644 --- a/mongodb-community-operator/test/e2e/replica_set_mongod_readiness/replica_set_mongod_readiness_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_mongod_readiness/replica_set_mongod_readiness_test.go @@ -6,9 +6,9 @@ import ( "os" "testing" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/replica_set_mount_connection_string/replica_set_mount_connection_string_test.go b/mongodb-community-operator/test/e2e/replica_set_mount_connection_string/replica_set_mount_connection_string_test.go index b4a03cbec..c64f23e21 100644 --- a/mongodb-community-operator/test/e2e/replica_set_mount_connection_string/replica_set_mount_connection_string_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_mount_connection_string/replica_set_mount_connection_string_test.go @@ -7,16 +7,16 @@ import ( "testing" "time" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/wait" "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/wait" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/replica_set_multiple/replica_set_multiple_test.go b/mongodb-community-operator/test/e2e/replica_set_multiple/replica_set_multiple_test.go index a38786eb0..d9f6981ed 100644 --- a/mongodb-community-operator/test/e2e/replica_set_multiple/replica_set_multiple_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_multiple/replica_set_multiple_test.go @@ -7,12 +7,11 @@ import ( "testing" "time" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { @@ -82,18 +81,17 @@ func TestReplicaSetMultiple(t *testing.T) { })) // TODO: Currently the scale down process takes too long to reasonably include this in the test - //t.Run("Scale MongoDB Resource Down", mongodbtests.Scale(&mdb0, 3)) - //t.Run("Stateful Set Scaled Down Correctly", mongodbtests.StatefulSetIsReadyAfterScaleDown(&mdb0)) - //t.Run("MongoDB Reaches Running Phase", mongodbtests.MongoDBReachesRunningPhase(&mdb0)) - //t.Run("AutomationConfig's version has been increased", mongodbtests.AutomationConfigVersionHasTheExpectedVersion(&mdb0, 3)) - //t.Run("Test Status Was Updated", mongodbtests.Status(&mdb0, + // t.Run("Scale MongoDB Resource Down", mongodbtests.Scale(&mdb0, 3)) + // t.Run("Stateful Set Scaled Down Correctly", mongodbtests.StatefulSetIsReadyAfterScaleDown(&mdb0)) + // t.Run("MongoDB Reaches Running Phase", mongodbtests.MongoDBReachesRunningPhase(&mdb0)) + // t.Run("AutomationConfig's version has been increased", mongodbtests.AutomationConfigVersionHasTheExpectedVersion(&mdb0, 3)) + // t.Run("Test Status Was Updated", mongodbtests.Status(&mdb0, // mdbv1.MongoDBStatus{ // MongoURI: mdb0.MongoURI(""), // Phase: mdbv1.Running, // CurrentMongoDBMembers: 5, // CurrentStatefulSetReplicas: 5, // })) - }) // One last check that mdb1 was not altered. diff --git a/mongodb-community-operator/test/e2e/replica_set_operator_upgrade/replica_set_operator_upgrade_test.go b/mongodb-community-operator/test/e2e/replica_set_operator_upgrade/replica_set_operator_upgrade_test.go index 726c52514..7f2ea3684 100644 --- a/mongodb-community-operator/test/e2e/replica_set_operator_upgrade/replica_set_operator_upgrade_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_operator_upgrade/replica_set_operator_upgrade_test.go @@ -5,12 +5,16 @@ import ( "fmt" "os" "testing" + "time" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { @@ -21,7 +25,82 @@ func TestMain(m *testing.M) { os.Exit(code) } +func TestReplicaSetOperatorUpgradeMCOToMCK(t *testing.T) { + ctx := context.Background() + resourceName := "mdb0" + testConfig := setup.LoadTestConfigFromEnv() + testCtx := setup.SetupWithTestConfigNoOperator(ctx, t, testConfig, false) + defer testCtx.Teardown() + + // Step 1: Install the latest community operator using public MongoDB Helm chart + + err := setup.InstallCommunityOperatorViaHelm(ctx, t, testConfig, testConfig.Namespace) + require.NoError(t, err) + + mdb, user := e2eutil.NewTestMongoDB(testCtx, resourceName, testConfig.Namespace) + mdb.Spec.Version = "6.0.5" + mdb.Spec.Arbiters = 1 + mdb.Spec.Members = 2 + + _, err = setup.GeneratePasswordForUser(testCtx, user, testConfig.Namespace) + if err != nil { + t.Fatal(err) + } + + t.Run("Create MongoDB Resource", mongodbtests.CreateMongoDBResource(&mdb, testCtx)) + t.Run("Basic tests with community operator", mongodbtests.BasicFunctionality(ctx, &mdb, true)) + t.Run("AutomationConfig has the correct version", mongodbtests.AutomationConfigVersionHasTheExpectedVersion(ctx, &mdb, 1)) + + tester, err := FromResource(ctx, t, mdb) + if err != nil { + t.Fatal(err) + } + + // Step 2: Scale down the MCO operator deployment to prevent it from running its reconciler + t.Log("Step 1: Scaling down MCO operator deployment") + err = setup.ScaleOperatorDeployment(ctx, t, testConfig.Namespace, setup.CommunityHelmChartAndDeploymentName, 0) + assert.NoError(t, err) + + // Step 3: Install the new MCK chart + t.Log("Step 2: Installing MCK operator") + err = setup.DeployMCKOperator(ctx, t, testConfig, resourceName, false, false, setup.HelmArg{ + Name: "operator.name", + Value: setup.MCKHelmChartAndDeploymentName, + }) + assert.NoError(t, err) + + // let's check whether all is healthy and fine + t.Run("Basic tests with community operator", mongodbtests.BasicFunctionality(ctx, &mdb, true)) + + t.Log("Successfully migrated from MCO to MCK") + + // Step 4: Remove the MCO chart now that migration is complete + t.Log("Step 8: Uninstalling MCO chart (CRDs will remain)") + err = setup.UninstallCommunityOperatorViaHelm(ctx, t, testConfig.Namespace) + assert.NoError(t, err, "Failed to uninstall MCO chart") + + // Verify functionality after migration to MCK + t.Run("Basic tests after migration to MCK", mongodbtests.BasicFunctionality(ctx, &mdb, true)) + t.Run("MongoDB is reachable after migration", func(t *testing.T) { + defer tester.StartBackgroundConnectivityTest(t, time.Second*10)() + t.Run("Scale MongoDB Resource Up", mongodbtests.Scale(ctx, &mdb, 5)) + t.Run("Stateful Set Scaled Up Correctly", mongodbtests.StatefulSetBecomesReady(ctx, &mdb)) + t.Run("MongoDB Reaches Running Phase", mongodbtests.MongoDBReachesRunningPhase(ctx, &mdb)) + t.Run("AutomationConfig's version has been increased", mongodbtests.AutomationConfigVersionHasTheExpectedVersion(ctx, &mdb, 4)) // 4, because the mck upgrade already forces one version bump + t.Run("Test Status Was Updated", mongodbtests.Status(ctx, &mdb, mdbv1.MongoDBCommunityStatus{ + MongoURI: mdb.MongoURI(""), + Phase: mdbv1.Running, + Version: mdb.GetMongoDBVersion(), + CurrentMongoDBMembers: 5, + CurrentStatefulSetReplicas: 5, + CurrentStatefulSetArbitersReplicas: 1, + CurrentMongoDBArbiters: 1, + })) + }) +} + func TestReplicaSetOperatorUpgrade(t *testing.T) { + t.Skipf("Skipping test until CLOUDP-308559 has been fixed, we should also update this test to update from MCO to MCK") ctx := context.Background() resourceName := "mdb0" testConfig := setup.LoadTestConfigFromEnv() @@ -63,7 +142,7 @@ func TestReplicaSetOperatorUpgrade(t *testing.T) { // upgrade the operator to master config := setup.LoadTestConfigFromEnv() - err = setup.DeployOperator(ctx, config, resourceName, true, false) + err = setup.DeployMCKOperator(ctx, t, config, resourceName, true, false) assert.NoError(t, err) // Perform the basic tests @@ -79,7 +158,9 @@ func TestReplicaSetOperatorUpgradeFrom0_7_2(t *testing.T) { testConfig := setup.LoadTestConfigFromEnv() // deploy operator and other components as it was at version 0.7.2 - testConfig.OperatorImage = "quay.io/mongodb/mongodb-kubernetes-operator:0.7.2" + testConfig.OperatorImageRepoUrl = "quay.io/mongodb" + testConfig.OperatorImage = "mongodb-kubernetes-operator" + testConfig.OperatorVersion = "0.7.2" testConfig.VersionUpgradeHookImage = "quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook:1.0.3" testConfig.ReadinessProbeImage = "quay.io/mongodb/mongodb-kubernetes-readinessprobe:1.0.6" testConfig.AgentImage = "quay.io/mongodb/mongodb-agent-ubi:11.0.5.6963-1" @@ -122,7 +203,7 @@ func TestReplicaSetOperatorUpgradeFrom0_7_2(t *testing.T) { // rescale helm operator deployment to zero and run local operator then. testConfig = setup.LoadTestConfigFromEnv() - err = setup.DeployOperator(ctx, testConfig, resourceName, true, false) + err = setup.DeployMCKOperator(ctx, t, testConfig, resourceName, true, false) assert.NoError(t, err) runTests(t) diff --git a/mongodb-community-operator/test/e2e/replica_set_recovery/replica_set_recovery_test.go b/mongodb-community-operator/test/e2e/replica_set_recovery/replica_set_recovery_test.go index 91c9426b7..171da64bb 100644 --- a/mongodb-community-operator/test/e2e/replica_set_recovery/replica_set_recovery_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_recovery/replica_set_recovery_test.go @@ -9,12 +9,11 @@ import ( "testing" "time" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { @@ -63,6 +62,5 @@ func TestReplicaSetRecovery(t *testing.T) { CurrentMongoDBMembers: 3, CurrentStatefulSetReplicas: 3, })) - }) } diff --git a/mongodb-community-operator/test/e2e/replica_set_remove_user/replica_set_remove_user_test.go b/mongodb-community-operator/test/e2e/replica_set_remove_user/replica_set_remove_user_test.go index 2abeb93c3..e27589ae0 100644 --- a/mongodb-community-operator/test/e2e/replica_set_remove_user/replica_set_remove_user_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_remove_user/replica_set_remove_user_test.go @@ -3,14 +3,15 @@ package replica_set_remove_user import ( "context" "fmt" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" "os" "testing" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/replica_set_scale/replica_set_scaling_test.go b/mongodb-community-operator/test/e2e/replica_set_scale/replica_set_scaling_test.go index 0361ba9f0..e93fd5463 100644 --- a/mongodb-community-operator/test/e2e/replica_set_scale/replica_set_scaling_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_scale/replica_set_scaling_test.go @@ -7,11 +7,11 @@ import ( "testing" "time" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { @@ -60,11 +60,11 @@ func TestReplicaSetScaleUp(t *testing.T) { })) // TODO: Currently the scale down process takes too long to reasonably include this in the test - //t.Run("Scale MongoDB Resource Down", mongodbtests.Scale(&mdb, 3)) - //t.Run("Stateful Set Scaled Down Correctly", mongodbtests.StatefulSetIsReadyAfterScaleDown(&mdb)) - //t.Run("MongoDB Reaches Running Phase", mongodbtests.MongoDBReachesRunningPhase(&mdb)) - //t.Run("AutomationConfig's version has been increased", mongodbtests.AutomationConfigVersionHasTheExpectedVersion(&mdb, 5)) - //t.Run("Test Status Was Updated", mongodbtests.Status(&mdb, + // t.Run("Scale MongoDB Resource Down", mongodbtests.Scale(&mdb, 3)) + // t.Run("Stateful Set Scaled Down Correctly", mongodbtests.StatefulSetIsReadyAfterScaleDown(&mdb)) + // t.Run("MongoDB Reaches Running Phase", mongodbtests.MongoDBReachesRunningPhase(&mdb)) + // t.Run("AutomationConfig's version has been increased", mongodbtests.AutomationConfigVersionHasTheExpectedVersion(&mdb, 5)) + // t.Run("Test Status Was Updated", mongodbtests.Status(&mdb, // mdbv1.MongoDBStatus{ // MongoURI: mdb.MongoURI(""), // Phase: mdbv1.Running, diff --git a/mongodb-community-operator/test/e2e/replica_set_scale_down/replica_set_scale_down_test.go b/mongodb-community-operator/test/e2e/replica_set_scale_down/replica_set_scale_down_test.go index fd03fdafc..34afaee21 100644 --- a/mongodb-community-operator/test/e2e/replica_set_scale_down/replica_set_scale_down_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_scale_down/replica_set_scale_down_test.go @@ -7,13 +7,11 @@ import ( "testing" "time" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/replica_set_tls/replica_set_tls_test.go b/mongodb-community-operator/test/e2e/replica_set_tls/replica_set_tls_test.go index 719bcdc8f..087015bd5 100644 --- a/mongodb-community-operator/test/e2e/replica_set_tls/replica_set_tls_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_tls/replica_set_tls_test.go @@ -6,11 +6,10 @@ import ( "os" "testing" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/replica_set_tls_recreate_mdbc/replica_set_tls_recreate_mdbc_test.go b/mongodb-community-operator/test/e2e/replica_set_tls_recreate_mdbc/replica_set_tls_recreate_mdbc_test.go index 751a048c4..ed88fe34d 100644 --- a/mongodb-community-operator/test/e2e/replica_set_tls_recreate_mdbc/replica_set_tls_recreate_mdbc_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_tls_recreate_mdbc/replica_set_tls_recreate_mdbc_test.go @@ -6,11 +6,10 @@ import ( "os" "testing" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/replica_set_tls_rotate/replica_set_tls_rotate_test.go b/mongodb-community-operator/test/e2e/replica_set_tls_rotate/replica_set_tls_rotate_test.go index 86c1b6614..c9af4f354 100644 --- a/mongodb-community-operator/test/e2e/replica_set_tls_rotate/replica_set_tls_rotate_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_tls_rotate/replica_set_tls_rotate_test.go @@ -7,12 +7,11 @@ import ( "testing" "time" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/tlstests" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/tlstests" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/replica_set_tls_rotate_delete_sts/replica_set_tls_rotate_delete_sts_test.go b/mongodb-community-operator/test/e2e/replica_set_tls_rotate_delete_sts/replica_set_tls_rotate_delete_sts_test.go index 0bc0448bd..550efbf94 100644 --- a/mongodb-community-operator/test/e2e/replica_set_tls_rotate_delete_sts/replica_set_tls_rotate_delete_sts_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_tls_rotate_delete_sts/replica_set_tls_rotate_delete_sts_test.go @@ -2,17 +2,15 @@ package replica_set_tls_rotate_delete_sts import ( "context" + "fmt" "os" "testing" - "fmt" - - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/tlstests" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/tlstests" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/replica_set_tls_upgrade/replica_set_tls_upgrade_test.go b/mongodb-community-operator/test/e2e/replica_set_tls_upgrade/replica_set_tls_upgrade_test.go index eb85477f3..c12fddba2 100644 --- a/mongodb-community-operator/test/e2e/replica_set_tls_upgrade/replica_set_tls_upgrade_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_tls_upgrade/replica_set_tls_upgrade_test.go @@ -7,13 +7,11 @@ import ( "testing" "time" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/tlstests" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/tlstests" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/replica_set_x509/replica_set_x509_test.go b/mongodb-community-operator/test/e2e/replica_set_x509/replica_set_x509_test.go index a7ed3503c..9b4a7c4d8 100644 --- a/mongodb-community-operator/test/e2e/replica_set_x509/replica_set_x509_test.go +++ b/mongodb-community-operator/test/e2e/replica_set_x509/replica_set_x509_test.go @@ -6,17 +6,18 @@ import ( "os" "testing" - corev1 "k8s.io/api/core/v1" + "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/types" - v1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/constants" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/tlstests" - . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" + + v1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/constants" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/tlstests" + . "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { @@ -31,8 +32,8 @@ func TestReplicaSetX509(t *testing.T) { ctx := context.Background() resourceName := "mdb-tls" helmArgs := []setup.HelmArg{ - {Name: "resource.tls.useX509", Value: "true"}, - {Name: "resource.tls.sampleX509User", Value: "true"}, + {Name: "community.resource.tls.useX509", Value: "true"}, + {Name: "community.resource.tls.sampleX509User", Value: "true"}, } testCtx, testConfig := setup.SetupWithTLS(ctx, t, resourceName, helmArgs...) defer testCtx.Teardown() @@ -152,7 +153,6 @@ func TestReplicaSetX509(t *testing.T) { t.Run("Basic tests", mongodbtests.BasicFunctionality(ctx, &mdb)) t.Run("Connectivity Succeeds", tester.ConnectivitySucceeds(WithURI(fmt.Sprintf("%s&tlsCAFile=%s&tlsCertificateKeyFile=%s", mongodbtests.GetConnectionStringForUser(ctx, mdb, users[0]), root, cert)))) }) - } func getValidUser() v1.MongoDBUser { diff --git a/mongodb-community-operator/test/e2e/setup/setup.go b/mongodb-community-operator/test/e2e/setup/setup.go index 8bf9595bd..7ff5adb14 100644 --- a/mongodb-community-operator/test/e2e/setup/setup.go +++ b/mongodb-community-operator/test/e2e/setup/setup.go @@ -4,52 +4,49 @@ import ( "context" "errors" "fmt" + "os/exec" "strconv" "strings" "testing" "time" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/helm" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar" - waite2e "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/wait" - - appsv1 "k8s.io/api/apps/v1" - apiErrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" + "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/generate" - - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/secret" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + apiErrors "k8s.io/apimachinery/pkg/api/errors" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/helm" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/secret" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/envvar" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/generate" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + waite2e "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/wait" ) -type tlsSecretType string - type HelmArg struct { Name string Value string } const ( - performCleanupEnv = "PERFORM_CLEANUP" - CertKeyPair tlsSecretType = "CERTKEYPAIR" - Pem tlsSecretType = "PEM" + performCleanupEnv = "PERFORM_CLEANUP" + CommunityHelmChartAndDeploymentName = "mongodb-community-operator" + MCKHelmChartAndDeploymentName = "mongodb-mck-operator" ) func Setup(ctx context.Context, t *testing.T) *e2eutil.TestContext { testCtx, err := e2eutil.NewContext(ctx, t, envvar.ReadBool(performCleanupEnv)) // nolint:forbidigo - if err != nil { t.Fatal(err) } config := LoadTestConfigFromEnv() - if err := DeployOperator(ctx, config, "mdb", false, false); err != nil { + if err := DeployMCKOperator(ctx, t, config, "mdb", false, false); err != nil { t.Fatal(err) } @@ -58,17 +55,16 @@ func Setup(ctx context.Context, t *testing.T) *e2eutil.TestContext { func SetupWithTLS(ctx context.Context, t *testing.T, resourceName string, additionalHelmArgs ...HelmArg) (*e2eutil.TestContext, TestConfig) { textCtx, err := e2eutil.NewContext(ctx, t, envvar.ReadBool(performCleanupEnv)) // nolint:forbidigo - if err != nil { t.Fatal(err) } config := LoadTestConfigFromEnv() - if err := deployCertManager(config); err != nil { + if err := deployCertManager(t, config); err != nil { t.Fatal(err) } - if err := DeployOperator(ctx, config, resourceName, true, false, additionalHelmArgs...); err != nil { + if err := DeployMCKOperator(ctx, t, config, resourceName, true, false, additionalHelmArgs...); err != nil { t.Fatal(err) } @@ -77,24 +73,38 @@ func SetupWithTLS(ctx context.Context, t *testing.T, resourceName string, additi func SetupWithTestConfig(ctx context.Context, t *testing.T, testConfig TestConfig, withTLS, defaultOperator bool, resourceName string) *e2eutil.TestContext { testCtx, err := e2eutil.NewContext(ctx, t, envvar.ReadBool(performCleanupEnv)) // nolint:forbidigo - if err != nil { t.Fatal(err) } if withTLS { - if err := deployCertManager(testConfig); err != nil { + if err := deployCertManager(t, testConfig); err != nil { t.Fatal(err) } } - if err := DeployOperator(ctx, testConfig, resourceName, withTLS, defaultOperator); err != nil { + if err := DeployMCKOperator(ctx, t, testConfig, resourceName, withTLS, defaultOperator); err != nil { t.Fatal(err) } return testCtx } +func SetupWithTestConfigNoOperator(ctx context.Context, t *testing.T, testConfig TestConfig, withTLS bool) *e2eutil.TestContext { + testCtx, err := e2eutil.NewContext(ctx, t, envvar.ReadBool(performCleanupEnv)) // nolint:forbidigo + if err != nil { + t.Fatal(err) + } + + if withTLS { + if err := deployCertManager(t, testConfig); err != nil { + t.Fatal(err) + } + } + + return testCtx +} + // GeneratePasswordForUser will create a secret with a password for the given user func GeneratePasswordForUser(testCtx *e2eutil.TestContext, mdbu mdbv1.MongoDBUser, namespace string) (string, error) { passwordKey := mdbu.PasswordSecretRef.Key @@ -142,8 +152,6 @@ func getHelmArgs(testConfig TestConfig, watchNamespace string, resourceName stri agentRegistry, agentName, agentVersion := extractRegistryNameAndVersion(testConfig.AgentImage) versionUpgradeHookRegistry, versionUpgradeHookName, versionUpgradeHookVersion := extractRegistryNameAndVersion(testConfig.VersionUpgradeHookImage) readinessProbeRegistry, readinessProbeName, readinessProbeVersion := extractRegistryNameAndVersion(testConfig.ReadinessProbeImage) - operatorRegistry, operatorName, operatorVersion := extractRegistryNameAndVersion(testConfig.OperatorImage) - helmArgs := make(map[string]string) helmArgs["namespace"] = testConfig.Namespace @@ -151,27 +159,70 @@ func getHelmArgs(testConfig TestConfig, watchNamespace string, resourceName stri helmArgs["operator.watchNamespace"] = watchNamespace if !defaultOperator { - helmArgs["operator.operatorImageName"] = operatorName - helmArgs["operator.version"] = operatorVersion + helmArgs["operator.operator_image_name"] = testConfig.OperatorImage + helmArgs["operator.version"] = testConfig.OperatorVersion + helmArgs["registry.operator"] = testConfig.OperatorImageRepoUrl + + helmArgs["community.agent.version"] = agentVersion + helmArgs["community.agent.name"] = agentName + + helmArgs["community.mongodb.name"] = testConfig.MongoDBImage + helmArgs["community.mongodb.repo"] = testConfig.MongoDBRepoUrl + helmArgs["community.registry.agent"] = agentRegistry + + helmArgs["registry.versionUpgradeHook"] = versionUpgradeHookRegistry + helmArgs["registry.readinessProbe"] = readinessProbeRegistry + helmArgs["registry.imagePullSecrets"] = "image-registries-secret" helmArgs["versionUpgradeHook.name"] = versionUpgradeHookName helmArgs["versionUpgradeHook.version"] = versionUpgradeHookVersion helmArgs["readinessProbe.name"] = readinessProbeName helmArgs["readinessProbe.version"] = readinessProbeVersion + } - helmArgs["agent.version"] = agentVersion - helmArgs["agent.name"] = agentName - - helmArgs["mongodb.name"] = testConfig.MongoDBImage - helmArgs["mongodb.repo"] = testConfig.MongoDBRepoUrl + // only used for one mco tls test + helmArgs["community.createResource"] = strconv.FormatBool(false) + helmArgs["community.resource.name"] = resourceName + helmArgs["community.resource.tls.enabled"] = strconv.FormatBool(withTLS) + helmArgs["community.resource.tls.useCertManager"] = strconv.FormatBool(withTLS) - helmArgs["registry.versionUpgradeHook"] = versionUpgradeHookRegistry - helmArgs["registry.operator"] = operatorRegistry - helmArgs["registry.agent"] = agentRegistry - helmArgs["registry.readinessProbe"] = readinessProbeRegistry + for _, arg := range additionalHelmArgs { + helmArgs[arg.Name] = arg.Value } - helmArgs["community-operator-crds.enabled"] = strconv.FormatBool(false) + return helmArgs +} + +// getMCOHelmArgs returns a map of helm arguments that were used to install mco with the mco chart +func getMCOHelmArgs(testConfig TestConfig, watchNamespace string, resourceName string, withTLS bool, additionalHelmArgs ...HelmArg) map[string]string { + agentRegistry, agentName, agentVersion := extractRegistryNameAndVersion(testConfig.AgentImage) + versionUpgradeHookRegistry, versionUpgradeHookName, versionUpgradeHookVersion := extractRegistryNameAndVersion(testConfig.VersionUpgradeHookImage) + readinessProbeRegistry, readinessProbeName, readinessProbeVersion := extractRegistryNameAndVersion(testConfig.ReadinessProbeImage) + helmArgs := make(map[string]string) + + helmArgs["namespace"] = testConfig.Namespace + + helmArgs["operator.watchNamespace"] = watchNamespace + + helmArgs["operator.operatorImageName"] = "mongodb-kubernetes-operator" + helmArgs["operator.version"] = "0.12.0" + helmArgs["versionUpgradeHook.name"] = versionUpgradeHookName + helmArgs["versionUpgradeHook.version"] = versionUpgradeHookVersion + + helmArgs["readinessProbe.name"] = readinessProbeName + helmArgs["readinessProbe.version"] = readinessProbeVersion + + helmArgs["agent.version"] = agentVersion + helmArgs["agent.name"] = agentName + + helmArgs["mongodb.name"] = testConfig.MongoDBImage + helmArgs["mongodb.repo"] = testConfig.MongoDBRepoUrl + + helmArgs["registry.versionUpgradeHook"] = versionUpgradeHookRegistry + helmArgs["registry.operator"] = "quay.io/mongodb" + helmArgs["registry.agent"] = agentRegistry + helmArgs["registry.readinessProbe"] = readinessProbeRegistry + helmArgs["registry.imagePullSecrets"] = "image-registries-secret" helmArgs["createResource"] = strconv.FormatBool(false) helmArgs["resource.name"] = resourceName @@ -185,8 +236,8 @@ func getHelmArgs(testConfig TestConfig, watchNamespace string, resourceName stri return helmArgs } -// DeployOperator installs all resources required by the operator using helm. -func DeployOperator(ctx context.Context, config TestConfig, resourceName string, withTLS bool, defaultOperator bool, additionalHelmArgs ...HelmArg) error { +// DeployMCKOperator installs all resources required by the operator using helm. +func DeployMCKOperator(ctx context.Context, t *testing.T, config TestConfig, resourceName string, withTLS bool, defaultOperator bool, additionalHelmArgs ...HelmArg) error { e2eutil.OperatorNamespace = config.Namespace fmt.Printf("Setting operator namespace to %s\n", e2eutil.OperatorNamespace) watchNamespace := config.Namespace @@ -195,30 +246,26 @@ func DeployOperator(ctx context.Context, config TestConfig, resourceName string, } fmt.Printf("Setting namespace to watch to %s\n", watchNamespace) - helmChartName := "mongodb-kubernetes-operator" - if err := helm.Uninstall(helmChartName, config.Namespace); err != nil { + if err := helm.Uninstall(t, MCKHelmChartAndDeploymentName, config.Namespace); err != nil { return err } helmArgs := getHelmArgs(config, watchNamespace, resourceName, withTLS, defaultOperator, additionalHelmArgs...) helmFlags := map[string]string{ - "namespace": config.Namespace, - "create-namespace": "", + "namespace": config.Namespace, } if config.LocalOperator { helmArgs["operator.replicas"] = "0" } - if err := helm.DependencyUpdate(config.HelmChartPath); err != nil { - return err - } + helmArgs["operator.name"] = MCKHelmChartAndDeploymentName - if err := helm.Install(config.HelmChartPath, helmChartName, helmFlags, helmArgs); err != nil { + if err := helm.Install(t, config.HelmChartPath, MCKHelmChartAndDeploymentName, helmFlags, helmArgs); err != nil { return err } - dep, err := waite2e.ForDeploymentToExist(ctx, "mongodb-kubernetes-operator", time.Second*10, time.Minute*1, e2eutil.OperatorNamespace) + dep, err := waite2e.ForDeploymentToExist(ctx, MCKHelmChartAndDeploymentName, time.Second*10, time.Minute*1, e2eutil.OperatorNamespace) if err != nil { return err } @@ -244,20 +291,20 @@ func DeployOperator(ctx context.Context, config TestConfig, resourceName string, return nil } -func deployCertManager(config TestConfig) error { +func deployCertManager(t *testing.T, config TestConfig) error { const helmChartName = "cert-manager" - if err := helm.Uninstall(helmChartName, config.CertManagerNamespace); err != nil { + if err := helm.Uninstall(t, helmChartName, config.CertManagerNamespace); err != nil { return fmt.Errorf("failed to uninstall cert-manager Helm chart: %s", err) } - charlUrl := fmt.Sprintf("https://charts.jetstack.io/charts/cert-manager-%s.tgz", config.CertManagerVersion) + chartUrl := fmt.Sprintf("https://charts.jetstack.io/charts/cert-manager-%s.tgz", config.CertManagerVersion) flags := map[string]string{ "version": config.CertManagerVersion, "namespace": config.CertManagerNamespace, "create-namespace": "", } values := map[string]string{"installCRDs": "true"} - if err := helm.Install(charlUrl, helmChartName, flags, values); err != nil { + if err := helm.Install(t, chartUrl, helmChartName, flags, values); err != nil { return fmt.Errorf("failed to install cert-manager Helm chart: %s", err) } return nil @@ -268,8 +315,10 @@ func deployCertManager(config TestConfig) error { func hasDeploymentRequiredReplicas(dep *appsv1.Deployment) wait.ConditionWithContextFunc { return func(ctx context.Context) (bool, error) { err := e2eutil.TestClient.Get(ctx, - types.NamespacedName{Name: dep.Name, - Namespace: e2eutil.OperatorNamespace}, + types.NamespacedName{ + Name: dep.Name, + Namespace: e2eutil.OperatorNamespace, + }, dep) if err != nil { if apiErrors.IsNotFound(err) { @@ -284,3 +333,128 @@ func hasDeploymentRequiredReplicas(dep *appsv1.Deployment) wait.ConditionWithCon return false, nil } } + +// InstallCommunityOperatorViaHelm installs the community operator using the public MongoDB Helm chart. +func InstallCommunityOperatorViaHelm(ctx context.Context, t *testing.T, config TestConfig, namespace string, additionalHelmArgs ...HelmArg) error { + e2eutil.OperatorNamespace = config.Namespace + + // Uninstall any existing chart with the same name + if err := helm.Uninstall(t, CommunityHelmChartAndDeploymentName, namespace); err != nil { + return err + } + + // Add the MongoDB repo if needed + addRepoCmd := exec.CommandContext(ctx, "helm", "repo", "add", "mongodb", "https://mongodb.github.io/helm-charts") + if output, err := addRepoCmd.CombinedOutput(); err != nil { + t.Logf("Failed to add MongoDB Helm repo: %s", string(output)) + return err + } + + updateCmd := exec.CommandContext(ctx, "helm", "repo", "update") + if output, err := updateCmd.CombinedOutput(); err != nil { + t.Logf("Failed to update Helm repos: %s", string(output)) + return err + } + + // Configure helm flags and args + helmFlags := map[string]string{ + "namespace": namespace, + } + + helmArgs := getMCOHelmArgs(config, namespace, "mdb", false, additionalHelmArgs...) + helmArgs["operator.name"] = CommunityHelmChartAndDeploymentName + + // Apply any additional helm args + for _, arg := range additionalHelmArgs { + helmArgs[arg.Name] = arg.Value + } + + // Use the helm package to install the chart + if err := helm.Install(t, "mongodb/community-operator", CommunityHelmChartAndDeploymentName, helmFlags, helmArgs); err != nil { + return fmt.Errorf("failed to install community operator: %s", err) + } + + t.Logf("Community operator installed successfully") + + // Wait for the deployment to be ready + dep, err := waite2e.ForDeploymentToExist(ctx, CommunityHelmChartAndDeploymentName, time.Second*10, time.Minute*1, namespace) + if err != nil { + return err + } + + if err := wait.PollUntilContextTimeout(ctx, time.Second*2, 120*time.Second, true, hasDeploymentRequiredReplicas(&dep)); err != nil { + return errors.New("error building community operator deployment: the deployment does not have the required replicas") + } + + fmt.Println("Successfully installed the community operator deployment") + return nil +} + +// UninstallCommunityOperatorViaHelm uninstalls the community operator using the public MongoDB Helm chart. +func UninstallCommunityOperatorViaHelm(ctx context.Context, t *testing.T, namespace string) error { + cmd := exec.CommandContext(ctx, "helm", "uninstall", CommunityHelmChartAndDeploymentName, "--namespace", namespace) + output, err := cmd.CombinedOutput() + if err != nil { + t.Logf("Failed to uninstall community operator: %s", string(output)) + return err + } + t.Logf("Community operator uninstalled: %s", string(output)) + return nil +} + +// ScaleOperatorDeployment scales the operator deployment to the specified number of replicas +// and waits for all replicas to become ready. +func ScaleOperatorDeployment(ctx context.Context, t *testing.T, namespace, deploymentName string, replicas int32) error { + cmd := exec.CommandContext(ctx, "kubectl", "scale", "deployment", deploymentName, fmt.Sprintf("--replicas=%d", replicas), "--namespace", namespace) //nolint:gosec + output, err := cmd.CombinedOutput() + if err != nil { + t.Logf("Failed to scale deployment: %s", string(output)) + return err + } + t.Logf("Scaling deployment %s to %d replicas: %s", deploymentName, replicas, string(output)) + + // Get the deployment object + var dep appsv1.Deployment + if err := e2eutil.TestClient.Get(ctx, types.NamespacedName{ + Name: deploymentName, + Namespace: namespace, + }, &dep); err != nil { + return fmt.Errorf("failed to get deployment after scaling: %s", err) + } + + // Update the replicas spec to match what we're expecting + dep.Spec.Replicas = &replicas + + // Wait for the deployment to reach the desired ready replicas + if err := wait.PollUntilContextTimeout(ctx, time.Second*2, time.Minute*2, true, hasDeploymentRequiredReplicas(&dep)); err != nil { + return fmt.Errorf("error waiting for deployment %s to scale to %d replicas: %s", deploymentName, replicas, err) + } + + // Only for scale-to-zero: additionally wait for pods to be fully gone + if replicas == 0 { + t.Logf("Waiting for pods to fully terminate...") + err := wait.PollUntilContextTimeout(ctx, time.Second*5, time.Minute*2, true, func(ctx context.Context) (bool, error) { + // List pods belonging to this deployment + var podList corev1.PodList + if err := e2eutil.TestClient.Client.List(ctx, &podList, + client.InNamespace(namespace), + client.MatchingLabels(map[string]string{"name": deploymentName})); err != nil { + t.Logf("Error listing pods: %v", err) + return false, nil + } + + if len(podList.Items) > 0 { + t.Logf("Still waiting for %d pods to terminate", len(podList.Items)) + return false, nil + } + return true, nil + }) + if err != nil { + return fmt.Errorf("pods did not fully terminate: %v", err) + } + t.Logf("All pods successfully terminated") + } + + t.Logf("Successfully scaled deployment %s to %d replicas and all are ready", deploymentName, replicas) + return nil +} diff --git a/mongodb-community-operator/test/e2e/setup/test_config.go b/mongodb-community-operator/test/e2e/setup/test_config.go index 1fc247021..9185b9330 100644 --- a/mongodb-community-operator/test/e2e/setup/test_config.go +++ b/mongodb-community-operator/test/e2e/setup/test_config.go @@ -1,26 +1,25 @@ package setup import ( - "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/envvar" ) const ( - testNamespaceEnvName = "TEST_NAMESPACE" + testNamespaceEnvName = "WATCH_NAMESPACE" testCertManagerNamespaceEnvName = "TEST_CERT_MANAGER_NAMESPACE" testCertManagerVersionEnvName = "TEST_CERT_MANAGER_VERSION" - operatorImageEnvName = "OPERATOR_IMAGE" + operatorImageRepoEnvName = "BASE_REPO_URL" clusterWideEnvName = "CLUSTER_WIDE" performCleanupEnvName = "PERFORM_CLEANUP" - helmChartPathEnvName = "HELM_CHART_PATH" - LocalOperatorEnvName = "MDB_LOCAL_OPERATOR" + LocalOperatorEnvName = "LOCAL_OPERATOR" + versionIdEnv = "VERSION_ID" ) type TestConfig struct { Namespace string CertManagerNamespace string CertManagerVersion string - OperatorImage string VersionUpgradeHookImage string ClusterWide bool PerformCleanup bool @@ -30,23 +29,30 @@ type TestConfig struct { MongoDBImage string MongoDBRepoUrl string LocalOperator bool + OperatorImageRepoUrl string + OperatorVersion string + OperatorImage string } func LoadTestConfigFromEnv() TestConfig { return TestConfig{ - Namespace: envvar.GetEnvOrDefault(testNamespaceEnvName, "mongodb"), // nolint:forbidigo - CertManagerNamespace: envvar.GetEnvOrDefault(testCertManagerNamespaceEnvName, "cert-manager"), // nolint:forbidigo - CertManagerVersion: envvar.GetEnvOrDefault(testCertManagerVersionEnvName, "v1.5.3"), // nolint:forbidigo - OperatorImage: envvar.GetEnvOrDefault(operatorImageEnvName, "quay.io/mongodb/community-operator-dev:latest"), // nolint:forbidigo - MongoDBImage: envvar.GetEnvOrDefault(construct.MongodbImageEnv, "mongodb-community-server"), // nolint:forbidigo + OperatorImage: "mongodb-enterprise-operator-ubi", + Namespace: envvar.GetEnvOrDefault(testNamespaceEnvName, "mongodb"), // nolint:forbidigo + // The operator version is based on the versionID, which context sets either locally manually or evg per patch + OperatorVersion: envvar.GetEnvOrDefault(versionIdEnv, ""), // nolint:forbidigo + CertManagerNamespace: envvar.GetEnvOrDefault(testCertManagerNamespaceEnvName, "cert-manager"), // nolint:forbidigo + CertManagerVersion: envvar.GetEnvOrDefault(testCertManagerVersionEnvName, "v1.5.3"), // nolint:forbidigo + OperatorImageRepoUrl: envvar.GetEnvOrDefault(operatorImageRepoEnvName, "quay.io/mongodb"), // nolint:forbidigo + // TODO: MCK + MongoDBImage: envvar.GetEnvOrDefault("MDB_COMMUNITY_IMAGE", "mongodb-community-server"), // nolint:forbidigo MongoDBRepoUrl: envvar.GetEnvOrDefault(construct.MongodbRepoUrlEnv, "quay.io/mongodb"), // nolint:forbidigo VersionUpgradeHookImage: envvar.GetEnvOrDefault(construct.VersionUpgradeHookImageEnv, "quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook:1.0.2"), // nolint:forbidigo - // TODO: better way to decide default agent image. - AgentImage: envvar.GetEnvOrDefault(construct.AgentImageEnv, "quay.io/mongodb/mongodb-agent-ubi:10.29.0.6830-1"), // nolint:forbidigo + // TODO: MCK better way to decide default agent image. + AgentImage: envvar.GetEnvOrDefault("MDB_COMMUNITY_AGENT_IMAGE", "quay.io/mongodb/mongodb-agent-ubi:108.0.2.8729-1"), // nolint:forbidigo ClusterWide: envvar.ReadBool(clusterWideEnvName), // nolint:forbidigo PerformCleanup: envvar.ReadBool(performCleanupEnvName), // nolint:forbidigo ReadinessProbeImage: envvar.GetEnvOrDefault(construct.ReadinessProbeImageEnv, "quay.io/mongodb/mongodb-kubernetes-readinessprobe:1.0.3"), // nolint:forbidigo - HelmChartPath: envvar.GetEnvOrDefault(helmChartPathEnvName, "/workspace/helm-charts/charts/community-operator"), // nolint:forbidigo - LocalOperator: envvar.ReadBool(LocalOperatorEnvName), // nolint:forbidigo + HelmChartPath: "../../../../helm_chart", // TODO: MCK update this later once we change folder or choose a different solution, alternatives, copy helm chart to test folder/search for helm_chart folder + LocalOperator: envvar.ReadBool(LocalOperatorEnvName), // nolint:forbidigo // TODO MCK: combine with meko one } } diff --git a/mongodb-community-operator/test/e2e/statefulset_arbitrary_config/statefulset_arbitrary_config_test.go b/mongodb-community-operator/test/e2e/statefulset_arbitrary_config/statefulset_arbitrary_config_test.go index d622cc68d..a1095b511 100644 --- a/mongodb-community-operator/test/e2e/statefulset_arbitrary_config/statefulset_arbitrary_config_test.go +++ b/mongodb-community-operator/test/e2e/statefulset_arbitrary_config/statefulset_arbitrary_config_test.go @@ -7,13 +7,13 @@ import ( "reflect" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" + + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/statefulset_arbitrary_config_update/statefulset_arbitrary_config_update_test.go b/mongodb-community-operator/test/e2e/statefulset_arbitrary_config_update/statefulset_arbitrary_config_update_test.go index 051189946..aa67cc956 100644 --- a/mongodb-community-operator/test/e2e/statefulset_arbitrary_config_update/statefulset_arbitrary_config_update_test.go +++ b/mongodb-community-operator/test/e2e/statefulset_arbitrary_config_update/statefulset_arbitrary_config_update_test.go @@ -7,15 +7,16 @@ import ( "reflect" "testing" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" - - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" "github.com/stretchr/testify/assert" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/util/mongotester" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/statefulset_delete/statefulset_delete_test.go b/mongodb-community-operator/test/e2e/statefulset_delete/statefulset_delete_test.go index 3117109e6..f284b6b9b 100644 --- a/mongodb-community-operator/test/e2e/statefulset_delete/statefulset_delete_test.go +++ b/mongodb-community-operator/test/e2e/statefulset_delete/statefulset_delete_test.go @@ -6,10 +6,10 @@ import ( "os" "testing" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" - "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/mongodbtests" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e/setup" ) func TestMain(m *testing.M) { diff --git a/mongodb-community-operator/test/e2e/tlstests/tlstests.go b/mongodb-community-operator/test/e2e/tlstests/tlstests.go index 6d327ec0d..a40f360a9 100644 --- a/mongodb-community-operator/test/e2e/tlstests/tlstests.go +++ b/mongodb-community-operator/test/e2e/tlstests/tlstests.go @@ -7,14 +7,16 @@ import ( "testing" "time" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" "github.com/stretchr/testify/assert" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" ) // EnableTLS will upgrade an existing TLS cluster to use TLS. diff --git a/mongodb-community-operator/test/e2e/util/mongotester/mongotester.go b/mongodb-community-operator/test/e2e/util/mongotester/mongotester.go index 58ad54181..bbce42ab9 100644 --- a/mongodb-community-operator/test/e2e/util/mongotester/mongotester.go +++ b/mongodb-community-operator/test/e2e/util/mongotester/mongotester.go @@ -13,19 +13,19 @@ import ( "time" "github.com/stretchr/objx" + "github.com/stretchr/testify/assert" + "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - "github.com/stretchr/testify/assert" - "go.mongodb.org/mongo-driver/bson" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" + + corev1 "k8s.io/api/core/v1" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/automationconfig" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" ) type Tester struct { @@ -232,7 +232,6 @@ func (m *Tester) hasAdminParameter(key string, expectedValue interface{}, tries } func (m *Tester) connectivityCheck(shouldSucceed bool, opts ...OptionApplier) func(t *testing.T) { - clientOpts := make([]*options.ClientOptions, 0) for _, optApplier := range opts { clientOpts = optApplier.ApplyOption(clientOpts...) @@ -240,7 +239,6 @@ func (m *Tester) connectivityCheck(shouldSucceed bool, opts ...OptionApplier) fu connectivityOpts := defaults() return func(t *testing.T) { - // We can optionally skip connectivity tests locally if testing.Short() { t.Skip() @@ -273,7 +271,6 @@ func (m *Tester) connectivityCheck(shouldSucceed bool, opts ...OptionApplier) fu } return true, nil }) - if err != nil { t.Fatal(fmt.Errorf("error during connectivity check: %s", err)) } @@ -326,7 +323,6 @@ func (m *Tester) EnsureMongodConfig(selector string, expected interface{}) func( }) assert.NoError(t, err) - } } @@ -384,14 +380,14 @@ func (m *Tester) StartBackgroundConnectivityTest(t *testing.T, interval time.Dur // ensureClient establishes a mongo client connection applying any addition // client options on top of what were provided at construction. -func (t *Tester) ensureClient(ctx context.Context, opts ...*options.ClientOptions) error { - allOpts := t.clientOpts +func (m *Tester) ensureClient(ctx context.Context, opts ...*options.ClientOptions) error { + allOpts := m.clientOpts allOpts = append(allOpts, opts...) mongoClient, err := mongo.Connect(ctx, allOpts...) if err != nil { return err } - t.mongoClient = mongoClient + m.mongoClient = mongoClient return nil } @@ -564,7 +560,6 @@ func getClientTLSConfig(ctx context.Context, mdb mdbv1.MongoDBCommunity) (*tls.C return &tls.Config{ //nolint RootCAs: caPool, }, nil - } // GetAgentCert reads the agent key certificate diff --git a/mongodb-community-operator/test/e2e/util/wait/wait.go b/mongodb-community-operator/test/e2e/util/wait/wait.go index 54798860e..7f8ca4546 100644 --- a/mongodb-community-operator/test/e2e/util/wait/wait.go +++ b/mongodb-community-operator/test/e2e/util/wait/wait.go @@ -6,15 +6,16 @@ import ( "testing" "time" - mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" - - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" "sigs.k8s.io/controller-runtime/pkg/client" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + mdbv1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" + e2eutil "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/test/e2e" ) type StatefulSetType int @@ -129,7 +130,7 @@ func ForArbitersStatefulSetToBeReady(ctx context.Context, t *testing.T, mdb *mdb func ForStatefulSetToBeReadyAfterScaleDown(ctx context.Context, t *testing.T, mdb *mdbv1.MongoDBCommunity, opts ...Configuration) error { options := newOptions(opts...) return waitForStatefulSetCondition(ctx, t, mdb, options, func(sts appsv1.StatefulSet) bool { - return int32(mdb.Spec.Members) == sts.Status.ReadyReplicas + return int32(mdb.Spec.Members) == sts.Status.ReadyReplicas //nolint:gosec }) } diff --git a/pipeline.py b/pipeline.py index 1421bff9b..cccc2bfbc 100755 --- a/pipeline.py +++ b/pipeline.py @@ -473,6 +473,24 @@ def build_tests_image(build_configuration: BuildConfiguration): sonar_build_image(image_name, build_configuration, buildargs, "inventories/test.yaml") +def build_mco_tests_image(build_configuration: BuildConfiguration): + """ + Builds image used to run community tests. + """ + image_name = "community-operator-e2e" + + # TODO: MCK update + # TODO: MCK copy go mod to build the community image + + golang_version = os.getenv("GOLANG_VERSION", "1.24") + if golang_version == "": + raise Exception("Missing PYTHON_VERSION environment variable") + + buildargs = dict({"golang_version": golang_version}) + + sonar_build_image(image_name, build_configuration, buildargs, "inventories/mco_test.yaml") + + def build_operator_image(build_configuration: BuildConfiguration): """Calculates arguments required to build the operator image, and starts the build process.""" # In evergreen, we can pass test_suffix env to publish the operator to a quay @@ -598,7 +616,7 @@ def get_supported_variants_for_image(image: str) -> List[str]: def image_config( image_name: str, - name_prefix: str = "mongodb-enterprise-", + name_prefix: str = "mongodb-kubernetes-", s3_bucket: str = "enterprise-operator-dockerfiles", ubi_suffix: str = "-ubi", base_suffix: str = "", @@ -626,11 +644,11 @@ def args_for_daily_image(image_name: str) -> Dict[str, str]: image_configs = [ image_config("database"), image_config("init-appdb"), - image_config("agent"), + image_config("agent", name_prefix="mongodb-enterprise-"), image_config("init-database"), image_config("init-ops-manager"), image_config("operator"), - image_config("ops-manager"), + image_config("ops-manager", name_prefix="mongodb-enterprise-"), image_config("mongodb-agent", name_prefix="", ubi_suffix="-ubi", base_suffix="-ubi"), image_config( image_name="mongodb-kubernetes-operator", @@ -1005,6 +1023,64 @@ def build_init_appdb(build_configuration: BuildConfiguration): build_image_generic(build_configuration, "init-appdb", "inventories/init_appdb.yaml", args) +def build_community_image(build_configuration: BuildConfiguration, image_type: str): + """ + Builds image for community components (readiness probe, upgrade hook). + + Args: + build_configuration: The build configuration to use + image_type: Type of image to build ("readiness-probe" or "upgrade-hook") + """ + + if image_type == "readiness-probe": + image_name = "mongodb-kubernetes-readinessprobe" + inventory_file = "inventories/readiness_probe.yaml" + elif image_type == "upgrade-hook": + image_name = "mongodb-kubernetes-operator-version-upgrade-post-start-hook" + inventory_file = "inventories/upgrade_hook.yaml" + else: + raise ValueError(f"Unsupported image type: {image_type}") + + version, is_release = get_git_release_tag() + golang_version = os.getenv("GOLANG_VERSION", "1.24") + architectures = build_configuration.architecture or ["amd64", "arm64"] + multi_arch_args_list = [] + + for arch in architectures: + arch_args = { + "version": version, + "golang_version": golang_version, + "architecture": arch, + } + multi_arch_args_list.append(arch_args) + + ecr_registry = os.environ.get("BASE_REPO_URL", "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev") + base_repo = QUAY_REGISTRY_URL if is_release else ecr_registry + + build_image_generic( + config=build_configuration, + image_name=image_name, + multi_arch_args_list=multi_arch_args_list, + inventory_file=inventory_file, + registry_address=f"{base_repo}/{image_name}", + is_multi_arch=True, + ) + + +def build_readiness_probe_image(build_configuration: BuildConfiguration): + """ + Builds image used for readiness probe. + """ + build_community_image(build_configuration, "readiness-probe") + + +def build_upgrade_hook_image(build_configuration: BuildConfiguration): + """ + Builds image used for version upgrade post-start hook. + """ + build_community_image(build_configuration, "upgrade-hook") + + def build_agent_in_sonar( build_configuration: BuildConfiguration, image_version, @@ -1238,7 +1314,7 @@ def _build_agent_operator( # We could rely on input params (quay_registry or registry), but it makes templating more complex in the inventory non_quay_registry = os.environ.get("REGISTRY", "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev") base_init_database_repo = QUAY_REGISTRY_URL if use_quay else non_quay_registry - init_database_image = f"{base_init_database_repo}/mongodb-enterprise-init-database-ubi:{operator_version}" + init_database_image = f"{base_init_database_repo}/mongodb-kubernetes-init-database-ubi:{operator_version}" tasks_queue.put( executor.submit( @@ -1321,6 +1397,10 @@ def get_builder_function_for_image_name() -> Dict[str, Callable]: "cli": build_CLI_SBOM, "test": build_tests_image, "operator": build_operator_image, + "mco-test": build_mco_tests_image, + # TODO: add support to build this per patch + "readiness-probe": build_readiness_probe_image, + "upgrade-hook": build_upgrade_hook_image, "operator-quick": build_operator_image_patch, "database": build_database_image, "agent-pct": build_agent_on_agent_bump, diff --git a/pkg/dependencymagnet/magnet.go b/pkg/dependencymagnet/magnet.go index 51c4ba93b..5380d1776 100644 --- a/pkg/dependencymagnet/magnet.go +++ b/pkg/dependencymagnet/magnet.go @@ -2,6 +2,6 @@ package depenencymagnet import ( // This is required to build both the Readiness Probe and Version Upgrade Hook. - // See docker/mongodb-enterprise-init-database/Dockerfile.builder + // See docker/mongodb-kubernetes-init-database/Dockerfile.builder _ "gopkg.in/natefinch/lumberjack.v2" ) diff --git a/pkg/images/Imageurls.go b/pkg/images/Imageurls.go index 076282318..dd19e61dc 100644 --- a/pkg/images/Imageurls.go +++ b/pkg/images/Imageurls.go @@ -6,9 +6,8 @@ import ( "regexp" "strings" - "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar" - + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/envvar" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/util/architectures" "github.com/10gen/ops-manager-kubernetes/pkg/util/env" diff --git a/pkg/images/Imageurls_test.go b/pkg/images/Imageurls_test.go index d3f8b11d6..e9b78795a 100644 --- a/pkg/images/Imageurls_test.go +++ b/pkg/images/Imageurls_test.go @@ -6,8 +6,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/mongodb/mongodb-kubernetes-operator/controllers/construct" - + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/controllers/construct" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/util/architectures" ) @@ -16,7 +15,7 @@ func TestReplaceImageTagOrDigestToTag(t *testing.T) { assert.Equal(t, "quay.io/mongodb/mongodb-agent:9876-54321", replaceImageTagOrDigestToTag("quay.io/mongodb/mongodb-agent:1234-567", "9876-54321")) assert.Equal(t, "docker.io/mongodb/mongodb-enterprise-server:9876-54321", replaceImageTagOrDigestToTag("docker.io/mongodb/mongodb-enterprise-server:1234-567", "9876-54321")) assert.Equal(t, "quay.io/mongodb/mongodb-agent:9876-54321", replaceImageTagOrDigestToTag("quay.io/mongodb/mongodb-agent@sha256:6a82abae27c1ba1133f3eefaad71ea318f8fa87cc57fe9355d6b5b817ff97f1a", "9876-54321")) - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-database:some-tag", replaceImageTagOrDigestToTag("quay.io/mongodb/mongodb-enterprise-database:45678", "some-tag")) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-database:some-tag", replaceImageTagOrDigestToTag("quay.io/mongodb/mongodb-kubernetes-database:45678", "some-tag")) assert.Equal(t, "quay.io:3000/mongodb/mongodb-enterprise-database:some-tag", replaceImageTagOrDigestToTag("quay.io:3000/mongodb/mongodb-enterprise-database:45678", "some-tag")) } @@ -25,37 +24,37 @@ func TestContainerImage(t *testing.T) { initDatabaseRelatedImageEnv2 := fmt.Sprintf("RELATED_IMAGE_%s_12_0_4_7554_1", util.InitDatabaseImageUrlEnv) initDatabaseRelatedImageEnv3 := fmt.Sprintf("RELATED_IMAGE_%s_2_0_0_b20220912000000", util.InitDatabaseImageUrlEnv) - t.Setenv(util.InitDatabaseImageUrlEnv, "quay.io/mongodb/mongodb-enterprise-init-database") - t.Setenv(initDatabaseRelatedImageEnv1, "quay.io/mongodb/mongodb-enterprise-init-database@sha256:608daf56296c10c9bd02cc85bb542a849e9a66aff0697d6359b449540696b1fd") - t.Setenv(initDatabaseRelatedImageEnv2, "quay.io/mongodb/mongodb-enterprise-init-database@sha256:b631ee886bb49ba8d7b90bb003fe66051dadecbc2ac126ac7351221f4a7c377c") - t.Setenv(initDatabaseRelatedImageEnv3, "quay.io/mongodb/mongodb-enterprise-init-database@sha256:f1a7f49cd6533d8ca9425f25cdc290d46bb883997f07fac83b66cc799313adad") + t.Setenv(util.InitDatabaseImageUrlEnv, "quay.io/mongodb/mongodb-kubernetes-init-database") + t.Setenv(initDatabaseRelatedImageEnv1, "quay.io/mongodb/mongodb-kubernetes-init-database@sha256:608daf56296c10c9bd02cc85bb542a849e9a66aff0697d6359b449540696b1fd") + t.Setenv(initDatabaseRelatedImageEnv2, "quay.io/mongodb/mongodb-kubernetes-init-database@sha256:b631ee886bb49ba8d7b90bb003fe66051dadecbc2ac126ac7351221f4a7c377c") + t.Setenv(initDatabaseRelatedImageEnv3, "quay.io/mongodb/mongodb-kubernetes-init-database@sha256:f1a7f49cd6533d8ca9425f25cdc290d46bb883997f07fac83b66cc799313adad") // there is no related image for 0.0.1 imageUrls := LoadImageUrlsFromEnv() - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-database:0.0.1", ContainerImage(imageUrls, util.InitDatabaseImageUrlEnv, "0.0.1")) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-database:0.0.1", ContainerImage(imageUrls, util.InitDatabaseImageUrlEnv, "0.0.1")) // for 10.2.25.6008-1 there is no RELATED_IMAGE variable set, so we use input instead of digest - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-database:10.2.25.6008-1", ContainerImage(imageUrls, util.InitDatabaseImageUrlEnv, "10.2.25.6008-1")) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-database:10.2.25.6008-1", ContainerImage(imageUrls, util.InitDatabaseImageUrlEnv, "10.2.25.6008-1")) // for following versions we set RELATED_IMAGE_MONGODB_IMAGE_* env variables to sha256 digest - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-database@sha256:608daf56296c10c9bd02cc85bb542a849e9a66aff0697d6359b449540696b1fd", ContainerImage(imageUrls, util.InitDatabaseImageUrlEnv, "1.0.0")) - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-database@sha256:b631ee886bb49ba8d7b90bb003fe66051dadecbc2ac126ac7351221f4a7c377c", ContainerImage(imageUrls, util.InitDatabaseImageUrlEnv, "12.0.4.7554-1")) - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-database@sha256:f1a7f49cd6533d8ca9425f25cdc290d46bb883997f07fac83b66cc799313adad", ContainerImage(imageUrls, util.InitDatabaseImageUrlEnv, "2.0.0-b20220912000000")) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-database@sha256:608daf56296c10c9bd02cc85bb542a849e9a66aff0697d6359b449540696b1fd", ContainerImage(imageUrls, util.InitDatabaseImageUrlEnv, "1.0.0")) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-database@sha256:b631ee886bb49ba8d7b90bb003fe66051dadecbc2ac126ac7351221f4a7c377c", ContainerImage(imageUrls, util.InitDatabaseImageUrlEnv, "12.0.4.7554-1")) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-database@sha256:f1a7f49cd6533d8ca9425f25cdc290d46bb883997f07fac83b66cc799313adad", ContainerImage(imageUrls, util.InitDatabaseImageUrlEnv, "2.0.0-b20220912000000")) // env var has input already, so it is replaced - t.Setenv(util.InitAppdbImageUrlEnv, "quay.io/mongodb/mongodb-enterprise-init-appdb:12.0.4.7554-1") + t.Setenv(util.InitAppdbImageUrlEnv, "quay.io/mongodb/mongodb-kubernetes-init-appdb:12.0.4.7554-1") imageUrls = LoadImageUrlsFromEnv() - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-appdb:10.2.25.6008-1", ContainerImage(imageUrls, util.InitAppdbImageUrlEnv, "10.2.25.6008-1")) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-appdb:10.2.25.6008-1", ContainerImage(imageUrls, util.InitAppdbImageUrlEnv, "10.2.25.6008-1")) // env var has input already, but there is related image with this input - t.Setenv(fmt.Sprintf("RELATED_IMAGE_%s_12_0_4_7554_1", util.InitAppdbImageUrlEnv), "quay.io/mongodb/mongodb-enterprise-init-appdb@sha256:a48829ce36bf479dc25a4de79234c5621b67beee62ca98a099d0a56fdb04791c") + t.Setenv(fmt.Sprintf("RELATED_IMAGE_%s_12_0_4_7554_1", util.InitAppdbImageUrlEnv), "quay.io/mongodb/mongodb-kubernetes-init-appdb@sha256:a48829ce36bf479dc25a4de79234c5621b67beee62ca98a099d0a56fdb04791c") imageUrls = LoadImageUrlsFromEnv() - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-appdb@sha256:a48829ce36bf479dc25a4de79234c5621b67beee62ca98a099d0a56fdb04791c", ContainerImage(imageUrls, util.InitAppdbImageUrlEnv, "12.0.4.7554-1")) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-appdb@sha256:a48829ce36bf479dc25a4de79234c5621b67beee62ca98a099d0a56fdb04791c", ContainerImage(imageUrls, util.InitAppdbImageUrlEnv, "12.0.4.7554-1")) - t.Setenv(util.InitAppdbImageUrlEnv, "quay.io/mongodb/mongodb-enterprise-init-appdb@sha256:608daf56296c10c9bd02cc85bb542a849e9a66aff0697d6359b449540696b1fd") + t.Setenv(util.InitAppdbImageUrlEnv, "quay.io/mongodb/mongodb-kubernetes-init-appdb@sha256:608daf56296c10c9bd02cc85bb542a849e9a66aff0697d6359b449540696b1fd") imageUrls = LoadImageUrlsFromEnv() // env var has input already as digest, but there is related image with this input - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-appdb@sha256:a48829ce36bf479dc25a4de79234c5621b67beee62ca98a099d0a56fdb04791c", ContainerImage(imageUrls, util.InitAppdbImageUrlEnv, "12.0.4.7554-1")) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-appdb@sha256:a48829ce36bf479dc25a4de79234c5621b67beee62ca98a099d0a56fdb04791c", ContainerImage(imageUrls, util.InitAppdbImageUrlEnv, "12.0.4.7554-1")) // env var has input already as digest, there is no related image with this input, so we use input instead of digest - assert.Equal(t, "quay.io/mongodb/mongodb-enterprise-init-appdb:1.2.3", ContainerImage(imageUrls, util.InitAppdbImageUrlEnv, "1.2.3")) + assert.Equal(t, "quay.io/mongodb/mongodb-kubernetes-init-appdb:1.2.3", ContainerImage(imageUrls, util.InitAppdbImageUrlEnv, "1.2.3")) t.Setenv(util.OpsManagerImageUrl, "quay.io:3000/mongodb/ops-manager-kubernetes") imageUrls = LoadImageUrlsFromEnv() diff --git a/pkg/kube/service/service.go b/pkg/kube/service/service.go index 2088124bb..ab84b7f78 100644 --- a/pkg/kube/service/service.go +++ b/pkg/kube/service/service.go @@ -6,10 +6,10 @@ import ( "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/service" - corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/service" ) func DeleteServiceIfItExists(ctx context.Context, getterDeleter service.GetDeleter, serviceName types.NamespacedName) error { diff --git a/pkg/multicluster/memberwatch/memberwatch.go b/pkg/multicluster/memberwatch/memberwatch.go index 849aaec32..02a524997 100644 --- a/pkg/multicluster/memberwatch/memberwatch.go +++ b/pkg/multicluster/memberwatch/memberwatch.go @@ -13,12 +13,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/cluster" "sigs.k8s.io/controller-runtime/pkg/event" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations" - - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" - "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" "github.com/10gen/ops-manager-kubernetes/api/v1/mdbmulti" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/annotations" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster" "github.com/10gen/ops-manager-kubernetes/pkg/multicluster/failedcluster" ) diff --git a/pkg/multicluster/multicluster.go b/pkg/multicluster/multicluster.go index 3139859d2..189d6139c 100644 --- a/pkg/multicluster/multicluster.go +++ b/pkg/multicluster/multicluster.go @@ -15,10 +15,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/cluster" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" restclient "k8s.io/client-go/rest" "github.com/10gen/ops-manager-kubernetes/controllers/operator/secrets" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" "github.com/10gen/ops-manager-kubernetes/pkg/util/env" intp "github.com/10gen/ops-manager-kubernetes/pkg/util/int" ) diff --git a/pkg/statefulset/statefulset_test.go b/pkg/statefulset/statefulset_test.go index a3c1ba4ae..e59447186 100644 --- a/pkg/statefulset/statefulset_test.go +++ b/pkg/statefulset/statefulset_test.go @@ -6,12 +6,12 @@ import ( "github.com/stretchr/testify/assert" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" ) const ( diff --git a/pkg/statefulset/statefulset_util.go b/pkg/statefulset/statefulset_util.go index b0b4e60b9..7b04c3bb4 100644 --- a/pkg/statefulset/statefulset_util.go +++ b/pkg/statefulset/statefulset_util.go @@ -12,8 +12,6 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "go.uber.org/zap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/statefulset" - gocmp "github.com/google/go-cmp/cmp" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -21,6 +19,7 @@ import ( apiErrors "k8s.io/apimachinery/pkg/api/errors" "github.com/10gen/ops-manager-kubernetes/controllers/operator/certs" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/statefulset" "github.com/10gen/ops-manager-kubernetes/pkg/kube" ) diff --git a/pkg/telemetry/client.go b/pkg/telemetry/client.go index 4ff8000f5..a7e905660 100644 --- a/pkg/telemetry/client.go +++ b/pkg/telemetry/client.go @@ -12,9 +12,9 @@ import ( "github.com/hashicorp/go-retryablehttp" "go.uber.org/zap" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar" - atlas "go.mongodb.org/atlas/mongodbatlas" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/envvar" ) type Client struct { diff --git a/pkg/telemetry/cluster.go b/pkg/telemetry/cluster.go index ead0c4c44..ca1fd146e 100644 --- a/pkg/telemetry/cluster.go +++ b/pkg/telemetry/cluster.go @@ -8,10 +8,10 @@ import ( "k8s.io/apimachinery/pkg/version" "k8s.io/client-go/discovery" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar" - corev1 "k8s.io/api/core/v1" kubeclient "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/envvar" ) const ( diff --git a/pkg/telemetry/collector.go b/pkg/telemetry/collector.go index 4634c456f..9e56d7174 100644 --- a/pkg/telemetry/collector.go +++ b/pkg/telemetry/collector.go @@ -13,13 +13,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/cluster" "sigs.k8s.io/controller-runtime/pkg/manager" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar" - kubeclient "sigs.k8s.io/controller-runtime/pkg/client" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" mdbmultiv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdbmulti" omv1 "github.com/10gen/ops-manager-kubernetes/api/v1/om" + mcov1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/envvar" "github.com/10gen/ops-manager-kubernetes/pkg/images" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/util/architectures" @@ -206,6 +206,7 @@ func collectDeploymentsSnapshot(ctx context.Context, operatorClusterMgr manager. events = append(events, addMultiEvents(ctx, operatorClusterClient, operatorUUID, mongodbImage, databaseNonStaticImage, now)...) // No need to pass databaseNonStaticImage because it is for sure not enterprise image events = append(events, addOmEvents(ctx, operatorClusterClient, operatorUUID, mongodbImage, now)...) + events = append(events, addCommunityEvents(ctx, operatorClusterClient, operatorUUID, mongodbImage, now)...) return events } @@ -330,6 +331,30 @@ func createEvent(properties any, now time.Time, eventType EventType) *Event { } } +func addCommunityEvents(ctx context.Context, operatorClusterClient kubeclient.Client, operatorUUID, mongodbImage string, now time.Time) []Event { + var events []Event + communityList := &mcov1.MongoDBCommunityList{} + + if err := operatorClusterClient.List(ctx, communityList); err != nil { + Logger.Warnf("failed to fetch MongoDBCommunityList from Kubernetes: %v", err) + } else { + for _, item := range communityList.Items { + properties := DeploymentUsageSnapshotProperties{ + DeploymentUID: string(item.UID), + OperatorID: operatorUUID, + Architecture: "static", // Community operator is always static + IsMultiCluster: false, // Community operator doesn't support multi-cluster + Type: "Community", + IsRunningEnterpriseImage: images.IsEnterpriseImage(mongodbImage), + } + if event := createEvent(properties, now, Deployments); event != nil { + events = append(events, *event) + } + } + } + return events +} + func getMaxNumberOfClustersSCIsDeployedOn(item mdbv1.MongoDB) int { var numberOfClustersUsed int if item.Spec.ConfigSrvSpec != nil { @@ -392,6 +417,7 @@ func collectClustersSnapshot(ctx context.Context, memberClusterMap map[string]Co events = append(events, *event) } } + return events } diff --git a/pkg/telemetry/collector_test.go b/pkg/telemetry/collector_test.go index d47a5e2ae..55175ee43 100644 --- a/pkg/telemetry/collector_test.go +++ b/pkg/telemetry/collector_test.go @@ -2,21 +2,24 @@ package telemetry import ( "context" + "errors" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" - mockClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" "github.com/10gen/ops-manager-kubernetes/api/v1/mdbmulti" omv1 "github.com/10gen/ops-manager-kubernetes/api/v1/om" "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" + mcov1 "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1" + mockClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" "github.com/10gen/ops-manager-kubernetes/pkg/util/architectures" ) @@ -835,3 +838,108 @@ func findEventWithDeploymentUID(events []Event, deploymentUID string) *Event { return nil } + +type MockClient struct { + client.Client + MockList func(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error +} + +func (m *MockClient) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error { + return m.MockList(ctx, list, opts...) +} + +func TestAddCommunityEvents(t *testing.T) { + operatorUUID := "test-operator-uuid" + + // Those 2 cases are when a customer uses Community reconciler to deploy enterprise or community MDB image + testCases := []struct { + name string + mongodbImage string + isEnterprise bool + }{ + { + name: "With community image", + mongodbImage: "mongodb-community-server", + isEnterprise: false, + }, + { + name: "With enterprise image", + mongodbImage: "mongodb-enterprise-server", + isEnterprise: true, + }, + } + + now := time.Now() + + for _, tc := range testCases { + t.Run("With community resources", func(t *testing.T) { + communityList := &mcov1.MongoDBCommunityList{ + Items: []mcov1.MongoDBCommunity{ + { + ObjectMeta: metav1.ObjectMeta{ + UID: types.UID("community-1"), + Name: "test-community-1", + }, + }, + { + ObjectMeta: metav1.ObjectMeta{ + UID: types.UID("community-2"), + Name: "test-community-2", + }, + }, + }, + } + + mc := &MockClient{ + MockList: func(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error { + if l, ok := list.(*mcov1.MongoDBCommunityList); ok { + *l = *communityList + } + return nil + }, + } + + events := addCommunityEvents(context.Background(), mc, operatorUUID, tc.mongodbImage, now) + + assert.Len(t, events, 2, "Should return 2 events for 2 community resources") + + assert.Equal(t, now, events[0].Timestamp) + assert.Equal(t, Deployments, events[0].Source) + assert.Equal(t, "community-1", events[0].Properties["deploymentUID"]) + assert.Equal(t, operatorUUID, events[0].Properties["operatorID"]) + assert.Equal(t, false, events[0].Properties["isMultiCluster"]) + assert.Equal(t, "Community", events[0].Properties["type"]) + assert.Equal(t, tc.isEnterprise, events[0].Properties["IsRunningEnterpriseImage"]) + + assert.Equal(t, "community-2", events[1].Properties["deploymentUID"]) + assert.Equal(t, tc.isEnterprise, events[1].Properties["IsRunningEnterpriseImage"]) + }) + + t.Run("With list error", func(t *testing.T) { + mc := &MockClient{ + MockList: func(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error { + return errors.New("list error") + }, + } + + events := addCommunityEvents(context.Background(), mc, operatorUUID, tc.mongodbImage, now) + + assert.Empty(t, events, "Should return empty slice on list error") + }) + + t.Run("With empty list", func(t *testing.T) { + mc := &MockClient{ + MockList: func(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error { + if l, ok := list.(*mcov1.MongoDBCommunityList); ok { + *l = mcov1.MongoDBCommunityList{} + } + return nil + }, + } + + events := addCommunityEvents(context.Background(), mc, operatorUUID, tc.mongodbImage, now) + + assert.Empty(t, events, "Should return empty slice for empty community list") + }) + } +} diff --git a/pkg/telemetry/configmap.go b/pkg/telemetry/configmap.go index 5eb98e265..5583af01a 100644 --- a/pkg/telemetry/configmap.go +++ b/pkg/telemetry/configmap.go @@ -10,12 +10,12 @@ import ( "github.com/google/uuid" "k8s.io/apimachinery/pkg/types" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar" - corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" v2 "k8s.io/apimachinery/pkg/apis/meta/v1" kubeclient "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/envvar" ) const ( diff --git a/pkg/test/sharded_cluster_builder.go b/pkg/test/sharded_cluster_builder.go index 15e92fca3..95bb8f0b9 100644 --- a/pkg/test/sharded_cluster_builder.go +++ b/pkg/test/sharded_cluster_builder.go @@ -7,6 +7,7 @@ import ( "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" "github.com/10gen/ops-manager-kubernetes/api/v1/status" "github.com/10gen/ops-manager-kubernetes/controllers/operator/mock" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/api/v1/common" "github.com/10gen/ops-manager-kubernetes/pkg/util" ) @@ -214,7 +215,7 @@ func (b *ClusterBuilder) SetShardSpecificPodSpecTemplate(specs []v12.PodTemplate mongoDBPodSpec := make([]mdb.MongoDbPodSpec, len(specs)) for n, e := range specs { - mongoDBPodSpec[n] = mdb.MongoDbPodSpec{PodTemplateWrapper: mdb.PodTemplateSpecWrapper{ + mongoDBPodSpec[n] = mdb.MongoDbPodSpec{PodTemplateWrapper: common.PodTemplateSpecWrapper{ PodTemplate: &e, }} } diff --git a/pkg/util/constants.go b/pkg/util/constants.go index 57e438c3c..77cfbb57c 100644 --- a/pkg/util/constants.go +++ b/pkg/util/constants.go @@ -82,7 +82,7 @@ const ( BackupDaemonContainerName = "mongodb-backup-daemon" DatabaseContainerName = "mongodb-enterprise-database" AgentContainerName = "mongodb-agent" - InitOpsManagerContainerName = "mongodb-enterprise-init-ops-manager" + InitOpsManagerContainerName = "mongodb-kubernetes-init-ops-manager" PvcNameData = "data" PvcMountPathData = "/data" PvcNameJournal = "journal" @@ -183,6 +183,7 @@ const ( CurrentNamespace = "NAMESPACE" WatchNamespace = "WATCH_NAMESPACE" OpsManagerMonitorAppDB = "OPS_MANAGER_MONITOR_APPDB" + MongodbCommunityAgentImageEnv = "MDB_COMMUNITY_AGENT_IMAGE" MdbWebhookRegisterConfigurationEnv = "MDB_WEBHOOK_REGISTER_CONFIGURATION" MdbWebhookPortEnv = "MDB_WEBHOOK_PORT" diff --git a/pkg/vault/vault.go b/pkg/vault/vault.go index f12ad1bbd..1dcece76d 100644 --- a/pkg/vault/vault.go +++ b/pkg/vault/vault.go @@ -12,11 +12,10 @@ import ( "golang.org/x/xerrors" "k8s.io/client-go/kubernetes" - "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/merge" - corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/util/merge" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/util/env" "github.com/10gen/ops-manager-kubernetes/pkg/util/maputil" diff --git a/pkg/vault/vaultwatcher/vaultsecretwatch.go b/pkg/vault/vaultwatcher/vaultsecretwatch.go index f9500332e..e2490e564 100644 --- a/pkg/vault/vaultwatcher/vaultsecretwatch.go +++ b/pkg/vault/vaultwatcher/vaultsecretwatch.go @@ -10,10 +10,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/event" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" - mdbv1 "github.com/10gen/ops-manager-kubernetes/api/v1/mdb" omv1 "github.com/10gen/ops-manager-kubernetes/api/v1/om" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" "github.com/10gen/ops-manager-kubernetes/pkg/vault" ) diff --git a/pkg/webhook/setup.go b/pkg/webhook/setup.go index 69a8ebc36..b3a9ed626 100644 --- a/pkg/webhook/setup.go +++ b/pkg/webhook/setup.go @@ -9,12 +9,12 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "sigs.k8s.io/controller-runtime/pkg/client" - kubernetesClient "github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/client" admissionv1 "k8s.io/api/admissionregistration/v1" corev1 "k8s.io/api/core/v1" apiErrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + kubernetesClient "github.com/10gen/ops-manager-kubernetes/mongodb-community-operator/pkg/kube/client" mekoService "github.com/10gen/ops-manager-kubernetes/pkg/kube/service" "github.com/10gen/ops-manager-kubernetes/pkg/util" "github.com/10gen/ops-manager-kubernetes/pkg/util/env" diff --git a/public/architectures/setup-multi-cluster/setup-operator/output/0210_helm_install_operator.out b/public/architectures/setup-multi-cluster/setup-operator/output/0210_helm_install_operator.out index e43b9e60e..e750ef003 100644 --- a/public/architectures/setup-multi-cluster/setup-operator/output/0210_helm_install_operator.out +++ b/public/architectures/setup-multi-cluster/setup-operator/output/0210_helm_install_operator.out @@ -44,9 +44,6 @@ mongodb: imageType: ubi8 name: mongodb-enterprise-server repo: quay.io/mongodb -mongodbLegacyAppDb: - name: mongodb-enterprise-appdb-database-ubi - repo: quay.io/mongodb multiCluster: clusterClientTimeout: 10 clusters: @@ -267,9 +264,9 @@ spec: value: Always # Database - name: MONGODB_ENTERPRISE_DATABASE_IMAGE - value: quay.io/mongodb/mongodb-enterprise-database-ubi + value: quay.io/mongodb/mongodb-kubernetes-database-ubi - name: INIT_DATABASE_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-database-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-database-ubi - name: INIT_DATABASE_VERSION value: 1.33.0 - name: DATABASE_VERSION @@ -278,12 +275,12 @@ spec: - name: OPS_MANAGER_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-enterprise-ops-manager-ubi - name: INIT_OPS_MANAGER_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-ops-manager-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-ops-manager-ubi - name: INIT_OPS_MANAGER_VERSION value: 1.33.0 # AppDB - name: INIT_APPDB_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-appdb-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-appdb-ubi - name: INIT_APPDB_VERSION value: 1.33.0 - name: OPS_MANAGER_IMAGE_PULL_POLICY diff --git a/public/crds.yaml b/public/crds.yaml index 4d12b7824..37c001ac6 100644 --- a/public/crds.yaml +++ b/public/crds.yaml @@ -2665,17 +2665,18 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.15.0 - name: mongodbmulticluster.mongodb.com + controller-gen.kubebuilder.io/version: v0.10.0 + creationTimestamp: null + name: mongodbmulti.mongodb.com spec: group: mongodb.com names: - kind: MongoDBMultiCluster - listKind: MongoDBMultiClusterList - plural: mongodbmulticluster + kind: MongoDBMulti + listKind: MongoDBMultiList + plural: mongodbmulti shortNames: - - mdbmc - singular: mongodbmulticluster + - mdbm + singular: mongodbmulti scope: Namespaced versions: - additionalPrinterColumns: @@ -2683,7 +2684,7 @@ spec: jsonPath: .status.phase name: Phase type: string - - description: The time since the MongoDBMultiCluster resource was created. + - description: The time since the MongoDBMulti resource was created. jsonPath: .metadata.creationTimestamp name: Age type: date @@ -2692,224 +2693,34 @@ spec: openAPIV3Schema: properties: apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' type: string kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string metadata: type: object spec: properties: additionalMongodConfig: - description: |- - AdditionalMongodConfig is additional configuration that can be passed to - each data-bearing mongod at runtime. Uses the same structure as the mongod - configuration file: - https://docs.mongodb.com/manual/reference/configuration-options/ + description: 'AdditionalMongodConfig is additional configuration that + can be passed to each data-bearing mongod at runtime. Uses the same + structure as the mongod configuration file: https://docs.mongodb.com/manual/reference/configuration-options/' type: object x-kubernetes-preserve-unknown-fields: true agent: properties: - backupAgent: - properties: - logRotate: - description: LogRotate configures log rotation for the BackupAgent - processes - properties: - sizeThresholdMB: - description: |- - Maximum size for an individual log file before rotation. - OM only supports ints - type: integer - timeThresholdHrs: - description: Number of hours after which this MongoDB - Agent rotates the log file. - type: integer - type: object - type: object - logLevel: - type: string - logRotate: - description: DEPRECATED please use mongod.logRotate - properties: - includeAuditLogsWithMongoDBLogs: - description: |- - set to 'true' to have the Automation Agent rotate the audit files along - with mongodb log files - type: boolean - numTotal: - description: maximum number of log files to have total - type: integer - numUncompressed: - description: maximum number of log files to leave uncompressed - type: integer - percentOfDiskspace: - description: |- - Maximum percentage of the total disk space these log files should take up. - The string needs to be able to be converted to float64 - type: string - sizeThresholdMB: - description: |- - Maximum size for an individual log file before rotation. - The string needs to be able to be converted to float64. - Fractional values of MB are supported. - type: string - timeThresholdHrs: - description: maximum hours for an individual log file before - rotation - type: integer - required: - - sizeThresholdMB - - timeThresholdHrs - type: object - maxLogFileDurationHours: - type: integer - mongod: - description: AgentLoggingMongodConfig contain settings for the - mongodb processes configured by the agent - properties: - auditlogRotate: - description: LogRotate configures audit log rotation for the - mongodb processes - properties: - includeAuditLogsWithMongoDBLogs: - description: |- - set to 'true' to have the Automation Agent rotate the audit files along - with mongodb log files - type: boolean - numTotal: - description: maximum number of log files to have total - type: integer - numUncompressed: - description: maximum number of log files to leave uncompressed - type: integer - percentOfDiskspace: - description: |- - Maximum percentage of the total disk space these log files should take up. - The string needs to be able to be converted to float64 - type: string - sizeThresholdMB: - description: |- - Maximum size for an individual log file before rotation. - The string needs to be able to be converted to float64. - Fractional values of MB are supported. - type: string - timeThresholdHrs: - description: maximum hours for an individual log file - before rotation - type: integer - required: - - sizeThresholdMB - - timeThresholdHrs - type: object - logRotate: - description: LogRotate configures log rotation for the mongodb - processes - properties: - includeAuditLogsWithMongoDBLogs: - description: |- - set to 'true' to have the Automation Agent rotate the audit files along - with mongodb log files - type: boolean - numTotal: - description: maximum number of log files to have total - type: integer - numUncompressed: - description: maximum number of log files to leave uncompressed - type: integer - percentOfDiskspace: - description: |- - Maximum percentage of the total disk space these log files should take up. - The string needs to be able to be converted to float64 - type: string - sizeThresholdMB: - description: |- - Maximum size for an individual log file before rotation. - The string needs to be able to be converted to float64. - Fractional values of MB are supported. - type: string - timeThresholdHrs: - description: maximum hours for an individual log file - before rotation - type: integer - required: - - sizeThresholdMB - - timeThresholdHrs - type: object - systemLog: - description: SystemLog configures system log of mongod - properties: - destination: - type: string - logAppend: - type: boolean - path: - type: string - required: - - destination - - logAppend - - path - type: object - type: object - monitoringAgent: - properties: - logRotate: - description: LogRotate configures log rotation for the BackupAgent - processes - properties: - sizeThresholdMB: - description: |- - Maximum size for an individual log file before rotation. - OM only supports ints - type: integer - timeThresholdHrs: - description: Number of hours after which this MongoDB - Agent rotates the log file. - type: integer - type: object - type: object - readinessProbe: - properties: - environmentVariables: - additionalProperties: - type: string - type: object - type: object startupOptions: additionalProperties: type: string - description: |- - StartupParameters can be used to configure the startup parameters with which the agent starts. That also contains - log rotation settings as defined here: - type: object - systemLog: - description: DEPRECATED please use mongod.systemLog - properties: - destination: - type: string - logAppend: - type: boolean - path: - type: string - required: - - destination - - logAppend - - path type: object type: object backup: - description: |- - Backup contains configuration options for configuring + description: Backup contains configuration options for configuring backup for this MongoDB resource properties: assignmentLabels: @@ -2918,9 +2729,9 @@ spec: type: string type: array autoTerminateOnDeletion: - description: |- - AutoTerminateOnDeletion indicates if the Operator should stop and terminate the Backup before the cleanup, - when the MongoDB CR is deleted + description: AutoTerminateOnDeletion indicates if the Operator + should stop and terminate the Backup before the cleanup, when + the MongoDB CR is deleted type: boolean encryption: description: Encryption settings @@ -2933,14 +2744,13 @@ spec: description: KMIP Client configuration properties: clientCertificatePrefix: - description: |- - A prefix used to construct KMIP client certificate (and corresponding password) Secret names. - The names are generated using the following pattern: - KMIP Client Certificate (TLS Secret): - --kmip-client - KMIP Client Certificate Password: - --kmip-client-password - The expected key inside is called "password". + description: 'A prefix used to construct KMIP client + certificate (and corresponding password) Secret + names. The names are generated using the following + pattern: KMIP Client Certificate (TLS Secret): --kmip-client KMIP Client Certificate Password: + --kmip-client-password + The expected key inside is called "password".' type: string type: object required: @@ -3050,168 +2860,62 @@ spec: format: hostname type: string clusterSpecList: - items: - description: |- - ClusterSpecItem is the mongodb multi-cluster spec that is specific to a - particular Kubernetes cluster, this maps to the statefulset created in each cluster - properties: - clusterName: - description: |- - ClusterName is name of the cluster where the MongoDB Statefulset will be scheduled, the - name should have a one on one mapping with the service-account created in the central cluster - to talk to the workload clusters. - type: string - externalAccess: - description: ExternalAccessConfiguration provides external access - configuration for Multi-Cluster. + description: ClusterSpecList holds a list with a clusterSpec corresponding + to each cluster + properties: + clusterSpecs: + items: + description: ClusterSpecItem is the mongodb multi-cluster spec + that is specific to a particular Kubernetes cluster, this + maps to the statefulset created in each cluster properties: - externalDomain: - description: An external domain that is used for exposing - MongoDB to the outside world. + clusterName: + description: ClusterName is name of the cluster where the + MongoDB Statefulset will be scheduled, the name should + have a one on one mapping with the service-account created + in the central cluster to talk to the workload clusters. type: string - externalService: - description: Provides a way to override the default (NodePort) - Service + exposedExternally: + description: ExposedExternally determines whether a NodePort + service should be created for the resource + type: boolean + members: + description: Amount of members for this MongoDB Replica + Set + type: integer + service: + description: this is an optional service, it will get the + name "-service" in case not provided + type: string + statefulSet: + description: StatefulSetConfiguration holds the optional + custom StatefulSet that should be merged into the operator + created one. properties: - annotations: - additionalProperties: - type: string - description: A map of annotations that shall be added - to the externally available Service. - type: object spec: - description: A wrapper for the Service spec object. type: object x-kubernetes-preserve-unknown-fields: true + required: + - spec type: object - type: object - memberConfig: - description: MemberConfig allows to specify votes, priorities - and tags for each of the mongodb process. - items: - properties: - priority: - type: string - tags: - additionalProperties: - type: string - type: object - votes: - type: integer - type: object - type: array - members: - description: Amount of members for this MongoDB Replica Set - type: integer - podSpec: - properties: - persistence: - description: Note, that this field is used by MongoDB resources - only, let's keep it here for simplicity - properties: - multiple: - properties: - data: - properties: - labelSelector: - type: object - x-kubernetes-preserve-unknown-fields: true - storage: - type: string - storageClass: - type: string - type: object - journal: - properties: - labelSelector: - type: object - x-kubernetes-preserve-unknown-fields: true - storage: - type: string - storageClass: - type: string - type: object - logs: - properties: - labelSelector: - type: object - x-kubernetes-preserve-unknown-fields: true - storage: - type: string - storageClass: - type: string - type: object - type: object - single: - properties: - labelSelector: - type: object - x-kubernetes-preserve-unknown-fields: true - storage: - type: string - storageClass: - type: string - type: object - type: object - podTemplate: - type: object - x-kubernetes-preserve-unknown-fields: true - type: object - service: - description: this is an optional service, it will get the name - "-service" in case not provided - type: string - statefulSet: - description: |- - StatefulSetConfiguration holds the optional custom StatefulSet - that should be merged into the operator created one. - properties: - metadata: - description: StatefulSetMetadataWrapper is a wrapper around - Labels and Annotations - properties: - annotations: - additionalProperties: - type: string - type: object - labels: - additionalProperties: - type: string - type: object - type: object - spec: - type: object - x-kubernetes-preserve-unknown-fields: true required: - - spec + - members type: object - required: - - members - type: object - type: array + type: array + type: object connectivity: properties: replicaSetHorizons: - description: |- - ReplicaSetHorizons holds list of maps of horizons to be configured in each of MongoDB processes. - Horizons map horizon names to the node addresses for each process in the replicaset, e.g.: - [ - { - "internal": "my-rs-0.my-internal-domain.com:31843", - "external": "my-rs-0.my-external-domain.com:21467" - }, - { - "internal": "my-rs-1.my-internal-domain.com:31843", - "external": "my-rs-1.my-external-domain.com:21467" - }, - ... - ] - The key of each item in the map is an arbitrary, user-chosen string that - represents the name of the horizon. The value of the item is the host and, - optionally, the port that this mongod node will be connected to from. items: additionalProperties: type: string + description: 'MongoDBHorizonConfig holds a map of horizon names + to the node addresses, e.g. { "internal": "my-rs-2.my-internal-domain.com:31843", "external": + "my-rs-2.my-external-domain.com:21467" } The key of each item + in the map is an arbitrary, user-chosen string that represents + the name of the horizon. The value of the item is the host + and, optionally, the port that this mongod node will be connected + to from.' type: object type: array type: object @@ -3219,37 +2923,16 @@ spec: description: Name of the Secret holding credentials information type: string duplicateServiceObjects: - description: |- - In few service mesh options for ex: Istio, by default we would need to duplicate the - service objects created per pod in all the clusters to enable DNS resolution. Users can - however configure their ServiceMesh with DNS proxy(https://istio.io/latest/docs/ops/configuration/traffic-management/dns-proxy/) - enabled in which case the operator doesn't need to create the service objects per cluster. This options tells the operator - whether it should create the service objects in all the clusters or not. By default, if not specified the operator would create the duplicate svc objects. + description: 'In few service mesh options for ex: Istio, by default + we would need to duplicate the service objects created per pod in + all the clusters to enable DNS resolution. Users can however configure + their ServiceMesh with DNS proxy(https://istio.io/latest/docs/ops/configuration/traffic-management/dns-proxy/) + enabled in which case the operator doesn''t need to create the service + objects per cluster. This options tells the operator whether it + should create the service objects in all the clusters or not. By + default, if not specified the operator would create the duplicate + svc objects.' type: boolean - externalAccess: - description: ExternalAccessConfiguration provides external access - configuration. - properties: - externalDomain: - description: An external domain that is used for exposing MongoDB - to the outside world. - type: string - externalService: - description: Provides a way to override the default (NodePort) - Service - properties: - annotations: - additionalProperties: - type: string - description: A map of annotations that shall be added to the - externally available Service. - type: object - spec: - description: A wrapper for the Service spec object. - type: object - x-kubernetes-preserve-unknown-fields: true - type: object - type: object featureCompatibilityVersion: type: string logLevel: @@ -3270,60 +2953,11 @@ spec: type: object persistent: type: boolean - prometheus: - description: Prometheus configurations. - properties: - metricsPath: - description: Indicates path to the metrics endpoint. - pattern: ^\/[a-z0-9]+$ - type: string - passwordSecretRef: - description: Name of a Secret containing a HTTP Basic Auth Password. - properties: - key: - description: Key is the key in the secret storing this password. - Defaults to "password" - type: string - name: - description: Name is the name of the secret storing this user's - password - type: string - required: - - name - type: object - port: - description: Port where metrics endpoint will bind to. Defaults - to 9216. - type: integer - tlsSecretKeyRef: - description: |- - Name of a Secret (type kubernetes.io/tls) holding the certificates to use in the - Prometheus endpoint. - properties: - key: - description: Key is the key in the secret storing this password. - Defaults to "password" - type: string - name: - description: Name is the name of the secret storing this user's - password - type: string - required: - - name - type: object - username: - description: HTTP Basic Auth Username for metrics endpoint. - type: string - required: - - passwordSecretRef - - username - type: object security: properties: authentication: - description: |- - Authentication holds various authentication related settings that affect - this MongoDB resource. + description: Authentication holds various authentication related + settings that affect this MongoDB resource. properties: agents: description: Agents contains authentication configuration @@ -3339,15 +2973,9 @@ spec: be a valid secret key. type: string name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' type: string optional: description: Specify whether the Secret or its key @@ -3398,15 +3026,9 @@ spec: description: The key to select. type: string name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' type: string optional: description: Specify whether the ConfigMap or its @@ -3436,13 +3058,6 @@ spec: type: object modes: items: - enum: - - X509 - - SCRAM - - SCRAM-SHA-1 - - MONGODB-CR - - SCRAM-SHA-256 - - LDAP type: string type: array requireClientTLSAuthentication: @@ -3518,59 +3133,35 @@ spec: type: string type: array ca: - description: |- - CA corresponds to a ConfigMap containing an entry for the CA certificate (ca.pem) - used to validate the certificates created already. + description: CA corresponds to a ConfigMap containing an entry + for the CA certificate (ca.pem) used to validate the certificates + created already. type: string enabled: - description: |- - DEPRECATED please enable TLS by setting `security.certsSecretPrefix` or `security.tls.secretRef.prefix`. - Enables TLS for this resource. This will make the operator try to mount a - Secret with a defined name (-cert). - This is only used when enabling TLS on a MongoDB resource, and not on the - AppDB, where TLS is configured by setting `secretRef.Name`. + description: DEPRECATED please enable TLS by setting `security.certsSecretPrefix` + or `security.tls.secretRef.prefix`. Enables TLS for this + resource. This will make the operator try to mount a Secret + with a defined name (-cert). This is only + used when enabling TLS on a MongoDB resource, and not on + the AppDB, where TLS is configured by setting `secretRef.Name`. type: boolean type: object type: object statefulSet: - description: |- - StatefulSetConfiguration provides the statefulset override for each of the cluster's statefulset - if "StatefulSetConfiguration" is specified at cluster level under "clusterSpecList" that takes precedence over - the global one + description: StatefulSetConfiguration provides the statefulset override + for each of the cluster's statefulset if "StatefulSetConfiguration" + is specified at cluster level under "clusterSpecList" that takes + precedence over the global one properties: - metadata: - description: StatefulSetMetadataWrapper is a wrapper around Labels - and Annotations - properties: - annotations: - additionalProperties: - type: string - type: object - labels: - additionalProperties: - type: string - type: object - type: object spec: type: object x-kubernetes-preserve-unknown-fields: true required: - spec type: object - topology: - description: |- - Topology sets the desired cluster topology of MongoDB resources - It defaults (if empty or not set) to SingleCluster. If MultiCluster specified, - then clusterSpecList field is mandatory and at least one member cluster has to be specified. - enum: - - SingleCluster - - MultiCluster - type: string type: enum: - - Standalone - ReplicaSet - - ShardedCluster type: string version: pattern: ^[0-9]+.[0-9]+.[0-9]+(-.+)?$|^$ @@ -3580,7 +3171,6 @@ spec: - type - version type: object - x-kubernetes-preserve-unknown-fields: true status: properties: backup: @@ -3596,15 +3186,15 @@ spec: properties: clusterStatuses: items: - description: |- - ClusterStatusItem is the mongodb multi-cluster spec that is specific to a - particular Kubernetes cluster, this maps to the statefulset created in each cluster + description: ClusterStatusItem is the mongodb multi-cluster + spec that is specific to a particular Kubernetes cluster, + this maps to the statefulset created in each cluster properties: clusterName: - description: |- - ClusterName is name of the cluster where the MongoDB Statefulset will be scheduled, the - name should have a one on one mapping with the service-account created in the central cluster - to talk to the workload clusters. + description: ClusterName is name of the cluster where the + MongoDB Statefulset will be scheduled, the name should + have a one on one mapping with the service-account created + in the central cluster to talk to the workload clusters. type: string lastTransition: type: string @@ -3617,18 +3207,6 @@ spec: type: integer phase: type: string - pvc: - items: - properties: - phase: - type: string - statefulsetName: - type: string - required: - - phase - - statefulsetName - type: object - type: array resourcesNotReady: items: description: ResourceNotReady describes the dependent @@ -3665,8 +3243,6 @@ spec: type: object type: array type: object - featureCompatibilityVersion: - type: string lastTransition: type: string link: @@ -3678,18 +3254,6 @@ spec: type: integer phase: type: string - pvc: - items: - properties: - phase: - type: string - statefulsetName: - type: string - required: - - phase - - statefulsetName - type: object - type: array resourcesNotReady: items: description: ResourceNotReady describes the dependent resource which @@ -3740,24 +3304,24 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.15.0 - name: mongodbusers.mongodb.com + name: mongodbmulticluster.mongodb.com spec: group: mongodb.com names: - kind: MongoDBUser - listKind: MongoDBUserList - plural: mongodbusers + kind: MongoDBMultiCluster + listKind: MongoDBMultiClusterList + plural: mongodbmulticluster shortNames: - - mdbu - singular: mongodbuser + - mdbmc + singular: mongodbmulticluster scope: Namespaced versions: - additionalPrinterColumns: - - description: The current state of the MongoDB User. + - description: Current state of the MongoDB deployment. jsonPath: .status.phase name: Phase type: string - - description: The time since the MongoDB User resource was created. + - description: The time since the MongoDBMultiCluster resource was created. jsonPath: .metadata.creationTimestamp name: Age type: date @@ -3784,247 +3348,111 @@ spec: type: object spec: properties: - connectionStringSecretName: - type: string - db: - type: string - mongodbResourceRef: - properties: - name: - type: string - namespace: - type: string - required: - - name - type: object - passwordSecretKeyRef: + additionalMongodConfig: description: |- - SecretKeyRef is a reference to a value in a given secret in the same - namespace. Based on: - https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.15/#secretkeyselector-v1-core + AdditionalMongodConfig is additional configuration that can be passed to + each data-bearing mongod at runtime. Uses the same structure as the mongod + configuration file: + https://docs.mongodb.com/manual/reference/configuration-options/ + type: object + x-kubernetes-preserve-unknown-fields: true + agent: properties: - key: - type: string - name: + backupAgent: + properties: + logRotate: + description: LogRotate configures log rotation for the BackupAgent + processes + properties: + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + OM only supports ints + type: integer + timeThresholdHrs: + description: Number of hours after which this MongoDB + Agent rotates the log file. + type: integer + type: object + type: object + logLevel: type: string - required: - - name - type: object - roles: - items: - properties: - db: - type: string - name: - type: string - required: - - db - - name - type: object - type: array - username: - type: string - required: - - db - - username - type: object - status: - properties: - db: - type: string - lastTransition: - type: string - message: - type: string - observedGeneration: - format: int64 - type: integer - phase: - type: string - project: - type: string - pvc: - items: - properties: - phase: - type: string - statefulsetName: - type: string - required: - - phase - - statefulsetName - type: object - type: array - resourcesNotReady: - items: - description: ResourceNotReady describes the dependent resource which - is not ready yet - properties: - errors: - items: + logRotate: + description: DEPRECATED please use mongod.logRotate + properties: + includeAuditLogsWithMongoDBLogs: + description: |- + set to 'true' to have the Automation Agent rotate the audit files along + with mongodb log files + type: boolean + numTotal: + description: maximum number of log files to have total + type: integer + numUncompressed: + description: maximum number of log files to leave uncompressed + type: integer + percentOfDiskspace: + description: |- + Maximum percentage of the total disk space these log files should take up. + The string needs to be able to be converted to float64 + type: string + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + The string needs to be able to be converted to float64. + Fractional values of MB are supported. + type: string + timeThresholdHrs: + description: maximum hours for an individual log file before + rotation + type: integer + required: + - sizeThresholdMB + - timeThresholdHrs + type: object + maxLogFileDurationHours: + type: integer + mongod: + description: AgentLoggingMongodConfig contain settings for the + mongodb processes configured by the agent + properties: + auditlogRotate: + description: LogRotate configures audit log rotation for the + mongodb processes properties: - message: + includeAuditLogsWithMongoDBLogs: + description: |- + set to 'true' to have the Automation Agent rotate the audit files along + with mongodb log files + type: boolean + numTotal: + description: maximum number of log files to have total + type: integer + numUncompressed: + description: maximum number of log files to leave uncompressed + type: integer + percentOfDiskspace: + description: |- + Maximum percentage of the total disk space these log files should take up. + The string needs to be able to be converted to float64 type: string - reason: + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + The string needs to be able to be converted to float64. + Fractional values of MB are supported. type: string + timeThresholdHrs: + description: maximum hours for an individual log file + before rotation + type: integer + required: + - sizeThresholdMB + - timeThresholdHrs type: object - type: array - kind: - description: ResourceKind specifies a kind of a Kubernetes resource. - Used in status of a Custom Resource - type: string - message: - type: string - name: - type: string - required: - - kind - - name - type: object - type: array - roles: - items: - properties: - db: - type: string - name: - type: string - required: - - db - - name - type: object - type: array - username: - type: string - warnings: - items: - type: string - type: array - required: - - db - - phase - - project - - username - type: object - required: - - spec - type: object - served: true - storage: true - subresources: - status: {} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.15.0 - name: opsmanagers.mongodb.com -spec: - group: mongodb.com - names: - kind: MongoDBOpsManager - listKind: MongoDBOpsManagerList - plural: opsmanagers - shortNames: - - om - singular: opsmanager - scope: Namespaced - versions: - - additionalPrinterColumns: - - description: The number of replicas of MongoDBOpsManager. - jsonPath: .spec.replicas - name: Replicas - type: integer - - description: The version of MongoDBOpsManager. - jsonPath: .spec.version - name: Version - type: string - - description: The current state of the MongoDBOpsManager. - jsonPath: .status.opsManager.phase - name: State (OpsManager) - type: string - - description: The current state of the MongoDBOpsManager Application Database. - jsonPath: .status.applicationDatabase.phase - name: State (AppDB) - type: string - - description: The current state of the MongoDBOpsManager Backup Daemon. - jsonPath: .status.backup.phase - name: State (Backup) - type: string - - description: The time since the MongoDBOpsManager resource was created. - jsonPath: .metadata.creationTimestamp - name: Age - type: date - - description: Warnings. - jsonPath: .status.warnings - name: Warnings - type: string - name: v1 - schema: - openAPIV3Schema: - description: The MongoDBOpsManager resource allows you to deploy Ops Manager - within your Kubernetes cluster - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - properties: - adminCredentials: - description: |- - AdminSecret is the secret for the first admin user to create - has the fields: "Username", "Password", "FirstName", "LastName" - type: string - applicationDatabase: - properties: - additionalMongodConfig: - description: |- - AdditionalMongodConfig are additional configurations that can be passed to - each data-bearing mongod at runtime. Uses the same structure as the mongod - configuration file: - https://docs.mongodb.com/manual/reference/configuration-options/ - type: object - x-kubernetes-preserve-unknown-fields: true - agent: - description: specify configuration like startup flags and automation - config settings for the AutomationAgent and MonitoringAgent - properties: - backupAgent: - properties: - logRotate: - description: LogRotate configures log rotation for the - BackupAgent processes - properties: - sizeThresholdMB: - description: |- - Maximum size for an individual log file before rotation. - OM only supports ints - type: integer - timeThresholdHrs: - description: Number of hours after which this MongoDB - Agent rotates the log file. - type: integer - type: object - type: object - logLevel: - type: string logRotate: - description: DEPRECATED please use mongod.logRotate + description: LogRotate configures log rotation for the mongodb + processes properties: includeAuditLogsWithMongoDBLogs: description: |- @@ -4056,34 +3484,1244 @@ spec: - sizeThresholdMB - timeThresholdHrs type: object - maxLogFileDurationHours: - type: integer - mongod: - description: AgentLoggingMongodConfig contain settings for - the mongodb processes configured by the agent + systemLog: + description: SystemLog configures system log of mongod properties: - auditlogRotate: - description: LogRotate configures audit log rotation for - the mongodb processes + destination: + type: string + logAppend: + type: boolean + path: + type: string + required: + - destination + - logAppend + - path + type: object + type: object + monitoringAgent: + properties: + logRotate: + description: LogRotate configures log rotation for the BackupAgent + processes + properties: + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + OM only supports ints + type: integer + timeThresholdHrs: + description: Number of hours after which this MongoDB + Agent rotates the log file. + type: integer + type: object + type: object + readinessProbe: + properties: + environmentVariables: + additionalProperties: + type: string + type: object + type: object + startupOptions: + additionalProperties: + type: string + description: |- + StartupParameters can be used to configure the startup parameters with which the agent starts. That also contains + log rotation settings as defined here: + type: object + systemLog: + description: DEPRECATED please use mongod.systemLog + properties: + destination: + type: string + logAppend: + type: boolean + path: + type: string + required: + - destination + - logAppend + - path + type: object + type: object + backup: + description: |- + Backup contains configuration options for configuring + backup for this MongoDB resource + properties: + assignmentLabels: + description: Assignment Labels set in the Ops Manager + items: + type: string + type: array + autoTerminateOnDeletion: + description: |- + AutoTerminateOnDeletion indicates if the Operator should stop and terminate the Backup before the cleanup, + when the MongoDB CR is deleted + type: boolean + encryption: + description: Encryption settings + properties: + kmip: + description: Kmip corresponds to the KMIP configuration assigned + to the Ops Manager Project's configuration. + properties: + client: + description: KMIP Client configuration properties: - includeAuditLogsWithMongoDBLogs: - description: |- - set to 'true' to have the Automation Agent rotate the audit files along - with mongodb log files - type: boolean - numTotal: - description: maximum number of log files to have total - type: integer - numUncompressed: - description: maximum number of log files to leave - uncompressed - type: integer - percentOfDiskspace: + clientCertificatePrefix: description: |- - Maximum percentage of the total disk space these log files should take up. - The string needs to be able to be converted to float64 + A prefix used to construct KMIP client certificate (and corresponding password) Secret names. + The names are generated using the following pattern: + KMIP Client Certificate (TLS Secret): + --kmip-client + KMIP Client Certificate Password: + --kmip-client-password + The expected key inside is called "password". type: string - sizeThresholdMB: + type: object + required: + - client + type: object + type: object + mode: + enum: + - enabled + - disabled + - terminated + type: string + snapshotSchedule: + properties: + clusterCheckpointIntervalMin: + enum: + - 15 + - 30 + - 60 + type: integer + dailySnapshotRetentionDays: + description: Number of days to retain daily snapshots. Setting + 0 will disable this rule. + maximum: 365 + minimum: 0 + type: integer + fullIncrementalDayOfWeek: + description: Day of the week when Ops Manager takes a full + snapshot. This ensures a recent complete backup. Ops Manager + sets the default value to SUNDAY. + enum: + - SUNDAY + - MONDAY + - TUESDAY + - WEDNESDAY + - THURSDAY + - FRIDAY + - SATURDAY + type: string + monthlySnapshotRetentionMonths: + description: Number of months to retain weekly snapshots. + Setting 0 will disable this rule. + maximum: 36 + minimum: 0 + type: integer + pointInTimeWindowHours: + description: Number of hours in the past for which a point-in-time + snapshot can be created. + enum: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 15 + - 30 + - 60 + - 90 + - 120 + - 180 + - 360 + type: integer + referenceHourOfDay: + description: Hour of the day to schedule snapshots using a + 24-hour clock, in UTC. + maximum: 23 + minimum: 0 + type: integer + referenceMinuteOfHour: + description: Minute of the hour to schedule snapshots, in + UTC. + maximum: 59 + minimum: 0 + type: integer + snapshotIntervalHours: + description: Number of hours between snapshots. + enum: + - 6 + - 8 + - 12 + - 24 + type: integer + snapshotRetentionDays: + description: Number of days to keep recent snapshots. + maximum: 365 + minimum: 1 + type: integer + weeklySnapshotRetentionWeeks: + description: Number of weeks to retain weekly snapshots. Setting + 0 will disable this rule + maximum: 365 + minimum: 0 + type: integer + type: object + type: object + cloudManager: + properties: + configMapRef: + properties: + name: + type: string + type: object + type: object + clusterDomain: + format: hostname + type: string + clusterSpecList: + items: + description: |- + ClusterSpecItem is the mongodb multi-cluster spec that is specific to a + particular Kubernetes cluster, this maps to the statefulset created in each cluster + properties: + clusterName: + description: |- + ClusterName is name of the cluster where the MongoDB Statefulset will be scheduled, the + name should have a one on one mapping with the service-account created in the central cluster + to talk to the workload clusters. + type: string + externalAccess: + description: ExternalAccessConfiguration provides external access + configuration for Multi-Cluster. + properties: + externalDomain: + description: An external domain that is used for exposing + MongoDB to the outside world. + type: string + externalService: + description: Provides a way to override the default (NodePort) + Service + properties: + annotations: + additionalProperties: + type: string + description: A map of annotations that shall be added + to the externally available Service. + type: object + spec: + description: A wrapper for the Service spec object. + type: object + x-kubernetes-preserve-unknown-fields: true + type: object + type: object + memberConfig: + description: MemberConfig allows to specify votes, priorities + and tags for each of the mongodb process. + items: + properties: + priority: + type: string + tags: + additionalProperties: + type: string + type: object + votes: + type: integer + type: object + type: array + members: + description: Amount of members for this MongoDB Replica Set + type: integer + podSpec: + properties: + persistence: + description: Note, that this field is used by MongoDB resources + only, let's keep it here for simplicity + properties: + multiple: + properties: + data: + properties: + labelSelector: + type: object + x-kubernetes-preserve-unknown-fields: true + storage: + type: string + storageClass: + type: string + type: object + journal: + properties: + labelSelector: + type: object + x-kubernetes-preserve-unknown-fields: true + storage: + type: string + storageClass: + type: string + type: object + logs: + properties: + labelSelector: + type: object + x-kubernetes-preserve-unknown-fields: true + storage: + type: string + storageClass: + type: string + type: object + type: object + single: + properties: + labelSelector: + type: object + x-kubernetes-preserve-unknown-fields: true + storage: + type: string + storageClass: + type: string + type: object + type: object + podTemplate: + type: object + x-kubernetes-preserve-unknown-fields: true + type: object + service: + description: this is an optional service, it will get the name + "-service" in case not provided + type: string + statefulSet: + description: |- + StatefulSetConfiguration holds the optional custom StatefulSet + that should be merged into the operator created one. + properties: + metadata: + description: StatefulSetMetadataWrapper is a wrapper around + Labels and Annotations + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + type: object + spec: + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + required: + - members + type: object + type: array + connectivity: + properties: + replicaSetHorizons: + description: |- + ReplicaSetHorizons holds list of maps of horizons to be configured in each of MongoDB processes. + Horizons map horizon names to the node addresses for each process in the replicaset, e.g.: + [ + { + "internal": "my-rs-0.my-internal-domain.com:31843", + "external": "my-rs-0.my-external-domain.com:21467" + }, + { + "internal": "my-rs-1.my-internal-domain.com:31843", + "external": "my-rs-1.my-external-domain.com:21467" + }, + ... + ] + The key of each item in the map is an arbitrary, user-chosen string that + represents the name of the horizon. The value of the item is the host and, + optionally, the port that this mongod node will be connected to from. + items: + additionalProperties: + type: string + type: object + type: array + type: object + credentials: + description: Name of the Secret holding credentials information + type: string + duplicateServiceObjects: + description: |- + In few service mesh options for ex: Istio, by default we would need to duplicate the + service objects created per pod in all the clusters to enable DNS resolution. Users can + however configure their ServiceMesh with DNS proxy(https://istio.io/latest/docs/ops/configuration/traffic-management/dns-proxy/) + enabled in which case the operator doesn't need to create the service objects per cluster. This options tells the operator + whether it should create the service objects in all the clusters or not. By default, if not specified the operator would create the duplicate svc objects. + type: boolean + externalAccess: + description: ExternalAccessConfiguration provides external access + configuration. + properties: + externalDomain: + description: An external domain that is used for exposing MongoDB + to the outside world. + type: string + externalService: + description: Provides a way to override the default (NodePort) + Service + properties: + annotations: + additionalProperties: + type: string + description: A map of annotations that shall be added to the + externally available Service. + type: object + spec: + description: A wrapper for the Service spec object. + type: object + x-kubernetes-preserve-unknown-fields: true + type: object + type: object + featureCompatibilityVersion: + type: string + logLevel: + enum: + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + type: string + opsManager: + properties: + configMapRef: + properties: + name: + type: string + type: object + type: object + persistent: + type: boolean + prometheus: + description: Prometheus configurations. + properties: + metricsPath: + description: Indicates path to the metrics endpoint. + pattern: ^\/[a-z0-9]+$ + type: string + passwordSecretRef: + description: Name of a Secret containing a HTTP Basic Auth Password. + properties: + key: + description: Key is the key in the secret storing this password. + Defaults to "password" + type: string + name: + description: Name is the name of the secret storing this user's + password + type: string + required: + - name + type: object + port: + description: Port where metrics endpoint will bind to. Defaults + to 9216. + type: integer + tlsSecretKeyRef: + description: |- + Name of a Secret (type kubernetes.io/tls) holding the certificates to use in the + Prometheus endpoint. + properties: + key: + description: Key is the key in the secret storing this password. + Defaults to "password" + type: string + name: + description: Name is the name of the secret storing this user's + password + type: string + required: + - name + type: object + username: + description: HTTP Basic Auth Username for metrics endpoint. + type: string + required: + - passwordSecretRef + - username + type: object + security: + properties: + authentication: + description: |- + Authentication holds various authentication related settings that affect + this MongoDB resource. + properties: + agents: + description: Agents contains authentication configuration + properties for the agents + properties: + automationLdapGroupDN: + type: string + automationPasswordSecretRef: + description: SecretKeySelector selects a key of a Secret. + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + automationUserName: + type: string + clientCertificateSecretRef: + type: object + x-kubernetes-preserve-unknown-fields: true + mode: + description: Mode is the desired Authentication mode that + the agents will use + type: string + required: + - mode + type: object + enabled: + type: boolean + ignoreUnknownUsers: + description: IgnoreUnknownUsers maps to the inverse of auth.authoritativeSet + type: boolean + internalCluster: + type: string + ldap: + description: LDAP Configuration + properties: + authzQueryTemplate: + type: string + bindQueryPasswordSecretRef: + properties: + name: + type: string + required: + - name + type: object + bindQueryUser: + type: string + caConfigMapRef: + description: Allows to point at a ConfigMap/key with a + CA file to mount on the Pod + properties: + key: + description: The key to select. + type: string + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + servers: + items: + type: string + type: array + timeoutMS: + type: integer + transportSecurity: + enum: + - tls + - none + type: string + userCacheInvalidationInterval: + type: integer + userToDNMapping: + type: string + validateLDAPServerConfig: + type: boolean + type: object + modes: + items: + enum: + - X509 + - SCRAM + - SCRAM-SHA-1 + - MONGODB-CR + - SCRAM-SHA-256 + - LDAP + type: string + type: array + requireClientTLSAuthentication: + description: Clients should present valid TLS certificates + type: boolean + required: + - enabled + type: object + certsSecretPrefix: + type: string + roles: + items: + properties: + authenticationRestrictions: + items: + properties: + clientSource: + items: + type: string + type: array + serverAddress: + items: + type: string + type: array + type: object + type: array + db: + type: string + privileges: + items: + properties: + actions: + items: + type: string + type: array + resource: + properties: + cluster: + type: boolean + collection: + type: string + db: + type: string + type: object + required: + - actions + - resource + type: object + type: array + role: + type: string + roles: + items: + properties: + db: + type: string + role: + type: string + required: + - db + - role + type: object + type: array + required: + - db + - role + type: object + type: array + tls: + properties: + additionalCertificateDomains: + items: + type: string + type: array + ca: + description: |- + CA corresponds to a ConfigMap containing an entry for the CA certificate (ca.pem) + used to validate the certificates created already. + type: string + enabled: + description: |- + DEPRECATED please enable TLS by setting `security.certsSecretPrefix` or `security.tls.secretRef.prefix`. + Enables TLS for this resource. This will make the operator try to mount a + Secret with a defined name (-cert). + This is only used when enabling TLS on a MongoDB resource, and not on the + AppDB, where TLS is configured by setting `secretRef.Name`. + type: boolean + type: object + type: object + statefulSet: + description: |- + StatefulSetConfiguration provides the statefulset override for each of the cluster's statefulset + if "StatefulSetConfiguration" is specified at cluster level under "clusterSpecList" that takes precedence over + the global one + properties: + metadata: + description: StatefulSetMetadataWrapper is a wrapper around Labels + and Annotations + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + type: object + spec: + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + topology: + description: |- + Topology sets the desired cluster topology of MongoDB resources + It defaults (if empty or not set) to SingleCluster. If MultiCluster specified, + then clusterSpecList field is mandatory and at least one member cluster has to be specified. + enum: + - SingleCluster + - MultiCluster + type: string + type: + enum: + - Standalone + - ReplicaSet + - ShardedCluster + type: string + version: + pattern: ^[0-9]+.[0-9]+.[0-9]+(-.+)?$|^$ + type: string + required: + - credentials + - type + - version + type: object + x-kubernetes-preserve-unknown-fields: true + status: + properties: + backup: + properties: + statusName: + type: string + required: + - statusName + type: object + clusterStatusList: + description: ClusterStatusList holds a list of clusterStatuses corresponding + to each cluster + properties: + clusterStatuses: + items: + description: |- + ClusterStatusItem is the mongodb multi-cluster spec that is specific to a + particular Kubernetes cluster, this maps to the statefulset created in each cluster + properties: + clusterName: + description: |- + ClusterName is name of the cluster where the MongoDB Statefulset will be scheduled, the + name should have a one on one mapping with the service-account created in the central cluster + to talk to the workload clusters. + type: string + lastTransition: + type: string + members: + type: integer + message: + type: string + observedGeneration: + format: int64 + type: integer + phase: + type: string + pvc: + items: + properties: + phase: + type: string + statefulsetName: + type: string + required: + - phase + - statefulsetName + type: object + type: array + resourcesNotReady: + items: + description: ResourceNotReady describes the dependent + resource which is not ready yet + properties: + errors: + items: + properties: + message: + type: string + reason: + type: string + type: object + type: array + kind: + description: ResourceKind specifies a kind of a Kubernetes + resource. Used in status of a Custom Resource + type: string + message: + type: string + name: + type: string + required: + - kind + - name + type: object + type: array + warnings: + items: + type: string + type: array + required: + - phase + type: object + type: array + type: object + featureCompatibilityVersion: + type: string + lastTransition: + type: string + link: + type: string + message: + type: string + observedGeneration: + format: int64 + type: integer + phase: + type: string + pvc: + items: + properties: + phase: + type: string + statefulsetName: + type: string + required: + - phase + - statefulsetName + type: object + type: array + resourcesNotReady: + items: + description: ResourceNotReady describes the dependent resource which + is not ready yet + properties: + errors: + items: + properties: + message: + type: string + reason: + type: string + type: object + type: array + kind: + description: ResourceKind specifies a kind of a Kubernetes resource. + Used in status of a Custom Resource + type: string + message: + type: string + name: + type: string + required: + - kind + - name + type: object + type: array + version: + type: string + warnings: + items: + type: string + type: array + required: + - phase + - version + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.15.0 + name: mongodbusers.mongodb.com +spec: + group: mongodb.com + names: + kind: MongoDBUser + listKind: MongoDBUserList + plural: mongodbusers + shortNames: + - mdbu + singular: mongodbuser + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: The current state of the MongoDB User. + jsonPath: .status.phase + name: Phase + type: string + - description: The time since the MongoDB User resource was created. + jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1 + schema: + openAPIV3Schema: + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + properties: + connectionStringSecretName: + type: string + db: + type: string + mongodbResourceRef: + properties: + name: + type: string + namespace: + type: string + required: + - name + type: object + passwordSecretKeyRef: + description: |- + SecretKeyRef is a reference to a value in a given secret in the same + namespace. Based on: + https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.15/#secretkeyselector-v1-core + properties: + key: + type: string + name: + type: string + required: + - name + type: object + roles: + items: + properties: + db: + type: string + name: + type: string + required: + - db + - name + type: object + type: array + username: + type: string + required: + - db + - username + type: object + status: + properties: + db: + type: string + lastTransition: + type: string + message: + type: string + observedGeneration: + format: int64 + type: integer + phase: + type: string + project: + type: string + pvc: + items: + properties: + phase: + type: string + statefulsetName: + type: string + required: + - phase + - statefulsetName + type: object + type: array + resourcesNotReady: + items: + description: ResourceNotReady describes the dependent resource which + is not ready yet + properties: + errors: + items: + properties: + message: + type: string + reason: + type: string + type: object + type: array + kind: + description: ResourceKind specifies a kind of a Kubernetes resource. + Used in status of a Custom Resource + type: string + message: + type: string + name: + type: string + required: + - kind + - name + type: object + type: array + roles: + items: + properties: + db: + type: string + name: + type: string + required: + - db + - name + type: object + type: array + username: + type: string + warnings: + items: + type: string + type: array + required: + - db + - phase + - project + - username + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.15.0 + name: opsmanagers.mongodb.com +spec: + group: mongodb.com + names: + kind: MongoDBOpsManager + listKind: MongoDBOpsManagerList + plural: opsmanagers + shortNames: + - om + singular: opsmanager + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: The number of replicas of MongoDBOpsManager. + jsonPath: .spec.replicas + name: Replicas + type: integer + - description: The version of MongoDBOpsManager. + jsonPath: .spec.version + name: Version + type: string + - description: The current state of the MongoDBOpsManager. + jsonPath: .status.opsManager.phase + name: State (OpsManager) + type: string + - description: The current state of the MongoDBOpsManager Application Database. + jsonPath: .status.applicationDatabase.phase + name: State (AppDB) + type: string + - description: The current state of the MongoDBOpsManager Backup Daemon. + jsonPath: .status.backup.phase + name: State (Backup) + type: string + - description: The time since the MongoDBOpsManager resource was created. + jsonPath: .metadata.creationTimestamp + name: Age + type: date + - description: Warnings. + jsonPath: .status.warnings + name: Warnings + type: string + name: v1 + schema: + openAPIV3Schema: + description: The MongoDBOpsManager resource allows you to deploy Ops Manager + within your Kubernetes cluster + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + properties: + adminCredentials: + description: |- + AdminSecret is the secret for the first admin user to create + has the fields: "Username", "Password", "FirstName", "LastName" + type: string + applicationDatabase: + properties: + additionalMongodConfig: + description: |- + AdditionalMongodConfig are additional configurations that can be passed to + each data-bearing mongod at runtime. Uses the same structure as the mongod + configuration file: + https://docs.mongodb.com/manual/reference/configuration-options/ + type: object + x-kubernetes-preserve-unknown-fields: true + agent: + description: specify configuration like startup flags and automation + config settings for the AutomationAgent and MonitoringAgent + properties: + backupAgent: + properties: + logRotate: + description: LogRotate configures log rotation for the + BackupAgent processes + properties: + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + OM only supports ints + type: integer + timeThresholdHrs: + description: Number of hours after which this MongoDB + Agent rotates the log file. + type: integer + type: object + type: object + logLevel: + type: string + logRotate: + description: DEPRECATED please use mongod.logRotate + properties: + includeAuditLogsWithMongoDBLogs: + description: |- + set to 'true' to have the Automation Agent rotate the audit files along + with mongodb log files + type: boolean + numTotal: + description: maximum number of log files to have total + type: integer + numUncompressed: + description: maximum number of log files to leave uncompressed + type: integer + percentOfDiskspace: + description: |- + Maximum percentage of the total disk space these log files should take up. + The string needs to be able to be converted to float64 + type: string + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + The string needs to be able to be converted to float64. + Fractional values of MB are supported. + type: string + timeThresholdHrs: + description: maximum hours for an individual log file + before rotation + type: integer + required: + - sizeThresholdMB + - timeThresholdHrs + type: object + maxLogFileDurationHours: + type: integer + mongod: + description: AgentLoggingMongodConfig contain settings for + the mongodb processes configured by the agent + properties: + auditlogRotate: + description: LogRotate configures audit log rotation for + the mongodb processes + properties: + includeAuditLogsWithMongoDBLogs: + description: |- + set to 'true' to have the Automation Agent rotate the audit files along + with mongodb log files + type: boolean + numTotal: + description: maximum number of log files to have total + type: integer + numUncompressed: + description: maximum number of log files to leave + uncompressed + type: integer + percentOfDiskspace: + description: |- + Maximum percentage of the total disk space these log files should take up. + The string needs to be able to be converted to float64 + type: string + sizeThresholdMB: description: |- Maximum size for an individual log file before rotation. The string needs to be able to be converted to float64. @@ -4147,30 +4785,357 @@ spec: - path type: object type: object - monitoringAgent: + monitoringAgent: + properties: + logRotate: + description: LogRotate configures log rotation for the + BackupAgent processes + properties: + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + OM only supports ints + type: integer + timeThresholdHrs: + description: Number of hours after which this MongoDB + Agent rotates the log file. + type: integer + type: object + type: object + readinessProbe: + properties: + environmentVariables: + additionalProperties: + type: string + type: object + type: object + startupOptions: + additionalProperties: + type: string + description: |- + StartupParameters can be used to configure the startup parameters with which the agent starts. That also contains + log rotation settings as defined here: + type: object + systemLog: + description: DEPRECATED please use mongod.systemLog + properties: + destination: + type: string + logAppend: + type: boolean + path: + type: string + required: + - destination + - logAppend + - path + type: object + type: object + automationConfig: + description: |- + AutomationConfigOverride holds any fields that will be merged on top of the Automation Config + that the operator creates for the AppDB. Currently only the process.disabled and logRotate field is recognized. + properties: + processes: + items: + description: OverrideProcess contains fields that we can + override on the AutomationConfig processes. + properties: + disabled: + type: boolean + logRotate: + description: CrdLogRotate is the crd definition of LogRotate + including fields in strings while the agent supports + them as float64 + properties: + includeAuditLogsWithMongoDBLogs: + description: |- + set to 'true' to have the Automation Agent rotate the audit files along + with mongodb log files + type: boolean + numTotal: + description: maximum number of log files to have + total + type: integer + numUncompressed: + description: maximum number of log files to leave + uncompressed + type: integer + percentOfDiskspace: + description: |- + Maximum percentage of the total disk space these log files should take up. + The string needs to be able to be converted to float64 + type: string + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + The string needs to be able to be converted to float64. + Fractional values of MB are supported. + type: string + timeThresholdHrs: + description: maximum hours for an individual log + file before rotation + type: integer + required: + - sizeThresholdMB + - timeThresholdHrs + type: object + name: + type: string + required: + - disabled + - name + type: object + type: array + replicaSet: + properties: + id: + description: |- + Id can be used together with additionalMongodConfig.replication.replSetName + to manage clusters where replSetName differs from the MongoDBCommunity resource name + type: string + settings: + description: |- + MapWrapper is a wrapper for a map to be used by other structs. + The CRD generator does not support map[string]interface{} + on the top level and hence we need to work around this with + a wrapping struct. + type: object + x-kubernetes-preserve-unknown-fields: true + type: object + type: object + cloudManager: + properties: + configMapRef: properties: - logRotate: - description: LogRotate configures log rotation for the - BackupAgent processes + name: + type: string + type: object + type: object + clusterDomain: + type: string + clusterSpecList: + items: + description: |- + ClusterSpecItem is the mongodb multi-cluster spec that is specific to a + particular Kubernetes cluster, this maps to the statefulset created in each cluster + properties: + clusterName: + description: |- + ClusterName is name of the cluster where the MongoDB Statefulset will be scheduled, the + name should have a one on one mapping with the service-account created in the central cluster + to talk to the workload clusters. + type: string + externalAccess: + description: ExternalAccessConfiguration provides external + access configuration for Multi-Cluster. + properties: + externalDomain: + description: An external domain that is used for exposing + MongoDB to the outside world. + type: string + externalService: + description: Provides a way to override the default + (NodePort) Service + properties: + annotations: + additionalProperties: + type: string + description: A map of annotations that shall be + added to the externally available Service. + type: object + spec: + description: A wrapper for the Service spec object. + type: object + x-kubernetes-preserve-unknown-fields: true + type: object + type: object + memberConfig: + description: MemberConfig allows to specify votes, priorities + and tags for each of the mongodb process. + items: properties: - sizeThresholdMB: - description: |- - Maximum size for an individual log file before rotation. - OM only supports ints - type: integer - timeThresholdHrs: - description: Number of hours after which this MongoDB - Agent rotates the log file. + priority: + type: string + tags: + additionalProperties: + type: string + type: object + votes: type: integer type: object - type: object - readinessProbe: + type: array + members: + description: Amount of members for this MongoDB Replica + Set + type: integer + podSpec: + properties: + persistence: + description: Note, that this field is used by MongoDB + resources only, let's keep it here for simplicity + properties: + multiple: + properties: + data: + properties: + labelSelector: + type: object + x-kubernetes-preserve-unknown-fields: true + storage: + type: string + storageClass: + type: string + type: object + journal: + properties: + labelSelector: + type: object + x-kubernetes-preserve-unknown-fields: true + storage: + type: string + storageClass: + type: string + type: object + logs: + properties: + labelSelector: + type: object + x-kubernetes-preserve-unknown-fields: true + storage: + type: string + storageClass: + type: string + type: object + type: object + single: + properties: + labelSelector: + type: object + x-kubernetes-preserve-unknown-fields: true + storage: + type: string + storageClass: + type: string + type: object + type: object + podTemplate: + type: object + x-kubernetes-preserve-unknown-fields: true + type: object + service: + description: this is an optional service, it will get the + name "-service" in case not provided + type: string + statefulSet: + description: |- + StatefulSetConfiguration holds the optional custom StatefulSet + that should be merged into the operator created one. + properties: + metadata: + description: StatefulSetMetadataWrapper is a wrapper + around Labels and Annotations + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + type: object + spec: + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + required: + - members + type: object + type: array + connectivity: + properties: + replicaSetHorizons: + description: |- + ReplicaSetHorizons holds list of maps of horizons to be configured in each of MongoDB processes. + Horizons map horizon names to the node addresses for each process in the replicaset, e.g.: + [ + { + "internal": "my-rs-0.my-internal-domain.com:31843", + "external": "my-rs-0.my-external-domain.com:21467" + }, + { + "internal": "my-rs-1.my-internal-domain.com:31843", + "external": "my-rs-1.my-external-domain.com:21467" + }, + ... + ] + The key of each item in the map is an arbitrary, user-chosen string that + represents the name of the horizon. The value of the item is the host and, + optionally, the port that this mongod node will be connected to from. + items: + additionalProperties: + type: string + type: object + type: array + type: object + credentials: + description: Name of the Secret holding credentials information + type: string + externalAccess: + description: ExternalAccessConfiguration provides external access + configuration. + properties: + externalDomain: + description: An external domain that is used for exposing + MongoDB to the outside world. + type: string + externalService: + description: Provides a way to override the default (NodePort) + Service properties: - environmentVariables: + annotations: additionalProperties: type: string + description: A map of annotations that shall be added + to the externally available Service. + type: object + spec: + description: A wrapper for the Service spec object. type: object + x-kubernetes-preserve-unknown-fields: true type: object + type: object + featureCompatibilityVersion: + type: string + memberConfig: + description: MemberConfig allows to specify votes, priorities + and tags for each of the mongodb process. + items: + properties: + priority: + type: string + tags: + additionalProperties: + type: string + type: object + votes: + type: integer + type: object + type: array + members: + description: Amount of members for this MongoDB Replica Set + maximum: 50 + minimum: 3 + type: integer + monitoringAgent: + description: |- + Specify configuration like startup flags just for the MonitoringAgent. + These take precedence over + the flags set in AutomationAgent + properties: startupOptions: additionalProperties: type: string @@ -4178,1691 +5143,2041 @@ spec: StartupParameters can be used to configure the startup parameters with which the agent starts. That also contains log rotation settings as defined here: type: object - systemLog: - description: DEPRECATED please use mongod.systemLog + required: + - startupOptions + type: object + opsManager: + properties: + configMapRef: properties: - destination: - type: string - logAppend: - type: boolean - path: + name: type: string - required: - - destination - - logAppend - - path type: object type: object - automationConfig: + passwordSecretKeyRef: description: |- - AutomationConfigOverride holds any fields that will be merged on top of the Automation Config - that the operator creates for the AppDB. Currently only the process.disabled and logRotate field is recognized. + PasswordSecretKeyRef contains a reference to the secret which contains the password + for the mongodb-ops-manager SCRAM-SHA user properties: - processes: - items: - description: OverrideProcess contains fields that we can - override on the AutomationConfig processes. - properties: - disabled: - type: boolean - logRotate: - description: CrdLogRotate is the crd definition of LogRotate - including fields in strings while the agent supports - them as float64 - properties: - includeAuditLogsWithMongoDBLogs: - description: |- - set to 'true' to have the Automation Agent rotate the audit files along - with mongodb log files - type: boolean - numTotal: - description: maximum number of log files to have - total - type: integer - numUncompressed: - description: maximum number of log files to leave - uncompressed - type: integer - percentOfDiskspace: - description: |- - Maximum percentage of the total disk space these log files should take up. - The string needs to be able to be converted to float64 - type: string - sizeThresholdMB: - description: |- - Maximum size for an individual log file before rotation. - The string needs to be able to be converted to float64. - Fractional values of MB are supported. - type: string - timeThresholdHrs: - description: maximum hours for an individual log - file before rotation - type: integer - required: - - sizeThresholdMB - - timeThresholdHrs - type: object - name: - type: string - required: - - disabled - - name - type: object - type: array - replicaSet: + key: + type: string + name: + type: string + required: + - name + type: object + podSpec: + properties: + persistence: + description: Note, that this field is used by MongoDB resources + only, let's keep it here for simplicity properties: - id: - description: |- - Id can be used together with additionalMongodConfig.replication.replSetName - to manage clusters where replSetName differs from the MongoDBCommunity resource name - type: string - settings: - description: |- - MapWrapper is a wrapper for a map to be used by other structs. - The CRD generator does not support map[string]interface{} - on the top level and hence we need to work around this with - a wrapping struct. + multiple: + properties: + data: + properties: + labelSelector: + type: object + x-kubernetes-preserve-unknown-fields: true + storage: + type: string + storageClass: + type: string + type: object + journal: + properties: + labelSelector: + type: object + x-kubernetes-preserve-unknown-fields: true + storage: + type: string + storageClass: + type: string + type: object + logs: + properties: + labelSelector: + type: object + x-kubernetes-preserve-unknown-fields: true + storage: + type: string + storageClass: + type: string + type: object type: object - x-kubernetes-preserve-unknown-fields: true + single: + properties: + labelSelector: + type: object + x-kubernetes-preserve-unknown-fields: true + storage: + type: string + storageClass: + type: string + type: object + type: object + podTemplate: type: object + x-kubernetes-preserve-unknown-fields: true type: object - cloudManager: + prometheus: + description: Enables Prometheus integration on the AppDB. properties: - configMapRef: + metricsPath: + description: Indicates path to the metrics endpoint. + pattern: ^\/[a-z0-9]+$ + type: string + passwordSecretRef: + description: Name of a Secret containing a HTTP Basic Auth + Password. + properties: + key: + description: Key is the key in the secret storing this + password. Defaults to "password" + type: string + name: + description: Name is the name of the secret storing this + user's password + type: string + required: + - name + type: object + port: + description: Port where metrics endpoint will bind to. Defaults + to 9216. + type: integer + tlsSecretKeyRef: + description: |- + Name of a Secret (type kubernetes.io/tls) holding the certificates to use in the + Prometheus endpoint. properties: + key: + description: Key is the key in the secret storing this + password. Defaults to "password" + type: string name: + description: Name is the name of the secret storing this + user's password type: string + required: + - name type: object + username: + description: HTTP Basic Auth Username for metrics endpoint. + type: string + required: + - passwordSecretRef + - username type: object - clusterDomain: - type: string - clusterSpecList: - items: - description: |- - ClusterSpecItem is the mongodb multi-cluster spec that is specific to a - particular Kubernetes cluster, this maps to the statefulset created in each cluster - properties: - clusterName: - description: |- - ClusterName is name of the cluster where the MongoDB Statefulset will be scheduled, the - name should have a one on one mapping with the service-account created in the central cluster - to talk to the workload clusters. - type: string - externalAccess: - description: ExternalAccessConfiguration provides external - access configuration for Multi-Cluster. - properties: - externalDomain: - description: An external domain that is used for exposing - MongoDB to the outside world. - type: string - externalService: - description: Provides a way to override the default - (NodePort) Service - properties: - annotations: - additionalProperties: + security: + properties: + authentication: + description: |- + Authentication holds various authentication related settings that affect + this MongoDB resource. + properties: + agents: + description: Agents contains authentication configuration + properties for the agents + properties: + automationLdapGroupDN: + type: string + automationPasswordSecretRef: + description: SecretKeySelector selects a key of a + Secret. + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. type: string - description: A map of annotations that shall be - added to the externally available Service. - type: object - spec: - description: A wrapper for the Service spec object. - type: object - x-kubernetes-preserve-unknown-fields: true - type: object - type: object - memberConfig: - description: MemberConfig allows to specify votes, priorities - and tags for each of the mongodb process. - items: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + optional: + description: Specify whether the Secret or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + automationUserName: + type: string + clientCertificateSecretRef: + type: object + x-kubernetes-preserve-unknown-fields: true + mode: + description: Mode is the desired Authentication mode + that the agents will use + type: string + required: + - mode + type: object + enabled: + type: boolean + ignoreUnknownUsers: + description: IgnoreUnknownUsers maps to the inverse of + auth.authoritativeSet + type: boolean + internalCluster: + type: string + ldap: + description: LDAP Configuration properties: - priority: + authzQueryTemplate: type: string - tags: - additionalProperties: - type: string + bindQueryPasswordSecretRef: + properties: + name: + type: string + required: + - name type: object - votes: + bindQueryUser: + type: string + caConfigMapRef: + description: Allows to point at a ConfigMap/key with + a CA file to mount on the Pod + properties: + key: + description: The key to select. + type: string + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + optional: + description: Specify whether the ConfigMap or + its key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + servers: + items: + type: string + type: array + timeoutMS: + type: integer + transportSecurity: + enum: + - tls + - none + type: string + userCacheInvalidationInterval: type: integer + userToDNMapping: + type: string + validateLDAPServerConfig: + type: boolean type: object - type: array - members: - description: Amount of members for this MongoDB Replica - Set - type: integer - podSpec: + modes: + items: + enum: + - X509 + - SCRAM + - SCRAM-SHA-1 + - MONGODB-CR + - SCRAM-SHA-256 + - LDAP + type: string + type: array + requireClientTLSAuthentication: + description: Clients should present valid TLS certificates + type: boolean + required: + - enabled + type: object + certsSecretPrefix: + type: string + roles: + items: properties: - persistence: - description: Note, that this field is used by MongoDB - resources only, let's keep it here for simplicity - properties: - multiple: - properties: - data: - properties: - labelSelector: - type: object - x-kubernetes-preserve-unknown-fields: true - storage: - type: string - storageClass: - type: string - type: object - journal: - properties: - labelSelector: - type: object - x-kubernetes-preserve-unknown-fields: true - storage: - type: string - storageClass: - type: string - type: object - logs: - properties: - labelSelector: - type: object - x-kubernetes-preserve-unknown-fields: true - storage: - type: string - storageClass: - type: string - type: object - type: object - single: - properties: - labelSelector: - type: object - x-kubernetes-preserve-unknown-fields: true - storage: + authenticationRestrictions: + items: + properties: + clientSource: + items: type: string - storageClass: + type: array + serverAddress: + items: type: string - type: object - type: object - podTemplate: - type: object - x-kubernetes-preserve-unknown-fields: true - type: object - service: - description: this is an optional service, it will get the - name "-service" in case not provided - type: string - statefulSet: - description: |- - StatefulSetConfiguration holds the optional custom StatefulSet - that should be merged into the operator created one. - properties: - metadata: - description: StatefulSetMetadataWrapper is a wrapper - around Labels and Annotations - properties: - annotations: - additionalProperties: + type: array + type: object + type: array + db: + type: string + privileges: + items: + properties: + actions: + items: + type: string + type: array + resource: + properties: + cluster: + type: boolean + collection: + type: string + db: + type: string + type: object + required: + - actions + - resource + type: object + type: array + role: + type: string + roles: + items: + properties: + db: type: string - type: object - labels: - additionalProperties: + role: type: string - type: object - type: object - spec: - type: object - x-kubernetes-preserve-unknown-fields: true + required: + - db + - role + type: object + type: array required: - - spec - type: object - required: - - members - type: object - type: array - connectivity: - properties: - replicaSetHorizons: - description: |- - ReplicaSetHorizons holds list of maps of horizons to be configured in each of MongoDB processes. - Horizons map horizon names to the node addresses for each process in the replicaset, e.g.: - [ - { - "internal": "my-rs-0.my-internal-domain.com:31843", - "external": "my-rs-0.my-external-domain.com:21467" - }, - { - "internal": "my-rs-1.my-internal-domain.com:31843", - "external": "my-rs-1.my-external-domain.com:21467" - }, - ... - ] - The key of each item in the map is an arbitrary, user-chosen string that - represents the name of the horizon. The value of the item is the host and, - optionally, the port that this mongod node will be connected to from. - items: - additionalProperties: - type: string + - db + - role type: object type: array - type: object - credentials: - description: Name of the Secret holding credentials information - type: string - externalAccess: - description: ExternalAccessConfiguration provides external access - configuration. - properties: - externalDomain: - description: An external domain that is used for exposing - MongoDB to the outside world. - type: string - externalService: - description: Provides a way to override the default (NodePort) - Service + tls: properties: - annotations: - additionalProperties: + additionalCertificateDomains: + items: type: string - description: A map of annotations that shall be added - to the externally available Service. - type: object - spec: - description: A wrapper for the Service spec object. - type: object - x-kubernetes-preserve-unknown-fields: true + type: array + ca: + description: |- + CA corresponds to a ConfigMap containing an entry for the CA certificate (ca.pem) + used to validate the certificates created already. + type: string + enabled: + description: |- + DEPRECATED please enable TLS by setting `security.certsSecretPrefix` or `security.tls.secretRef.prefix`. + Enables TLS for this resource. This will make the operator try to mount a + Secret with a defined name (-cert). + This is only used when enabling TLS on a MongoDB resource, and not on the + AppDB, where TLS is configured by setting `secretRef.Name`. + type: boolean type: object type: object - featureCompatibilityVersion: + service: + description: this is an optional service, it will get the name + "-svc" in case not provided type: string - memberConfig: - description: MemberConfig allows to specify votes, priorities - and tags for each of the mongodb process. + topology: + enum: + - SingleCluster + - MultiCluster + type: string + type: + enum: + - Standalone + - ReplicaSet + - ShardedCluster + type: string + version: + pattern: ^[0-9]+.[0-9]+.[0-9]+(-.+)?$|^$ + type: string + required: + - version + type: object + backup: + description: Backup + properties: + assignmentLabels: + description: Assignment Labels set in the Ops Manager + items: + type: string + type: array + blockStores: items: + description: |- + DataStoreConfig is the description of the config used to reference to database. Reused by Oplog and Block stores + Optionally references the user if the Mongodb is configured with authentication properties: - priority: - type: string - tags: - additionalProperties: + assignmentLabels: + description: Assignment Labels set in the Ops Manager + items: type: string + type: array + mongodbResourceRef: + properties: + name: + type: string + namespace: + type: string + required: + - name type: object - votes: - type: integer + mongodbUserRef: + properties: + name: + type: string + required: + - name + type: object + name: + type: string + required: + - mongodbResourceRef + - name type: object type: array - members: - description: Amount of members for this MongoDB Replica Set - maximum: 50 - minimum: 3 - type: integer - monitoringAgent: - description: |- - Specify configuration like startup flags just for the MonitoringAgent. - These take precedence over - the flags set in AutomationAgent - properties: - startupOptions: - additionalProperties: - type: string - description: |- - StartupParameters can be used to configure the startup parameters with which the agent starts. That also contains - log rotation settings as defined here: - type: object - required: - - startupOptions - type: object - opsManager: - properties: - configMapRef: - properties: - name: - type: string - type: object - type: object - passwordSecretKeyRef: - description: |- - PasswordSecretKeyRef contains a reference to the secret which contains the password - for the mongodb-ops-manager SCRAM-SHA user - properties: - key: - type: string - name: - type: string - required: - - name - type: object - podSpec: + enabled: + description: Enabled indicates if Backups will be enabled for + this Ops Manager. + type: boolean + encryption: + description: Encryption settings properties: - persistence: - description: Note, that this field is used by MongoDB resources - only, let's keep it here for simplicity + kmip: + description: Kmip corresponds to the KMIP configuration assigned + to the Ops Manager Project's configuration. properties: - multiple: - properties: - data: - properties: - labelSelector: - type: object - x-kubernetes-preserve-unknown-fields: true - storage: - type: string - storageClass: - type: string - type: object - journal: - properties: - labelSelector: - type: object - x-kubernetes-preserve-unknown-fields: true - storage: - type: string - storageClass: - type: string - type: object - logs: - properties: - labelSelector: - type: object - x-kubernetes-preserve-unknown-fields: true - storage: - type: string - storageClass: - type: string - type: object - type: object - single: + server: + description: KMIP Server configuration properties: - labelSelector: - type: object - x-kubernetes-preserve-unknown-fields: true - storage: + ca: + description: |- + CA corresponds to a ConfigMap containing an entry for the CA certificate (ca.pem) + used for KMIP authentication type: string - storageClass: + url: + description: |- + KMIP Server url in the following format: hostname:port + Valid examples are: + 10.10.10.3:5696 + my-kmip-server.mycorp.com:5696 + kmip-svc.svc.cluster.local:5696 + pattern: '[^\:]+:[0-9]{0,5}' type: string + required: + - ca + - url type: object + required: + - server type: object - podTemplate: + type: object + externalServiceEnabled: + type: boolean + fileSystemStores: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + headDB: + description: HeadDB specifies configuration options for the HeadDB + properties: + labelSelector: type: object x-kubernetes-preserve-unknown-fields: true + storage: + type: string + storageClass: + type: string type: object - prometheus: - description: Enables Prometheus integration on the AppDB. + jvmParameters: + items: + type: string + type: array + logging: properties: - metricsPath: - description: Indicates path to the metrics endpoint. - pattern: ^\/[a-z0-9]+$ - type: string - passwordSecretRef: - description: Name of a Secret containing a HTTP Basic Auth - Password. + LogBackAccessRef: + description: LogBackAccessRef points at a ConfigMap/key with + the logback access configuration file to mount on the Pod properties: - key: - description: Key is the key in the secret storing this - password. Defaults to "password" - type: string name: - description: Name is the name of the secret storing this - user's password type: string - required: - - name type: object - port: - description: Port where metrics endpoint will bind to. Defaults - to 9216. - type: integer - tlsSecretKeyRef: - description: |- - Name of a Secret (type kubernetes.io/tls) holding the certificates to use in the - Prometheus endpoint. + LogBackRef: + description: LogBackRef points at a ConfigMap/key with the + logback configuration file to mount on the Pod properties: - key: - description: Key is the key in the secret storing this - password. Defaults to "password" - type: string name: - description: Name is the name of the secret storing this - user's password type: string - required: - - name type: object - username: - description: HTTP Basic Auth Username for metrics endpoint. + type: object + members: + description: Members indicate the number of backup daemon pods + to create. + minimum: 1 + type: integer + opLogStores: + description: OplogStoreConfigs describes the list of oplog store + configs used for backup + items: + description: |- + DataStoreConfig is the description of the config used to reference to database. Reused by Oplog and Block stores + Optionally references the user if the Mongodb is configured with authentication + properties: + assignmentLabels: + description: Assignment Labels set in the Ops Manager + items: + type: string + type: array + mongodbResourceRef: + properties: + name: + type: string + namespace: + type: string + required: + - name + type: object + mongodbUserRef: + properties: + name: + type: string + required: + - name + type: object + name: + type: string + required: + - mongodbResourceRef + - name + type: object + type: array + queryableBackupSecretRef: + description: |- + QueryableBackupSecretRef references the secret which contains the pem file which is used + for queryable backup. This will be mounted into the Ops Manager pod. + properties: + name: type: string required: - - passwordSecretRef - - username + - name type: object - security: - properties: - authentication: - description: |- - Authentication holds various authentication related settings that affect - this MongoDB resource. - properties: - agents: - description: Agents contains authentication configuration - properties for the agents + s3OpLogStores: + description: S3OplogStoreConfigs describes the list of s3 oplog + store configs used for backup. + items: + properties: + assignmentLabels: + description: Assignment Labels set in the Ops Manager + items: + type: string + type: array + customCertificate: + description: |- + Set this to "true" to use the appDBCa as a CA to access S3. + Deprecated: This has been replaced by CustomCertificateSecretRefs, + In the future all custom certificates, which includes the appDBCa + for s3Config should be configured in CustomCertificateSecretRefs instead. + type: boolean + customCertificateSecretRefs: + description: |- + CustomCertificateSecretRefs is a list of valid Certificate Authority certificate secrets + that apply to the associated S3 bucket. + items: + description: SecretKeySelector selects a key of a Secret. properties: - automationLdapGroupDN: - type: string - automationPasswordSecretRef: - description: SecretKeySelector selects a key of a - Secret. - properties: - key: - description: The key of the secret to select from. Must - be a valid secret key. - type: string - name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. - type: string - optional: - description: Specify whether the Secret or its - key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - automationUserName: + key: + description: The key of the secret to select from. Must + be a valid secret key. type: string - clientCertificateSecretRef: - type: object - x-kubernetes-preserve-unknown-fields: true - mode: - description: Mode is the desired Authentication mode - that the agents will use + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean required: - - mode + - key type: object - enabled: - type: boolean - ignoreUnknownUsers: - description: IgnoreUnknownUsers maps to the inverse of - auth.authoritativeSet - type: boolean - internalCluster: + x-kubernetes-map-type: atomic + type: array + irsaEnabled: + description: |- + This is only set to "true" when a user is running in EKS and is using AWS IRSA to configure + S3 snapshot store. For more details refer this: https://aws.amazon.com/blogs/opensource/introducing-fine-grained-iam-roles-service-accounts/ + type: boolean + mongodbResourceRef: + properties: + name: + type: string + namespace: + type: string + required: + - name + type: object + mongodbUserRef: + properties: + name: + type: string + required: + - name + type: object + name: + type: string + pathStyleAccessEnabled: + type: boolean + s3BucketEndpoint: + type: string + s3BucketName: + type: string + s3RegionOverride: + type: string + s3SecretRef: + description: |- + S3SecretRef is the secret that contains the AWS credentials used to access S3 + It is optional because the credentials can be provided via AWS IRSA + properties: + name: + type: string + required: + - name + type: object + required: + - name + - pathStyleAccessEnabled + - s3BucketEndpoint + - s3BucketName + type: object + type: array + s3Stores: + items: + properties: + assignmentLabels: + description: Assignment Labels set in the Ops Manager + items: type: string - ldap: - description: LDAP Configuration + type: array + customCertificate: + description: |- + Set this to "true" to use the appDBCa as a CA to access S3. + Deprecated: This has been replaced by CustomCertificateSecretRefs, + In the future all custom certificates, which includes the appDBCa + for s3Config should be configured in CustomCertificateSecretRefs instead. + type: boolean + customCertificateSecretRefs: + description: |- + CustomCertificateSecretRefs is a list of valid Certificate Authority certificate secrets + that apply to the associated S3 bucket. + items: + description: SecretKeySelector selects a key of a Secret. properties: - authzQueryTemplate: - type: string - bindQueryPasswordSecretRef: - properties: - name: - type: string - required: - - name - type: object - bindQueryUser: - type: string - caConfigMapRef: - description: Allows to point at a ConfigMap/key with - a CA file to mount on the Pod - properties: - key: - description: The key to select. - type: string - name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. - type: string - optional: - description: Specify whether the ConfigMap or - its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - servers: - items: - type: string - type: array - timeoutMS: - type: integer - transportSecurity: - enum: - - tls - - none + key: + description: The key of the secret to select from. Must + be a valid secret key. type: string - userCacheInvalidationInterval: - type: integer - userToDNMapping: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string - validateLDAPServerConfig: + optional: + description: Specify whether the Secret or its key + must be defined type: boolean + required: + - key type: object - modes: - items: - enum: - - X509 - - SCRAM - - SCRAM-SHA-1 - - MONGODB-CR - - SCRAM-SHA-256 - - LDAP - type: string - type: array - requireClientTLSAuthentication: - description: Clients should present valid TLS certificates - type: boolean - required: - - enabled - type: object - certsSecretPrefix: - type: string - roles: - items: + x-kubernetes-map-type: atomic + type: array + irsaEnabled: + description: |- + This is only set to "true" when a user is running in EKS and is using AWS IRSA to configure + S3 snapshot store. For more details refer this: https://aws.amazon.com/blogs/opensource/introducing-fine-grained-iam-roles-service-accounts/ + type: boolean + mongodbResourceRef: properties: - authenticationRestrictions: - items: - properties: - clientSource: - items: - type: string - type: array - serverAddress: - items: - type: string - type: array - type: object - type: array - db: + name: type: string - privileges: - items: - properties: - actions: - items: - type: string - type: array - resource: - properties: - cluster: - type: boolean - collection: - type: string - db: - type: string - type: object - required: - - actions - - resource - type: object - type: array - role: + namespace: type: string - roles: - items: - properties: - db: - type: string - role: - type: string - required: - - db - - role - type: object - type: array required: - - db - - role + - name type: object - type: array - tls: - properties: - additionalCertificateDomains: - items: + mongodbUserRef: + properties: + name: type: string - type: array - ca: - description: |- - CA corresponds to a ConfigMap containing an entry for the CA certificate (ca.pem) - used to validate the certificates created already. - type: string - enabled: - description: |- - DEPRECATED please enable TLS by setting `security.certsSecretPrefix` or `security.tls.secretRef.prefix`. - Enables TLS for this resource. This will make the operator try to mount a - Secret with a defined name (-cert). - This is only used when enabling TLS on a MongoDB resource, and not on the - AppDB, where TLS is configured by setting `secretRef.Name`. - type: boolean - type: object - type: object - service: - description: this is an optional service, it will get the name - "-svc" in case not provided - type: string - topology: - enum: - - SingleCluster - - MultiCluster - type: string - type: - enum: - - Standalone - - ReplicaSet - - ShardedCluster - type: string - version: - pattern: ^[0-9]+.[0-9]+.[0-9]+(-.+)?$|^$ - type: string + required: + - name + type: object + name: + type: string + pathStyleAccessEnabled: + type: boolean + s3BucketEndpoint: + type: string + s3BucketName: + type: string + s3RegionOverride: + type: string + s3SecretRef: + description: |- + S3SecretRef is the secret that contains the AWS credentials used to access S3 + It is optional because the credentials can be provided via AWS IRSA + properties: + name: + type: string + required: + - name + type: object + required: + - name + - pathStyleAccessEnabled + - s3BucketEndpoint + - s3BucketName + type: object + type: array + statefulSet: + description: |- + StatefulSetConfiguration holds the optional custom StatefulSet + that should be merged into the operator created one. + properties: + metadata: + description: StatefulSetMetadataWrapper is a wrapper around + Labels and Annotations + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + type: object + spec: + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object required: - - version + - enabled type: object - backup: - description: Backup - properties: - assignmentLabels: - description: Assignment Labels set in the Ops Manager - items: - type: string - type: array - blockStores: - items: + clusterDomain: + format: hostname + type: string + clusterName: + description: |- + Deprecated: This has been replaced by the ClusterDomain which should be + used instead + format: hostname + type: string + clusterSpecList: + items: + description: ClusterSpecOMItem defines members cluster details for + Ops Manager multi-cluster deployment. + properties: + backup: description: |- - DataStoreConfig is the description of the config used to reference to database. Reused by Oplog and Block stores - Optionally references the user if the Mongodb is configured with authentication + Backup contains settings to override from top-level `spec.backup` for this member cluster. + If the value is not set here, then the value is taken from `spec.backup`. properties: assignmentLabels: description: Assignment Labels set in the Ops Manager items: type: string type: array - mongodbResourceRef: + headDB: + description: HeadDB specifies configuration options for + the HeadDB properties: - name: + labelSelector: + type: object + x-kubernetes-preserve-unknown-fields: true + storage: type: string - namespace: + storageClass: type: string - required: - - name type: object - mongodbUserRef: + jvmParameters: + items: + type: string + type: array + members: + description: Members indicate the number of backup daemon + pods to create. + minimum: 0 + type: integer + statefulSet: + description: StatefulSetConfiguration specified optional + overrides for backup datemon statefulset. properties: - name: - type: string + metadata: + description: StatefulSetMetadataWrapper is a wrapper + around Labels and Annotations + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + type: object + spec: + type: object + x-kubernetes-preserve-unknown-fields: true required: - - name + - spec type: object - name: + type: object + clusterDomain: + description: Cluster domain to override the default *.svc.cluster.local + if the default cluster domain has been changed on a cluster + level. + format: hostname + type: string + clusterName: + description: |- + ClusterName is name of the cluster where the Ops Manager Statefulset will be scheduled. + The operator is using ClusterName to find API credentials in `mongodb-enterprise-operator-member-list` config map to use for this member cluster. + If the credentials are not found, then the member cluster is considered unreachable and ignored in the reconcile process. + type: string + configuration: + additionalProperties: + type: string + description: |- + The configuration properties passed to Ops Manager and Backup Daemon in this cluster. + If specified (not empty) then this field overrides `spec.configuration` field entirely. + If not specified, then `spec.configuration` field is used for the Ops Manager and Backup Daemon instances in this cluster. + type: object + externalConnectivity: + description: |- + MongoDBOpsManagerExternalConnectivity if sets allows for the creation of a Service for + accessing Ops Manager instances in this member cluster from outside the Kubernetes cluster. + If specified (even if provided empty) then this field overrides `spec.externalConnectivity` field entirely. + If not specified, then `spec.externalConnectivity` field is used for the Ops Manager and Backup Daemon instances in this cluster. + properties: + annotations: + additionalProperties: + type: string + description: Annotations is a list of annotations to be + directly passed to the Service object. + type: object + clusterIP: + description: ClusterIP IP that will be assigned to this + Service when creating a ClusterIP type Service + type: string + externalTrafficPolicy: + description: |- + ExternalTrafficPolicy mechanism to preserve the client source IP. + Only supported on GCE and Google Kubernetes Engine. + enum: + - Cluster + - Local + type: string + loadBalancerIP: + description: LoadBalancerIP IP that will be assigned to + this LoadBalancer. + type: string + port: + description: Port in which this `Service` will listen to, + this applies to `NodePort`. + format: int32 + type: integer + type: + description: Type of the `Service` to be created. + enum: + - LoadBalancer + - NodePort + - ClusterIP type: string required: - - mongodbResourceRef - - name + - type type: object - type: array - enabled: - description: Enabled indicates if Backups will be enabled for - this Ops Manager. - type: boolean - encryption: - description: Encryption settings - properties: - kmip: - description: Kmip corresponds to the KMIP configuration assigned - to the Ops Manager Project's configuration. - properties: - server: - description: KMIP Server configuration - properties: - ca: - description: |- - CA corresponds to a ConfigMap containing an entry for the CA certificate (ca.pem) - used for KMIP authentication + jvmParameters: + description: |- + JVM parameters to pass to Ops Manager and Backup Daemon instances in this member cluster. + If specified (not empty) then this field overrides `spec.jvmParameters` field entirely. + If not specified, then `spec.jvmParameters` field is used for the Ops Manager and Backup Daemon instances in this cluster. + items: + type: string + type: array + members: + description: Number of Ops Manager instances in this member + cluster. + type: integer + statefulSet: + description: |- + Configure custom StatefulSet configuration to override in Ops Manager's statefulset in this member cluster. + If specified (even if provided empty) then this field overrides `spec.externalConnectivity` field entirely. + If not specified, then `spec.externalConnectivity` field is used for the Ops Manager and Backup Daemon instances in this cluster. + properties: + metadata: + description: StatefulSetMetadataWrapper is a wrapper around + Labels and Annotations + properties: + annotations: + additionalProperties: type: string - url: - description: |- - KMIP Server url in the following format: hostname:port - Valid examples are: - 10.10.10.3:5696 - my-kmip-server.mycorp.com:5696 - kmip-svc.svc.cluster.local:5696 - pattern: '[^\:]+:[0-9]{0,5}' + type: object + labels: + additionalProperties: type: string - required: - - ca - - url - type: object - required: - - server - type: object + type: object + type: object + spec: + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + required: + - members + type: object + type: array + configuration: + additionalProperties: + type: string + description: The configuration properties passed to Ops Manager/Backup + Daemon + type: object + externalConnectivity: + description: |- + MongoDBOpsManagerExternalConnectivity if sets allows for the creation of a Service for + accessing this Ops Manager resource from outside the Kubernetes cluster. + properties: + annotations: + additionalProperties: + type: string + description: Annotations is a list of annotations to be directly + passed to the Service object. + type: object + clusterIP: + description: ClusterIP IP that will be assigned to this Service + when creating a ClusterIP type Service + type: string + externalTrafficPolicy: + description: |- + ExternalTrafficPolicy mechanism to preserve the client source IP. + Only supported on GCE and Google Kubernetes Engine. + enum: + - Cluster + - Local + type: string + loadBalancerIP: + description: LoadBalancerIP IP that will be assigned to this LoadBalancer. + type: string + port: + description: Port in which this `Service` will listen to, this + applies to `NodePort`. + format: int32 + type: integer + type: + description: Type of the `Service` to be created. + enum: + - LoadBalancer + - NodePort + - ClusterIP + type: string + required: + - type + type: object + internalConnectivity: + description: |- + InternalConnectivity if set allows for overriding the settings of the default service + used for internal connectivity to the OpsManager servers. + properties: + annotations: + additionalProperties: + type: string + description: Annotations is a list of annotations to be directly + passed to the Service object. type: object - externalServiceEnabled: - type: boolean - fileSystemStores: - items: - properties: - name: - type: string - required: - - name - type: object - type: array - headDB: - description: HeadDB specifies configuration options for the HeadDB + clusterIP: + description: ClusterIP IP that will be assigned to this Service + when creating a ClusterIP type Service + type: string + externalTrafficPolicy: + description: |- + ExternalTrafficPolicy mechanism to preserve the client source IP. + Only supported on GCE and Google Kubernetes Engine. + enum: + - Cluster + - Local + type: string + loadBalancerIP: + description: LoadBalancerIP IP that will be assigned to this LoadBalancer. + type: string + port: + description: Port in which this `Service` will listen to, this + applies to `NodePort`. + format: int32 + type: integer + type: + description: Type of the `Service` to be created. + enum: + - LoadBalancer + - NodePort + - ClusterIP + type: string + required: + - type + type: object + jvmParameters: + description: Custom JVM parameters passed to the Ops Manager JVM + items: + type: string + type: array + logging: + properties: + LogBackAccessRef: + description: LogBackAccessRef points at a ConfigMap/key with the + logback access configuration file to mount on the Pod properties: - labelSelector: - type: object - x-kubernetes-preserve-unknown-fields: true - storage: + name: type: string - storageClass: + type: object + LogBackRef: + description: LogBackRef points at a ConfigMap/key with the logback + configuration file to mount on the Pod + properties: + name: type: string type: object - jvmParameters: - items: - type: string - type: array - logging: + type: object + opsManagerURL: + description: |- + OpsManagerURL specified the URL with which the operator and AppDB monitoring agent should access Ops Manager instance (or instances). + When not set, the operator is using FQDN of Ops Manager's headless service `{name}-svc.{namespace}.svc.cluster.local` to connect to the instance. If that URL cannot be used, then URL in this field should be provided for the operator to connect to Ops Manager instances. + type: string + replicas: + minimum: 1 + type: integer + security: + description: Configure HTTPS. + properties: + certsSecretPrefix: + type: string + tls: properties: - LogBackAccessRef: - description: LogBackAccessRef points at a ConfigMap/key with - the logback access configuration file to mount on the Pod + ca: + type: string + secretRef: properties: name: type: string + required: + - name type: object - LogBackRef: - description: LogBackRef points at a ConfigMap/key with the - logback configuration file to mount on the Pod - properties: - name: - type: string + type: object + type: object + statefulSet: + description: Configure custom StatefulSet configuration + properties: + metadata: + description: StatefulSetMetadataWrapper is a wrapper around Labels + and Annotations + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string type: object type: object - members: - description: Members indicate the number of backup daemon pods - to create. - minimum: 1 - type: integer - opLogStores: - description: OplogStoreConfigs describes the list of oplog store - configs used for backup + spec: + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + topology: + description: |- + Topology sets the desired cluster topology of Ops Manager deployment. + It defaults (and if not set) to SingleCluster. If MultiCluster specified, + then clusterSpecList field is mandatory and at least one member cluster has to be specified. + enum: + - SingleCluster + - MultiCluster + type: string + version: + type: string + required: + - applicationDatabase + - version + type: object + status: + properties: + applicationDatabase: + properties: + backup: + properties: + statusName: + type: string + required: + - statusName + type: object + clusterStatusList: items: - description: |- - DataStoreConfig is the description of the config used to reference to database. Reused by Oplog and Block stores - Optionally references the user if the Mongodb is configured with authentication properties: - assignmentLabels: - description: Assignment Labels set in the Ops Manager - items: - type: string - type: array - mongodbResourceRef: - properties: - name: - type: string - namespace: - type: string - required: - - name - type: object - mongodbUserRef: - properties: - name: - type: string - required: - - name - type: object - name: + clusterName: type: string - required: - - mongodbResourceRef - - name + members: + type: integer type: object type: array - queryableBackupSecretRef: - description: |- - QueryableBackupSecretRef references the secret which contains the pem file which is used - for queryable backup. This will be mounted into the Ops Manager pod. - properties: - name: - type: string - required: - - name - type: object - s3OpLogStores: - description: S3OplogStoreConfigs describes the list of s3 oplog - store configs used for backup. + configServerCount: + type: integer + featureCompatibilityVersion: + type: string + lastTransition: + type: string + link: + type: string + members: + type: integer + message: + type: string + mongodsPerShardCount: + type: integer + mongosCount: + type: integer + observedGeneration: + format: int64 + type: integer + phase: + type: string + pvc: + items: + properties: + phase: + type: string + statefulsetName: + type: string + required: + - phase + - statefulsetName + type: object + type: array + resourcesNotReady: items: + description: ResourceNotReady describes the dependent resource + which is not ready yet properties: - assignmentLabels: - description: Assignment Labels set in the Ops Manager - items: - type: string - type: array - customCertificate: - description: |- - Set this to "true" to use the appDBCa as a CA to access S3. - Deprecated: This has been replaced by CustomCertificateSecretRefs, - In the future all custom certificates, which includes the appDBCa - for s3Config should be configured in CustomCertificateSecretRefs instead. - type: boolean - customCertificateSecretRefs: - description: |- - CustomCertificateSecretRefs is a list of valid Certificate Authority certificate secrets - that apply to the associated S3 bucket. + errors: items: - description: SecretKeySelector selects a key of a Secret. properties: - key: - description: The key of the secret to select from. Must - be a valid secret key. + message: type: string - name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + reason: type: string - optional: - description: Specify whether the Secret or its key - must be defined - type: boolean - required: - - key type: object - x-kubernetes-map-type: atomic type: array - irsaEnabled: - description: |- - This is only set to "true" when a user is running in EKS and is using AWS IRSA to configure - S3 snapshot store. For more details refer this: https://aws.amazon.com/blogs/opensource/introducing-fine-grained-iam-roles-service-accounts/ - type: boolean - mongodbResourceRef: - properties: - name: - type: string - namespace: - type: string - required: - - name - type: object - mongodbUserRef: - properties: - name: - type: string - required: - - name - type: object + kind: + description: ResourceKind specifies a kind of a Kubernetes + resource. Used in status of a Custom Resource + type: string + message: + type: string name: type: string - pathStyleAccessEnabled: - type: boolean - s3BucketEndpoint: + required: + - kind + - name + type: object + type: array + shardCount: + type: integer + sizeStatusInClusters: + description: MongodbShardedSizeStatusInClusters describes the + number and sizes of replica sets members deployed across member + clusters + properties: + configServerMongodsInClusters: + additionalProperties: + type: integer + type: object + mongosCountInClusters: + additionalProperties: + type: integer + type: object + shardMongodsInClusters: + additionalProperties: + type: integer + type: object + shardOverridesInClusters: + additionalProperties: + additionalProperties: + type: integer + type: object + type: object + type: object + version: + type: string + warnings: + items: + type: string + type: array + required: + - phase + - version + type: object + backup: + properties: + clusterStatusList: + items: + properties: + clusterName: type: string - s3BucketName: + replicas: + type: integer + type: object + type: array + lastTransition: + type: string + message: + type: string + observedGeneration: + format: int64 + type: integer + phase: + type: string + pvc: + items: + properties: + phase: type: string - s3RegionOverride: + statefulsetName: type: string - s3SecretRef: - description: |- - S3SecretRef is the secret that contains the AWS credentials used to access S3 - It is optional because the credentials can be provided via AWS IRSA - properties: - name: - type: string - required: - - name - type: object required: - - name - - pathStyleAccessEnabled - - s3BucketEndpoint - - s3BucketName + - phase + - statefulsetName type: object type: array - s3Stores: + resourcesNotReady: items: + description: ResourceNotReady describes the dependent resource + which is not ready yet properties: - assignmentLabels: - description: Assignment Labels set in the Ops Manager - items: - type: string - type: array - customCertificate: - description: |- - Set this to "true" to use the appDBCa as a CA to access S3. - Deprecated: This has been replaced by CustomCertificateSecretRefs, - In the future all custom certificates, which includes the appDBCa - for s3Config should be configured in CustomCertificateSecretRefs instead. - type: boolean - customCertificateSecretRefs: - description: |- - CustomCertificateSecretRefs is a list of valid Certificate Authority certificate secrets - that apply to the associated S3 bucket. + errors: items: - description: SecretKeySelector selects a key of a Secret. properties: - key: - description: The key of the secret to select from. Must - be a valid secret key. + message: type: string - name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + reason: type: string - optional: - description: Specify whether the Secret or its key - must be defined - type: boolean - required: - - key type: object - x-kubernetes-map-type: atomic type: array - irsaEnabled: - description: |- - This is only set to "true" when a user is running in EKS and is using AWS IRSA to configure - S3 snapshot store. For more details refer this: https://aws.amazon.com/blogs/opensource/introducing-fine-grained-iam-roles-service-accounts/ - type: boolean - mongodbResourceRef: - properties: - name: - type: string - namespace: - type: string - required: - - name - type: object - mongodbUserRef: - properties: - name: - type: string - required: - - name - type: object - name: - type: string - pathStyleAccessEnabled: - type: boolean - s3BucketEndpoint: + kind: + description: ResourceKind specifies a kind of a Kubernetes + resource. Used in status of a Custom Resource type: string - s3BucketName: + message: type: string - s3RegionOverride: + name: type: string - s3SecretRef: - description: |- - S3SecretRef is the secret that contains the AWS credentials used to access S3 - It is optional because the credentials can be provided via AWS IRSA - properties: - name: - type: string - required: - - name - type: object required: - - name - - pathStyleAccessEnabled - - s3BucketEndpoint - - s3BucketName + - kind + - name type: object type: array - statefulSet: - description: |- - StatefulSetConfiguration holds the optional custom StatefulSet - that should be merged into the operator created one. - properties: - metadata: - description: StatefulSetMetadataWrapper is a wrapper around - Labels and Annotations - properties: - annotations: - additionalProperties: - type: string - type: object - labels: - additionalProperties: - type: string - type: object - type: object - spec: - type: object - x-kubernetes-preserve-unknown-fields: true - required: - - spec - type: object + version: + type: string + warnings: + items: + type: string + type: array required: - - enabled + - phase type: object - clusterDomain: - format: hostname - type: string - clusterName: - description: |- - Deprecated: This has been replaced by the ClusterDomain which should be - used instead - format: hostname - type: string - clusterSpecList: - items: - description: ClusterSpecOMItem defines members cluster details for - Ops Manager multi-cluster deployment. - properties: - backup: - description: |- - Backup contains settings to override from top-level `spec.backup` for this member cluster. - If the value is not set here, then the value is taken from `spec.backup`. + opsManager: + properties: + clusterStatusList: + items: properties: - assignmentLabels: - description: Assignment Labels set in the Ops Manager - items: - type: string - type: array - headDB: - description: HeadDB specifies configuration options for - the HeadDB - properties: - labelSelector: - type: object - x-kubernetes-preserve-unknown-fields: true - storage: - type: string - storageClass: - type: string - type: object - jvmParameters: - items: - type: string - type: array - members: - description: Members indicate the number of backup daemon - pods to create. - minimum: 0 + clusterName: + type: string + replicas: type: integer - statefulSet: - description: StatefulSetConfiguration specified optional - overrides for backup datemon statefulset. - properties: - metadata: - description: StatefulSetMetadataWrapper is a wrapper - around Labels and Annotations - properties: - annotations: - additionalProperties: - type: string - type: object - labels: - additionalProperties: - type: string - type: object - type: object - spec: - type: object - x-kubernetes-preserve-unknown-fields: true - required: - - spec - type: object - type: object - clusterDomain: - description: Cluster domain to override the default *.svc.cluster.local - if the default cluster domain has been changed on a cluster - level. - format: hostname - type: string - clusterName: - description: |- - ClusterName is name of the cluster where the Ops Manager Statefulset will be scheduled. - The operator is using ClusterName to find API credentials in `mongodb-enterprise-operator-member-list` config map to use for this member cluster. - If the credentials are not found, then the member cluster is considered unreachable and ignored in the reconcile process. - type: string - configuration: - additionalProperties: - type: string - description: |- - The configuration properties passed to Ops Manager and Backup Daemon in this cluster. - If specified (not empty) then this field overrides `spec.configuration` field entirely. - If not specified, then `spec.configuration` field is used for the Ops Manager and Backup Daemon instances in this cluster. type: object - externalConnectivity: - description: |- - MongoDBOpsManagerExternalConnectivity if sets allows for the creation of a Service for - accessing Ops Manager instances in this member cluster from outside the Kubernetes cluster. - If specified (even if provided empty) then this field overrides `spec.externalConnectivity` field entirely. - If not specified, then `spec.externalConnectivity` field is used for the Ops Manager and Backup Daemon instances in this cluster. + type: array + lastTransition: + type: string + message: + type: string + observedGeneration: + format: int64 + type: integer + phase: + type: string + pvc: + items: properties: - annotations: - additionalProperties: - type: string - description: Annotations is a list of annotations to be - directly passed to the Service object. - type: object - clusterIP: - description: ClusterIP IP that will be assigned to this - Service when creating a ClusterIP type Service - type: string - externalTrafficPolicy: - description: |- - ExternalTrafficPolicy mechanism to preserve the client source IP. - Only supported on GCE and Google Kubernetes Engine. - enum: - - Cluster - - Local - type: string - loadBalancerIP: - description: LoadBalancerIP IP that will be assigned to - this LoadBalancer. + phase: type: string - port: - description: Port in which this `Service` will listen to, - this applies to `NodePort`. - format: int32 - type: integer - type: - description: Type of the `Service` to be created. - enum: - - LoadBalancer - - NodePort - - ClusterIP + statefulsetName: type: string required: - - type + - phase + - statefulsetName type: object - jvmParameters: - description: |- - JVM parameters to pass to Ops Manager and Backup Daemon instances in this member cluster. - If specified (not empty) then this field overrides `spec.jvmParameters` field entirely. - If not specified, then `spec.jvmParameters` field is used for the Ops Manager and Backup Daemon instances in this cluster. - items: - type: string - type: array - members: - description: Number of Ops Manager instances in this member - cluster. - type: integer - statefulSet: - description: |- - Configure custom StatefulSet configuration to override in Ops Manager's statefulset in this member cluster. - If specified (even if provided empty) then this field overrides `spec.externalConnectivity` field entirely. - If not specified, then `spec.externalConnectivity` field is used for the Ops Manager and Backup Daemon instances in this cluster. + type: array + replicas: + type: integer + resourcesNotReady: + items: + description: ResourceNotReady describes the dependent resource + which is not ready yet properties: - metadata: - description: StatefulSetMetadataWrapper is a wrapper around - Labels and Annotations - properties: - annotations: - additionalProperties: + errors: + items: + properties: + message: type: string - type: object - labels: - additionalProperties: + reason: type: string - type: object - type: object - spec: - type: object - x-kubernetes-preserve-unknown-fields: true + type: object + type: array + kind: + description: ResourceKind specifies a kind of a Kubernetes + resource. Used in status of a Custom Resource + type: string + message: + type: string + name: + type: string required: - - spec + - kind + - name type: object - required: - - members - type: object - type: array - configuration: - additionalProperties: - type: string - description: The configuration properties passed to Ops Manager/Backup - Daemon + type: array + url: + type: string + version: + type: string + warnings: + items: + type: string + type: array + required: + - phase type: object - externalConnectivity: + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.15.0 + service.binding: path={.metadata.name}-{.spec.users[0].db}-{.spec.users[0].name},objectType=Secret + service.binding/connectionString: path={.metadata.name}-{.spec.users[0].db}-{.spec.users[0].name},objectType=Secret,sourceKey=connectionString.standardSrv + service.binding/password: path={.metadata.name}-{.spec.users[0].db}-{.spec.users[0].name},objectType=Secret,sourceKey=password + service.binding/provider: community + service.binding/type: mongodb + service.binding/username: path={.metadata.name}-{.spec.users[0].db}-{.spec.users[0].name},objectType=Secret,sourceKey=username + name: mongodbcommunity.mongodbcommunity.mongodb.com +spec: + group: mongodbcommunity.mongodb.com + names: + kind: MongoDBCommunity + listKind: MongoDBCommunityList + plural: mongodbcommunity + shortNames: + - mdbc + singular: mongodbcommunity + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: Current state of the MongoDB deployment + jsonPath: .status.phase + name: Phase + type: string + - description: Version of MongoDB server + jsonPath: .status.version + name: Version + type: string + name: v1 + schema: + openAPIV3Schema: + description: MongoDBCommunity is the Schema for the mongodbs API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: MongoDBCommunitySpec defines the desired state of MongoDB + properties: + additionalConnectionStringConfig: + description: Additional options to be appended to the connection string. + These options apply to the entire resource and to each user. + nullable: true + type: object + x-kubernetes-preserve-unknown-fields: true + additionalMongodConfig: description: |- - MongoDBOpsManagerExternalConnectivity if sets allows for the creation of a Service for - accessing this Ops Manager resource from outside the Kubernetes cluster. + AdditionalMongodConfig is additional configuration that can be passed to + each data-bearing mongod at runtime. Uses the same structure as the mongod + configuration file: https://www.mongodb.com/docs/manual/reference/configuration-options/ + nullable: true + type: object + x-kubernetes-preserve-unknown-fields: true + agent: + description: AgentConfiguration sets options for the MongoDB automation + agent properties: - annotations: - additionalProperties: - type: string - description: Annotations is a list of annotations to be directly - passed to the Service object. + auditLogRotate: + description: AuditLogRotate if enabled, will enable AuditLogRotate + for all processes. + properties: + includeAuditLogsWithMongoDBLogs: + description: |- + set to 'true' to have the Automation Agent rotate the audit files along + with mongodb log files + type: boolean + numTotal: + description: maximum number of log files to have total + type: integer + numUncompressed: + description: maximum number of log files to leave uncompressed + type: integer + percentOfDiskspace: + description: |- + Maximum percentage of the total disk space these log files should take up. + The string needs to be able to be converted to float64 + type: string + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + The string needs to be able to be converted to float64. + Fractional values of MB are supported. + type: string + timeThresholdHrs: + description: maximum hours for an individual log file before + rotation + type: integer + required: + - sizeThresholdMB + - timeThresholdHrs type: object - clusterIP: - description: ClusterIP IP that will be assigned to this Service - when creating a ClusterIP type Service - type: string - externalTrafficPolicy: - description: |- - ExternalTrafficPolicy mechanism to preserve the client source IP. - Only supported on GCE and Google Kubernetes Engine. - enum: - - Cluster - - Local + logFile: type: string - loadBalancerIP: - description: LoadBalancerIP IP that will be assigned to this LoadBalancer. + logLevel: type: string - port: - description: Port in which this `Service` will listen to, this - applies to `NodePort`. - format: int32 + logRotate: + description: LogRotate if enabled, will enable LogRotate for all + processes. + properties: + includeAuditLogsWithMongoDBLogs: + description: |- + set to 'true' to have the Automation Agent rotate the audit files along + with mongodb log files + type: boolean + numTotal: + description: maximum number of log files to have total + type: integer + numUncompressed: + description: maximum number of log files to leave uncompressed + type: integer + percentOfDiskspace: + description: |- + Maximum percentage of the total disk space these log files should take up. + The string needs to be able to be converted to float64 + type: string + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + The string needs to be able to be converted to float64. + Fractional values of MB are supported. + type: string + timeThresholdHrs: + description: maximum hours for an individual log file before + rotation + type: integer + required: + - sizeThresholdMB + - timeThresholdHrs + type: object + maxLogFileDurationHours: type: integer - type: - description: Type of the `Service` to be created. - enum: - - LoadBalancer - - NodePort - - ClusterIP - type: string - required: - - type + systemLog: + description: SystemLog configures system log of mongod + properties: + destination: + type: string + logAppend: + type: boolean + path: + type: string + required: + - destination + - logAppend + - path + type: object type: object - internalConnectivity: + arbiters: description: |- - InternalConnectivity if set allows for overriding the settings of the default service - used for internal connectivity to the OpsManager servers. + Arbiters is the number of arbiters to add to the Replica Set. + It is not recommended to have more than one arbiter per Replica Set. + More info: https://www.mongodb.com/docs/manual/tutorial/add-replica-set-arbiter/ + type: integer + automationConfig: + description: |- + AutomationConfigOverride is merged on top of the operator created automation config. Processes are merged + by name. Currently Only the process.disabled field is supported. properties: - annotations: - additionalProperties: - type: string - description: Annotations is a list of annotations to be directly - passed to the Service object. + processes: + items: + description: OverrideProcess contains fields that we can override + on the AutomationConfig processes. + properties: + disabled: + type: boolean + logRotate: + description: CrdLogRotate is the crd definition of LogRotate + including fields in strings while the agent supports them + as float64 + properties: + includeAuditLogsWithMongoDBLogs: + description: |- + set to 'true' to have the Automation Agent rotate the audit files along + with mongodb log files + type: boolean + numTotal: + description: maximum number of log files to have total + type: integer + numUncompressed: + description: maximum number of log files to leave uncompressed + type: integer + percentOfDiskspace: + description: |- + Maximum percentage of the total disk space these log files should take up. + The string needs to be able to be converted to float64 + type: string + sizeThresholdMB: + description: |- + Maximum size for an individual log file before rotation. + The string needs to be able to be converted to float64. + Fractional values of MB are supported. + type: string + timeThresholdHrs: + description: maximum hours for an individual log file + before rotation + type: integer + required: + - sizeThresholdMB + - timeThresholdHrs + type: object + name: + type: string + required: + - disabled + - name + type: object + type: array + replicaSet: + properties: + id: + description: |- + Id can be used together with additionalMongodConfig.replication.replSetName + to manage clusters where replSetName differs from the MongoDBCommunity resource name + type: string + settings: + description: |- + MapWrapper is a wrapper for a map to be used by other structs. + The CRD generator does not support map[string]interface{} + on the top level and hence we need to work around this with + a wrapping struct. + type: object + x-kubernetes-preserve-unknown-fields: true type: object - clusterIP: - description: ClusterIP IP that will be assigned to this Service - when creating a ClusterIP type Service - type: string - externalTrafficPolicy: - description: |- - ExternalTrafficPolicy mechanism to preserve the client source IP. - Only supported on GCE and Google Kubernetes Engine. - enum: - - Cluster - - Local - type: string - loadBalancerIP: - description: LoadBalancerIP IP that will be assigned to this LoadBalancer. - type: string - port: - description: Port in which this `Service` will listen to, this - applies to `NodePort`. - format: int32 - type: integer - type: - description: Type of the `Service` to be created. - enum: - - LoadBalancer - - NodePort - - ClusterIP - type: string - required: - - type type: object - jvmParameters: - description: Custom JVM parameters passed to the Ops Manager JVM + featureCompatibilityVersion: + description: |- + FeatureCompatibilityVersion configures the feature compatibility version that will + be set for the deployment + type: string + memberConfig: + description: MemberConfig items: - type: string + properties: + priority: + type: string + tags: + additionalProperties: + type: string + type: object + votes: + type: integer + type: object type: array - logging: + members: + description: Members is the number of members in the replica set + type: integer + prometheus: + description: Prometheus configurations. properties: - LogBackAccessRef: - description: LogBackAccessRef points at a ConfigMap/key with the - logback access configuration file to mount on the Pod + metricsPath: + description: Indicates path to the metrics endpoint. + pattern: ^\/[a-z0-9]+$ + type: string + passwordSecretRef: + description: Name of a Secret containing a HTTP Basic Auth Password. properties: + key: + description: Key is the key in the secret storing this password. + Defaults to "password" + type: string name: + description: Name is the name of the secret storing this user's + password type: string + required: + - name type: object - LogBackRef: - description: LogBackRef points at a ConfigMap/key with the logback - configuration file to mount on the Pod + port: + description: Port where metrics endpoint will bind to. Defaults + to 9216. + type: integer + tlsSecretKeyRef: + description: |- + Name of a Secret (type kubernetes.io/tls) holding the certificates to use in the + Prometheus endpoint. properties: + key: + description: Key is the key in the secret storing this password. + Defaults to "password" + type: string name: + description: Name is the name of the secret storing this user's + password type: string + required: + - name type: object + username: + description: HTTP Basic Auth Username for metrics endpoint. + type: string + required: + - passwordSecretRef + - username type: object - opsManagerURL: + replicaSetHorizons: description: |- - OpsManagerURL specified the URL with which the operator and AppDB monitoring agent should access Ops Manager instance (or instances). - When not set, the operator is using FQDN of Ops Manager's headless service `{name}-svc.{namespace}.svc.cluster.local` to connect to the instance. If that URL cannot be used, then URL in this field should be provided for the operator to connect to Ops Manager instances. - type: string - replicas: - minimum: 1 - type: integer + ReplicaSetHorizons Add this parameter and values if you need your database + to be accessed outside of Kubernetes. This setting allows you to + provide different DNS settings within the Kubernetes cluster and + to the Kubernetes cluster. The Kubernetes Operator uses split horizon + DNS for replica set members. This feature allows communication both + within the Kubernetes cluster and from outside Kubernetes. + items: + additionalProperties: + type: string + type: object + type: array security: - description: Configure HTTPS. + description: Security configures security features, such as TLS, and + authentication settings for a deployment properties: - certsSecretPrefix: - type: string - tls: + authentication: properties: - ca: - type: string - secretRef: + agentCertificateSecretRef: + description: |- + AgentCertificateSecret is a reference to a Secret containing the certificate and the key for the automation agent + The secret needs to have available: + - certificate under key: "tls.crt" + - private key under key: "tls.key" + If additionally, tls.pem is present, then it needs to be equal to the concatenation of tls.crt and tls.key properties: name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string - required: - - name - type: object - type: object - type: object - statefulSet: - description: Configure custom StatefulSet configuration - properties: - metadata: - description: StatefulSetMetadataWrapper is a wrapper around Labels - and Annotations - properties: - annotations: - additionalProperties: - type: string - type: object - labels: - additionalProperties: - type: string type: object - type: object - spec: - type: object - x-kubernetes-preserve-unknown-fields: true - required: - - spec - type: object - topology: - description: |- - Topology sets the desired cluster topology of Ops Manager deployment. - It defaults (and if not set) to SingleCluster. If MultiCluster specified, - then clusterSpecList field is mandatory and at least one member cluster has to be specified. - enum: - - SingleCluster - - MultiCluster - type: string - version: - type: string - required: - - applicationDatabase - - version - type: object - status: - properties: - applicationDatabase: - properties: - backup: - properties: - statusName: + x-kubernetes-map-type: atomic + agentMode: + description: AgentMode contains the authentication mode used + by the automation agent. + enum: + - SCRAM + - SCRAM-SHA-256 + - SCRAM-SHA-1 + - X509 type: string - required: - - statusName - type: object - clusterStatusList: - items: - properties: - clusterName: - type: string - members: - type: integer - type: object - type: array - configServerCount: - type: integer - featureCompatibilityVersion: - type: string - lastTransition: - type: string - link: - type: string - members: - type: integer - message: - type: string - mongodsPerShardCount: - type: integer - mongosCount: - type: integer - observedGeneration: - format: int64 - type: integer - phase: - type: string - pvc: - items: - properties: - phase: - type: string - statefulsetName: - type: string - required: - - phase - - statefulsetName - type: object - type: array - resourcesNotReady: - items: - description: ResourceNotReady describes the dependent resource - which is not ready yet - properties: - errors: - items: - properties: - message: - type: string - reason: - type: string - type: object - type: array - kind: - description: ResourceKind specifies a kind of a Kubernetes - resource. Used in status of a Custom Resource - type: string - message: - type: string - name: - type: string - required: - - kind - - name - type: object - type: array - shardCount: - type: integer - sizeStatusInClusters: - description: MongodbShardedSizeStatusInClusters describes the - number and sizes of replica sets members deployed across member - clusters - properties: - configServerMongodsInClusters: - additionalProperties: - type: integer - type: object - mongosCountInClusters: - additionalProperties: - type: integer - type: object - shardMongodsInClusters: - additionalProperties: - type: integer - type: object - shardOverridesInClusters: - additionalProperties: - additionalProperties: - type: integer - type: object - type: object - type: object - version: - type: string - warnings: - items: - type: string - type: array - required: - - phase - - version - type: object - backup: - properties: - clusterStatusList: - items: - properties: - clusterName: + ignoreUnknownUsers: + default: true + nullable: true + type: boolean + modes: + description: Modes is an array specifying which authentication + methods should be enabled. + items: + enum: + - SCRAM + - SCRAM-SHA-256 + - SCRAM-SHA-1 + - X509 type: string - replicas: - type: integer - type: object - type: array - lastTransition: - type: string - message: - type: string - observedGeneration: - format: int64 - type: integer - phase: - type: string - pvc: + type: array + required: + - modes + type: object + roles: + description: User-specified custom MongoDB roles that should be + configured in the deployment. items: + description: CustomRole defines a custom MongoDB role. properties: - phase: + authenticationRestrictions: + description: The authentication restrictions the server + enforces on the role. + items: + description: |- + AuthenticationRestriction specifies a list of IP addresses and CIDR ranges users + are allowed to connect to or from. + properties: + clientSource: + items: + type: string + type: array + serverAddress: + items: + type: string + type: array + required: + - clientSource + - serverAddress + type: object + type: array + db: + description: The database of the role. type: string - statefulsetName: + privileges: + description: The privileges to grant the role. + items: + description: Privilege defines the actions a role is allowed + to perform on a given resource. + properties: + actions: + items: + type: string + type: array + resource: + description: |- + Resource specifies specifies the resources upon which a privilege permits actions. + See https://www.mongodb.com/docs/manual/reference/resource-document for more. + properties: + anyResource: + type: boolean + cluster: + type: boolean + collection: + type: string + db: + type: string + type: object + required: + - actions + - resource + type: object + type: array + role: + description: The name of the role. type: string - required: - - phase - - statefulsetName - type: object - type: array - resourcesNotReady: - items: - description: ResourceNotReady describes the dependent resource - which is not ready yet - properties: - errors: + roles: + description: An array of roles from which this role inherits + privileges. items: + description: Role is the database role this user should + have properties: - message: + db: + description: DB is the database the role can act on type: string - reason: + name: + description: Name is the name of the role type: string + required: + - db + - name type: object type: array - kind: - description: ResourceKind specifies a kind of a Kubernetes - resource. Used in status of a Custom Resource - type: string - message: - type: string - name: - type: string required: - - kind - - name + - db + - privileges + - role type: object type: array - version: - type: string - warnings: - items: - type: string - type: array - required: - - phase + tls: + description: TLS configuration for both client-server and server-server + communication + properties: + caCertificateSecretRef: + description: |- + CaCertificateSecret is a reference to a Secret containing the certificate for the CA which signed the server certificates + The certificate is expected to be available under the key "ca.crt" + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + type: object + x-kubernetes-map-type: atomic + caConfigMapRef: + description: |- + CaConfigMap is a reference to a ConfigMap containing the certificate for the CA which signed the server certificates + The certificate is expected to be available under the key "ca.crt" + This field is ignored when CaCertificateSecretRef is configured + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + type: object + x-kubernetes-map-type: atomic + certificateKeySecretRef: + description: |- + CertificateKeySecret is a reference to a Secret containing a private key and certificate to use for TLS. + The key and cert are expected to be PEM encoded and available at "tls.key" and "tls.crt". + This is the same format used for the standard "kubernetes.io/tls" Secret type, but no specific type is required. + Alternatively, an entry tls.pem, containing the concatenation of cert and key, can be provided. + If all of tls.pem, tls.crt and tls.key are present, the tls.pem one needs to be equal to the concatenation of tls.crt and tls.key + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + TODO: Add other useful fields. apiVersion, kind, uid? + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. + type: string + type: object + x-kubernetes-map-type: atomic + enabled: + type: boolean + optional: + description: Optional configures if TLS should be required + or optional for connections + type: boolean + required: + - enabled + type: object type: object - opsManager: + statefulSet: + description: |- + StatefulSetConfiguration holds the optional custom StatefulSet + that should be merged into the operator created one. properties: - clusterStatusList: - items: - properties: - clusterName: - type: string - replicas: - type: integer - type: object - type: array - lastTransition: - type: string - message: - type: string - observedGeneration: - format: int64 - type: integer - phase: - type: string - pvc: - items: - properties: - phase: + metadata: + description: StatefulSetMetadataWrapper is a wrapper around Labels + and Annotations + properties: + annotations: + additionalProperties: type: string - statefulsetName: + type: object + labels: + additionalProperties: type: string - required: - - phase - - statefulsetName + type: object + type: object + spec: + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + type: + description: Type defines which type of MongoDB deployment the resource + should create + enum: + - ReplicaSet + type: string + users: + description: Users specifies the MongoDB users that should be configured + in your deployment + items: + properties: + additionalConnectionStringConfig: + description: |- + Additional options to be appended to the connection string. + These options apply only to this user and will override any existing options in the resource. + nullable: true type: object - type: array - replicas: - type: integer - resourcesNotReady: - items: - description: ResourceNotReady describes the dependent resource - which is not ready yet + x-kubernetes-preserve-unknown-fields: true + connectionStringSecretName: + description: |- + ConnectionStringSecretName is the name of the secret object created by the operator which exposes the connection strings for the user. + If provided, this secret must be different for each user in a deployment. + type: string + connectionStringSecretNamespace: + description: ConnectionStringSecretNamespace is the namespace + of the secret object created by the operator which exposes + the connection strings for the user. + type: string + db: + default: admin + description: DB is the database the user is stored in. Defaults + to "admin" + type: string + name: + description: Name is the username of the user + type: string + passwordSecretRef: + description: PasswordSecretRef is a reference to the secret + containing this user's password properties: - errors: - items: - properties: - message: - type: string - reason: - type: string - type: object - type: array - kind: - description: ResourceKind specifies a kind of a Kubernetes - resource. Used in status of a Custom Resource - type: string - message: + key: + description: Key is the key in the secret storing this password. + Defaults to "password" type: string name: + description: Name is the name of the secret storing this + user's password type: string required: - - kind - name type: object - type: array - url: - type: string - version: - type: string - warnings: - items: + roles: + description: Roles is an array of roles assigned to this user + items: + description: Role is the database role this user should have + properties: + db: + description: DB is the database the role can act on + type: string + name: + description: Name is the name of the role + type: string + required: + - db + - name + type: object + type: array + scramCredentialsSecretName: + description: |- + ScramCredentialsSecretName appended by string "scram-credentials" is the name of the secret object created by the mongoDB operator for storing SCRAM credentials + These secrets names must be different for each user in a deployment. + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ type: string - type: array - required: - - phase - type: object + required: + - name + - roles + type: object + type: array + version: + description: Version defines which version of MongoDB will be used + type: string + required: + - security + - type + - users + type: object + status: + description: MongoDBCommunityStatus defines the observed state of MongoDB + properties: + currentMongoDBArbiters: + type: integer + currentMongoDBMembers: + type: integer + currentStatefulSetArbitersReplicas: + type: integer + currentStatefulSetReplicas: + type: integer + message: + type: string + mongoUri: + type: string + phase: + type: string + version: + type: string + required: + - currentMongoDBMembers + - currentStatefulSetReplicas + - mongoUri + - phase type: object - required: - - spec type: object served: true storage: true diff --git a/public/mongodb-enterprise-multi-cluster.yaml b/public/mongodb-enterprise-multi-cluster.yaml index 680232b53..3aec6f2ba 100644 --- a/public/mongodb-enterprise-multi-cluster.yaml +++ b/public/mongodb-enterprise-multi-cluster.yaml @@ -134,6 +134,15 @@ rules: - watch - delete - deletecollection + - apiGroups: + - mongodbcommunity.mongodb.com + resources: + - mongodbcommunity + - mongodbcommunity/status + - mongodbcommunity/spec + - mongodbcommunity/finalizers + verbs: + - '*' - apiGroups: - mongodb.com verbs: @@ -270,7 +279,7 @@ spec: runAsUser: 2000 containers: - name: mongodb-enterprise-operator-multi-cluster - image: "quay.io/mongodb/mongodb-enterprise-operator-ubi:1.33.0" + image: "quay.io/mongodb/mongodb-enterprise-operator-ubi:0.1.0" imagePullPolicy: Always args: - -watch-resource=mongodb @@ -312,25 +321,25 @@ spec: value: Always # Database - name: MONGODB_ENTERPRISE_DATABASE_IMAGE - value: quay.io/mongodb/mongodb-enterprise-database-ubi + value: quay.io/mongodb/mongodb-kubernetes-database-ubi - name: INIT_DATABASE_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-database-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-database-ubi - name: INIT_DATABASE_VERSION - value: 1.33.0 + value: 0.1.0 - name: DATABASE_VERSION - value: 1.33.0 + value: 0.1.0 # Ops Manager - name: OPS_MANAGER_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-enterprise-ops-manager-ubi - name: INIT_OPS_MANAGER_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-ops-manager-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-ops-manager-ubi - name: INIT_OPS_MANAGER_VERSION - value: 1.33.0 + value: 0.1.0 # AppDB - name: INIT_APPDB_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-appdb-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-appdb-ubi - name: INIT_APPDB_VERSION - value: 1.33.0 + value: 0.1.0 - name: OPS_MANAGER_IMAGE_PULL_POLICY value: Always - name: AGENT_IMAGE @@ -347,6 +356,26 @@ spec: value: 'true' - name: MDB_MAX_CONCURRENT_RECONCILES value: "1" + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: OPERATOR_NAME + value: mongodb-enterprise-operator-multi-cluster + # Community Env Vars Start + - name: MDB_COMMUNITY_AGENT_IMAGE + value: "quay.io/mongodb/mongodb-agent-ubi:108.0.2.8729-1" + - name: VERSION_UPGRADE_HOOK_IMAGE + value: "quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook:1.0.9" + - name: READINESS_PROBE_IMAGE + value: "quay.io/mongodb/mongodb-kubernetes-readinessprobe:1.0.22" + - name: MDB_COMMUNITY_IMAGE + value: "mongodb-community-server" + - name: MDB_COMMUNITY_REPO_URL + value: "quay.io/mongodb" + - name: MDB_COMMUNITY_IMAGE_TYPE + value: "ubi8" + # Community Env Vars End volumes: - name: kube-config-volume secret: diff --git a/public/mongodb-enterprise-openshift.yaml b/public/mongodb-enterprise-openshift.yaml index 8ad548b24..e5d772c8f 100644 --- a/public/mongodb-enterprise-openshift.yaml +++ b/public/mongodb-enterprise-openshift.yaml @@ -134,6 +134,15 @@ rules: - watch - delete - deletecollection + - apiGroups: + - mongodbcommunity.mongodb.com + resources: + - mongodbcommunity + - mongodbcommunity/status + - mongodbcommunity/spec + - mongodbcommunity/finalizers + verbs: + - '*' - apiGroups: - mongodb.com verbs: @@ -267,7 +276,7 @@ spec: serviceAccountName: mongodb-enterprise-operator containers: - name: mongodb-enterprise-operator - image: "quay.io/mongodb/mongodb-enterprise-operator-ubi:1.33.0" + image: "quay.io/mongodb/mongodb-enterprise-operator-ubi:0.1.0" imagePullPolicy: Always args: - -watch-resource=mongodb @@ -307,25 +316,25 @@ spec: value: Always # Database - name: MONGODB_ENTERPRISE_DATABASE_IMAGE - value: quay.io/mongodb/mongodb-enterprise-database-ubi + value: quay.io/mongodb/mongodb-kubernetes-database-ubi - name: INIT_DATABASE_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-database-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-database-ubi - name: INIT_DATABASE_VERSION - value: 1.33.0 + value: 0.1.0 - name: DATABASE_VERSION - value: 1.33.0 + value: 0.1.0 # Ops Manager - name: OPS_MANAGER_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-enterprise-ops-manager-ubi - name: INIT_OPS_MANAGER_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-ops-manager-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-ops-manager-ubi - name: INIT_OPS_MANAGER_VERSION - value: 1.33.0 + value: 0.1.0 # AppDB - name: INIT_APPDB_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-appdb-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-appdb-ubi - name: INIT_APPDB_VERSION - value: 1.33.0 + value: 0.1.0 - name: OPS_MANAGER_IMAGE_PULL_POLICY value: Always - name: AGENT_IMAGE @@ -342,14 +351,34 @@ spec: value: 'true' - name: MDB_MAX_CONCURRENT_RECONCILES value: "1" - - name: RELATED_IMAGE_MONGODB_ENTERPRISE_DATABASE_IMAGE_1_33_0 - value: "quay.io/mongodb/mongodb-enterprise-database-ubi:1.33.0" - - name: RELATED_IMAGE_INIT_DATABASE_IMAGE_REPOSITORY_1_33_0 - value: "quay.io/mongodb/mongodb-enterprise-init-database-ubi:1.33.0" - - name: RELATED_IMAGE_INIT_OPS_MANAGER_IMAGE_REPOSITORY_1_33_0 - value: "quay.io/mongodb/mongodb-enterprise-init-ops-manager-ubi:1.33.0" - - name: RELATED_IMAGE_INIT_APPDB_IMAGE_REPOSITORY_1_33_0 - value: "quay.io/mongodb/mongodb-enterprise-init-appdb-ubi:1.33.0" + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: OPERATOR_NAME + value: mongodb-enterprise-operator + # Community Env Vars Start + - name: MDB_COMMUNITY_AGENT_IMAGE + value: "quay.io/mongodb/mongodb-agent-ubi:108.0.2.8729-1" + - name: VERSION_UPGRADE_HOOK_IMAGE + value: "quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook:1.0.9" + - name: READINESS_PROBE_IMAGE + value: "quay.io/mongodb/mongodb-kubernetes-readinessprobe:1.0.22" + - name: MDB_COMMUNITY_IMAGE + value: "mongodb-community-server" + - name: MDB_COMMUNITY_REPO_URL + value: "quay.io/mongodb" + - name: MDB_COMMUNITY_IMAGE_TYPE + value: "ubi8" + # Community Env Vars End + - name: RELATED_IMAGE_MONGODB_ENTERPRISE_DATABASE_IMAGE_0_1_0 + value: "quay.io/mongodb/mongodb-kubernetes-database-ubi:0.1.0" + - name: RELATED_IMAGE_INIT_DATABASE_IMAGE_REPOSITORY_0_1_0 + value: "quay.io/mongodb/mongodb-kubernetes-init-database-ubi:0.1.0" + - name: RELATED_IMAGE_INIT_OPS_MANAGER_IMAGE_REPOSITORY_0_1_0 + value: "quay.io/mongodb/mongodb-kubernetes-init-ops-manager-ubi:0.1.0" + - name: RELATED_IMAGE_INIT_APPDB_IMAGE_REPOSITORY_0_1_0 + value: "quay.io/mongodb/mongodb-kubernetes-init-appdb-ubi:0.1.0" - name: RELATED_IMAGE_AGENT_IMAGE_107_0_13_8702_1 value: "quay.io/mongodb/mongodb-agent-ubi:107.0.13.8702-1" - name: RELATED_IMAGE_AGENT_IMAGE_107_0_13_8702_1_1_31_0 diff --git a/public/mongodb-enterprise.yaml b/public/mongodb-enterprise.yaml index f18f40ba2..6d07534aa 100644 --- a/public/mongodb-enterprise.yaml +++ b/public/mongodb-enterprise.yaml @@ -134,6 +134,15 @@ rules: - watch - delete - deletecollection + - apiGroups: + - mongodbcommunity.mongodb.com + resources: + - mongodbcommunity + - mongodbcommunity/status + - mongodbcommunity/spec + - mongodbcommunity/finalizers + verbs: + - '*' - apiGroups: - mongodb.com verbs: @@ -270,7 +279,7 @@ spec: runAsUser: 2000 containers: - name: mongodb-enterprise-operator - image: "quay.io/mongodb/mongodb-enterprise-operator-ubi:1.33.0" + image: "quay.io/mongodb/mongodb-enterprise-operator-ubi:0.1.0" imagePullPolicy: Always args: - -watch-resource=mongodb @@ -308,25 +317,25 @@ spec: value: Always # Database - name: MONGODB_ENTERPRISE_DATABASE_IMAGE - value: quay.io/mongodb/mongodb-enterprise-database-ubi + value: quay.io/mongodb/mongodb-kubernetes-database-ubi - name: INIT_DATABASE_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-database-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-database-ubi - name: INIT_DATABASE_VERSION - value: 1.33.0 + value: 0.1.0 - name: DATABASE_VERSION - value: 1.33.0 + value: 0.1.0 # Ops Manager - name: OPS_MANAGER_IMAGE_REPOSITORY value: quay.io/mongodb/mongodb-enterprise-ops-manager-ubi - name: INIT_OPS_MANAGER_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-ops-manager-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-ops-manager-ubi - name: INIT_OPS_MANAGER_VERSION - value: 1.33.0 + value: 0.1.0 # AppDB - name: INIT_APPDB_IMAGE_REPOSITORY - value: quay.io/mongodb/mongodb-enterprise-init-appdb-ubi + value: quay.io/mongodb/mongodb-kubernetes-init-appdb-ubi - name: INIT_APPDB_VERSION - value: 1.33.0 + value: 0.1.0 - name: OPS_MANAGER_IMAGE_PULL_POLICY value: Always - name: AGENT_IMAGE @@ -343,3 +352,23 @@ spec: value: 'true' - name: MDB_MAX_CONCURRENT_RECONCILES value: "1" + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: OPERATOR_NAME + value: mongodb-enterprise-operator + # Community Env Vars Start + - name: MDB_COMMUNITY_AGENT_IMAGE + value: "quay.io/mongodb/mongodb-agent-ubi:108.0.2.8729-1" + - name: VERSION_UPGRADE_HOOK_IMAGE + value: "quay.io/mongodb/mongodb-kubernetes-operator-version-upgrade-post-start-hook:1.0.9" + - name: READINESS_PROBE_IMAGE + value: "quay.io/mongodb/mongodb-kubernetes-readinessprobe:1.0.22" + - name: MDB_COMMUNITY_IMAGE + value: "mongodb-community-server" + - name: MDB_COMMUNITY_REPO_URL + value: "quay.io/mongodb" + - name: MDB_COMMUNITY_IMAGE_TYPE + value: "ubi8" + # Community Env Vars End diff --git a/public/samples/community/mongodb.com_v1_mongodbcommunity_cr.yaml b/public/samples/community/mongodb.com_v1_mongodbcommunity_cr.yaml new file mode 100644 index 000000000..65d8e68c1 --- /dev/null +++ b/public/samples/community/mongodb.com_v1_mongodbcommunity_cr.yaml @@ -0,0 +1,36 @@ +--- +apiVersion: mongodbcommunity.mongodb.com/v1 +kind: MongoDBCommunity +metadata: + name: example-mongodb +spec: + members: 3 + type: ReplicaSet + version: "6.0.5" + security: + authentication: + modes: ["SCRAM"] + users: + - name: my-user + db: admin + passwordSecretRef: # a reference to the secret that will be used to generate the user's password + name: my-user-password + roles: + - name: clusterAdmin + db: admin + - name: userAdminAnyDatabase + db: admin + scramCredentialsSecretName: my-scram + additionalMongodConfig: + storage.wiredTiger.engineConfig.journalCompressor: zlib + +# the user credentials will be generated from this secret +# once the credentials are generated, this secret is no longer required +--- +apiVersion: v1 +kind: Secret +metadata: + name: my-user-password +type: Opaque +stringData: + password: test123 diff --git a/public/tools/multicluster/pkg/common/common.go b/public/tools/multicluster/pkg/common/common.go index bc03b05ed..9ce3b7f5b 100644 --- a/public/tools/multicluster/pkg/common/common.go +++ b/public/tools/multicluster/pkg/common/common.go @@ -383,6 +383,16 @@ func getCentralRules() []rbacv1.PolicyRule { }, APIGroups: []string{"mongodb.com"}, }, + { + Verbs: []string{"*"}, + Resources: []string{ + "mongodbcommunity", + "mongodbcommunity/status", + "mongodbcommunity/spec", + "mongodbcommunity/finalizers", + }, + APIGroups: []string{"mongodbcommunity.mongodb.com"}, + }, } } diff --git a/release.json b/release.json index 2b69e1e07..1d39f0d1a 100644 --- a/release.json +++ b/release.json @@ -2,11 +2,11 @@ "mongodbToolsBundle": { "ubi": "mongodb-database-tools-rhel88-x86_64-100.11.0.tgz" }, - "mongodbOperator": "1.33.0", - "initDatabaseVersion": "1.33.0", - "initOpsManagerVersion": "1.33.0", - "initAppDbVersion": "1.33.0", - "databaseImageVersion": "1.33.0", + "mongodbOperator": "0.1.0", + "initDatabaseVersion": "0.1.0", + "initOpsManagerVersion": "0.1.0", + "initAppDbVersion": "0.1.0", + "databaseImageVersion": "0.1.0", "agentVersion": "108.0.2.8729-1", "openshift": { "minimumSupportedVersion": "4.6" @@ -51,6 +51,7 @@ "Description": "We support 3 last versions, see https://wiki.corp.mongodb.com/display/MMS/Kubernetes+Operator+Support+Policy", "ssdlc_name": "MongoDB Enterprise Kubernetes Operator", "versions": [ + "0.1.0", "1.31.0", "1.32.0", "1.33.0" @@ -141,6 +142,7 @@ "Description": "The lowest version corresponds to the lowest supported Operator version, see https://wiki.corp.mongodb.com/display/MMS/Kubernetes+Operator+Support+Policy", "ssdlc_name": "MongoDB Enterprise Kubernetes Operator Init Ops Manager", "versions": [ + "0.1.0", "1.31.0", "1.32.0", "1.33.0" @@ -153,6 +155,7 @@ "Description": "The lowest version corresponds to the lowest supported Operator version, see https://wiki.corp.mongodb.com/display/MMS/Kubernetes+Operator+Support+Policy", "ssdlc_name": "MongoDB Enterprise Kubernetes Operator Init Database", "versions": [ + "0.1.0", "1.31.0", "1.32.0", "1.33.0" @@ -165,6 +168,7 @@ "Description": "The lowest version corresponds to the lowest supported Operator version, see https://wiki.corp.mongodb.com/display/MMS/Kubernetes+Operator+Support+Policy", "ssdlc_name": "MongoDB Enterprise Kubernetes Operator Init AppDB", "versions": [ + "0.1.0", "1.31.0", "1.32.0", "1.33.0" @@ -177,6 +181,7 @@ "Description": "The lowest version corresponds to the lowest supported Operator version, see https://wiki.corp.mongodb.com/display/MMS/Kubernetes+Operator+Support+Policy", "ssdlc_name": "MongoDB Enterprise Kubernetes Operator Database", "versions": [ + "0.1.0", "1.31.0", "1.32.0", "1.33.0" diff --git a/scripts/dev/contexts/e2e_mco_tests b/scripts/dev/contexts/e2e_mco_tests new file mode 100644 index 000000000..95db56f5e --- /dev/null +++ b/scripts/dev/contexts/e2e_mco_tests @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -Eeou pipefail + +script_name=$(readlink -f "${BASH_SOURCE[0]}") +script_dir=$(dirname "${script_name}") + +source "${script_dir}/root-context" + +# TODO: MCK this is requires that we skip trying to configure/reach om +export OM_EXTERNALLY_CONFIGURED=true diff --git a/scripts/dev/contexts/e2e_mdb_community b/scripts/dev/contexts/e2e_mdb_community new file mode 100644 index 000000000..117a524d4 --- /dev/null +++ b/scripts/dev/contexts/e2e_mdb_community @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -Eeou pipefail + +script_name=$(readlink -f "${BASH_SOURCE[0]}") +script_dir=$(dirname "${script_name}") + +source "${script_dir}/root-context" + +# TODO: MCK This variable is needed otherwise the `fetch_om_information.sh` script is called and fails the test +export OM_EXTERNALLY_CONFIGURED="true" diff --git a/scripts/dev/contexts/evg-private-context b/scripts/dev/contexts/evg-private-context index 80e60df32..ff2e6c0fc 100644 --- a/scripts/dev/contexts/evg-private-context +++ b/scripts/dev/contexts/evg-private-context @@ -46,13 +46,13 @@ export DATABASE_REGISTRY=${INIT_IMAGES_REGISTRY:-"${QUAY_REGISTRY}"} export OPS_MANAGER_REGISTRY=${QUAY_REGISTRY} export APPDB_REGISTRY=${QUAY_REGISTRY} export MONGODB_ENTERPRISE_DATABASE_IMAGE="${INIT_IMAGES_REGISTRY}/mongodb-enterprise-database" -export INIT_DATABASE_IMAGE_REPOSITORY="${INIT_IMAGES_REGISTRY}/mongodb-enterprise-init-database" +export INIT_DATABASE_IMAGE_REPOSITORY="${INIT_IMAGES_REGISTRY}/mongodb-kubernetes-init-database" export MDB_AGENT_IMAGE_REPOSITORY="${INIT_IMAGES_REGISTRY}/mongodb-agent-ubi" # these are needed to deploy OM -export INIT_APPDB_IMAGE_REPOSITORY="${INIT_IMAGES_REGISTRY}/mongodb-enterprise-init-appdb" +export INIT_APPDB_IMAGE_REPOSITORY="${INIT_IMAGES_REGISTRY}/mongodb-kubernetes-init-appdb" export OPS_MANAGER_IMAGE_REPOSITORY="${QUAY_REGISTRY}/mongodb-enterprise-ops-manager-ubi" -export INIT_OPS_MANAGER_IMAGE_REPOSITORY=${INIT_IMAGES_REGISTRY}/mongodb-enterprise-init-ops-manager +export INIT_OPS_MANAGER_IMAGE_REPOSITORY=${INIT_IMAGES_REGISTRY}/mongodb-kubernetes-init-ops-manager export CLUSTER_TYPE="kind" # Empty sting means that we're not using it. @@ -100,3 +100,10 @@ export BUILD_VARIANT="${build_variant:-"unknown"}" export RUNNING_IN_EVG="true" export DELETE_KIND_NETWORK="true" + +# MCO +# shellcheck disable=SC2154 +export OPERATOR_IMAGE="268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-enterprise-operator:${version_id}" +export MCO_TEST_IMAGE="268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-community-tests:${version_id}" +export READINESS_PROBE_IMAGE="268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-readinessprobe:${version_id}" +export VERSION_UPGRADE_HOOK_IMAGE="268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-operator-version-upgrade-post-start-hook:${version_id}" diff --git a/scripts/dev/contexts/local-defaults-context b/scripts/dev/contexts/local-defaults-context index 46edddb64..0690ffa14 100644 --- a/scripts/dev/contexts/local-defaults-context +++ b/scripts/dev/contexts/local-defaults-context @@ -32,7 +32,7 @@ export INIT_IMAGES_REGISTRY=${INIT_IMAGES_REGISTRY:-"${REGISTRY}"} export INIT_APPDB_REGISTRY="${BASE_REPO_URL_SHARED}" export INIT_OPS_MANAGER_REGISTRY=${BASE_REPO_URL_SHARED:-"${QUAY_REGISTRY}"} export INIT_DATABASE_REGISTRY=${BASE_REPO_URL_SHARED:-"${QUAY_REGISTRY}"} -export INIT_DATABASE_IMAGE_REPOSITORY="${BASE_REPO_URL_SHARED}/mongodb-enterprise-init-database" +export INIT_DATABASE_IMAGE_REPOSITORY="${BASE_REPO_URL_SHARED}/mongodb-kubernetes-init-database" export DATABASE_REGISTRY=${BASE_REPO_URL_SHARED:-"${QUAY_REGISTRY}"} export OPS_MANAGER_REGISTRY="${QUAY_REGISTRY}" export MONGODB_REPO_URL="${QUAY_REGISTRY}" @@ -44,9 +44,9 @@ export AGENT_BASE_REGISTRY=${BASE_REPO_URL_SHARED} export AGENT_IMAGE="268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-agent-ubi:12.0.30.7791-1" # these are needed to deploy OM -export INIT_APPDB_IMAGE_REPOSITORY="${INIT_IMAGES_REGISTRY}/mongodb-enterprise-init-appdb" +export INIT_APPDB_IMAGE_REPOSITORY="${INIT_IMAGES_REGISTRY}/mongodb-kubernetes-init-appdb" export OPS_MANAGER_IMAGE_REPOSITORY="${QUAY_REGISTRY}/mongodb-enterprise-ops-manager-ubi" -export INIT_OPS_MANAGER_IMAGE_REPOSITORY="${INIT_IMAGES_REGISTRY}/mongodb-enterprise-init-ops-manager" +export INIT_OPS_MANAGER_IMAGE_REPOSITORY="${INIT_IMAGES_REGISTRY}/mongodb-kubernetes-init-ops-manager" # Environment variable needed for local development @@ -61,3 +61,11 @@ export skip_tags="release" # This setting is set if you want to remove your namespaces after running the tests export ALWAYS_REMOVE_TESTING_NAMESPACE="true" + +# MCO settings +## whether we want to run cleanup after the run +export PERFORM_CLEANUP=false + +# TODO: unify this with MEKO local operator +## Should local runs use the local operator +export MDB_LOCAL_OPERATOR=true diff --git a/scripts/dev/contexts/root-context b/scripts/dev/contexts/root-context index 1475bc1a8..45a503602 100644 --- a/scripts/dev/contexts/root-context +++ b/scripts/dev/contexts/root-context @@ -93,3 +93,10 @@ export OLM_VERSION=v0.31.0 # Python version we use locally and in CI export PYTHON_VERSION=3.13 + + +## MCO +export MDB_COMMUNITY_IMAGE=mongodb-community-server +export MDB_COMMUNITY_REPO_URL=quay.io/mongodb +export MDB_COMMUNITY_AGENT_IMAGE=${AGENT_IMAGE} +export MDB_COMMUNITY_IMAGE_TYPE=ubi8 diff --git a/scripts/dev/launch_e2e.sh b/scripts/dev/launch_e2e.sh index 14e908ab6..740a2c167 100755 --- a/scripts/dev/launch_e2e.sh +++ b/scripts/dev/launch_e2e.sh @@ -24,14 +24,6 @@ if [[ "${DATABASE_REGISTRY}" == quay.io* ]]; then export DATABASE_NAME=mongodb-enterprise-database-ubi fi -# For any cluster except for kops (Kind, Openshift) access to ECR registry needs authorization - it will be handled -# later in single_e2e.sh -if [[ ${CLUSTER_TYPE} != "kops" ]] && [[ ${REGISTRY} == *".ecr."* ]]; then - export ecr_registry_needs_auth="ecr-registry-secret" - ecr_registry="$(echo "${REGISTRY}" | cut -d "/" -f 1)" - export ecr_registry -fi - [[ ${skip:-} = "true" ]] && export SKIP_EXECUTION="'true'" # If we are running this with local, it means we assume that the test is running on the local machine and not @@ -44,21 +36,9 @@ if [[ -n "${local:-}" ]]; then prepare_operator_config_map "${operator_context}" - HELM_CHART_DIR="helm_chart" \ pytest -m "${test}" docker/mongodb-enterprise-tests --disable-pytest-warnings else - current_context="$(kubectl config current-context)" - if [[ "${KUBE_ENVIRONMENT_NAME:-}" = "multi" ]]; then - # shellcheck disable=SC2154 - current_context="${CENTRAL_CLUSTER}" - # shellcheck disable=SC2154 - kubectl --context "${test_pod_cluster}" delete pod -l role=operator-tests - fi - # e2e test application doesn't update CRDs if they exist (as Helm 3 doesn't do this anymore) - # so we need to make sure the CRDs are upgraded when run locally - kubectl --context "${current_context}" replace -f "helm_chart/crds" || kubectl apply -f "helm_chart/crds" - TASK_NAME=${test} \ WAIT_TIMEOUT="4m" \ MODE="dev" \ diff --git a/scripts/dev/print_operator_env.sh b/scripts/dev/print_operator_env.sh index 84fc95f9a..f7184410c 100755 --- a/scripts/dev/print_operator_env.sh +++ b/scripts/dev/print_operator_env.sh @@ -14,13 +14,13 @@ WATCH_NAMESPACE=\"${WATCH_NAMESPACE}\" NAMESPACE=\"${NAMESPACE}\" IMAGE_PULL_POLICY=\"Always\" MONGODB_ENTERPRISE_DATABASE_IMAGE=\"${MONGODB_ENTERPRISE_DATABASE_IMAGE:-${DATABASE_REGISTRY}/mongodb-enterprise-database${UBI_IMAGE_SUFFIX}}\" -INIT_DATABASE_IMAGE_REPOSITORY=\"${INIT_DATABASE_REGISTRY}/mongodb-enterprise-init-database${UBI_IMAGE_SUFFIX}\" +INIT_DATABASE_IMAGE_REPOSITORY=\"${INIT_DATABASE_REGISTRY}/mongodb-kubernetes-init-database${UBI_IMAGE_SUFFIX}\" INIT_DATABASE_VERSION=\"${INIT_DATABASE_VERSION}\" DATABASE_VERSION=\"${DATABASE_VERSION}\" OPS_MANAGER_IMAGE_REPOSITORY=\"${OPS_MANAGER_REGISTRY}/mongodb-enterprise-ops-manager${UBI_IMAGE_SUFFIX}\" -INIT_OPS_MANAGER_IMAGE_REPOSITORY=\"${INIT_OPS_MANAGER_REGISTRY}/mongodb-enterprise-init-ops-manager${UBI_IMAGE_SUFFIX}\" +INIT_OPS_MANAGER_IMAGE_REPOSITORY=\"${INIT_OPS_MANAGER_REGISTRY}/mongodb-kubernetes-init-ops-manager${UBI_IMAGE_SUFFIX}\" INIT_OPS_MANAGER_VERSION=\"${INIT_OPS_MANAGER_VERSION}\" -INIT_APPDB_IMAGE_REPOSITORY=\"${INIT_APPDB_REGISTRY}/mongodb-enterprise-init-appdb${UBI_IMAGE_SUFFIX}\" +INIT_APPDB_IMAGE_REPOSITORY=\"${INIT_APPDB_REGISTRY}/mongodb-kubernetes-init-appdb${UBI_IMAGE_SUFFIX}\" INIT_APPDB_VERSION=\"${INIT_APPDB_VERSION}\" OPS_MANAGER_IMAGE_PULL_POLICY=\"Always\" MONGODB_IMAGE=\"mongodb-enterprise-server\" @@ -31,6 +31,10 @@ MDB_DEFAULT_ARCHITECTURE=\"${MDB_DEFAULT_ARCHITECTURE:-non-static}\" MDB_IMAGE_TYPE=\"${MDB_IMAGE_TYPE:-ubi8}\" MDB_OPERATOR_TELEMETRY_COLLECTION_FREQUENCY=\"${MDB_OPERATOR_TELEMETRY_COLLECTION_FREQUENCY:-1m}\" MDB_OPERATOR_TELEMETRY_SEND_ENABLED=\"${MDB_OPERATOR_TELEMETRY_SEND_ENABLED:-false}\" +MDB_COMMUNITY_IMAGE=\"${MDB_COMMUNITY_IMAGE}\" +MDB_COMMUNITY_REPO_URL=\"${MDB_COMMUNITY_REPO_URL}\" +MDB_COMMUNITY_AGENT_IMAGE=\"${MDB_COMMUNITY_AGENT_IMAGE}\" +MDB_COMMUNITY_IMAGE_TYPE=\"${MDB_COMMUNITY_IMAGE_TYPE}\" " if [[ "${AGENT_IMAGE:-}" != "" ]]; then diff --git a/scripts/dev/reset.go b/scripts/dev/reset.go index 2ef6646cb..6cda1206f 100644 --- a/scripts/dev/reset.go +++ b/scripts/dev/reset.go @@ -292,6 +292,7 @@ func resetNamespace(ctx context.Context, contextName string, namespace string, d if deleteCRD { crdNames := []string{ "mongodb.mongodb.com", + "mongodbcommunity.mongodbcommunity.mongodb.com", "mongodbmulti.mongodb.com", "mongodbmulticluster.mongodb.com", "mongodbusers.mongodb.com", diff --git a/scripts/dev/reset_helm.sh b/scripts/dev/reset_helm.sh new file mode 100755 index 000000000..080cbffb1 --- /dev/null +++ b/scripts/dev/reset_helm.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Set Helm release name +HELM_RELEASE="mongodb-kubernetes-operator" + +echo "Deleting all resources with annotation meta.helm.sh/release-name=${HELM_RELEASE}..." + +# List of resource types to check +RESOURCE_TYPES=("sa" "roles" "rolebindings" "all" "clusterroles" "clusterrolebindings" "deployments" "statefulsets" "services" "configmaps" "secrets" "jobs" "cronjobs" "daemonsets" "ingresses" "networkpolicies" "pvc") + +# Loop through each resource type and delete resources with the specified annotation +for RESOURCE in "${RESOURCE_TYPES[@]}"; do + kubectl get "${RESOURCE}" --all-namespaces -o json | jq -r --arg HELM_RELEASE "${HELM_RELEASE}" ' + .items[] | select(.metadata.annotations["meta.helm.sh/release-name"] == $HELM_RELEASE) | + "kubectl delete " + .kind + " " + .metadata.name + " -n " + .metadata.namespace + ' | sh +done + +# Delete Cluster-wide resources separately (they don't belong to a namespace) +for RESOURCE in "clusterroles" "clusterrolebindings"; do + kubectl get "${RESOURCE}" -o json | jq -r --arg HELM_RELEASE "${HELM_RELEASE}" ' + .items[] | select(.metadata.annotations["meta.helm.sh/release-name"] == $HELM_RELEASE) | + "kubectl delete " + .kind + " " + .metadata.name + ' | sh +done + +echo "All resources related to ${HELM_RELEASE} have been deleted." diff --git a/scripts/evergreen/build_multi_cluster_kubeconfig_creator.sh b/scripts/evergreen/build_multi_cluster_kubeconfig_creator.sh index 99e277942..56902e46b 100755 --- a/scripts/evergreen/build_multi_cluster_kubeconfig_creator.sh +++ b/scripts/evergreen/build_multi_cluster_kubeconfig_creator.sh @@ -26,5 +26,5 @@ chmod +x docker/mongodb-enterprise-tests/multi-cluster-kube-config-creator chmod +x docker/mongodb-enterprise-tests/multi-cluster-kube-config-creator_linux mkdir -p bin || true -cp docker/mongodb-enterprise-tests/multi-cluster-kube-config-creator bin/kubectl-mongodb -cp bin/kubectl-mongodb "${WORKDIR}/bin/kubectl-mongodb" +cp docker/mongodb-enterprise-tests/multi-cluster-kube-config-creator bin/kubectl-mongodb || true +cp bin/kubectl-mongodb "${WORKDIR}/bin/kubectl-mongodb" || true diff --git a/scripts/evergreen/e2e/dump_diagnostic_information.sh b/scripts/evergreen/e2e/dump_diagnostic_information.sh index 1233aa203..7691871e8 100755 --- a/scripts/evergreen/e2e/dump_diagnostic_information.sh +++ b/scripts/evergreen/e2e/dump_diagnostic_information.sh @@ -8,7 +8,7 @@ set +e source scripts/funcs/printing -dump_all () { +dump_all() { [[ "${MODE-}" = "dev" ]] && return # TODO: provide a cleaner way of handling this. For now we run the same command with kubectl configured @@ -26,7 +26,8 @@ dump_all () { # but in some exceptional cases (e.g. clusterwide operator) there can be more than 1 namespace to print diagnostics # In this case the python test app may create the test namespace and add necessary labels and annotations so they # would be dumped for diagnostics as well - for ns in $(kubectl get namespace -l "evg=task" --output=jsonpath={.items..metadata.name}); do + # TODO: MCK mco not all + for ns in $(kubectl get namespace --output=jsonpath={.items..metadata.name}); do if kubectl get namespace "${ns}" -o jsonpath='{.metadata.annotations}' | grep -q "${task_id:?}"; then echo "Dumping all diagnostic information for namespace ${ns}" dump_namespace "${ns}" "${prefix}" @@ -220,14 +221,45 @@ dump_diagnostics() { local namespace="${1}" dump_objects mongodb "MongoDB Resources" "${namespace}" + dump_objects mongodbcommunity "MongoDBCommunity Resources" "${namespace}" dump_objects mongodbusers "MongoDBUser Resources" "${namespace}" dump_objects opsmanagers "MongoDBOpsManager Resources" "${namespace}" dump_objects mongodbmulticluster "MongoDB Multi Resources" "${namespace}" + dump_objects mongodbcommunity "MongoDB Community Resources" "${namespace}" header "All namespace resources" kubectl get all -n "${namespace}" } +download_test_results() { + local namespace="${1}" + local test_pod_name="${2:-e2e-test}" + + echo "Downloading test results from ${test_pod_name} pod" + + # Try to copy from shared volume using the keepalive container + if kubectl cp "${namespace}/${test_pod_name}:/tmp/results/result.suite" "logs/result.suite" -c keepalive 2>/dev/null; then + echo "Successfully downloaded result.suite from test pod" + else + echo "Could not find result.suite via direct copy" + # Get logs from the test container + kubectl logs -n "${namespace}" "${test_pod_name}" -c e2e-test > "logs/result.suite" 2>/dev/null + fi +} + +# dump_events gets all events from a namespace and saves them to a file +dump_events() { + local namespace="${1}" + local prefix="${2}" + + echo "Collecting events for namespace ${namespace}" + # Sort by lastTimestamp to have the most recent events at the top + kubectl get events --sort-by='.lastTimestamp' -n "${namespace}" > "logs/${prefix}events.txt" + + # Also get events in yaml format for more details + kubectl get events -n "${namespace}" -o yaml > "logs/${prefix}events_detailed.yaml" +} + # dump_namespace dumps a namespace, diagnostics, logs and generic Kubernetes # resources. dump_namespace() { @@ -251,6 +283,10 @@ dump_namespace() { dump_configmaps "${namespace}" "${prefix}" dump_secrets "${namespace}" "${prefix}" dump_services "${namespace}" "${prefix}" + dump_events "${namespace}" "${prefix}" + + # Download test results from the test pod in community + download_test_results "${namespace}" "e2e-test" dump_objects pvc "Persistent Volume Claims" "${namespace}" > "logs/${prefix}z_persistent_volume_claims.txt" dump_objects deploy "Deployments" "${namespace}" > "logs/${prefix}z_deployments.txt" @@ -267,9 +303,9 @@ dump_namespace() { dump_objects clusterserviceversions "OLM ClusterServiceVersions" "${namespace}" 2> /dev/null > "logs/${prefix}z_olm_clusterserviceversions.txt" dump_objects pods "Pods" "${namespace}" 2> /dev/null > "logs/${prefix}z_pods.txt" + kubectl get crd -o name # shellcheck disable=SC2046 - kubectl describe $(kubectl get crd -o name | grep mongodb.com) > "logs/${prefix}z_mongodb_crds.log" + kubectl describe $(kubectl get crd -o name | grep mongodb) > "logs/${prefix}z_mongodb_crds.log" kubectl describe nodes > "logs/${prefix}z_nodes_detailed.log" || true - } diff --git a/scripts/evergreen/e2e/e2e.sh b/scripts/evergreen/e2e/e2e.sh index 76c62c0d5..f0294787f 100755 --- a/scripts/evergreen/e2e/e2e.sh +++ b/scripts/evergreen/e2e/e2e.sh @@ -10,6 +10,24 @@ source scripts/evergreen/e2e/dump_diagnostic_information.sh source scripts/evergreen/e2e/lib.sh source scripts/dev/set_env_context.sh +run_e2e_mco_tests() { + local cluster_wide="false" + + if [[ "${TEST_NAME}" == "replica_set_cross_namespace_deploy" ]]; then + cluster_wide="true" + fi + + # mco pv test relies on this + docker exec kind-control-plane mkdir -p /opt/data/mongo-data-{0..2} /opt/data/mongo-logs-{0..2} + + set +e # let's not fail here, such that we can still dump all information + scripts/evergreen/run_python.sh mongodb-community-operator/scripts/dev/e2e.py --test "${TEST_NAME}" --distro ubi --cluster-wide "${cluster_wide}" + local test_results=$? + set -e + + return ${test_results} +} + if [[ -n "${KUBECONFIG:-}" && ! -f "${KUBECONFIG}" ]]; then echo "Kube configuration: ${KUBECONFIG} file does not exist!" exit 1 @@ -61,8 +79,6 @@ echo "TEST_NAME is set to: ${TEST_NAME}" delete_operator "${NAMESPACE}" -# 4. Main test run. - # We'll have the task running for the alloca ted time, minus the time it took us # to get all the way here, assuming configuring and deploying the operator can # take a bit of time. This is needed because Evergreen kills the process *AND* @@ -78,7 +94,14 @@ task_timeout=$(get_timeout_for_task "${TASK_NAME:?}") timeout_sec=$((task_timeout - elapsed_time - 60)) echo "This task is allowed to run for ${timeout_sec} seconds" TEST_RESULTS=0 -timeout --foreground "${timeout_sec}" scripts/evergreen/e2e/single_e2e.sh || TEST_RESULTS=$? + +# 4. Main test run. +if [[ "${BUILD_VARIANT:-${CURRENT_VARIANT_CONTEXT}}" == "e2e_mco_tests" ]]; then + run_e2e_mco_tests || TEST_RESULTS=$? +else + timeout --foreground "${timeout_sec}" scripts/evergreen/e2e/single_e2e.sh || TEST_RESULTS=$? +fi + # Dump information from all clusters. # TODO: ensure cluster name is included in log files so there is no overwriting of cross cluster files. # shellcheck disable=SC2154 diff --git a/scripts/evergreen/e2e/mco/create_mco_tests.py b/scripts/evergreen/e2e/mco/create_mco_tests.py new file mode 100755 index 000000000..eb41b325e --- /dev/null +++ b/scripts/evergreen/e2e/mco/create_mco_tests.py @@ -0,0 +1,76 @@ +from shrub.v2 import BuildVariant, ShrubProject, TaskGroup +from shrub.v2.command import FunctionCall, gotest_parse_files +from shrub.v2.task import Task + +# Define the list of dynamically generated task names +task_names = [ + "replica_set", + "replica_set_enterprise_upgrade_4_5", + "replica_set_enterprise_upgrade_5_6", + "replica_set_enterprise_upgrade_6_7", + "replica_set_enterprise_upgrade_7_8", + "replica_set_recovery", + "replica_set_mongod_readiness", + "replica_set_scale", + "replica_set_scale_down", + "replica_set_change_version", + "feature_compatibility_version", + "prometheus", + "replica_set_tls", + "replica_set_tls_recreate_mdbc", + "replica_set_tls_rotate", + "replica_set_tls_rotate_delete_sts", + "replica_set_tls_upgrade", + "statefulset_arbitrary_config", + "statefulset_arbitrary_config_update", + "replica_set_mongod_config", + "replica_set_cross_namespace_deploy", + "replica_set_custom_role", + "replica_set_arbiter", + "replica_set_custom_persistent_volume", + "replica_set_mount_connection_string", + "replica_set_mongod_port_change_with_arbiters", + "replica_set_operator_upgrade", + "replica_set_connection_string_options", + "replica_set_x509", + "replica_set_remove_user", +] + +tasks = [] +# Create dynamically generated tasks +for task_name in task_names: + task = Task( + name=task_name, + commands=[ + FunctionCall(name="e2e_test"), + ], + ) + tasks.append(task) + +group = TaskGroup( + f"e2e_mco_task_group", + tasks=tasks, + max_hosts=-1, + setup_group=[ + FunctionCall("clone"), + FunctionCall("download_kube_tools"), + FunctionCall("setup_building_host"), + ], + setup_task=[ + FunctionCall("cleanup_exec_environment"), + FunctionCall("configure_docker_auth"), + FunctionCall("setup_kubernetes_environment"), + ], + teardown_task=[ + FunctionCall("upload_e2e_logs_gotest"), + FunctionCall("teardown_kubernetes_environment"), + ], + teardown_group=[FunctionCall("prune_docker_resources"), FunctionCall("run_retry_script")], +) + + +build_variant = BuildVariant("e2e_mco_tests").display_task("e2e_mco_tests") +build_variant.add_task_group(group) +project = ShrubProject({build_variant}) + +print(project.yaml()) diff --git a/scripts/evergreen/operator-sdk/prepare-openshift-bundles-for-e2e.sh b/scripts/evergreen/operator-sdk/prepare-openshift-bundles-for-e2e.sh index 1f8b47f1e..5d4c0848d 100755 --- a/scripts/evergreen/operator-sdk/prepare-openshift-bundles-for-e2e.sh +++ b/scripts/evergreen/operator-sdk/prepare-openshift-bundles-for-e2e.sh @@ -2,11 +2,19 @@ set -Eeou pipefail -# This scripts prepares bundles and catalog source for operator upgrade tests using OLM. -# It builds and publishes the following docker images: -# - certified bundle from the last published version of the operator, from RedHat's certified operators repository -# - bundle from the current branch, referencing images built as part of EVG pipeline -# - catalog source with two channels: stable - referencing last published version, fast - referencing bundle built from the current branch +# This script prepares and publishes OpenShift bundles and catalog source for operator upgrade tests using OLM. +# It enables testing two upgrade scenarios: +# 1. Upgrade from the latest release of MEKO (MongoDB Enterprise Kubernetes Operator) +# to the current version of MCK (MongoDB Controllers for Kubernetes). +# 2. Upgrade from the latest release of MCK to the current version of MCK. +# +# The script builds a test catalog with: +# - MEKO package (mongodb-enterprise) with one channel: +# - stable channel: latest release of MEKO +# - MCK package (mongodb-kubernetes) with two channels: +# - stable channel: latest release of MCK +# - fast channel: current version of MCK with an upgrade path from stable +# - migration channel: current version of MCK with an upgrade path from stable of MEKO # # Required env vars: # - BASE_REPO_URL (or REGISTRY for EVG run) @@ -53,79 +61,141 @@ function clone_git_repo_into_temp() { function find_the_latest_certified_operator() { certified_operators_cloned_repo=$1 + operator_name=$2 # In this specific case, we don't want to use find as ls sorts things lexicographically - we need this! # shellcheck disable=SC2012 - ls -r "${certified_operators_cloned_repo}/operators/mongodb-enterprise" | sed -n '2 p' + ls -r "${certified_operators_cloned_repo}/operators/${operator_name}" | sed -n '2 p' } # Clones git_repo_url, builds the bundle in the given version and publishes it to bundle_image_url. function build_bundle_from_git_repo() { tmpdir=$1 - version=$2 - bundle_image_url=$3 + operator_name=$2 + version=$3 + bundle_image_url=$4 pushd "${tmpdir}" mkdir -p "bundle" - mv "operators/mongodb-enterprise/${version}" "bundle/" + mv "operators/${operator_name}/${version}" "bundle/" docker build --platform "${DOCKER_PLATFORM}" -f "./bundle/${version}/bundle.Dockerfile" -t "${bundle_image_url}" . docker push "${bundle_image_url}" popd } -# Builds and publishes catalog source with two channels: stable and fast. -build_and_publish_catalog_with_two_channels() { +function init_test_catalog() { temp_dir=$1 - latest_bundle_version=$2 - latest_bundle_image=$3 - current_bundle_version=$4 - current_bundle_image=$5 - catalog_image=$6 - echo "Building catalog with latest released bundle and the current one" # The OPM tool generates the Dockerfile one directory higher then specified - catalog_dir="${temp_dir}/mongodb-enterprise-operator-catalog/mongodb-enterprise-operator-catalog" + catalog_dir="${temp_dir}/operator-test-catalog/operator-test-catalog" mkdir -p "${catalog_dir}" - echo "Generating the dockerfile" opm generate dockerfile "${catalog_dir}" - echo "Generating the catalog" - # Stable - latest release, fast - current version - opm init mongodb-enterprise \ - --default-channel="stable" \ - --output=yaml \ - > "${catalog_dir}"/operator.yaml + echo "${catalog_dir}" +} - echo "Adding latest release ${latest_bundle_image} to the catalog" - opm render "${latest_bundle_image}" --output=yaml >> "${catalog_dir}"/operator.yaml +function generate_mck_catalog_metadata() { + catalog_dir=$1 + mck_package_name=$2 + latest_bundle_version=$3 + latest_bundle_image=$4 + current_bundle_version=$5 + current_bundle_image=$6 + meko_package_name=$7 + meko_latest_bundle_version=$8 + + catalog_yaml="${catalog_dir}/${mck_package_name}.yaml" + + echo "Generating catalog metadata for ${mck_package_name} in ${catalog_yaml}" + + # TODO: CLOUDP-310820 - After 1.0.0 release we need to clean this up: always use stable. + default_channel="migration" + if [[ -n "${latest_bundle_version}" ]]; then + default_channel="stable" + fi + + opm init "${mck_package_name}" \ + --default-channel="${default_channel}" \ + --output=yaml \ + > "${catalog_yaml}" echo "Adding current unreleased ${current_bundle_image} to the catalog" - opm render "${current_bundle_image}" --output=yaml >> "${catalog_dir}"/operator.yaml + opm render "${current_bundle_image}" --output=yaml >> "${catalog_yaml}" - echo "Adding previous release channel as STABLE to ${catalog_dir}/operator.yaml" - echo "--- + # TODO: CLOUDP-310820 - After 1.0.0 release we need to clean this up: always run it. + if [[ -n "${latest_bundle_version}" ]]; then + echo "Adding latest release ${latest_bundle_image} to the catalog" + opm render "${latest_bundle_image}" --output=yaml >> "${catalog_yaml}" + + echo "Adding latest MCK release into STABLE channel to ${catalog_yaml}" + echo "--- schema: olm.channel -package: mongodb-enterprise +package: ${mck_package_name} name: stable entries: - - name: mongodb-enterprise.v${latest_bundle_version}" >> "${catalog_dir}"/operator.yaml + - name: ${mck_package_name}.v${latest_bundle_version}" >> "${catalog_yaml}" - echo "Adding current version channel as FAST to ${catalog_dir}/operator.yaml" - echo "--- + echo "Adding current MCK version replacing the latest MCK version into FAST channel to ${catalog_yaml}" + echo "--- schema: olm.channel -package: mongodb-enterprise +package: ${mck_package_name} name: fast entries: - - name: mongodb-enterprise.v${current_bundle_version} - replaces: mongodb-enterprise.v${latest_bundle_version}" >> "${catalog_dir}"/operator.yaml + - name: ${mck_package_name}.v${current_bundle_version} + replaces: ${mck_package_name}.v${latest_bundle_version}" >> "${catalog_yaml}" + else + echo "Skipping addition of latest MCK release as we haven't published MCK 1.0.0 yet" + fi + + echo "Adding current MCK version replacing the latest MEKO version into MIGRATION channel to ${catalog_yaml}" + echo "--- +schema: olm.channel +package: ${mck_package_name} +name: migration +entries: + - name: ${mck_package_name}.v${current_bundle_version} + replaces: ${meko_package_name}.v${meko_latest_bundle_version}" >> "${catalog_yaml}" +} + +function generate_meko_catalog_metadata() { + catalog_dir=$1 + meko_package_name=$2 + latest_bundle_version=$3 + latest_bundle_image=$4 + + catalog_yaml="${catalog_dir}/${meko_package_name}.yaml" + + echo "Generating catalog metadata for ${meko_package_name} in ${catalog_yaml}" + + # Stable - latest release + opm init "${meko_package_name}" \ + --default-channel="stable" \ + --output=yaml \ + > "${catalog_yaml}" + + echo "Adding latest release ${latest_bundle_image} to the catalog" + opm render "${latest_bundle_image}" --output=yaml >> "${catalog_yaml}" + + echo "Adding latest MEKO release into STABLE channel to ${catalog_yaml}" + echo "--- +schema: olm.channel +package: ${meko_package_name} +name: stable +entries: + - name: ${meko_package_name}.v${latest_bundle_version}" >> "${catalog_yaml}" +} + +function build_and_publish_test_catalog() { + catalog_dir=$1 + catalog_image=$2 echo "Validating catalog" opm validate "${catalog_dir}" echo "Catalog is valid" echo "Building catalog image" cd "${catalog_dir}" && cd ../ - docker build --platform "${DOCKER_PLATFORM}" . -f mongodb-enterprise-operator-catalog.Dockerfile -t "${catalog_image}" + docker build --platform "${DOCKER_PLATFORM}" . -f operator-test-catalog.Dockerfile -t "${catalog_image}" docker push "${catalog_image}" echo "Catalog has been build and published" cd - @@ -135,41 +205,65 @@ title "Executing prepare-openshift-bundles-for-e2e.sh" export BUILD_DOCKER_IMAGES=true export DOCKER_PLATFORM=${DOCKER_PLATFORM:-"linux/amd64"} -CERTIFIED_OPERATORS_REPO="https://github.com/redhat-openshift-ecosystem/certified-operators.git" -certified_repo_cloned="$(clone_git_repo_into_temp ${CERTIFIED_OPERATORS_REPO})" -latest_released_operator_version="$(find_the_latest_certified_operator "${certified_repo_cloned}")" +mck_package_name="mongodb-kubernetes" +meko_package_name="mongodb-enterprise" + +certified_operators_repo="https://github.com/redhat-openshift-ecosystem/certified-operators.git" current_operator_version_from_release_json=$(jq -r .mongodbOperator < release.json) current_incremented_operator_version_from_release_json=$(increment_version "${current_operator_version_from_release_json}") current_incremented_operator_version_from_release_json_with_version_id="${current_incremented_operator_version_from_release_json}-${VERSION_ID:-"latest"}" -certified_catalog_image="${base_repo_url}/mongodb-enterprise-operator-certified-catalog:${current_incremented_operator_version_from_release_json_with_version_id}" +test_catalog_image="${base_repo_url}/mongodb-kubernetes-test-catalog:${current_incremented_operator_version_from_release_json_with_version_id}" +certified_repo_cloned="$(clone_git_repo_into_temp ${certified_operators_repo})" + +# TODO: CLOUDP-310820 - After 1.0.0 release we need to clean this up: always run it. +if [[ "${current_operator_version_from_release_json}" =~ ^0\. ]]; then + # Version is < 1.0.0 (0.y.z) + mck_latest_released_operator_version="" + echo "Skipping MCK bundle lookup as we haven't published MCK 1.0.0 yet (${current_operator_version_from_release_json} is < 1.0.0)" +else + # Version is >= 1.0.0 + mck_latest_released_operator_version="$(find_the_latest_certified_operator "${certified_repo_cloned}" "${mck_package_name}")" +fi +meko_latest_released_operator_version="$(find_the_latest_certified_operator "${certified_repo_cloned}" "${meko_package_name}")" -export LATEST_CERTIFIED_BUNDLE_IMAGE="${base_repo_url}/mongodb-enterprise-operator-certified-bundle:${latest_released_operator_version}" -export CURRENT_BUNDLE_IMAGE="${base_repo_url}/mongodb-enterprise-operator-certified-bundle:${current_incremented_operator_version_from_release_json_with_version_id}" +meko_latest_certified_bundle_image="${base_repo_url}/mongodb-enterprise-operator-certified-bundle:${meko_latest_released_operator_version}" +mck_latest_certified_bundle_image="${base_repo_url}/mongodb-kubernetes-certified-bundle:${mck_latest_released_operator_version}" +current_bundle_image="${base_repo_url}/mongodb-kubernetes-certified-bundle:${current_incremented_operator_version_from_release_json_with_version_id}" header "Configuration:" +echo "certified_operators_repo: ${certified_operators_repo}" echo "certified_repo_cloned: ${certified_repo_cloned}" -echo "latest_released_operator_version: ${latest_released_operator_version}" +echo "mck_latest_released_operator_version: ${mck_latest_released_operator_version:-"NONE"}" +echo "meko_latest_released_operator_version: ${meko_latest_released_operator_version}" echo "current_incremented_operator_version_from_release_json: ${current_incremented_operator_version_from_release_json}" echo "current_incremented_operator_version_from_release_json_with_version_id: ${current_incremented_operator_version_from_release_json_with_version_id}" -echo "certified_catalog_image: ${certified_catalog_image}" -echo "LATEST_CERTIFIED_BUNDLE_IMAGE: ${LATEST_CERTIFIED_BUNDLE_IMAGE}" -echo "CURRENT_BUNDLE_IMAGE: ${CURRENT_BUNDLE_IMAGE}" +echo "test_catalog_image: ${test_catalog_image}" +echo "meko_latest_certified_bundle_image: ${meko_latest_certified_bundle_image}" +echo "mck_latest_certified_bundle_image: ${mck_latest_certified_bundle_image}" +echo "current_bundle_image: ${current_bundle_image}" echo "BUILD_DOCKER_IMAGES: ${BUILD_DOCKER_IMAGES}" echo "DOCKER_PLATFORM: ${DOCKER_PLATFORM}" -echo "CERTIFIED_OPERATORS_REPO: ${CERTIFIED_OPERATORS_REPO}" -# Build latest published bundle form RedHat's certified operators repository. -header "Building bundle:" -build_bundle_from_git_repo "${certified_repo_cloned}" "${latest_released_operator_version}" "${LATEST_CERTIFIED_BUNDLE_IMAGE}" +# Build latest published bundles form RedHat's certified operators repository. +header "Building MCK bundle:" +if [[ -n "${mck_latest_released_operator_version}" ]]; then + build_bundle_from_git_repo "${certified_repo_cloned}" "${mck_package_name}" "${mck_latest_released_operator_version}" "${mck_latest_certified_bundle_image}" +else + # TODO: CLOUDP-310820 - After 1.0.0 release we need to clean this up: always run it. + echo "Skipping MCK bundle build as we haven't published MCK 1.0.0 yet" +fi + +header "Building MEKO bundle:" +build_bundle_from_git_repo "${certified_repo_cloned}" "${meko_package_name}" "${meko_latest_released_operator_version}" "${meko_latest_certified_bundle_image}" # Generate helm charts providing overrides for images to reference images build in EVG pipeline. header "Building Helm charts:" generate_helm_charts # prepare openshift bundles the same way it's built in release process from the current sources and helm charts. -export CERTIFIED_BUNDLE_IMAGE=${CURRENT_BUNDLE_IMAGE} +export CERTIFIED_BUNDLE_IMAGE=${current_bundle_image} export VERSION="${current_incremented_operator_version_from_release_json}" export OPERATOR_IMAGE="${OPERATOR_REGISTRY:-${REGISTRY}}/mongodb-enterprise-operator-ubi:${VERSION_ID}" header "Preparing OpenShift bundles:" @@ -177,7 +271,10 @@ scripts/evergreen/operator-sdk/prepare-openshift-bundles.sh # publish two-channel catalog source to be used in e2e test. header "Building and pushing the catalog:" -build_and_publish_catalog_with_two_channels "${certified_repo_cloned}" "${latest_released_operator_version}" "${LATEST_CERTIFIED_BUNDLE_IMAGE}" "${current_incremented_operator_version_from_release_json}" "${CURRENT_BUNDLE_IMAGE}" "${certified_catalog_image}" +catalog_dir="$(init_test_catalog "${certified_repo_cloned}")" +generate_mck_catalog_metadata "${catalog_dir}" "${mck_package_name}" "${mck_latest_released_operator_version}" "${mck_latest_certified_bundle_image}" "${current_incremented_operator_version_from_release_json}" "${current_bundle_image}" "${meko_package_name}" "${meko_latest_released_operator_version}" +generate_meko_catalog_metadata "${catalog_dir}" "${meko_package_name}" "${meko_latest_released_operator_version}" "${meko_latest_certified_bundle_image}" +build_and_publish_test_catalog "${catalog_dir}" "${test_catalog_image}" header "Cleaning up tmp directory" rm -rf "${certified_repo_cloned}" diff --git a/scripts/evergreen/operator-sdk/prepare-openshift-bundles.sh b/scripts/evergreen/operator-sdk/prepare-openshift-bundles.sh index ffa5bcc84..82af2b2a9 100755 --- a/scripts/evergreen/operator-sdk/prepare-openshift-bundles.sh +++ b/scripts/evergreen/operator-sdk/prepare-openshift-bundles.sh @@ -21,7 +21,7 @@ mv bundle.Dockerfile "./bundle/${VERSION}/bundle.Dockerfile" minimum_supported_openshift_version=$(jq -r .openshift.minimumSupportedVersion < "${RELEASE_JSON_PATH}") bundle_annotations_file="bundle/${VERSION}/metadata/annotations.yaml" bundle_dockerfile="bundle/${VERSION}/bundle.Dockerfile" -bundle_csv_file="bundle/${VERSION}/manifests/mongodb-enterprise.clusterserviceversion.yaml" +bundle_csv_file="bundle/${VERSION}/manifests/mongodb-kubernetes.clusterserviceversion.yaml" echo "Aligning metadata.annotations.containerImage version with deployment's image in ${bundle_csv_file}" operator_deployment_image=$(yq '.spec.install.spec.deployments[0].spec.template.spec.containers[0].image' < "${bundle_csv_file}") @@ -42,11 +42,11 @@ echo "Running digest pinning for certified bundle" # This can fail during the release because the latest image is not available yet and will be available the next day/next daily rebuild. # We decided to skip digest pinning during the as it is a post-processing step and it should be fine to skip it when testing OLM during the release. if [[ "${DIGEST_PINNING_ENABLED:-"true"}" == "true" ]]; then - operator_image=$(yq ".spec.install.spec.deployments[0].spec.template.spec.containers[0].image" < ./bundle/"${VERSION}"/manifests/mongodb-enterprise.clusterserviceversion.yaml) - operator_annotation_image=$(yq ".metadata.annotations.containerImage" < ./bundle/"${VERSION}"/manifests/mongodb-enterprise.clusterserviceversion.yaml) + operator_image=$(yq ".spec.install.spec.deployments[0].spec.template.spec.containers[0].image" < ./bundle/"${VERSION}"/manifests/mongodb-kubernetes.clusterserviceversion.yaml) + operator_annotation_image=$(yq ".metadata.annotations.containerImage" < ./bundle/"${VERSION}"/manifests/mongodb-kubernetes.clusterserviceversion.yaml) if [[ "${operator_image}" != "${operator_annotation_image}" ]]; then echo "Inconsistent operator images in CSV (.spec.install.spec.deployments[0].spec.template.spec.containers[0].image=${operator_image}, .metadata.annotations.containerImage=${operator_annotation_image})" - cat ./bundle/"${VERSION}"/manifests/mongodb-enterprise.clusterserviceversion.yaml + cat ./bundle/"${VERSION}"/manifests/mongodb-kubernetes.clusterserviceversion.yaml exit 1 fi @@ -58,7 +58,7 @@ if [[ "${DIGEST_PINNING_ENABLED:-"true"}" == "true" ]]; then fi fi -certified_bundle_file="./bundle/operator-certified-${VERSION}.tgz" +certified_bundle_file="./bundle/mck-operator-certified-${VERSION}.tgz" echo "Generating certified bundle" tar -czvf "${certified_bundle_file}" "./bundle/${VERSION}" diff --git a/scripts/evergreen/periodic-cleanup-aws.py b/scripts/evergreen/periodic-cleanup-aws.py index 652b82f7d..4988557f6 100755 --- a/scripts/evergreen/periodic-cleanup-aws.py +++ b/scripts/evergreen/periodic-cleanup-aws.py @@ -7,10 +7,10 @@ REPOSITORIES_NAMES = [ "dev/mongodb-agent-ubi", - "dev/mongodb-enterprise-init-appdb-ubi", + "dev/mongodb-kubernetes-init-appdb-ubi", "dev/mongodb-enterprise-database-ubi", - "dev/mongodb-enterprise-init-database-ubi", - "dev/mongodb-enterprise-init-ops-manager-ubi", + "dev/mongodb-kubernetes-init-database-ubi", + "dev/mongodb-kubernetes-init-ops-manager-ubi", "dev/mongodb-enterprise-ops-manager-ubi", "dev/mongodb-enterprise-operator-ubi", ] diff --git a/scripts/evergreen/release/update_helm_values_files.py b/scripts/evergreen/release/update_helm_values_files.py index bfacded9c..d744fa31d 100755 --- a/scripts/evergreen/release/update_helm_values_files.py +++ b/scripts/evergreen/release/update_helm_values_files.py @@ -18,6 +18,7 @@ update_all_helm_values_files, update_standalone_installer, ) +from packaging.version import Version RELEASE_JSON_TO_HELM_KEY = { "mongodbOperator": "operator", @@ -83,22 +84,40 @@ def update_helm_charts(operator_version, release): def update_cluster_service_version(operator_version): - old_operator_version = get_value_in_yaml_file( - "config/manifests/bases/mongodb-enterprise.clusterserviceversion.yaml", "metadata.annotations.containerImage" - ).split(":")[-1] + container_image_value = get_value_in_yaml_file( + "config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml", + "metadata.annotations.containerImage", + ) + + image_parts = container_image_value.split(":") + old_operator_version = image_parts[-1] + image_repo = ":".join(image_parts[:-1]) if old_operator_version != operator_version: + olm_package_name = "mongodb-kubernetes" + # TODO: CLOUDP-310820 - After 1.0.0 release we need to clean this up: remove this condition + if Version(operator_version) <= Version("1.0.0"): + # MCK version 1.0.0 is a special case, where we need to + # set the olm_package_name to "mongodb-enterprise" because + # this is the version which provides a migration path + # from the old mongodb-enterprise operator (MEKO) + # to the new mongodb-kubernetes (MCK). + olm_package_name = "mongodb-enterprise" + # This is the latest MEKO version we are going to release. + # We hardcode it for now. Later this whole condition will be removed. + old_operator_version = "1.33.0" + set_value_in_yaml_file( - "config/manifests/bases/mongodb-enterprise.clusterserviceversion.yaml", + "config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml", "spec.replaces", - f"mongodb-enterprise.v{old_operator_version}", + f"{olm_package_name}.v{old_operator_version}", preserve_quotes=True, ) set_value_in_yaml_file( - "config/manifests/bases/mongodb-enterprise.clusterserviceversion.yaml", + "config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml", "metadata.annotations.containerImage", - f"quay.io/mongodb/mongodb-enterprise-operator-ubi:{operator_version}", + f"{image_repo}:{operator_version}", preserve_quotes=True, ) diff --git a/scripts/evergreen/release/update_release.py b/scripts/evergreen/release/update_release.py index d76007c0c..2e4cc156f 100755 --- a/scripts/evergreen/release/update_release.py +++ b/scripts/evergreen/release/update_release.py @@ -19,11 +19,17 @@ def get_latest_om_versions_from_evergreen_yml(): return data["variables"][0], data["variables"][1] -def trim_versions(versions_list, number_of_versions=3): +def trim_versions(versions_list, number_of_versions=3, always_keep=None): """ - Keep only the latest number_of_versions versions per major version in a versions list. + Keep only the latest number_of_versions versions per major version in a versions list, + plus any versions specified in always_keep. Returns a sorted list with trimmed versions. """ + + # TODO: mck test release + if always_keep is None: + always_keep = ["0.1.0"] + major_version_groups = defaultdict(list) for v in versions_list: try: @@ -31,14 +37,20 @@ def trim_versions(versions_list, number_of_versions=3): major_version_groups[major_version].append(v) except (IndexError, AttributeError): # Keep versions that don't follow the expected format - # In MEKO we didn't follow semver continue trimmed_versions = [] + # Add versions that should always be kept + for v in always_keep: + if v in versions_list and v not in trimmed_versions: + trimmed_versions.append(v) + for major_version, versions in major_version_groups.items(): versions.sort(key=lambda x: version.parse(x), reverse=True) latest_versions = versions[:number_of_versions] - trimmed_versions.extend(latest_versions) + for v in latest_versions: + if v not in trimmed_versions: + trimmed_versions.append(v) # Sort the final list in ascending order trimmed_versions.sort(key=lambda x: version.parse(x)) diff --git a/scripts/evergreen/setup_kubectl.sh b/scripts/evergreen/setup_kubectl.sh index 45f382fec..ab9066ac1 100755 --- a/scripts/evergreen/setup_kubectl.sh +++ b/scripts/evergreen/setup_kubectl.sh @@ -21,3 +21,4 @@ curl -s https://get.helm.sh/helm-${helm_version}-linux-amd64.tar.gz --output "${ tar xfz "${helm_archive}" -C "${tmpdir}" &> /dev/null mv "${tmpdir}/linux-amd64/helm" "${bindir}" +"${bindir}"/helm version diff --git a/scripts/evergreen/should_prepare_openshift_bundles.sh b/scripts/evergreen/should_prepare_openshift_bundles.sh index c85ed5e0b..3a029fb6c 100755 --- a/scripts/evergreen/should_prepare_openshift_bundles.sh +++ b/scripts/evergreen/should_prepare_openshift_bundles.sh @@ -21,7 +21,7 @@ check_file_exists() { } version=$(jq -r .mongodbOperator