diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..f4b3bfba195c26bb3e167a1f4869c10252cb5619 --- /dev/null +++ b/LICENSE @@ -0,0 +1,74 @@ +# MongoDB Enterprise Advanced (EA) - Customer Agreement # + +By agreeing to an Order Form that references this Customer Agreement (this “Agreement”), or by downloading our Software for a free trial, you agree to this Agreement. If you represent an organization, you represent and warrant that you have the authority to agree to this Agreement on behalf of your organization. + +1. Definitions. The following terms have the following meanings: + +“Affiliate” means an organization that controls, is controlled by, or is under common control with, a party, where “control” means direct or indirect ownership of more than 50% of the voting interests of the organization. + +“Confidential Information” means information a party designates as confidential or reasonably considers as confidential, and includes pricing information on an Order Form. “Confidential Information” excludes information that is (a) or becomes publicly available through no fault of the recipient, (b) received from a third party without a duty of confidentiality, (c) independently developed by the receiving party without breaching this Agreement, or (d) rightfully known or lawfully in the possession of the receiving party prior to disclosure from the other party. + +“Consulting Services” means the consulting or professional services included in your Subscription. + +“Customer,” “you” and “your” means the organization that agrees to an Order Form or downloads the Software for a free trial. + +“Deliverable” means a work provided to you as a part of the Consulting Services, including any report. + +“Documentation” means the instructions, specifications and information regarding the Software available at https://docs.mongodb.com/. + +“MongoDB,” “we,” “our” and “us” means the MongoDB company that agrees to an Order Form. + +“Order Form” means an ordering document for Subscriptions signed by both parties that refers to this Agreement. + +“Server” means each unit of RAM as specified on an Order Form of: (a) a physical machine, dedicated server or server blade that stores data; or (b) an instance that stores data in a public or private cloud, where “cloud” includes any type of virtualized or containerized environment (e.g., simple operating systems, virtual machines, CGroups). + +“Software” means the MongoDB Enterprise database software, MongoDB Ops Manager, MongoDB Charts, MongoDB Connector for Business Intelligence, and any other software included with a Subscription, including any generally available updates to such software, but excluding open source software components, each of which has its copyright notice and license included in the license file and Documentation. + +“Subscription” means a subscription for our Software, Support, or Consulting Services set forth in an Order Form. + +“Support” means support, if any, included in a Subscription. + +2. Subscriptions. + +(a) Generally. We will provide you with the Software, Support and Consulting Services included in the Subscription. We will provide you with Support in accordance with the applicable support policy available on our website, currently available at https://www.mongodb.com/support-policy. While we may modify our support policy from time to time, we will not modify it in a way that materially and adversely affects your Support. Your Affiliates may purchase Subscriptions directly from us by signing an Order Form and you may allow an Affiliate to use your Subscriptions as long as you are responsible for the Affiliate’s compliance with this Agreement. + +(b) Free Evaluation and Development. MongoDB grants you a royalty-free, nontransferable and nonexclusive license to use and reproduce the Software in your internal environment for evaluation and development purposes. You will not use the Software for any other purpose, including testing, quality assurance or production purposes without purchasing an Enterprise Advanced Subscription. We provide the free evaluation and development license of our Software on an “AS-IS” basis without any warranty. + +(c) Enterprise Advanced Subscription. MongoDB grants you a nontransferable and nonexclusive license during the term of the Subscription to use and reproduce the Software in your internal environment for the purposes and on the number of Servers stated on the Order Form. You will cover each Server used by an application with an Enterprise Advanced Subscription. + +3. Consulting Services. You will provide MongoDB with reasonable assistance and information to facilitate scheduling and performance of Consulting Services. You will also appoint an engagement manager to help ensure effective delivery of the Consulting Services. Consulting Services and any Deliverables are accepted when delivered unless otherwise set forth in an Order Form. We may engage qualified subcontractors to provide the Consulting Services, and we are responsible for any subcontractor’s compliance with this Agreement. We grant you a royalty-free, perpetual, nontransferable and nonexclusive license to use and reproduce any Deliverables for your internal business purposes, except for training materials, which may only be used by the individual employees who attended the training session. + +4. Your Responsibilities. As a condition to your use of the Software, you will not, and will not allow any third party to: (a) decompile, disassemble, translate, reverse engineer or attempt to derive source code from any portion of the Software; (b) sell, sublicense, rent, lease, distribute, market, or commercialize the Software, your Subscription or any Deliverables, provided that you may use the Software in connection with an application available to your end customers as long as they cannot access the Software directly; (c) directly or indirectly circumvent or violate the technical restrictions of the Software; (d) remove any identification, proprietary, copyright or other notices in the Software, Documentation or Deliverables; (e) modify or create a derivative work of any portion of the Software; (f) publicly disseminate performance information about, or analysis of, the Software, including benchmarking test results, or your Subscription; (g) use the Software on more Servers than licensed on an Order Form; (h) use Support or Ops Manager, Cloud Manager, MongoDB Charts, or MongoDB Connector for Business Intelligence in connection with any application that is not covered by an Enterprise Advanced Subscription; or (i) access or use the Software in a way intended to avoid incurring fees or exceeding usage limits or quotas. You will comply with applicable laws in connection with your use of Software, Deliverables, Consulting Services and your Subscriptions, including any applicable U.S. export regulations and anti-corruption laws. + +5. Payment and Taxes. You will pay undisputed fees and reimburse any business expenses as set forth on and in accordance with an Order Form. Your payment for Subscriptions is non-refundable and you may not terminate or cancel an Order Form except as stated in this Agreement. Our fees exclude and you will pay applicable taxes and similar charges, including sales, usage, excise and value added taxes. Nothing in this Agreement requires either party to pay any income taxes or similar charges of the other party. If applicable law requires you to withhold any amount from your payment, you will provide us with copies of documents related to your withholding upon our request. + +6. Confidentiality. This Agreement supersedes any applicable non-disclosure agreement between the parties with respect to your use of the Software. The receiving party will use the disclosing party’s Confidential Information only in connection with this Agreement and protect the disclosing party’s Confidential Information by using the same degree of care used to protect its own confidential information, but not less than a reasonable degree of care. The receiving party will limit disclosure of the disclosing party’s Confidential Information to its and its Affiliates’ directors, officers, employees and contractors bound to confidentiality obligations at least as protective as the confidentiality provisions in this Agreement and who have a need to know the Confidential Information. The receiving party will not disclose the disclosing party’s Confidential Information to a any other third party without the disclosing party's consent, except where required to comply with applicable law or a compulsory legal order or process, provided that the receiving party will, if legally permitted, promptly notify the disclosing party. Each party will return or destroy the other party’s Confidential Information upon written request from the other party. + +7. Intellectual Property. This Agreement does not transfer any right, title or interest in any intellectual property to any party, except as expressly set forth in this Agreement. You are not obligated to provide us with any suggestions or other feedback, but if you do, we may use and modify this feedback without any restriction or payment. + +8. Warranties. MongoDB represents and warrants that: (a) the Software will perform substantially in accordance with the Documentation, and (b) it will perform Consulting Services and Support in a diligent and workmanlike manner consistent with industry standards. Your exclusive remedy for MongoDB’s material breach of warranty is to terminate any affected Subscription in accordance with Section 11 and receive a refund of any prepaid fees for unused Subscriptions. Except as set forth in this Section, we provide the Software, Consulting Services and Support on an “AS-IS” basis. To the fullest extent not prohibited by law, MongoDB disclaims and this Agreement excludes any implied or statutory warranty, including any warranty of title, non-infringement, merchantability or fitness for a particular purpose. + +9. Limitation of Liability. + +(a) Neither party will be liable to the other for any incidental or consequential damages, including lost profits or business opportunities, or any special or punitive damages. + +(b) Except as set forth in Section 9(c) and 9(d), each party’s cumulative liability will not exceed the total fees payable to MongoDB by Customer under this Agreement during the 12-month period before the event giving rise to the liability. + +(c) Each party’s cumulative liability under Section 10 will not exceed $3,000,000. + +(d) Nothing in this Agreement limits either party’s liability for: (i) fraud or fraudulent misrepresentation; (ii) death or personal injury caused by negligence, gross negligence or intentional misconduct; (iii) Customer’s payment obligations; or (iv) any liability which cannot legally be limited. + +10. Indemnification. + +(a) Customer Indemnification. If a third party asserts a claim against MongoDB alleging that software, content or data used by Customer in connection with the Software or any Subscription, or provided to MongoDB in order for MongoDB to perform Consulting Services, infringes a third party’s intellectual property right (a “Claim Against Us”), Customer will defend MongoDB against the Claim Against Us at Customer’s expense, and indemnify MongoDB from any damages, reasonable legal fees and costs finally awarded against MongoDB to the extent resulting from the Claim Against Us or for amounts paid by MongoDB to settle the Claim Against Us. Customer will have no obligation to defend or indemnify MongoDB if the Claim Against Us is based on MongoDB’s unauthorized changes to Customer’s software, content, data or other information. + +(b) MongoDB Indemnification. If a third party asserts a claim against Customer that the Software infringes a third party’s intellectual property right or any Deliverable infringes a third party’s copyright (a “Claim Against You”), MongoDB will defend Customer against the Claim Against You at MongoDB’s expense and indemnify Customer from any damages, reasonable legal fees and costs finally awarded against Customer to the extent resulting from the Claim Against You or for amounts paid by Customer to settle the Claim Against You. MongoDB will not be obligated to defend or indemnify Customer if the Claim Against You is based on: (i) combination of the Software with other software, content, data or business process not contemplated by Documentation; (ii) use of any older release of the Software when use of a newer version would have avoided the alleged or actual infringement; (iii) any modification of the Software made by anyone other than MongoDB; or (iv) MongoDB's compliance with any materials, designs, specifications or instructions provided by Customer. + +(c) Infringement Remedies. In addition to MongoDB’s indemnity obligations, if the Software or any Deliverable becomes, or in MongoDB’s opinion is likely to become, the subject of an infringement claim, MongoDB may at its option and expense and as Customer’s sole and exclusive remedy: (i) procure for Customer the right to make continued use of the Software or Deliverable; (ii) replace or modify the Software or Deliverable so that it becomes non-infringing; or (iii) terminate Customer’s license to the Software or Deliverable and refund any prepaid fees for unused Subscriptions. + +(d) Indemnification Procedures. Each party will provide the other with prompt notice of any claim. A party’s failure to provide prompt notice to the other party relieves the party of its obligation to defend and indemnify the other party only to the extent that the failure to provide notice materially harms the party’s ability to defend the claim. The indemnifying party will have sole control of the defense of the claim, including any settlement. The indemnified party will provide the indemnifying party with reasonable cooperation in connection with the defense of the claim, and may participate in the defense at its own expense. This Section 10 sets forth each party’s exclusive remedy for any third party infringement claim. + +11. Term and Termination. The term of this Agreement commences when you agree to an Order Form, or you download our Software for a free trial, and will remain in effect until terminated in accordance with this Agreement. Either party may terminate this Agreement for convenience immediately upon notice if all Order Forms under this Agreement have expired or been terminated. Neither party may terminate an Order Form for convenience. If a party fails to cure a material breach of this Agreement within 30 days after receipt of written notice of the breach, the other party may terminate this Agreement and any affected Order Form. Upon termination of an Order Form or this Agreement, you will remove the Software from all Servers covered by the terminated Subscriptions. Provisions intended by their nature to survive termination of this Agreement survive termination. During the term of this Agreement and one year following termination, we may inspect your records relating to your use of the Software or Consulting Services for the purposes of verifying compliance with this Agreement. + +12. General. Notices under this Agreement will be in writing and effective on the delivery date. The parties will deliver notices by personal delivery or courier to the address of the other party set forth on the Order Form. If you are located in North, Central or South America, New York law governs this Agreement, excluding any applicable conflict of laws rules or principles, and the parties agree to the exclusive jurisdiction of the courts in New York, New York. For customers located elsewhere, the law of England and Wales governs this Agreement, excluding any applicable conflict of laws rules or principles, and the parties agree to the exclusive jurisdiction of the courts in London, England. This Agreement does not create a partnership, agency relationship, or joint venture between the parties. The United Nations Convention for the International Sale of Goods does not apply to this Agreement. Unless you tell us otherwise in writing, we may refer to our relationship with you as a customer. Any assignment of this Agreement by you without our prior written consent will be null and void, except an assignment to an Affiliate or in connection with a merger or sale of all or substantially all of your assets or stock, provided that you may not assign this Agreement to a competitor of ours without our prior written consent. If any provision of this Agreement is unenforceable, that provision will be modified to render it enforceable to the extent possible to effect the parties’ intention and the remaining provisions will not be affected. The parties may amend this Agreement only by a written amendment signed by both parties. This Agreement incorporates any addenda or exhibits, and any Order Form, and comprises the parties’ entire agreement relating to the subject matter of this Agreement. Neither party has entered into this Agreement in reliance on any representations or warranties other than those expressly set forth in this Agreement or in an applicable Order Form. If any conflict exists between the provisions in this Agreement and any Order Form, the Order Form controls, and if any conflict exists between this Agreement and any addenda, exhibit or other agreement, this Agreement controls. A purchase order is for convenience only and any terms that govern the purchase order are of no effect. Customer’s purchase of any Subscription is not contingent on, and Customer has not relied on, the delivery of any future functionality, regardless of any communication about our products. Neither party will be liable for failures or delays in performance due to causes beyond its reasonable control. + diff --git a/README.md b/README.md index 9f4993090b7f37037be9d2376355be41b0c18d08..0dd5011568c8435c6af8926b6cd979f7e21a9e59 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,243 @@ -# Mongodb Enterprise Kubernetes +# Before You Begin # -Welcome to the MongoDB Enterprise Kubernetes Operator. The Operator enables easy deploy of the MongoDB applications into Kubernetes clusters. \ No newline at end of file +**PRIOR TO UTILIZING THE MONGODB ENTERPRISE ADVANCED CONTAINER, CONTACT YOUR MONGODB SALES REPRESENTATIVE.** YOUR USE OF THE MONGODB ENTERPRISE SERVER IS SUBJECT TO THE TERMS AND CONDITIONS OF THE AGREEMENT BETWEEN USAF AND THE APPLICABLE RESELLER OF THE MONGODB ENTERPRISE SERVER. SUCH AGREEMENT INCORPORATES THE TERMS & CONDITIONS OF THE MONGODB ENTERPRISE ADVANCED LICENSE AGREEMENT, THE VERSION OF WHICH CURRENT AS OF SEPTEMBER 2020 IS SET FORTH BELOW. THE MONGODB ENTERPRISE ADVANCED LICENSE AGREEMENT IS SUBJECT TO AMENDMENT AND MODIFICATION FROM TIME TO TIME. + + +# Contact Information # + +For licensing and technical information, please use the following contact information: + +Anton Hoffman, EAE USAF +781-996-8860 +anton.hoffman@mongodb.com +Please also CC: publicsector@mongodb.com + + + +# MongoDB Enterprise Kubernetes Operator # + +Welcome to the MongoDB Enterprise Kubernetes Operator. The Operator enables easy deploy of the following applications into Kubernetes clusters: +* MongoDB - Replica Sets, Sharded Clusters and Standalones, with authentication, TLS and many more options. +* Ops Manager - our enterprise management, monitoring and backup platform for MongoDB. The Operator can install and manage Ops Manager in Kubernetes for you. + +The Operator requires access to one of our database management tools - Ops Manager or Cloud Manager - to deploy MongoDB instances. +You may run Ops Manager either inside or outside Kubernetes, or may use Cloud Manager (cloud.mongodb.com) instead. + +The Operator is currently Generally Available, supported by the [MongoDB Support Team](https://support.mongodb.com/). If you need urgent help, please file a support ticket. +For non-urgent requests, you may file a Github Issue in the public repo (https://github.com/mongodb/mongodb-enterprise-kubernetes). + +You can discuss this integration in our new [Community Forum](https://community.mongodb.com/) - please use the tag [enterprise-kubernetes-operator](https://community.mongodb.com/tags/enterprise-kubernetes-operator). + +## Documentation ## + +[Install Kubernetes Operator](https://docs.opsmanager.mongodb.com/current/tutorial/install-k8s-operator) + +[Deploy MongoDB](https://docs.mongodb.com/kubernetes-operator/stable/mdb-resources/) + +[Deploy Ops Manager](https://docs.mongodb.com/kubernetes-operator/stable/om-resources/) + +[MongoDB Resource Specification](https://docs.opsmanager.mongodb.com/current/reference/k8s-operator-specification) + +[Ops Manager Resource Specification](https://docs.mongodb.com/kubernetes-operator/stable/reference/k8s-operator-om-specification/) + +[Troubleshooting Kubernetes Operator](https://docs.opsmanager.mongodb.com/current/reference/troubleshooting/k8s/) + +[Known Issues for Kubernetes Operator](https://docs.mongodb.com/kubernetes-operator/stable/reference/known-issues/) + +## Requirements ## + +Please refer to the [Installation Instructions](https://docs.mongodb.com/kubernetes-operator/stable/tutorial/plan-k8s-operator-install/) +to see which Kubernetes and Openshift versions the Operator is compatible with + +To work with MongoDB resource this Operator requires [Ops Manager](https://docs.opsmanager.mongodb.com/current/) (Ops Manager can +be installed into the same Kubernetes cluster by the Operator or installed outside of the cluster manually) + + + +## Installation + +### Create Kubernetes Namespace + +The Mongodb Enterprise Operator is installed, by default, into the `mongodb` Namespace, but this Namespace is not created automatically. To create this Namespace you should execute: + + kubectl create namespace mongodb + +If you plan on using any other Namespace, please make sure you update the yaml files' `metadata.namespace` attribute to +point to your preferred Namespace. If using `helm` you need to override the `namespace` attribute with `--set namespace=<..>` +during helm installation + +### Installation using yaml files + +#### Create CustomResourceDefinitions + +The `CustomResourceDefinition` (or `crds`) should be installed before installing the operator into your Kubernetes cluster. To do this, make sure you have logged into your Kubernetes cluster and that you can perform Cluster level operations: + + kubectl apply -f https://raw.githubusercontent.com/mongodb/mongodb-enterprise-kubernetes/master/crds.yaml + +This will create a new `crd` in your cluster, `MongoDB`. This new object will be the one used by the operator to perform the MongoDb operations needed to prepare each one of the different MongoDb types of deployments. + +#### Operator Installation + +> In order to install the Operator in OpenShift, please follow [these](openshift-install.md) instructions instead. + +This operator can also be installed using yaml files, in case you are not using Helm. You may apply the config directly from github clone this repo, and apply the file + + kubectl apply -f https://raw.githubusercontent.com/mongodb/mongodb-enterprise-kubernetes/master/mongodb-enterprise.yaml + +or clone this repo, make any edits you need, and apply it from your machine. + + kubectl apply -f mongodb-enterprise.yaml + +### Installation using Helm Chart + +If you have installed the Helm client locally then you can run (note that `helm install` is a less preferred way as makes upgrades more complicated. +`kubectl apply` is a much clearer way of installing/upgrading): + + helm template helm_chart > operator.yaml + kubectl apply -f operator.yaml + +You can customize installation by simple overriding of helm variables, for example use `--set operator.env="dev"` to run the Operator in development mode +(this will turn logging level to `Debug` and will make logging output as non-json) + +Pass the `--values helm_chart/values-openshift.yaml` parameter if you want to install the Operator to an OpenShift cluster. +You need to specify the image pull secret name using `--set registry.imagePullSecrets=` + +Check the end of the page for instructions on how to remove the Operator. + +## MongoDB Resource ## + +*This section describes how to create the MongoDB resource. Follow the next section on how to work with Ops Manager resource.* + +### Adding Ops Manager Credentials ### + +For the Operator to work, you will need the following information: + +* Base URL - the URL of an Ops Manager instance +* (optionally) Project Name - the name of an Ops Manager Project where MongoDBs will be deployed into. It will be +created by the Operator if it doesn't exist (and this is the recommended way instead of reusing the project created +in OpsManager directly). If omitted the name of the MongoDB resource will be used as a project name. +* (optionally) Organization ID - the ID of the organization which the Project belongs to. The Operator will create +an Organization with the same name as the Project if Organization ID is omitted. +* API Credentials. This can be any pair of: + * Public and Private Programmatic API keys. They correspond to `user` and `publicApiKey` fields in the Secret storing +credentials. More information about the way to create them using Ops Manager UI can be found +[here](https://docs.opsmanager.mongodb.com/current/tutorial/configure-public-api-access/#programmatic-api-keys) + * Username and Public API key. More information about the way to create them using Ops Manager UI can be found + [here](https://docs.opsmanager.mongodb.com/current/tutorial/configure-public-api-access/#personal-api-keys-deprecated) + +Note that you must whitelist the IP +range of your Kubernetes cluster so that the Operator could make API requests to Ops Manager + +This is documented in greater detail in our [installation guide](https://docs.opsmanager.mongodb.com/current/tutorial/install-k8s-operator) + + +### Projects ### + +A `Project` object is a Kubernetes `ConfigMap` that points to an Ops Manager installation and a `Project`. This `ConfigMap` has the following structure: + +``` +$ cat my-project.yaml +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: my-project + namespace: mongodb +data: + projectName: myProjectName # this is an optional parameter + orgId: 5b890e0feacf0b76ff3e7183 # this is an optional parameter + baseUrl: https://my-ops-manager-or-cloud-manager-url +``` +> Note, that if `orgId` is skipped then the new organization named `projectName` will be automatically created and new +project will be added there. +> If `projectName` is skipped the project created in Ops Manager will get the same name as the MongoDB object + +Apply this file to create the new `Project`: + + kubectl apply -f my-project.yaml + +### Credentials ### + +For a user to be able to create or update objects in this Ops Manager Project they need either a Public API Key or a +Programmatic API Key. These will be held by Kubernetes as a `Secret` object. You can create this Secret with the following command: + +``` bash +$ kubectl -n mongodb create secret generic my-credentials --from-literal="user=some@example.com" --from-literal="publicApiKey=my-public-api-key" +``` + +### Creating a MongoDB Resource ### + +A MongoDB resource in Kubernetes is a MongoDB (short name `mdb`). We are going to create a replica set to test that everything is working as expected. There is a MongoDB replica set yaml file in `samples/mongodb/minimal/replica-set.yaml`. + +If you have a correctly created Project with the name `my-project` and Credentials stored in a secret called `my-credentials` then, after applying this file then everything should be running and a new Replica Set with 3 members should soon appear in Ops Manager UI. + + kubectl apply -f samples/mongodb/minimal/replica-set.yaml + +## MongoDBOpsManager Resource ## + +This section describes how to create the Ops Manager Custom Resource in Kubernetes. Note, that this requires all +the CRDs and the Operator application to be installed as described above. + +### Create Admin Credentials Secret ### + +Before creating the Ops Manager resource you need to prepare the information about the admin user which will be +created automatically in Ops Manager. You can use the following command to do it: + +```bash +$ kubectl create secret generic ops-manager-admin-secret --from-literal=Username="jane.doe@example.com" --from-literal=Password="Passw0rd." --from-literal=FirstName="Jane" --from-literal=LastName="Doe" -n +``` + +Note, that the secret is needed only during the initialization of the Ops Manager object - you can remove it or +change the password using Ops Manager UI after the Ops Manager object was created + +### Create MongoDBOpsManager Resource ### + +Use the file `samples/ops-manager/ops-manager.yaml`. Edit the fields and create the object in Kubernetes: + +```bash +$ kubectl apply -f samples/ops-manager/ops-manager.yaml +``` + +Note, that it takes up to 8 minutes to initialize the Application Database and start Ops Manager. + +### (Optionally) Create a MongoDB Resource Referencing the MongoDBOpsManager + +Now you can use the Ops Manager application to create MongoDB objects. You need to follow the +[instructions](https://docs.mongodb.com/kubernetes-operator/stable/tutorial/create-operator-credentials/#prerequisites) +to prepare keys and enable network access to Ops Manager. +Then you need to perform the standard steps necessary to create MongoDB resource: +* Create a [credentials Secret](https://docs.mongodb.com/kubernetes-operator/stable/tutorial/create-operator-credentials/#create-k8s-credentials) +* Create a [connection ConfigMap](https://docs.mongodb.com/kubernetes-operator/stable/tutorial/create-project-using-configmap/) + * Note, that you should use the value from `status.opsManager.url` in MongoDBOpsManager Resource as a value for `baseUrl` field in the ConfigMap + +## Accessing Ops Manager UI (from a browser) + +In order to access Ops Manager UI, from outside the Kubernetes cluster (from a browser), make sure you enable +`spec.externalConnectivity` in the Ops Manager resource definition. The easiest way is by configuring the LoadBalancer service type. + +You will be able to fetch the URL to connect to Ops Manager UI from the `Service` created by the Operator. + +## Deleting the Operator ## + +It's important to keep correct order or removal operations. The simple rule is: **never remove Operator before MongoDB resources**! +The reason is that the Operator cleans state in Ops Manager on deletion of the MongoDB resource in Kubernetes. + +These are the correct steps to remove any MongoDB Operator resources: + +```bash +# this operation must be called first! +kubectl delete mdb --all -n + +# any of the following commands must be called after removing all existing mongodb resources +kubectl delete namespace +kubectl delete deployment mongodb-enterprise-operator -n +kubectl delete crd/mongodb.mongodb.com +kubectl delete crd/opsmanagers.mongodb.com +kubectl delete crd/mongodbusers.mongodb.com +``` + +## Contributing + +Please file issues before filing PRs. For PRs to be accepted, contributors must sign our [CLA](https://www.mongodb.com/legal/contributor-agreement). + +Reviewers, please ensure that the CLA has been signed by referring to [the contributors tool](https://contributors.corp.mongodb.com/) (internal link). diff --git a/crds.yaml b/crds.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ae6911379a0f66256f3ebedf4ec5b33151718774 --- /dev/null +++ b/crds.yaml @@ -0,0 +1,997 @@ +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: mongodb.mongodb.com +spec: + group: mongodb.com + version: v1 + scope: Namespaced + names: + kind: MongoDB + plural: mongodb + shortNames: + - mdb + singular: mongodb + additionalPrinterColumns: + - name: Type + type: string + description: "The type of MongoDB deployment. One of 'ReplicaSet', 'ShardedCluster' and 'Standalone'." + JSONPath: .spec.type + - name: State + type: string + description: The current state of the MongoDB deployment. + JSONPath: .status.phase + - name: Version + type: string + description: The version of MongoDB. + JSONPath: .spec.version + - name: Age + type: date + description: The time since the MongoDB resource was created. + JSONPath: .metadata.creationTimestamp + subresources: + status: {} + validation: + openAPIV3Schema: + type: object + properties: + spec: + type: object + required: + - credentials + - type + - version + oneOf: + - required: [cloudManager] + - required: [opsManager] + - required: [project] + properties: + type: + type: string + enum: ["Standalone", "ReplicaSet", "ShardedCluster"] + credentials: + type: string + project: + type: string + description: "DEPRECATED The name of a configMap in the same namespace" + opsManager: + type: object + properties: + configMapRef: + type: object + properties: + name: + type: string + cloudManager: + type: object + properties: + configMapRef: + type: object + properties: + name: + type: string + + version: + type: string + pattern: "^[0-9]+.[0-9]+.[0-9]+(-.+)?$" + logLevel: + type: string + enum: ["DEBUG", "INFO", "WARN", "ERROR", "FATAL"] + persistent: + type: boolean + clusterName: + type: string + format: hostname + description: "DEPRECATED Use clusterDomain instead" + clusterDomain: + type: string + format: hostname + + additionalMongodConfig: + type: object + exposedExternally: + type: boolean + + agent: + type: object + properties: + startupOptions: + type: object + + # Generic PodSpec configuration + podSpec: + type: object + properties: + podTemplate: + type: object + properties: + metadata: + type: object + spec: + type: object + podAntiAffinityTopologyKey: + type: string + cpu: + type: string + cpuRequests: + type: string + memory: + type: string + memoryRequests: + type: string + podAffinity: + type: object + nodeAffinity: + type: object + persistence: + type: object + properties: + single: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + multiple: + type: object + properties: + data: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + journal: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + logs: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + + # TLS & authentication properties + security: + type: object + properties: + authentication: + type: object + properties: + agents: + type: object + properties: + mode: + type: string + enum: ["SCRAM", "X509", "LDAP"] + automationUsername: + type: string + automationPasswordSecretRef: + type: object + properties: + name: + type: string + key: + type: string + automationLdapGroupDN: + type: string + clientCertificateSecretRef: + type: object + properties: + name: + type: string + required: + - mode + enabled: + type: boolean + modes: + type: array + items: + type: string + enum: ["SCRAM", "X509", "LDAP"] + ignoreUnknownUsers: + type: boolean + requireClientTLSAuthentication: + type: boolean + tls: + type: object + properties: + enabled: + type: boolean + ca: + type: string + secretRef: + type: object + properties: + name: + type: string + additionalCertificateDomains: + type: array + items: + type: string + + ldap: + type: object + properties: + bindQueryUser: + type: string + servers: + type: array + items: + type: string + transportSecurity: + type: string + enum: ["none", "tls"] + bindQueryPasswordSecretRef: + type: object + properties: + name: + type: string + caConfigMapRef: + type: object + authzQueryTemplate: + type: string + userToDNMapping: + type: string + roles: + type: array + description: "List of roles not bounded to specific users" + items: + type: object + properties: + role: + type: string + description: "The name of the role" + db: + type: string + description: "The db the role belongs to" + roles: + type: array + description: "List of roles this role inherits from" + items: + type: object + properties: + db: + type: string + description: "The db the role belongs to" + role: + type: string + description: "The name of the role" + authenticationRestrictions: + type: array + description: "List of restriction for users authenticating to this role" + items: + type: object + properties: + clientSource: + type: array + description: "List of IP addresses or CIDR ranges allowed the user can connect from" + items: + type: string + serverAddress: + type: array + description: "List of IP addresses or CIDR ranges allowed the user can connect to" + items: + type: string + privileges: + type: array + description: "List of privileges granted to this role" + items: + type: object + properties: + actions: + type: array + description: "List of actions allowed to this role" + items: + type: string + resource: + type: object + description: "Resource on which the privileges are granted" + properties: + db: + type: string + description: "Name of the database" + collection: + type: string + description: "Name of the collection" + cluster: + type: boolean + description: "True for cluster-wide privileges" + + # Sharded Cluster properties + shardPodSpec: + type: object + properties: + podTemplate: + type: object + properties: + metadata: + type: object + spec: + type: object + podAntiAffinityTopologyKey: + type: string + cpu: + type: string + cpuRequests: + type: string + memory: + type: string + memoryRequests: + type: string + podAffinity: + type: object + nodeAffinity: + type: object + persistence: + type: object + properties: + single: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + multiple: + type: object + properties: + data: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + journal: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + logs: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + mongosPodSpec: + type: object + properties: + podTemplate: + type: object + properties: + metadata: + type: object + spec: + type: object + podAntiAffinityTopologyKey: + type: string + cpu: + type: string + cpuRequests: + type: string + memory: + type: string + memoryRequests: + type: string + podAffinity: + type: object + nodeAffinity: + type: object + persistence: + type: object + properties: + single: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + multiple: + type: object + properties: + data: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + journal: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + logs: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + configSrvPodSpec: + type: object + properties: + podTemplate: + type: object + properties: + metadata: + type: object + spec: + type: object + podAntiAffinityTopologyKey: + type: string + cpu: + type: string + cpuRequests: + type: string + memory: + type: string + memoryRequests: + type: string + podAffinity: + type: object + nodeAffinity: + type: object + persistence: + type: object + properties: + single: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + multiple: + type: object + properties: + data: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + journal: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + logs: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + configServerCount: + minimum: 1 + type: integer + mongodsPerShardCount: + minimum: 1 + type: integer + mongosCount: + minimum: 1 + type: integer + shardCount: + minimum: 1 + type: integer + mongos: + type: object + properties: + additionalMongodConfig: + type: object + agent: + type: object + properties: + startupOptions: + type: object + configSrv: + type: object + properties: + additionalMongodConfig: + type: object + agent: + type: object + properties: + startupOptions: + type: object + shard: + type: object + properties: + additionalMongodConfig: + type: object + agent: + type: object + properties: + startupOptions: + type: object +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: mongodbusers.mongodb.com +spec: + group: mongodb.com + version: v1 + scope: Namespaced + names: + kind: MongoDBUser + plural: mongodbusers + shortNames: + - mdbu + singular: mongodbuser + additionalPrinterColumns: + - name: State + type: string + description: The current state of the MongoDB User + JSONPath: .status.phase + - name: Age + type: date + description: The time since the MongoDB User resource was created + JSONPath: .metadata.creationTimestamp + subresources: + status: {} + validation: + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + username: + type: string + description: "The username of the user" + db: + type: string + description: "The database the user is stored in" + project: + type: string + description: "The project the user belongs to" + passwordSecretKeyRef: + type: object + properties: + name: + type: string + key: + type: string + description: "DEPRECATED The project the user belongs to" + mongodbResourceRef: + type: object + properties: + name: + type: string + description: "The name of a MongoDB resource in the same namespace" + roles: + type: array + items: + type: object + properties: + name: + type: string + description: "The name of the role" + db: + type: string + description: "The db the role can act on" + passwordSecretKeyRef: + type: object + properties: + name: + type: string + key: + type: string + required: + - name + - db + required: + - username + - db +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: opsmanagers.mongodb.com +spec: + group: mongodb.com + version: v1 + scope: Namespaced + names: + kind: MongoDBOpsManager + plural: opsmanagers + shortNames: + - om + singular: opsmanager + additionalPrinterColumns: + - name: Replicas + type: integer + description: The number of replicas of MongoDBOpsManager. + JSONPath: .spec.replicas + - name: Version + type: string + description: The version of MongoDBOpsManager. + JSONPath: .spec.version + - name: State (OpsManager) + type: string + description: The current state of the MongoDBOpsManager. + JSONPath: .status.opsManager.phase + - name: State (AppDB) + type: string + description: The current state of the MongoDBOpsManager Application Database. + JSONPath: .status.applicationDatabase.phase + - name: State (Backup) + type: string + description: The current state of the MongoDBOpsManager Backup Daemon. + JSONPath: .status.backup.phase + - name: Age + type: date + description: The time since the MongoDBOpsManager resource was created. + JSONPath: .metadata.creationTimestamp + - name: Warnings + type: string + description: Warnings + JSONPath: .status.warnings + subresources: + status: {} + validation: + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + version: + type: string + replicas: + minimum: 1 + type: integer + clusterName: + type: string + format: hostname + description: "DEPRECATED Use clusterDomain instead" + clusterDomain: + type: string + format: hostname + + security: + type: object + properties: + tls: + type: object + properties: + ca: + type: string + secretRef: + type: object + properties: + name: + type: string + required: + - name + + adminCredentials: + type: string + externalConnectivity: + type: object + properties: + type: + type: string + enum: ["LoadBalancer", "NodePort"] + port: + type: integer + loadBalancerIP: + type: string + externalTrafficPolicy: + type: string + enum: ["Cluster", "Local"] + annotations: + type: object + required: + - type + configuration: + type: object + jvmParameters: + type: array + items: + type: string + statefulSet: + type: object + properties: + spec: + type: object + backup: + type: object + properties: + enabled: + type: boolean + jvmParameters: + type: array + items: + type: string + headDB: + type: object + properties: + storage: + type: string + storageClass: + type: string + opLogStores: + type: array + items: + type: object + properties: + name: + type: string + mongodbResourceRef: + type: object + properties: + name: + type: string + required: + - name + mongodbUserRef: + type: object + properties: + name: + type: string + required: + - name + required: + - name + - mongodbResourceRef + blockStores: + type: array + items: + type: object + properties: + name: + type: string + mongodbResourceRef: + type: object + properties: + name: + type: string + required: + - name + mongodbUserRef: + type: object + properties: + name: + type: string + required: + - name + required: + - name + - mongodbResourceRef + s3Stores: + type: array + items: + type: object + properties: + name: + type: string + mongodbResourceRef: + type: object + properties: + name: + type: string + required: + - name + mongodbUserRef: + type: object + properties: + name: + type: string + required: + - name + pathStyleAccessEnabled: + type: boolean + s3BucketEndpoint: + type: string + s3BucketName: + type: string + s3SecretRef: + type: object + properties: + name: + type: string + required: + - name + - pathStyleAccessEnabled + - s3BucketEndpoint + - s3BucketName + - s3SecretRef + statefulSet: + type: object + properties: + spec: + type: object + required: + - enabled + applicationDatabase: + type: object + properties: + passwordSecretKeyRef: + type: object + properties: + name: + type: string + key: + type: string + required: + - name + security: + type: object + properties: + tls: + type: object + properties: + ca: + type: string + secretRef: + type: object + properties: + name: + type: string + required: + - name + required: + - secretRef + members: + maximum: 50 + minimum: 3 + type: integer + version: + type: string + pattern: "^[0-9]+.[0-9]+.[0-9]+(-.+)?$|^$" + logLevel: + type: string + enum: ["DEBUG", "INFO", "WARN", "ERROR", "FATAL"] + persistent: + type: boolean + statefulSet: + type: object + properties: + spec: + type: object + + agent: + type: object + properties: + startupOptions: + type: object + + podSpec: + type: object + properties: + podTemplate: + type: object + properties: + metadata: + type: object + spec: + type: object + podAntiAffinityTopologyKey: + type: string + cpu: + type: string + cpuRequests: + type: string + memory: + type: string + memoryRequests: + type: string + podAffinity: + type: object + nodeAffinity: + type: object + persistence: + type: object + properties: + single: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + multiple: + type: object + properties: + data: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + journal: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + logs: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + required: + - members + required: + - version + - applicationDatabase +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-enterprise-operator-mongodb-webhook +rules: + - apiGroups: + - "admissionregistration.k8s.io" + resources: + - validatingwebhookconfigurations + verbs: + - get + - create + - update + - delete diff --git a/docs/assets/image--000.png b/docs/assets/image--000.png new file mode 100644 index 0000000000000000000000000000000000000000..7c2ee0d6e242874572062d0f1bab3320ebd3155a Binary files /dev/null and b/docs/assets/image--000.png differ diff --git a/docs/assets/image--002.png b/docs/assets/image--002.png new file mode 100644 index 0000000000000000000000000000000000000000..cbebc06e79040cfc735816f8ae049a206331fdad Binary files /dev/null and b/docs/assets/image--002.png differ diff --git a/docs/assets/image--004.png b/docs/assets/image--004.png new file mode 100644 index 0000000000000000000000000000000000000000..96934769b8e5fadd50b4078bf4d10a0f829bcc54 Binary files /dev/null and b/docs/assets/image--004.png differ diff --git a/docs/assets/image--008.png b/docs/assets/image--008.png new file mode 100644 index 0000000000000000000000000000000000000000..ef776fd77a1a69803c565190e0da3018a5c3eac6 Binary files /dev/null and b/docs/assets/image--008.png differ diff --git a/docs/assets/image--014.png b/docs/assets/image--014.png new file mode 100644 index 0000000000000000000000000000000000000000..8d0c75e7a564d80291bef5aaec249fc2bf9d3ec3 Binary files /dev/null and b/docs/assets/image--014.png differ diff --git a/docs/assets/image--030.png b/docs/assets/image--030.png new file mode 100644 index 0000000000000000000000000000000000000000..3321b971e5f73c2c5415a6e9ce2897fd4186d647 Binary files /dev/null and b/docs/assets/image--030.png differ diff --git a/docs/assets/image--032.png b/docs/assets/image--032.png new file mode 100644 index 0000000000000000000000000000000000000000..510c89a9e14c5d0935fd4962edf197cb4519fe2f Binary files /dev/null and b/docs/assets/image--032.png differ diff --git a/docs/assets/image--034.png b/docs/assets/image--034.png new file mode 100644 index 0000000000000000000000000000000000000000..e21b432325676cd498fabee8c0b14e1170690903 Binary files /dev/null and b/docs/assets/image--034.png differ diff --git a/docs/openshift-marketplace.md b/docs/openshift-marketplace.md new file mode 100644 index 0000000000000000000000000000000000000000..ea639c1a228228c9a536e619d5accc9da1c4fe2f --- /dev/null +++ b/docs/openshift-marketplace.md @@ -0,0 +1,149 @@ +# OpenShift MongoDB Enterprise Kubernetes Operator +## Operator Service Catalog and Marketplace + +This installation document is a guide for deploying MongoDB Enterprise Kubernetes Operator, Ops Manager and first MongoDB DataBase using OpenShift Operator catalog or Marketplace. + +## Configuring required components + +Step 1: Create a namespace to install MongoDB + +``` +oc create ns mongodb +``` + +Step 2: Install the operator in the cluster in the namespace created above + +![Installed Operators](assets/image--000.png) + +Step 3: Wait for the Operator to be deployed. + +![Operator Installed](assets/image--002.png) + +Step 4: Deploy MongoDB Ops Manager. + +Ops Manager is an Enterprise Control Plane for all your MongoDB Clusters. It is a extensive application and may seem complicated. Please visit [Documentation](https://docs.mongodb.com/kubernetes-operator/stable/om-resources/) to plan and configure production deployments. + +*Only a single Ops Manager deployment is required for all MongoDB clusters in your organization. This step could be skipped if Ops Manager is already deployed. Alternatively [Cloud Manager](https://cloud.mongodb.com) - hosted Ops Manager could be used instead.* + +![Screenshot](assets/image--004.png) + + +To deploy a very simple Ops Manager configuration two steps are required. +1. Create Admin Credential Secret +```bash +create secret generic ops-manager-admin-secret \ +--from-literal=Username="jane.doe@example.com" \ +--from-literal=Password="Passw0rd." \ +--from-literal=FirstName="Jane" \ +--from-literal=LastName="Doe" -n mongodb +``` +2. Deploy Ops Manager instance with CRD +![Screenshot](assets/image--008.png) + +With sample yaml CRD definition + +```yaml +apiVersion: mongodb.com/v1 +kind: MongoDBOpsManager +metadata: + name: ops-manager + namespace: mongodb +spec: + # the version of Ops Manager to use + version: 4.4.1 + + # the name of the secret containing admin user credentials. + adminCredentials: ops-manager-admin-secret + + externalConnectivity: + type: LoadBalancer + + # the Replica Set backing Ops Manager. + # appDB has the SCRAM-SHA authentication mode always enabled + applicationDatabase: + members: 3 +``` + +Change the `adminCredentials` property to link to the name of the secret created previously. In this example it is ops-manager-admin. + +`Click create.` + +>For more detailed installation visit our blog post: https://www.mongodb.com/blog/post/running-mongodb-ops-manager-in-kubernetes + +Step 7: Verify MongoDB Ops Manager is successfully deployed. Verify Ops Manager resource and ensure that ops-manager resource reached Running state : +`oc describe om ops-manager` + + +>NOTE: Wait for the secret ops-manager-admin-key to be created. It contains Global Admin Programmatic API that will be required in the subsequent steps. We recommend to create new Programmatic API Key scoped to a single Ops Manager Organization https://docs.opsmanager.mongodb.com/rapid/tutorial/manage-programmatic-api-keys/#mms-prog-api-key + + +Please note OpsManager URL exposed by LoadBalancer before moving to the next Section + +## Deploy MongoDB + +In order to create MongoDB Cluster three Kubernetes resources need to be deployed. https://docs.mongodb.com/kubernetes-operator/stable/mdb-resources/ + +1. Kubernetes ConfigMap that contain settings for Operator to connect to Ops Manager + ```bash + os create configmap \ + --from-literal="baseUrl=" \ + --from-literal="projectName=" \ #Optional + --from-literal="orgId=" + ``` + >OpsManagerURL is an Ops Manager url including port (default 8080) noted in Step 7. + +>Documentation: https://docs.mongodb.com/kubernetes-operator/stable/tutorial/create-project-using-configmap/#create-k8s-project + + +2. Kubernetes Secret containing Programmatic API Key to Operator to connect to Ops Manager. +> ops-manager-admin-key secret could be used instead for none production deployments. + +``` +oc -n \ + create secret generic \ + --from-literal="user=" \ + --from-literal="publicApiKey=" + ``` + +For instructions on how to create Ops Manager Organization and Programmatic API Key please refer to documentation: https://docs.mongodb.com/kubernetes-operator/stable/tutorial/create-operator-credentials/#create-k8s-credentials + +3. Deploy Ops Manager +![Deploy MongoDB](assets/image--030.png) + +Click on the first tile to create the MongoDB Deployment Instance + +![Deploy MongoDB](assets/image--032.png) + +* Choose a name for MongoDB cluster 'metadata.name` +* Substitute the values `spec.OpsManager` with a reference to the config map `` +* Substitute the values `spec.credentials` with secret name ``. + +`Click Create. ` + +>For comprehensive Documentation, please visit https://docs.mongodb.com/kubernetes-operator/stable/mdb-resources/ + +### Verify MongoDB cluster is operational + +Verify Status of MongoDB Resource reached ``Running`` state +>Optionally monitor state of pods, sts and services linked to MongoDB CRD +![Deploy MongoDB](assets/image--034.png) + +>Note: MongoDB Enterprise Operator logs are the best source to start troubleshooting any issues with deployments + +### Connect to MongoDB Cluster + +MongoDB Enterprise Operator create Kubernetes Service For each MongoDB deployed using default port 27017. + +` ..svc.` + +MongoDB Connection String could be built using SRV record + +` mongodb+srv://..svc.` + +***In order to connect to MongoDB from outside of OpenShift cluster an ingress route needs to be created manually. Operator does not create ingress or external services.*** + +***MongoDB ReplicaSet External connectivity requires Split Horizon Configuration: [Connect to a MongoDB Database Resource from Outside Kubernetes](https://docs.mongodb.com/kubernetes-operator/stable/tutorial/connect-from-outside-k8s/)*** + +>EXAMPLE +To connect to a sharded cluster resource named shardedcluster, you might use the following connection string:
``mongo --host shardedcluster-mongos-0.shardedcluster-svc.mongodb.svc.cluster.local --port 27017`` + diff --git a/helm_chart/Chart.yaml b/helm_chart/Chart.yaml new file mode 100644 index 0000000000000000000000000000000000000000..43cda30a0ec8b3f94e929e468044b53650d3115a --- /dev/null +++ b/helm_chart/Chart.yaml @@ -0,0 +1,11 @@ +name: mongodb-enterprise-operator +description: MongoDB Kubernetes Enterprise Operator +version: 1.8.0 +kubeVersion: '>=1.13-0' +keywords: +- mongodb +- database +- nosql +home: https://github.com/mongodb/mongodb-enterprise-kubernetes +maintainers: +- name: Cloud Team diff --git a/helm_chart/crds/mongodb.mongodb.com.yaml b/helm_chart/crds/mongodb.mongodb.com.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fe9a453b67b5fa8ee81c32c3445ebee9ab6afc8d --- /dev/null +++ b/helm_chart/crds/mongodb.mongodb.com.yaml @@ -0,0 +1,557 @@ +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: mongodb.mongodb.com +spec: + group: mongodb.com + version: v1 + scope: Namespaced + names: + kind: MongoDB + plural: mongodb + shortNames: + - mdb + singular: mongodb + additionalPrinterColumns: + - name: Type + type: string + description: "The type of MongoDB deployment. One of 'ReplicaSet', 'ShardedCluster' and 'Standalone'." + JSONPath: .spec.type + - name: State + type: string + description: The current state of the MongoDB deployment. + JSONPath: .status.phase + - name: Version + type: string + description: The version of MongoDB. + JSONPath: .spec.version + - name: Age + type: date + description: The time since the MongoDB resource was created. + JSONPath: .metadata.creationTimestamp + subresources: + status: {} + validation: + openAPIV3Schema: + type: object + properties: + spec: + type: object + required: + - credentials + - type + - version + oneOf: + - required: [cloudManager] + - required: [opsManager] + - required: [project] + properties: + type: + type: string + enum: ["Standalone", "ReplicaSet", "ShardedCluster"] + credentials: + type: string + project: + type: string + description: "DEPRECATED The name of a configMap in the same namespace" + opsManager: + type: object + properties: + configMapRef: + type: object + properties: + name: + type: string + cloudManager: + type: object + properties: + configMapRef: + type: object + properties: + name: + type: string + + version: + type: string + pattern: "^[0-9]+.[0-9]+.[0-9]+(-.+)?$" + logLevel: + type: string + enum: ["DEBUG", "INFO", "WARN", "ERROR", "FATAL"] + persistent: + type: boolean + clusterName: + type: string + format: hostname + description: "DEPRECATED Use clusterDomain instead" + clusterDomain: + type: string + format: hostname + + additionalMongodConfig: + type: object + exposedExternally: + type: boolean + + agent: + type: object + properties: + startupOptions: + type: object + + # Generic PodSpec configuration + podSpec: + type: object + properties: + podTemplate: + type: object + properties: + metadata: + type: object + spec: + type: object + podAntiAffinityTopologyKey: + type: string + cpu: + type: string + cpuRequests: + type: string + memory: + type: string + memoryRequests: + type: string + podAffinity: + type: object + nodeAffinity: + type: object + persistence: + type: object + properties: + single: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + multiple: + type: object + properties: + data: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + journal: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + logs: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + + # TLS & authentication properties + security: + type: object + properties: + authentication: + type: object + properties: + agents: + type: object + properties: + mode: + type: string + enum: ["SCRAM", "X509", "LDAP"] + automationUsername: + type: string + automationPasswordSecretRef: + type: object + properties: + name: + type: string + key: + type: string + automationLdapGroupDN: + type: string + clientCertificateSecretRef: + type: object + properties: + name: + type: string + required: + - mode + enabled: + type: boolean + modes: + type: array + items: + type: string + enum: ["SCRAM", "X509", "LDAP"] + ignoreUnknownUsers: + type: boolean + requireClientTLSAuthentication: + type: boolean + tls: + type: object + properties: + enabled: + type: boolean + ca: + type: string + secretRef: + type: object + properties: + name: + type: string + additionalCertificateDomains: + type: array + items: + type: string + + ldap: + type: object + properties: + bindQueryUser: + type: string + servers: + type: array + items: + type: string + transportSecurity: + type: string + enum: ["none", "tls"] + bindQueryPasswordSecretRef: + type: object + properties: + name: + type: string + caConfigMapRef: + type: object + authzQueryTemplate: + type: string + userToDNMapping: + type: string + roles: + type: array + description: "List of roles not bounded to specific users" + items: + type: object + properties: + role: + type: string + description: "The name of the role" + db: + type: string + description: "The db the role belongs to" + roles: + type: array + description: "List of roles this role inherits from" + items: + type: object + properties: + db: + type: string + description: "The db the role belongs to" + role: + type: string + description: "The name of the role" + authenticationRestrictions: + type: array + description: "List of restriction for users authenticating to this role" + items: + type: object + properties: + clientSource: + type: array + description: "List of IP addresses or CIDR ranges allowed the user can connect from" + items: + type: string + serverAddress: + type: array + description: "List of IP addresses or CIDR ranges allowed the user can connect to" + items: + type: string + privileges: + type: array + description: "List of privileges granted to this role" + items: + type: object + properties: + actions: + type: array + description: "List of actions allowed to this role" + items: + type: string + resource: + type: object + description: "Resource on which the privileges are granted" + properties: + db: + type: string + description: "Name of the database" + collection: + type: string + description: "Name of the collection" + cluster: + type: boolean + description: "True for cluster-wide privileges" + + # Sharded Cluster properties + shardPodSpec: + type: object + properties: + podTemplate: + type: object + properties: + metadata: + type: object + spec: + type: object + podAntiAffinityTopologyKey: + type: string + cpu: + type: string + cpuRequests: + type: string + memory: + type: string + memoryRequests: + type: string + podAffinity: + type: object + nodeAffinity: + type: object + persistence: + type: object + properties: + single: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + multiple: + type: object + properties: + data: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + journal: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + logs: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + mongosPodSpec: + type: object + properties: + podTemplate: + type: object + properties: + metadata: + type: object + spec: + type: object + podAntiAffinityTopologyKey: + type: string + cpu: + type: string + cpuRequests: + type: string + memory: + type: string + memoryRequests: + type: string + podAffinity: + type: object + nodeAffinity: + type: object + persistence: + type: object + properties: + single: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + multiple: + type: object + properties: + data: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + journal: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + logs: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + configSrvPodSpec: + type: object + properties: + podTemplate: + type: object + properties: + metadata: + type: object + spec: + type: object + podAntiAffinityTopologyKey: + type: string + cpu: + type: string + cpuRequests: + type: string + memory: + type: string + memoryRequests: + type: string + podAffinity: + type: object + nodeAffinity: + type: object + persistence: + type: object + properties: + single: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + multiple: + type: object + properties: + data: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + journal: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + logs: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + configServerCount: + minimum: 1 + type: integer + mongodsPerShardCount: + minimum: 1 + type: integer + mongosCount: + minimum: 1 + type: integer + shardCount: + minimum: 1 + type: integer + mongos: + type: object + properties: + additionalMongodConfig: + type: object + agent: + type: object + properties: + startupOptions: + type: object + configSrv: + type: object + properties: + additionalMongodConfig: + type: object + agent: + type: object + properties: + startupOptions: + type: object + shard: + type: object + properties: + additionalMongodConfig: + type: object + agent: + type: object + properties: + startupOptions: + type: object diff --git a/helm_chart/crds/mongodbusers.mongodb.com.yaml b/helm_chart/crds/mongodbusers.mongodb.com.yaml new file mode 100644 index 0000000000000000000000000000000000000000..856e461a2bee14e3c25e48e5575fd6a9ff52cefb --- /dev/null +++ b/helm_chart/crds/mongodbusers.mongodb.com.yaml @@ -0,0 +1,80 @@ +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: mongodbusers.mongodb.com +spec: + group: mongodb.com + version: v1 + scope: Namespaced + names: + kind: MongoDBUser + plural: mongodbusers + shortNames: + - mdbu + singular: mongodbuser + additionalPrinterColumns: + - name: State + type: string + description: The current state of the MongoDB User + JSONPath: .status.phase + - name: Age + type: date + description: The time since the MongoDB User resource was created + JSONPath: .metadata.creationTimestamp + subresources: + status: {} + validation: + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + username: + type: string + description: "The username of the user" + db: + type: string + description: "The database the user is stored in" + project: + type: string + description: "The project the user belongs to" + passwordSecretKeyRef: + type: object + properties: + name: + type: string + key: + type: string + description: "DEPRECATED The project the user belongs to" + mongodbResourceRef: + type: object + properties: + name: + type: string + description: "The name of a MongoDB resource in the same namespace" + roles: + type: array + items: + type: object + properties: + name: + type: string + description: "The name of the role" + db: + type: string + description: "The db the role can act on" + passwordSecretKeyRef: + type: object + properties: + name: + type: string + key: + type: string + required: + - name + - db + required: + - username + - db diff --git a/helm_chart/crds/opsmanagers.mongodb.com.yaml b/helm_chart/crds/opsmanagers.mongodb.com.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e595a3552f7d41fb11a65b1f85b913a0f98c4da1 --- /dev/null +++ b/helm_chart/crds/opsmanagers.mongodb.com.yaml @@ -0,0 +1,345 @@ +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: opsmanagers.mongodb.com +spec: + group: mongodb.com + version: v1 + scope: Namespaced + names: + kind: MongoDBOpsManager + plural: opsmanagers + shortNames: + - om + singular: opsmanager + additionalPrinterColumns: + - name: Replicas + type: integer + description: The number of replicas of MongoDBOpsManager. + JSONPath: .spec.replicas + - name: Version + type: string + description: The version of MongoDBOpsManager. + JSONPath: .spec.version + - name: State (OpsManager) + type: string + description: The current state of the MongoDBOpsManager. + JSONPath: .status.opsManager.phase + - name: State (AppDB) + type: string + description: The current state of the MongoDBOpsManager Application Database. + JSONPath: .status.applicationDatabase.phase + - name: State (Backup) + type: string + description: The current state of the MongoDBOpsManager Backup Daemon. + JSONPath: .status.backup.phase + - name: Age + type: date + description: The time since the MongoDBOpsManager resource was created. + JSONPath: .metadata.creationTimestamp + - name: Warnings + type: string + description: Warnings + JSONPath: .status.warnings + subresources: + status: {} + validation: + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + version: + type: string + replicas: + minimum: 1 + type: integer + clusterName: + type: string + format: hostname + description: "DEPRECATED Use clusterDomain instead" + clusterDomain: + type: string + format: hostname + + security: + type: object + properties: + tls: + type: object + properties: + ca: + type: string + secretRef: + type: object + properties: + name: + type: string + required: + - name + + adminCredentials: + type: string + externalConnectivity: + type: object + properties: + type: + type: string + enum: ["LoadBalancer", "NodePort"] + port: + type: integer + loadBalancerIP: + type: string + externalTrafficPolicy: + type: string + enum: ["Cluster", "Local"] + annotations: + type: object + required: + - type + configuration: + type: object + jvmParameters: + type: array + items: + type: string + statefulSet: + type: object + properties: + spec: + type: object + backup: + type: object + properties: + enabled: + type: boolean + jvmParameters: + type: array + items: + type: string + headDB: + type: object + properties: + storage: + type: string + storageClass: + type: string + opLogStores: + type: array + items: + type: object + properties: + name: + type: string + mongodbResourceRef: + type: object + properties: + name: + type: string + required: + - name + mongodbUserRef: + type: object + properties: + name: + type: string + required: + - name + required: + - name + - mongodbResourceRef + blockStores: + type: array + items: + type: object + properties: + name: + type: string + mongodbResourceRef: + type: object + properties: + name: + type: string + required: + - name + mongodbUserRef: + type: object + properties: + name: + type: string + required: + - name + required: + - name + - mongodbResourceRef + s3Stores: + type: array + items: + type: object + properties: + name: + type: string + mongodbResourceRef: + type: object + properties: + name: + type: string + required: + - name + mongodbUserRef: + type: object + properties: + name: + type: string + required: + - name + pathStyleAccessEnabled: + type: boolean + s3BucketEndpoint: + type: string + s3BucketName: + type: string + s3SecretRef: + type: object + properties: + name: + type: string + required: + - name + - pathStyleAccessEnabled + - s3BucketEndpoint + - s3BucketName + - s3SecretRef + statefulSet: + type: object + properties: + spec: + type: object + required: + - enabled + applicationDatabase: + type: object + properties: + passwordSecretKeyRef: + type: object + properties: + name: + type: string + key: + type: string + required: + - name + security: + type: object + properties: + tls: + type: object + properties: + ca: + type: string + secretRef: + type: object + properties: + name: + type: string + required: + - name + required: + - secretRef + members: + maximum: 50 + minimum: 3 + type: integer + version: + type: string + pattern: "^[0-9]+.[0-9]+.[0-9]+(-.+)?$|^$" + logLevel: + type: string + enum: ["DEBUG", "INFO", "WARN", "ERROR", "FATAL"] + persistent: + type: boolean + statefulSet: + type: object + properties: + spec: + type: object + + agent: + type: object + properties: + startupOptions: + type: object + + podSpec: + type: object + properties: + podTemplate: + type: object + properties: + metadata: + type: object + spec: + type: object + podAntiAffinityTopologyKey: + type: string + cpu: + type: string + cpuRequests: + type: string + memory: + type: string + memoryRequests: + type: string + podAffinity: + type: object + nodeAffinity: + type: object + persistence: + type: object + properties: + single: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + multiple: + type: object + properties: + data: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + journal: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + logs: + type: object + properties: + storage: + type: string + storageClass: + type: string + labelSelector: + type: object + required: + - members + required: + - version + - applicationDatabase diff --git a/helm_chart/crds/webhook-cluster-role.yaml b/helm_chart/crds/webhook-cluster-role.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a487956d26a673b74dec2ecb1d9edb719adecf97 --- /dev/null +++ b/helm_chart/crds/webhook-cluster-role.yaml @@ -0,0 +1,15 @@ +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-enterprise-operator-mongodb-webhook +rules: + - apiGroups: + - "admissionregistration.k8s.io" + resources: + - validatingwebhookconfigurations + verbs: + - get + - create + - update + - delete diff --git a/helm_chart/templates/database-roles.yaml b/helm_chart/templates/database-roles.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4461c722ab1c155deedb8d7cdbede89cda3d080b --- /dev/null +++ b/helm_chart/templates/database-roles.yaml @@ -0,0 +1,86 @@ +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-enterprise-appdb + {{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }} + namespace: {{ .Values.operator.watchNamespace }} + {{- else }} + namespace: {{ .Values.namespace }} + {{- end }} +{{- if .Values.registry.imagePullSecrets}} +imagePullSecrets: + - name: {{ .Values.registry.imagePullSecrets }} +{{- end }} + +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-enterprise-database-pods + {{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }} + namespace: {{ .Values.operator.watchNamespace }} + {{- else }} + namespace: {{ .Values.namespace }} + {{- end }} +{{- if .Values.registry.imagePullSecrets}} +imagePullSecrets: + - name: {{ .Values.registry.imagePullSecrets }} +{{- end }} + +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-enterprise-ops-manager + {{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }} + namespace: {{ .Values.operator.watchNamespace }} + {{- else }} + namespace: {{ .Values.namespace }} + {{- end }} +{{- if .Values.registry.imagePullSecrets}} +imagePullSecrets: + - name: {{ .Values.registry.imagePullSecrets }} +{{- end }} + +--- +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-enterprise-appdb + {{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }} + namespace: {{ .Values.operator.watchNamespace }} + {{- else }} + namespace: {{ .Values.namespace }} + {{- end }} +rules: + - apiGroups: + - "" + resources: + - secrets + verbs: + - get + +--- +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-enterprise-appdb + {{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }} + namespace: {{ .Values.operator.watchNamespace }} + {{- else }} + namespace: {{ .Values.namespace }} + {{- end }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: mongodb-enterprise-appdb +subjects: + - kind: ServiceAccount + name: mongodb-enterprise-appdb + {{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }} + namespace: {{ .Values.operator.watchNamespace }} + {{- else }} + namespace: {{ .Values.namespace }} + {{- end }} + diff --git a/helm_chart/templates/operator-roles.yaml b/helm_chart/templates/operator-roles.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ccca3e754008cd9c21cdf85463bb559c2a6ae537 --- /dev/null +++ b/helm_chart/templates/operator-roles.yaml @@ -0,0 +1,150 @@ +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Values.operator.name }} + {{- if .Values.namespace }} + namespace: {{ .Values.namespace }} + {{- end }} +{{- if .Values.registry.imagePullSecrets}} +imagePullSecrets: + - name: {{ .Values.registry.imagePullSecrets }} +{{- end }} + + +--- +kind: {{ if eq (.Values.operator.watchNamespace | default "") "*" }} ClusterRole {{ else }} Role {{ end }} +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ .Values.operator.name }} + {{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }} + namespace: {{ .Values.operator.watchNamespace }} + {{- else }} + namespace: {{ .Values.namespace }} + {{- end }} +rules: +- apiGroups: + - "" + resources: + - configmaps + - secrets + - services + verbs: + - get + - list + - create + - update + - delete + - watch +- apiGroups: + - apps + resources: + - statefulsets + verbs: + - create + - get + - list + - watch + - delete + - update + {{- if eq (.Values.operator.watchNamespace | default "") "*" }} +- apiGroups: + - "" + resources: + - namespaces + verbs: + - list + - watch + {{- end}} +- apiGroups: + - mongodb.com + resources: + - mongodb + - mongodb/finalizers + - mongodbusers + - opsmanagers + - opsmanagers/finalizers +{{- if .Values.subresourceEnabled }} + - mongodb/status + - mongodbusers/status + - opsmanagers/status +{{- end }} + verbs: + - "*" +# This ClusterRoleBinding is necessary in order to use validating +# webhooks—these will prevent you from applying a variety of invalid resource +# definitions. The validating webhooks are optional so this can be removed if +# necessary. +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ .Values.operator.name }}-{{ .Values.namespace }}-webhook-binding + namespace: {{ .Values.namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: mongodb-enterprise-operator-mongodb-webhook +subjects: +- kind: ServiceAccount + name: {{ .Values.operator.name }} + namespace: {{ .Values.namespace }} + +--- +kind: {{ if eq (.Values.operator.watchNamespace | default "") "*" }} ClusterRoleBinding {{ else }} RoleBinding {{ end }} +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ .Values.operator.name }} + {{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }} + namespace: {{ .Values.operator.watchNamespace }} + {{- else }} + namespace: {{ .Values.namespace }} + {{- end }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: {{ if eq (.Values.operator.watchNamespace | default "") "*" }} ClusterRole {{ else }} Role {{ end }} + name: {{ .Values.operator.name }} +subjects: +- kind: ServiceAccount + name: {{ .Values.operator.name }} + {{- if .Values.namespace }} + namespace: {{ .Values.namespace }} + {{- end }} + +# This ClusterRole is needed if the user wants to use the Kubernetes CA +# infrastructure to generate certificates. +{{- if .Values.needsCAInfrastructure }} +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ .Values.operator.name }}-{{ .Values.namespace }}-certs +rules: +- apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests + verbs: + - get + - create + - list + - watch + +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ .Values.operator.name }}-{{ .Values.namespace }}-certs-binding + namespace: {{ .Values.namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ .Values.operator.name }}-{{ .Values.namespace }}-certs +subjects: +- kind: ServiceAccount + name: {{ .Values.operator.name }} + namespace: {{ .Values.namespace }} + +{{- end }} + + diff --git a/helm_chart/templates/operator.yaml b/helm_chart/templates/operator.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e662a019d1b4efd32f4a1f1c8a50df750df029c8 --- /dev/null +++ b/helm_chart/templates/operator.yaml @@ -0,0 +1,110 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.operator.name }} +{{- if .Values.namespace }} + namespace: {{ .Values.namespace }} +{{- end }} +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: {{ .Values.operator.name }} + app.kubernetes.io/instance: {{ .Values.operator.name }} + template: + metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: {{ .Values.operator.name }} + app.kubernetes.io/instance: {{ .Values.operator.name }} + spec: + serviceAccountName: {{ .Values.operator.name }} +{{- if not .Values.managedSecurityContext }} + securityContext: + runAsNonRoot: true + runAsUser: 2000 +{{- end }} +{{- if .Values.registry.imagePullSecrets}} + imagePullSecrets: + - name: {{ .Values.registry.imagePullSecrets }} +{{- end }} + containers: + - name: {{ .Values.operator.deployment_name }} + image: {{ .Values.registry.operator }}/{{ .Values.operator.name }}:{{ .Values.operator.version }} + imagePullPolicy: {{ .Values.registry.pullPolicy }} + {{- if .Values.operator.watchedResources }} + args: + {{- range .Values.operator.watchedResources }} + - "-watch-resource={{ . }}" + {{- end }} + command: + - "/usr/local/bin/mongodb-enterprise-operator" + {{- end }} + env: + - name: OPERATOR_ENV + value: {{ .Values.operator.env }} + - name: WATCH_NAMESPACE +{{- if .Values.operator.watchNamespace}} + value: "{{ .Values.operator.watchNamespace }}" +{{- else }} + valueFrom: + fieldRef: + fieldPath: metadata.namespace +{{- end }} + - name: CURRENT_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace +{{- if eq .Values.managedSecurityContext true }} + - name: MANAGED_SECURITY_CONTEXT + value: 'true' +{{- end }} + - name: IMAGE_PULL_POLICY + value: {{ .Values.registry.pullPolicy }} + # Database + - name: MONGODB_ENTERPRISE_DATABASE_IMAGE + value: {{ .Values.registry.database }}/{{ .Values.database.name }} + - name: INIT_DATABASE_IMAGE_REPOSITORY + value: {{ .Values.registry.initDatabase }}/{{ .Values.initDatabase.name }} + - name: INIT_DATABASE_VERSION + value: {{ .Values.initDatabase.version }} + - name: DATABASE_VERSION + value: {{ .Values.database.version }} + # Ops Manager + - name: OPS_MANAGER_IMAGE_REPOSITORY + value: {{ .Values.registry.opsManager }}/{{ .Values.opsManager.name }} + - name: INIT_OPS_MANAGER_IMAGE_REPOSITORY + value: {{ .Values.registry.initOpsManager }}/{{ .Values.initOpsManager.name }} + - name: INIT_OPS_MANAGER_VERSION + value: {{ .Values.initOpsManager.version }} + # AppDB + - name: APPDB_IMAGE_REPOSITORY + value: {{ .Values.registry.appDb }}/{{ .Values.appDb.name }} + - name: INIT_APPDB_IMAGE_REPOSITORY + value: {{ .Values.registry.initAppDb }}/{{ .Values.initAppDb.name }} + - name: INIT_APPDB_VERSION + value: {{ .Values.initAppDb.version }} + - name: OPS_MANAGER_IMAGE_PULL_POLICY + value: {{ .Values.registry.pullPolicy }} +{{- if .Values.registry.imagePullSecrets }} + - name: IMAGE_PULL_SECRETS + value: {{ .Values.registry.imagePullSecrets }} +{{- end }} + +{{- if .Values.debug }} +--- +apiVersion: v1 +kind: Service +metadata: + name: debug-svc +spec: + type: NodePort + ports: + - nodePort: {{ .Values.debugPort }} + port: 40000 + protocol: TCP + selector: + app: {{ .Values.operator.name }} +{{- end }} diff --git a/helm_chart/values-openshift.yaml b/helm_chart/values-openshift.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9cfe6aa78ebf4ec7ce321f43ad81788309033eef --- /dev/null +++ b/helm_chart/values-openshift.yaml @@ -0,0 +1,70 @@ +# Name of the Namespace to use +namespace: mongodb + +# OpenShift manages security context on its own +managedSecurityContext: true + +operator: + # Execution environment for the operator, dev or prod. Use dev for more verbose logging + env: prod + + # Name that will be assigned to most of internal Kubernetes objects like Deployment, ServiceAccount, Role etc. + name: enterprise-operator + + # Name of the deployment of the operator pod + deployment_name: mongodb-enterprise-operator + + # Version of mongodb-enterprise-operator and mongodb-enterprise-database images + version: 1.8.0 + + # The Custom Resources that will be watched by the Operator. Needs to be changed if only some of the CRDs are installed + watchedResources: + - mongodb + - opsmanagers + - mongodbusers + +## Database +database: + name: enterprise-database + version: 2.0.0 + +initDatabase: + name: mongodb-enterprise-init-database + version: 1.0.0 + +## Ops Manager +opsManager: + name: mongodb-enterprise-ops-manager + +initOpsManager: + name: mongodb-enterprise-init-ops-manager + version: 1.0.2 + +## Application Database +appDb: + name: mongodb-enterprise-appdb + +initAppDb: + name: mongodb-enterprise-init-appdb + version: 1.0.4 + +## Registry +registry: + # The pull secret must be specified + imagePullSecrets: + pullPolicy: Always + database: registry.connect.redhat.com/mongodb + operator: registry.connect.redhat.com/mongodb + initDatabase: registry.connect.redhat.com/mongodb + initOpsManager: registry.connect.redhat.com/mongodb + opsManager: registry.connect.redhat.com/mongodb + initAppDb: registry.connect.redhat.com/mongodb + appDb: registry.connect.redhat.com/mongodb + +# Set this to true if the operator will require Kubernetes CA +# infrastructure to generate TLS certificates. +needsCAInfrastructure: true + +# Set this to false to disable subresource utilization +# It might be required on some versions of Openshift +subresourceEnabled: true diff --git a/helm_chart/values.yaml b/helm_chart/values.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f121f99e20fc24c3dc69e980d28756024c458b21 --- /dev/null +++ b/helm_chart/values.yaml @@ -0,0 +1,74 @@ +# Name of the Namespace to use +namespace: mongodb + +## Operator + +# Set this to true if your cluster is managing SecurityContext for you. +# If running OpenShift (Cloud, Minishift, etc.), set this to true. +managedSecurityContext: false + +operator: + # Execution environment for the operator, dev or prod. Use dev for more verbose logging + env: prod + + # Name that will be assigned to most of internal Kubernetes objects like Deployment, ServiceAccount, Role etc. + name: mongodb-enterprise-operator + + # Name of the deployment of the operator pod + deployment_name: mongodb-enterprise-operator + + # Version of mongodb-enterprise-operator and mongodb-enterprise-database images + version: 1.8.0 + + # The Custom Resources that will be watched by the Operator. Needs to be changed if only some of the CRDs are installed + watchedResources: + - mongodb + - opsmanagers + - mongodbusers + +## Database +database: + name: mongodb-enterprise-database + version: 2.0.0 + +initDatabase: + name: mongodb-enterprise-init-database + version: 1.0.0 + +## Ops Manager +opsManager: + name: mongodb-enterprise-ops-manager + +initOpsManager: + name: mongodb-enterprise-init-ops-manager + version: 1.0.2 + +## Application Database +appDb: + name: mongodb-enterprise-appdb + +initAppDb: + name: mongodb-enterprise-init-appdb + version: 1.0.4 + +## Registry +registry: + imagePullSecrets: + # TODO: specify for each image and move there? + pullPolicy: Always + # Specify if images are pulled from private registry + operator: quay.io/mongodb + database: quay.io/mongodb + initDatabase: quay.io/mongodb + initOpsManager: quay.io/mongodb + opsManager: quay.io/mongodb + initAppDb: quay.io/mongodb + appDb: quay.io/mongodb + +# Set this to true if the operator will require Kubernetes CA +# infrastructure to generate TLS certificates. +needsCAInfrastructure: true + +# Set this to false to disable subresource utilization +# It might be required on some versions of Openshift +subresourceEnabled: true diff --git a/mongodb-enterprise-openshift.yaml b/mongodb-enterprise-openshift.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d00b8c9d6b954592c3c1883bbf06e1032379cf8a --- /dev/null +++ b/mongodb-enterprise-openshift.yaml @@ -0,0 +1,242 @@ +--- +# Source: mongodb-enterprise-operator/templates/operator-roles.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: enterprise-operator + namespace: mongodb +--- +# Source: mongodb-enterprise-operator/templates/operator-roles.yaml +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: enterprise-operator-mongodb-certs +rules: +- apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests + verbs: + - get + - create + - list + - watch +--- +# Source: mongodb-enterprise-operator/templates/operator-roles.yaml +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: enterprise-operator-mongodb-webhook-binding + namespace: mongodb +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: mongodb-enterprise-operator-mongodb-webhook +subjects: +- kind: ServiceAccount + name: enterprise-operator + namespace: mongodb +--- +# Source: mongodb-enterprise-operator/templates/operator-roles.yaml +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: enterprise-operator-mongodb-certs-binding + namespace: mongodb +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: enterprise-operator-mongodb-certs +subjects: +- kind: ServiceAccount + name: enterprise-operator + namespace: mongodb +--- +# Source: mongodb-enterprise-operator/templates/operator-roles.yaml +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: enterprise-operator + namespace: mongodb +rules: +- apiGroups: + - "" + resources: + - configmaps + - secrets + - services + verbs: + - get + - list + - create + - update + - delete + - watch +- apiGroups: + - apps + resources: + - statefulsets + verbs: + - create + - get + - list + - watch + - delete + - update +- apiGroups: + - mongodb.com + resources: + - mongodb + - mongodb/finalizers + - mongodbusers + - opsmanagers + - opsmanagers/finalizers + - mongodb/status + - mongodbusers/status + - opsmanagers/status + verbs: + - "*" +# This ClusterRoleBinding is necessary in order to use validating +# webhooks—these will prevent you from applying a variety of invalid resource +# definitions. The validating webhooks are optional so this can be removed if +# necessary. +--- +# Source: mongodb-enterprise-operator/templates/operator-roles.yaml +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: enterprise-operator + namespace: mongodb +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: enterprise-operator +subjects: +- kind: ServiceAccount + name: enterprise-operator + namespace: mongodb + +# This ClusterRole is needed if the user wants to use the Kubernetes CA +# infrastructure to generate certificates. +--- +# Source: mongodb-enterprise-operator/templates/database-roles.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-enterprise-appdb + namespace: mongodb +--- +# Source: mongodb-enterprise-operator/templates/database-roles.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-enterprise-database-pods + namespace: mongodb +--- +# Source: mongodb-enterprise-operator/templates/database-roles.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-enterprise-ops-manager + namespace: mongodb +--- +# Source: mongodb-enterprise-operator/templates/database-roles.yaml +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-enterprise-appdb + namespace: mongodb +rules: + - apiGroups: + - "" + resources: + - secrets + verbs: + - get +--- +# Source: mongodb-enterprise-operator/templates/database-roles.yaml +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-enterprise-appdb + namespace: mongodb +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: mongodb-enterprise-appdb +subjects: + - kind: ServiceAccount + name: mongodb-enterprise-appdb + namespace: mongodb +--- +# Source: mongodb-enterprise-operator/templates/operator.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: enterprise-operator + namespace: mongodb +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: enterprise-operator + app.kubernetes.io/instance: enterprise-operator + template: + metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: enterprise-operator + app.kubernetes.io/instance: enterprise-operator + spec: + serviceAccountName: enterprise-operator + containers: + - name: mongodb-enterprise-operator + image: registry.connect.redhat.com/mongodb/enterprise-operator:1.8.0 + imagePullPolicy: Always + args: + - "-watch-resource=mongodb" + - "-watch-resource=opsmanagers" + - "-watch-resource=mongodbusers" + command: + - "/usr/local/bin/mongodb-enterprise-operator" + env: + - name: OPERATOR_ENV + value: prod + - name: WATCH_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: CURRENT_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: MANAGED_SECURITY_CONTEXT + value: 'true' + - name: IMAGE_PULL_POLICY + value: Always + # Database + - name: MONGODB_ENTERPRISE_DATABASE_IMAGE + value: registry.connect.redhat.com/mongodb/enterprise-database + - name: INIT_DATABASE_IMAGE_REPOSITORY + value: registry.connect.redhat.com/mongodb/mongodb-enterprise-init-database + - name: INIT_DATABASE_VERSION + value: 1.0.0 + - name: DATABASE_VERSION + value: 2.0.0 + # Ops Manager + - name: OPS_MANAGER_IMAGE_REPOSITORY + value: registry.connect.redhat.com/mongodb/mongodb-enterprise-ops-manager + - name: INIT_OPS_MANAGER_IMAGE_REPOSITORY + value: registry.connect.redhat.com/mongodb/mongodb-enterprise-init-ops-manager + - name: INIT_OPS_MANAGER_VERSION + value: 1.0.2 + # AppDB + - name: APPDB_IMAGE_REPOSITORY + value: registry.connect.redhat.com/mongodb/mongodb-enterprise-appdb + - name: INIT_APPDB_IMAGE_REPOSITORY + value: registry.connect.redhat.com/mongodb/mongodb-enterprise-init-appdb + - name: INIT_APPDB_VERSION + value: 1.0.4 + - name: OPS_MANAGER_IMAGE_PULL_POLICY + value: Always diff --git a/mongodb-enterprise.yaml b/mongodb-enterprise.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e63d699c652976102adc0aeadfe2db5d69a5a281 --- /dev/null +++ b/mongodb-enterprise.yaml @@ -0,0 +1,243 @@ +--- +# Source: mongodb-enterprise-operator/templates/operator-roles.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-enterprise-operator + namespace: mongodb +--- +# Source: mongodb-enterprise-operator/templates/operator-roles.yaml +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-enterprise-operator-mongodb-certs +rules: +- apiGroups: + - certificates.k8s.io + resources: + - certificatesigningrequests + verbs: + - get + - create + - list + - watch +--- +# Source: mongodb-enterprise-operator/templates/operator-roles.yaml +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-enterprise-operator-mongodb-webhook-binding + namespace: mongodb +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: mongodb-enterprise-operator-mongodb-webhook +subjects: +- kind: ServiceAccount + name: mongodb-enterprise-operator + namespace: mongodb +--- +# Source: mongodb-enterprise-operator/templates/operator-roles.yaml +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-enterprise-operator-mongodb-certs-binding + namespace: mongodb +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: mongodb-enterprise-operator-mongodb-certs +subjects: +- kind: ServiceAccount + name: mongodb-enterprise-operator + namespace: mongodb +--- +# Source: mongodb-enterprise-operator/templates/operator-roles.yaml +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-enterprise-operator + namespace: mongodb +rules: +- apiGroups: + - "" + resources: + - configmaps + - secrets + - services + verbs: + - get + - list + - create + - update + - delete + - watch +- apiGroups: + - apps + resources: + - statefulsets + verbs: + - create + - get + - list + - watch + - delete + - update +- apiGroups: + - mongodb.com + resources: + - mongodb + - mongodb/finalizers + - mongodbusers + - opsmanagers + - opsmanagers/finalizers + - mongodb/status + - mongodbusers/status + - opsmanagers/status + verbs: + - "*" +# This ClusterRoleBinding is necessary in order to use validating +# webhooks—these will prevent you from applying a variety of invalid resource +# definitions. The validating webhooks are optional so this can be removed if +# necessary. +--- +# Source: mongodb-enterprise-operator/templates/operator-roles.yaml +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-enterprise-operator + namespace: mongodb +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: mongodb-enterprise-operator +subjects: +- kind: ServiceAccount + name: mongodb-enterprise-operator + namespace: mongodb + +# This ClusterRole is needed if the user wants to use the Kubernetes CA +# infrastructure to generate certificates. +--- +# Source: mongodb-enterprise-operator/templates/database-roles.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-enterprise-appdb + namespace: mongodb +--- +# Source: mongodb-enterprise-operator/templates/database-roles.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-enterprise-database-pods + namespace: mongodb +--- +# Source: mongodb-enterprise-operator/templates/database-roles.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: mongodb-enterprise-ops-manager + namespace: mongodb +--- +# Source: mongodb-enterprise-operator/templates/database-roles.yaml +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-enterprise-appdb + namespace: mongodb +rules: + - apiGroups: + - "" + resources: + - secrets + verbs: + - get +--- +# Source: mongodb-enterprise-operator/templates/database-roles.yaml +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: mongodb-enterprise-appdb + namespace: mongodb +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: mongodb-enterprise-appdb +subjects: + - kind: ServiceAccount + name: mongodb-enterprise-appdb + namespace: mongodb +--- +# Source: mongodb-enterprise-operator/templates/operator.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mongodb-enterprise-operator + namespace: mongodb +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: mongodb-enterprise-operator + app.kubernetes.io/instance: mongodb-enterprise-operator + template: + metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/name: mongodb-enterprise-operator + app.kubernetes.io/instance: mongodb-enterprise-operator + spec: + serviceAccountName: mongodb-enterprise-operator + securityContext: + runAsNonRoot: true + runAsUser: 2000 + containers: + - name: mongodb-enterprise-operator + image: quay.io/mongodb/mongodb-enterprise-operator:1.8.0 + imagePullPolicy: Always + args: + - "-watch-resource=mongodb" + - "-watch-resource=opsmanagers" + - "-watch-resource=mongodbusers" + command: + - "/usr/local/bin/mongodb-enterprise-operator" + env: + - name: OPERATOR_ENV + value: prod + - name: WATCH_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: CURRENT_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: IMAGE_PULL_POLICY + value: Always + # Database + - name: MONGODB_ENTERPRISE_DATABASE_IMAGE + value: quay.io/mongodb/mongodb-enterprise-database + - name: INIT_DATABASE_IMAGE_REPOSITORY + value: quay.io/mongodb/mongodb-enterprise-init-database + - name: INIT_DATABASE_VERSION + value: 1.0.0 + - name: DATABASE_VERSION + value: 2.0.0 + # Ops Manager + - name: OPS_MANAGER_IMAGE_REPOSITORY + value: quay.io/mongodb/mongodb-enterprise-ops-manager + - name: INIT_OPS_MANAGER_IMAGE_REPOSITORY + value: quay.io/mongodb/mongodb-enterprise-init-ops-manager + - name: INIT_OPS_MANAGER_VERSION + value: 1.0.2 + # AppDB + - name: APPDB_IMAGE_REPOSITORY + value: quay.io/mongodb/mongodb-enterprise-appdb + - name: INIT_APPDB_IMAGE_REPOSITORY + value: quay.io/mongodb/mongodb-enterprise-init-appdb + - name: INIT_APPDB_VERSION + value: 1.0.4 + - name: OPS_MANAGER_IMAGE_PULL_POLICY + value: Always diff --git a/openshift-install.md b/openshift-install.md new file mode 100644 index 0000000000000000000000000000000000000000..df87d1a41b1671e1a3621214cdc8fc3e265c2ad9 --- /dev/null +++ b/openshift-install.md @@ -0,0 +1,91 @@ +# OpenShift Install + +The MongoDB Enterprise Operator requires a set of images including `operator`, `database` and others. The Openshift +installation requires images to be based on Red Hat Enterprise Linux, and these images are published to [Red Hat +Container Catalog](https://catalog.redhat.com/software/containers/explore/). You will have to create special credentials +for your OpenShift installation to be able to fetch images from this registry. + +## Create your OpenShift Secret + +First, complete the instructions +[here](https://access.redhat.com/terms-based-registry/#/token/openshift3-test-cluster/docker-config). Unfortunately, +these instructions refer to a `registry.redhat.io` Registry which is not the one we need, but they accept the same +credentials. First, click on "view its contents" to display the contents we need, and save these contents into a json +file. This file includes 1 entry for `registry.redhat.io`; replicate that entry with a new name, +"`registry.connect.redhat.com`", as in the following example: + +```json +{ + "auths": { + "registry.redhat.io": { + "auth": "YOURBASE64USERNAMEANDPASSWORD" + }, + "registry.connect.redhat.com": { + "auth": "YOURBASE64USERNAMEANDPASSWORD" + } + } +} +``` + +Now save this file and create a `Secret` object from it: +``` +$ kubectl -n create secret generic openshift-pull-secrets --from-file=.dockerconfigjson= \ + --type=kubernetes.io/dockerconfigjson +``` + +## Install the Operator using the new Secret to pull images + +### Installation using .yaml config file + +Now that the `Secret` has been created, you need to reference it from the `mongodb-enterprise-openshift.yaml` file. +When you edit this file, you'll realize that there's a `Deployment` object at the end (the one with name +`enterprise-operator`). This `Deployment` needs to be modified slightly, under the `spec` section you need to add +a new attribute, with name `imagePullSecrets` and use the name of the `Secrets` object that you downloaded and created. +The `spec` section will look something like: + +```yaml +# ... + +spec: + imagePullSecrets: + - name: openshift-pull-secrets # this is where the name of the Secret goes + ... + containers: + - name: enterprise-operator + ... +# ... +``` + +That's one image. You will also have to set a new environment variable, on the `env` section, like in the following +snippet: + +```yaml +containers: +- name: enterprise-operator + image: registry.connect.redhat.com/mongodb/enterprise-operator: + imagePullPolicy: Always + + env: + ... + - name: IMAGE_PULL_SECRETS + value: openshift-pull-secrets + ... +``` + +Now that we have instructed our OpenShift cluster to be able to fetch images from the Red Hat registry we will be able +to install the operator using: + +```bash +$ kubectl -n -f mongodb-enterprise-openshift.yaml +``` + +From now on, the OpenShift cluster will be authenticated to pull images from the Red Hat registry. Now you should be +able to return to the regular instructions for Kubernetes. + +### Installation using Helm + +As an alternative to manual editing the config files you can use the following command to install the Operator using `Helm`: + +```bash +helm install --set registry.imagePullSecrets=openshift-pull-secrets --values helm_chart/values-openshift.yaml helm_chart +``` diff --git a/samples/mongodb/affinity/replica-set-affinity.yaml b/samples/mongodb/affinity/replica-set-affinity.yaml new file mode 100644 index 0000000000000000000000000000000000000000..99ef0467674216c943b22b35915f038b3f55be87 --- /dev/null +++ b/samples/mongodb/affinity/replica-set-affinity.yaml @@ -0,0 +1,40 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-replica-set +spec: + members: 3 + version: 4.2.1-ent + service: my-service + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + type: ReplicaSet + + persistent: true + podSpec: + memory: 512M + # For podAffinity and nodeAffinity see Kubernetes Docs + # https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + podAntiAffinityTopologyKey: nodeId + podAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: security + operator: In + values: + - S1 + topologyKey: failure-domain.beta.kubernetes.io/zone + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/e2e-az-name + operator: In + values: + - e2e-az1 + - e2e-az2 diff --git a/samples/mongodb/affinity/sharded-cluster-affinity.yaml b/samples/mongodb/affinity/sharded-cluster-affinity.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4aea7a1f1570be6f941d99877fed99a4951c01f7 --- /dev/null +++ b/samples/mongodb/affinity/sharded-cluster-affinity.yaml @@ -0,0 +1,45 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-sharded-cluster +spec: + shardCount: 2 + mongodsPerShardCount: 3 + mongosCount: 2 + configServerCount: 3 + version: 4.2.1-ent + service: my-service + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + type: ShardedCluster + + persistent: true + configSrvPodSpec: + # For podAffinity and nodeAffinity see Kubernetes Docs + # https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + podAntiAffinityTopologyKey: kubernetes.io/hostname + podAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: security + operator: In + values: + - S1 + topologyKey: failure-domain.beta.kubernetes.io/zone + mongosPodSpec: + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + preference: + matchExpressions: + - key: another-node-label-key + operator: In + values: + - another-node-label-value + shardPodSpec: + podAntiAffinityTopologyKey: rackId diff --git a/samples/mongodb/affinity/standalone-affinity.yaml b/samples/mongodb/affinity/standalone-affinity.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e8a62db69eae7b6669bb1a14cb671e803b952aed --- /dev/null +++ b/samples/mongodb/affinity/standalone-affinity.yaml @@ -0,0 +1,37 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-standalone +spec: + version: 4.2.1-ent + service: my-service + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + type: Standalone + + persistent: true + podSpec: + # For podAffinity and nodeAffinity see Kubernetes Docs + # https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + podAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: security + operator: In + values: + - S1 + topologyKey: failure-domain.beta.kubernetes.io/zone + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/e2e-az-name + operator: In + values: + - e2e-az1 + - e2e-az2 diff --git a/samples/mongodb/agent-startup-options/replica-set-agent-startup-options.yaml b/samples/mongodb/agent-startup-options/replica-set-agent-startup-options.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8e651a77cc8dacf9ce8fdeec2da7bdec16cd7b72 --- /dev/null +++ b/samples/mongodb/agent-startup-options/replica-set-agent-startup-options.yaml @@ -0,0 +1,21 @@ +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-replica-set-agent-parameters +spec: + members: 3 + version: 4.4.0-ent + type: ReplicaSet + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + persistent: true + # optional. Allows to pass custom flags that will be used + # when launching the mongodb agent. All values must be strings + # The full list of available settings is at: + # https://docs.opsmanager.mongodb.com/current/reference/mongodb-agent-settings/ + agent: + startupOptions: + maxLogFiles: "30" + dialTimeoutSeconds: "40" diff --git a/samples/mongodb/agent-startup-options/sharded-cluster-agent-startup-options.yaml b/samples/mongodb/agent-startup-options/sharded-cluster-agent-startup-options.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a32a9c04f7abd50edae02543a99819a72918c197 --- /dev/null +++ b/samples/mongodb/agent-startup-options/sharded-cluster-agent-startup-options.yaml @@ -0,0 +1,45 @@ +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-sharded-cluster-options +spec: + version: 4.4.0-ent + type: ShardedCluster + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + persistent: true + shardCount: 2 + mongodsPerShardCount: 3 + mongosCount: 2 + configServerCount: 1 + + mongos: + # optional. Allows to pass custom flags that will be used + # when launching the mongodb agent for mongos processes. + # All values must be string + # The full list of available settings is at: + # https://docs.opsmanager.mongodb.com/current/reference/mongodb-agent-settings/ + agent: + startupOptions: + maxLogFiles: "30" + + configSrv: + # optional. Allows to pass custom flags that will be used + # when launching the mongodb agent for Config Server mongod processes. + # All values must be string + # The full list of available settings is at: + # https://docs.opsmanager.mongodb.com/current/reference/mongodb-agent-settings/ + agent: + startupOptions: + dialTimeoutSeconds: "40" + shard: + # optional. Allows to pass custom flags that will be used + # when launching the mongodb agent for Shards mongod processes. + # All values must be string + # The full list of available settings is at: + # https://docs.opsmanager.mongodb.com/current/reference/mongodb-agent-settings/ + agent: + startupOptions: + serverSelectionTimeoutSeconds: "20" diff --git a/samples/mongodb/agent-startup-options/standalone-agent-startup-options.yaml b/samples/mongodb/agent-startup-options/standalone-agent-startup-options.yaml new file mode 100644 index 0000000000000000000000000000000000000000..55ae9a0e51376e10efc4a211bfcbd2c07401e4a3 --- /dev/null +++ b/samples/mongodb/agent-startup-options/standalone-agent-startup-options.yaml @@ -0,0 +1,24 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-standalone +spec: + version: 4.4.0-ent + service: my-service + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + type: Standalone + + persistent: true + # optional. Allows to pass custom flags that will be used + # when launching the mongodb agent. All values must be strings + # The full list of available settings is at: + # https://docs.opsmanager.mongodb.com/current/reference/mongodb-agent-settings/ + agent: + startupOptions: + maxLogFiles: "30" + dialTimeoutSeconds: "40" diff --git a/samples/mongodb/authentication/ldap/replica-set/replica-set-ldap-user.yaml b/samples/mongodb/authentication/ldap/replica-set/replica-set-ldap-user.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cd7571646d2c841d5fffb4966e9eb78fa6f798ed --- /dev/null +++ b/samples/mongodb/authentication/ldap/replica-set/replica-set-ldap-user.yaml @@ -0,0 +1,19 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDBUser +metadata: + name: my-ldap-user +spec: + username: my-ldap-user + db: $external + mongodbResourceRef: + name: my-ldap-enabled-replica-set # The name of the MongoDB resource this user will be added to + roles: + - db: admin + name: clusterAdmin + - db: admin + name: userAdminAnyDatabase + - db: admin + name: readWrite + - db: admin + name: userAdminAnyDatabase diff --git a/samples/mongodb/authentication/ldap/replica-set/replica-set-ldap.yaml b/samples/mongodb/authentication/ldap/replica-set/replica-set-ldap.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8ba72fcec2ea8512e57aa99c0dddd0e55b2605c6 --- /dev/null +++ b/samples/mongodb/authentication/ldap/replica-set/replica-set-ldap.yaml @@ -0,0 +1,53 @@ +# Creates a MongoDB Replica Set with LDAP Authentication Enabled. +# LDAP is an Enterprise-only feature. + +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-ldap-enabled-replica-set +spec: + type: ReplicaSet + members: 3 + version: 4.0.4-ent + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + + security: + authentication: + enabled: true + # Enabled LDAP Authentication Mode + modes: ["LDAP"] + + # LDAP related configuration + ldap: + # Specify the hostname:port combination of one or + # more LDAP servers + servers: + - "" + - "" + + # Set to "tls" to use LDAP over TLS. Leave blank if + # LDAP server does not accept TLS. + transportSecurity: "tls" + + # ConfigMap containing a CA certificate that validates + # the LDAP server's TLS certificate. + caConfigMapRef: + name: "" + key: "" + + # Specify the LDAP Distinguished Name to which + # MongoDB binds when connecting to the LDAP server + bindQueryUser: "cn=admin,dc=example,dc=org" + + # Specify the password with which MongoDB binds + # when connecting to an LDAP server. This is a + # reference to a Secret Kubernetes Object containing + # one "password" key. + bindQueryPasswordSecretRef: + name: "" + diff --git a/samples/mongodb/authentication/ldap/sharded-cluster/sharded-cluster-ldap-user.yaml b/samples/mongodb/authentication/ldap/sharded-cluster/sharded-cluster-ldap-user.yaml new file mode 100644 index 0000000000000000000000000000000000000000..aeb7e7d6967d2b34f5a967112648cc00f59c6dff --- /dev/null +++ b/samples/mongodb/authentication/ldap/sharded-cluster/sharded-cluster-ldap-user.yaml @@ -0,0 +1,19 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDBUser +metadata: + name: my-ldap-user +spec: + username: my-ldap-user + db: $external + mongodbResourceRef: + name: my-ldap-enabled-sharded-cluster # The name of the MongoDB resource this user will be added to + roles: + - db: admin + name: clusterAdmin + - db: admin + name: userAdminAnyDatabase + - db: admin + name: readWrite + - db: admin + name: userAdminAnyDatabase diff --git a/samples/mongodb/authentication/ldap/sharded-cluster/sharded-cluster-ldap.yaml b/samples/mongodb/authentication/ldap/sharded-cluster/sharded-cluster-ldap.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c1fe491ba5061ae27eeba4e36cfad419cf32f023 --- /dev/null +++ b/samples/mongodb/authentication/ldap/sharded-cluster/sharded-cluster-ldap.yaml @@ -0,0 +1,56 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-ldap-enabled-sharded-cluster +spec: + type: ShardedCluster + + shardCount: 2 + mongodsPerShardCount: 3 + mongosCount: 2 + configServerCount: 3 + + version: 4.0.4-ent + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + + security: + authentication: + enabled: true + + # Enabled LDAP Authentication Mode + modes: ["LDAP"] + + # LDAP related configuration + ldap: + # Specify the hostname:port combination of one or + # more LDAP servers + servers: + - "" + - "" + + # Set to "tls" to use LDAP over TLS. Leave blank if + # LDAP server does not accept TLS. + transportSecurity: "tls" + + # ConfigMap containing a CA certificate that validates + # the LDAP server's TLS certificate. + caConfigMapRef: + name: "" + key: "" + + # Specify the LDAP Distinguished Name to which + # MongoDB binds when connecting to the LDAP server + bindQueryUser: "cn=admin,dc=example,dc=org" + + # Specify the password with which MongoDB binds + # when connecting to an LDAP server. This is a + # reference to a Secret Kubernetes Object containing + # one "password" key. + bindQueryPasswordSecretRef: + name: "" + diff --git a/samples/mongodb/authentication/scram/replica-set/replica-set-scram-password.yaml b/samples/mongodb/authentication/scram/replica-set/replica-set-scram-password.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6fa081096b6ea4bcf65c3ec1b99b31606b4e1ede --- /dev/null +++ b/samples/mongodb/authentication/scram/replica-set/replica-set-scram-password.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: v1 +kind: Secret +metadata: + name: my-scram-secret +type: Opaque +stringData: + password: my-replica-set-password diff --git a/samples/mongodb/authentication/scram/replica-set/replica-set-scram-sha.yaml b/samples/mongodb/authentication/scram/replica-set/replica-set-scram-sha.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1b924ca4ca1c283fe2ab59aa566158adbce1346b --- /dev/null +++ b/samples/mongodb/authentication/scram/replica-set/replica-set-scram-sha.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-scram-enabled-replica-set +spec: + type: ReplicaSet + members: 3 + + # Using a version >= 4.0 will enable SCRAM-SHA-256 authentication + # setting a version < 4.0 will enable SCRAM-SHA-1/MONGODB-CR authentication + version: 4.0.4-ent + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + + security: + authentication: + enabled: true + modes: ["SCRAM"] # Valid authentication modes are "SCRAM' and "X509" + + # Optional field - ignoreUnknownUsers + # A value of true means that any users not configured via the Operator or the Ops Manager or Cloud Manager UI + # will not be altered in any way + + # If you need to manage MongoDB users directly via the mongods, set this value to true + ignoreUnknownUsers: true # default value false + diff --git a/samples/mongodb/authentication/scram/replica-set/replica-set-scram-user.yaml b/samples/mongodb/authentication/scram/replica-set/replica-set-scram-user.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0e43b9f27e4dffa38929c90c9dd31b12a40e45e6 --- /dev/null +++ b/samples/mongodb/authentication/scram/replica-set/replica-set-scram-user.yaml @@ -0,0 +1,22 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDBUser +metadata: + name: my-scram-user +spec: + passwordSecretKeyRef: + name: my-scram-secret # the name of the secret that stores this user's password + key: password # the key in the secret that stores the password + username: my-scram-user + db: admin + mongodbResourceRef: + name: my-scram-enabled-replica-set # The name of the MongoDB resource this user will be added to + roles: + - db: admin + name: clusterAdmin + - db: admin + name: userAdminAnyDatabase + - db: admin + name: readWrite + - db: admin + name: userAdminAnyDatabase diff --git a/samples/mongodb/authentication/scram/sharded-cluster/sharded-cluster-scram-password.yaml b/samples/mongodb/authentication/scram/sharded-cluster/sharded-cluster-scram-password.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fb1b353af82beb4418bb491cff52f98e3ba88160 --- /dev/null +++ b/samples/mongodb/authentication/scram/sharded-cluster/sharded-cluster-scram-password.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: v1 +kind: Secret +metadata: + name: my-scram-secret +type: Opaque +stringData: + password: my-sharded-cluster-password diff --git a/samples/mongodb/authentication/scram/sharded-cluster/sharded-cluster-scram-sha.yaml b/samples/mongodb/authentication/scram/sharded-cluster/sharded-cluster-scram-sha.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a1477a4b543ad2050be79d6468c2249dec55fb2e --- /dev/null +++ b/samples/mongodb/authentication/scram/sharded-cluster/sharded-cluster-scram-sha.yaml @@ -0,0 +1,34 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-scram-enabled-sharded-cluster +spec: + type: ShardedCluster + + shardCount: 2 + mongodsPerShardCount: 3 + mongosCount: 2 + configServerCount: 3 + + # Using a version >= 4.0 will enable SCRAM-SHA-256 authentication + # setting a version < 4.0 will enable SCRAM-SHA-1/MONGODB-CR authentication + version: 4.0.4-ent + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + + security: + authentication: + enabled: true + modes: ["SCRAM"] # Valid authentication modes are "SCRAM' and "X509" + + # Optional field - ignoreUnknownUsers + # A value of true means that any users not configured via the Operator or the Ops Manager or Cloud Manager UI + # will not be altered in any way + + # If you need to manage MongoDB users directly via the mongods, set this value to true + ignoreUnknownUsers: true # default value false + diff --git a/samples/mongodb/authentication/scram/sharded-cluster/sharded-cluster-scram-user.yaml b/samples/mongodb/authentication/scram/sharded-cluster/sharded-cluster-scram-user.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a62c3f10d3effc946c9aed2f6c0dcde83d7c2e19 --- /dev/null +++ b/samples/mongodb/authentication/scram/sharded-cluster/sharded-cluster-scram-user.yaml @@ -0,0 +1,19 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDBUser +metadata: + name: my-scram-user +spec: + passwordSecretKeyRef: + name: my-scram-secret # the name of the secret that stores this user's password + key: password # the key in the secret that stores the password + username: my-scram-user + db: admin + mongodbResourceRef: + name: my-scram-enabled-sharded-cluster # The name of the MongoDB resource this user will be added to + roles: + - db: admin + name: clusterAdmin + - db: admin + name: userAdminAnyDatabase + diff --git a/samples/mongodb/authentication/scram/standalone/standalone-scram-password.yaml b/samples/mongodb/authentication/scram/standalone/standalone-scram-password.yaml new file mode 100644 index 0000000000000000000000000000000000000000..92101f7f5a9c6f24f5692dd555ef4a64d845edfa --- /dev/null +++ b/samples/mongodb/authentication/scram/standalone/standalone-scram-password.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: v1 +kind: Secret +metadata: + name: my-scram-secret +type: Opaque +stringData: + password: my-standalone-password diff --git a/samples/mongodb/authentication/scram/standalone/standalone-scram-sha.yaml b/samples/mongodb/authentication/scram/standalone/standalone-scram-sha.yaml new file mode 100644 index 0000000000000000000000000000000000000000..10a056a401a82e43465894459e77115d4ce221b8 --- /dev/null +++ b/samples/mongodb/authentication/scram/standalone/standalone-scram-sha.yaml @@ -0,0 +1,29 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-scram-enabled-standalone +spec: + type: Standalone + + # Using a version >= 4.0 will enable SCRAM-SHA-256 authentication + # setting a version < 4.0 will enable SCRAM-SHA-1/MONGODB-CR authentication + version: 3.6.0-ent + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + + security: + authentication: + enabled: true + modes: ["SCRAM"] # Valid authentication modes are "SCRAM' and "X509" + + # Optional field - ignoreUnknownUsers + # A value of true means that any users not configured via the Operator or the Ops Manager or Cloud Manager UI + # will not be altered in any way + + # If you need to manage MongoDB users directly via the mongods, set this value to true + ignoreUnknownUsers: true # default value false + diff --git a/samples/mongodb/authentication/scram/standalone/standalone-scram-user.yaml b/samples/mongodb/authentication/scram/standalone/standalone-scram-user.yaml new file mode 100644 index 0000000000000000000000000000000000000000..02948d75c0e3372f1a9fd92b8bdcdcb3275b20d4 --- /dev/null +++ b/samples/mongodb/authentication/scram/standalone/standalone-scram-user.yaml @@ -0,0 +1,18 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDBUser +metadata: + name: my-scram-user +spec: + passwordSecretKeyRef: + name: my-scram-secret # the name of the secret that stores this user's password + key: password # the key in the secret that stores the password + username: my-scram-user + db: admin + mongodbResourceRef: + name: my-scram-enabled-standalone # The name of the MongoDB resource this user will be added to + roles: + - db: admin + name: readWrite + - db: admin + name: userAdminAnyDatabase diff --git a/samples/mongodb/authentication/x509/replica-set/replica-set-x509.yaml b/samples/mongodb/authentication/x509/replica-set/replica-set-x509.yaml new file mode 100644 index 0000000000000000000000000000000000000000..45af6b3f29dc3f8420200e120e668209759a174e --- /dev/null +++ b/samples/mongodb/authentication/x509/replica-set/replica-set-x509.yaml @@ -0,0 +1,39 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-replica-set +spec: + type: ReplicaSet + + members: 3 + version: 4.0.4-ent + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + + # look into `replica-set-persistent-volumes.yaml` for an example on how to use + # Kubernetes Persistent Volumes in your MDB deployment. + persistent: false + + # This will create a TLS & x509 enabled Replica Set, which means that all the traffic + # between members of the Replica Set and clients, will be encrypted using TLS + # certificates. These certificates will be generated on the fly by the operator + # using the Kubernetes CA. + # + # More information about setting up x509 client authentication in Ops Manager: + # + # https://docs.opsmanager.mongodb.com/current/tutorial/enable-x509-authentication-for-group + # + # Please refer to Kubernetes TLS Documentation on how to approve these certs: + # + # https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/ + # + security: + tls: + enabled: true + authentication: + enabled: true + modes: ["X509"] diff --git a/samples/mongodb/authentication/x509/replica-set/user.yaml b/samples/mongodb/authentication/x509/replica-set/user.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b639671075aedba0c1fbc73022d456a7ea6a3584 --- /dev/null +++ b/samples/mongodb/authentication/x509/replica-set/user.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDBUser +metadata: + name: my-replica-set-x509-user +spec: + username: CN=my-replica-set-x509-user,OU=cloud,O=MongoDB,L=New York,ST=New York,C=US + db: $external + mongodbResourceRef: + name: my-replica-set + roles: + - db: admin + name: dbOwner diff --git a/samples/mongodb/authentication/x509/sharded-cluster/sharded-cluster-x509.yaml b/samples/mongodb/authentication/x509/sharded-cluster/sharded-cluster-x509.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fbee157dd14dececd794bf3faf1fd2326d3a11d0 --- /dev/null +++ b/samples/mongodb/authentication/x509/sharded-cluster/sharded-cluster-x509.yaml @@ -0,0 +1,42 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-x509-enabled-sc +spec: + type: ShardedCluster + + shardCount: 2 + mongodsPerShardCount: 3 + mongosCount: 2 + configServerCount: 3 + + version: 4.0.6-ent + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + + persistent: false + + # This will create a TLS & x509 enabled Sharded Cluster, which means that all the traffic + # between members of the Shards and clients, will be encrypted using TLS + # certificates. These certificates will be generated on the fly by the operator + # using the Kubernetes CA. + # + # More information about setting up x509 client authentication in Ops Manager: + # + # https://docs.opsmanager.mongodb.com/current/tutorial/enable-x509-authentication-for-group + # + # Please refer to Kubernetes TLS Documentation on how to approve these certs: + # + # https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/ + # + security: + authentication: + enabled: true + modes: ["X509"] + internalCluster: "X509" + tls: + enabled: true diff --git a/samples/mongodb/authentication/x509/sharded-cluster/user.yaml b/samples/mongodb/authentication/x509/sharded-cluster/user.yaml new file mode 100644 index 0000000000000000000000000000000000000000..67005b42971be28509c993fefb8b2292366643ea --- /dev/null +++ b/samples/mongodb/authentication/x509/sharded-cluster/user.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDBUser +metadata: + name: my-sharded-cluster-x509-user +spec: + username: CN=my-sharded-cluster-x509-user,OU=cloud,O=MongoDB,L=New York,ST=New York,C=US + db: $external + mongodbResourceRef: + name: my-replica-set + roles: + - db: admin + name: dbOwner diff --git a/samples/mongodb/external-connectivity/replica-set-external.yaml b/samples/mongodb/external-connectivity/replica-set-external.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f890f3cc0be0769dd458520b0954acfac14fc37e --- /dev/null +++ b/samples/mongodb/external-connectivity/replica-set-external.yaml @@ -0,0 +1,36 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-externally-connectible-rs +spec: + type: ReplicaSet + + members: 3 + version: 4.2.0-ent + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + + security: + tls: + # TLS must be enabled to allow external connectivity + enabled: true + + connectivity: + # replicaSetHorizons consists of a list of maps where each map represents a node within + # the replica set and maps names of DNS horizons to externally connectable DNS names. + # In the following example, this would allow a client to make a replica set connection + # from outside the replica set using a connection string like + # mongodb://mdb0-test-website.com:1337,mdb1-test-website.com:1338,mdb2-test-website.com:1339. + # The length of the replicaSetHorizons list must be equal to the number of the members in the + # replica set and each member should have all of the same DNS horizon names specified. + replicaSetHorizons: + - "test-horizon-1": "mdb0-test-website.com:1337" + "test-horizon-2": "mdb0-test-internal-website.com:2337" + - "test-horizon-1": "mdb1-test-website.com:1338" + "test-horizon-2": "mdb1-test-internal-website.com:2338" + - "test-horizon-1": "mdb2-test-website.com:1339" + "test-horizon-2": "mdb2-test-internal-website.com:2339" diff --git a/samples/mongodb/minimal/replica-set.yaml b/samples/mongodb/minimal/replica-set.yaml new file mode 100644 index 0000000000000000000000000000000000000000..363cac3549fa40ba10f524fc689aa383221a0396 --- /dev/null +++ b/samples/mongodb/minimal/replica-set.yaml @@ -0,0 +1,35 @@ +# +# This is a minimal config. To see all the options available, refer to the +# "extended" directory +# +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-replica-set +spec: + members: 3 + version: 4.4.0-ent + type: ReplicaSet + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + + persistent: false + + podSpec: + # 'podTemplate' allows to set custom fields in PodTemplateSpec (https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#podtemplatespec-v1-core) + # for the Database StatefulSet. + podTemplate: + spec: + containers: + - name: mongodb-enterprise-database + resources: + limits: + cpu: "2" + memory: 700m + requests: + cpu: "1" + memory: 500m diff --git a/samples/mongodb/minimal/sharded-cluster.yaml b/samples/mongodb/minimal/sharded-cluster.yaml new file mode 100644 index 0000000000000000000000000000000000000000..493fc4b60254484ddaa47031fe580cd655bbb24b --- /dev/null +++ b/samples/mongodb/minimal/sharded-cluster.yaml @@ -0,0 +1,66 @@ +# +# This is a minimal config. To see all the options available, refer to the +# "extended" directory +# +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-sharded-cluster +spec: + shardCount: 2 + mongodsPerShardCount: 3 + mongosCount: 2 + configServerCount: 3 + version: 4.4.0-ent + type: ShardedCluster + # Before you create this object, you'll need to create a project ConfigMap and a + # credentials Secret. For instructions on how to do this, please refer to our + # documentation, here: + # https://docs.opsmanager.mongodb.com/current/tutorial/install-k8s-operator + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + + # This flag allows the creation of pods without persistent volumes. This is for + # testing only, and must not be used in production. 'false' will disable + # Persistent Volume Claims. The default is 'true' + persistent: false + + configSrvPodSpec: + podTemplate: + spec: + containers: + - name: mongodb-enterprise-database + resources: + limits: + cpu: "2" + memory: 700m + requests: + cpu: "1" + memory: 500m + shardPodSpec: + podTemplate: + spec: + containers: + - name: mongodb-enterprise-database + resources: + limits: + cpu: "2" + memory: 700m + requests: + cpu: "1" + memory: 500m + mongosPodSpec: + podTemplate: + spec: + containers: + - name: mongodb-enterprise-database + resources: + limits: + cpu: "1" + memory: 200m + requests: + cpu: "0.5" + memory: 100m \ No newline at end of file diff --git a/samples/mongodb/minimal/standalone.yaml b/samples/mongodb/minimal/standalone.yaml new file mode 100644 index 0000000000000000000000000000000000000000..30e1b8acf5c04d55e7dc1a943ad96e65a6142100 --- /dev/null +++ b/samples/mongodb/minimal/standalone.yaml @@ -0,0 +1,40 @@ +# +# This is a minimal config. To see all the options available, refer to the +# "extended" directory +# +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-standalone +spec: + version: 4.4.0-ent + type: Standalone + # Before you create this object, you'll need to create a project ConfigMap and a + # credentials Secret. For instructions on how to do this, please refer to our + # documentation, here: + # https://docs.opsmanager.mongodb.com/current/tutorial/install-k8s-operator + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + + # This flag allows the creation of pods without persistent volumes. This is for + # testing only, and must not be used in production. 'false' will disable + # Persistent Volume Claims. The default is 'true' + persistent: false + + podSpec: + # 'podTemplate' allows to set custom fields in PodTemplateSpec (https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#podtemplatespec-v1-core) + # for the Database StatefulSet. + podTemplate: + spec: + containers: + - name: mongodb-enterprise-database + resources: + limits: + cpu: "2" + memory: 700m + requests: + cpu: "1" + memory: 500m \ No newline at end of file diff --git a/samples/mongodb/mongodb-options/replica-set-mongod-options.yaml b/samples/mongodb/mongodb-options/replica-set-mongod-options.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a6c3265c6479f6335c9411add6187d908bd72d62 --- /dev/null +++ b/samples/mongodb/mongodb-options/replica-set-mongod-options.yaml @@ -0,0 +1,20 @@ +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-replica-set-options +spec: + members: 3 + version: 4.2.8-ent + type: ReplicaSet + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + persistent: true + # optional. Allows to pass custom MongoDB process configuration + additionalMongodConfig: + systemLog: + logAppend: true + verbosity: 4 + operationProfiling: + mode: slowOp diff --git a/samples/mongodb/mongodb-options/sharded-cluster-mongod-options.yaml b/samples/mongodb/mongodb-options/sharded-cluster-mongod-options.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fa5d40287e57e4af89b9c29f88a0453dedfc9e68 --- /dev/null +++ b/samples/mongodb/mongodb-options/sharded-cluster-mongod-options.yaml @@ -0,0 +1,33 @@ +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-sharded-cluster-options +spec: + version: 4.2.8-ent + type: ShardedCluster + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + persistent: true + shardCount: 2 + mongodsPerShardCount: 3 + mongosCount: 2 + configServerCount: 1 + mongos: + # optional. Allows to pass custom configuration for mongos processes + additionalMongodConfig: + systemLog: + logAppend: true + verbosity: 4 + configSrv: + # optional. Allows to pass custom configuration for Config Server mongod processes + additionalMongodConfig: + operationProfiling: + mode: slowOp + shard: + additionalMongodConfig: + # optional. Allows to pass custom configuration for Shards mongod processes + storage: + journal: + commitIntervalMs: 50 diff --git a/samples/mongodb/persistent-volumes/replica-set-persistent-volumes.yaml b/samples/mongodb/persistent-volumes/replica-set-persistent-volumes.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ffea5bac1a08ec7fea9382ec12a1cad23a55f973 --- /dev/null +++ b/samples/mongodb/persistent-volumes/replica-set-persistent-volumes.yaml @@ -0,0 +1,48 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-replica-set +spec: + members: 3 + version: 4.2.1-ent + service: my-service + + # Indicates featureCompatibilityVersion. This attribute will make the data + # format to persist in a particular version, maybe older, allowing for + # future downgrades if necessary. + featureCompatibilityVersion: "3.6" + + # Please Note: The default Kubernetes cluster domain is `cluster.local`. + # If your cluster has been configured with another domain, you can specify it + # with the `clusterDomain` attribute. + # clusterDomain: mycompany.net + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + type: ReplicaSet + + # log level affects the level of logging for the agent. Use DEBUG cautiously as log file size may grow very quickly + logLevel: WARN + + persistent: true + podSpec: + cpu: '0.25' + # note: it's important to always specify memory otherwise wired tiger cache will be calculated incorrectly and + # monitoring tools will report the size of Kubernetes node instead of the real size of the container + memory: 512M + # "multiple" persistence allows to mount different directories to different Persistent Volumes + persistence: + multiple: + data: + storage: 10Gi + journal: + storage: 1Gi + labelSelector: + matchLabels: + app: "my-app" + logs: + storage: 500M + storageClass: standard diff --git a/samples/mongodb/persistent-volumes/sharded-cluster-persistent-volumes.yaml b/samples/mongodb/persistent-volumes/sharded-cluster-persistent-volumes.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e5e580013df8cebb3b47d2e9c3b583293dcbceba --- /dev/null +++ b/samples/mongodb/persistent-volumes/sharded-cluster-persistent-volumes.yaml @@ -0,0 +1,52 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-sharded-cluster +spec: + shardCount: 2 + mongodsPerShardCount: 3 + mongosCount: 2 + configServerCount: 3 + version: 4.2.1-ent + service: my-service + + # Indicates featureCompatibilityVersion. This attribute will make the data + # format to persist in a particular version, maybe older, allowing for + # future downgrades if necessary. + featureCompatibilityVersion: "3.6" + + # Please Note: The default Kubernetes cluster domain is `cluster.local`. + # If your cluster has been configured with another domain, you can specify it + # with the `clusterDomain` attribute. + # clusterDomain: mycompany.net + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + type: ShardedCluster + + persistent: true + configSrvPodSpec: + cpu: '0.5' + # note: it's important to always specify memory otherwise wired tiger cache will be calculated incorrectly and + # monitoring tools will report the size of Kubernetes node instead of the real size of the container + memory: 512M + + # if "persistence" element is omitted then Operator uses the default size (5G) for mounting single Persistent Volume + # for config server + mongosPodSpec: + cpu: '0.8' + memory: 1G + shardPodSpec: + memory: 3G + persistence: + multiple: + # if the child of "multiple" is omitted then the default size will be used. + # 16G for "data", 1G for "journal", 3Gb for "logs" + data: + storage: 20G + logs: + storage: 4G + storageClass: standard diff --git a/samples/mongodb/persistent-volumes/standalone-persistent-volumes.yaml b/samples/mongodb/persistent-volumes/standalone-persistent-volumes.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1c55df30c76bc72ed58c4e7278f6593d332c914c --- /dev/null +++ b/samples/mongodb/persistent-volumes/standalone-persistent-volumes.yaml @@ -0,0 +1,39 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-standalone +spec: + version: 4.2.1-ent + service: my-service + + # Indicates featureCompatibilityVersion. This attribute will make the data + # format to persist in a particular version, maybe older, allowing for + # future downgrades if necessary. + featureCompatibilityVersion: "4.0" + + # Please Note: The default Kubernetes cluster domain is `cluster.local`. + # If your cluster has been configured with another domain, you can specify it + # with the `clusterDomain` attribute. + # clusterDomain: mycompany.net + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + type: Standalone + + persistent: true + podSpec: + cpu: '0.25' + # note: it's important to always specify memory otherwise wired tiger cache will be calculated incorrectly and + # monitoring tools will report the size of Kubernetes node instead of the real size of the container + memory: 512M + # "single" persistence allows to mount different directories to single Persistent Volume + persistence: + single: + storage: 12G + storageClass: standard + labelSelector: + matchExpressions: + - {key: environment, operator: In, values: [dev]} diff --git a/samples/mongodb/pod-template/initcontainer-sysctl_config.yaml b/samples/mongodb/pod-template/initcontainer-sysctl_config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..80f40acb86e0ed2faa2b115a33e838b2871d94d8 --- /dev/null +++ b/samples/mongodb/pod-template/initcontainer-sysctl_config.yaml @@ -0,0 +1,25 @@ +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-replica-set + namespace: mongodb +spec: + members: 3 + version: 4.2.2 + type: ReplicaSet + + cloudManager: + configMapRef: + name: my-project + credentials: my-credentials + + persistent: false + podSpec: + podTemplate: + spec: + initContainers: + - name: "apply-sysctl-test" + image: "busybox:latest" + securityContext: + privileged: true + command: ["sysctl", "-w", "net.ipv4.tcp_keepalive_time=120"] diff --git a/samples/mongodb/pod-template/replica-set-pod-template.yaml b/samples/mongodb/pod-template/replica-set-pod-template.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a104f2aa8f8c387ff99d0b09aa3d022dc18610c7 --- /dev/null +++ b/samples/mongodb/pod-template/replica-set-pod-template.yaml @@ -0,0 +1,31 @@ +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-replica-set-pod-template +spec: + members: 3 + version: 4.2.2-ent + type: ReplicaSet + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + + podSpec: + memory: 512M + # 'podTemplate' allows to set custom fields in PodTemplateSpec (https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#podtemplatespec-v1-core) + # for the Database StatefulSet. + podTemplate: + spec: + # This container will be added to each pod as a sidecar + containers: + - name: standalone-sidecar + image: busybox + command: ["sleep"] + args: [ "infinity" ] + resources: + limits: + cpu: "1" + requests: + cpu: 500m + diff --git a/samples/mongodb/pod-template/sharded-cluster-pod-template.yaml b/samples/mongodb/pod-template/sharded-cluster-pod-template.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1354b0e69815953d221eac42635d25aa093a3d31 --- /dev/null +++ b/samples/mongodb/pod-template/sharded-cluster-pod-template.yaml @@ -0,0 +1,45 @@ +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-sharded-cluster-pod-template +spec: + shardCount: 1 + mongodsPerShardCount: 1 + mongosCount: 1 + configServerCount: 1 + version: 4.0.14-ent + type: ShardedCluster + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + configSrvPodSpec: + podAntiAffinityTopologyKey: nodeId + podTemplate: + spec: + terminationGracePeriodSeconds: 120 + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + # Note, that this topology key will overwrite the antiAffinity topologyKey set by the Operator + # from 'spec.configSrvPodSpec.podAntiAffinityTopologyKey' + topologyKey: "failure-domain.beta.kubernetes.io/zone" + weight: 30 + mongosPodSpec: + podTemplate: + spec: + restartPolicy: Never + serviceAccountName: the-custom-user + shardPodSpec: + cpu: '0.8' + memory: 1G + podTemplate: + metadata: + annotations: + key1: value1 + spec: + tolerations: + - key: "key" + operator: "Exists" + effect: "NoSchedule" diff --git a/samples/mongodb/pod-template/standalone-pod-template.yaml b/samples/mongodb/pod-template/standalone-pod-template.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4d5a3ade9cb682ab03d64a930574d04d52af4220 --- /dev/null +++ b/samples/mongodb/pod-template/standalone-pod-template.yaml @@ -0,0 +1,17 @@ +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-standalone-pod-template +spec: + version: 4.2.2-ent + type: Standalone + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + podSpec: + podTemplate: + spec: + hostAliases: + - ip: "1.2.3.4" + hostnames: ["hostname"] diff --git a/samples/mongodb/podspec/replica-set-podspec.yaml b/samples/mongodb/podspec/replica-set-podspec.yaml new file mode 100644 index 0000000000000000000000000000000000000000..eda5edcbee60d60a88aadbba083b41703a3dfa23 --- /dev/null +++ b/samples/mongodb/podspec/replica-set-podspec.yaml @@ -0,0 +1,70 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-replica-set +spec: + members: 3 + version: 4.0.0-ent + service: my-service + + # Indicates featureCompatibilityVersion. This attribute will make the data + # format to persist in a particular version, maybe older, allowing for + # future downgrades if necessary. + featureCompatibilityVersion: "3.6" + + # Please Note: The default Kubernetes cluster domain is `cluster.local`. + # If your cluster has been configured with another domain, you can specify it + # with the `clusterDomain` attribute. + # clusterDomain: mycompany.net + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + type: ReplicaSet + + # log level affects the level of logging for the agent. Use DEBUG cautiously as log file size may grow very quickly + logLevel: WARN + + persistent: true + podSpec: + cpu: '0.25' + # note: it's important to always specify memory otherwise wired tiger cache will be calculated incorrectly and + # monitoring tools will report the size of Kubernetes node instead of the real size of the container + memory: 512M + # "multiple" persistence allows to mount different directories to different Persistent Volumes + persistence: + multiple: + data: + storage: 10Gi + journal: + storage: 1Gi + labelSelector: + matchLabels: + app: "my-app" + logs: + storage: 500M + storageClass: standard + + # For podAffinity and nodeAffinity see Kubernetes Docs + # https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + podAntiAffinityTopologyKey: nodeId + podAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: security + operator: In + values: + - S1 + topologyKey: failure-domain.beta.kubernetes.io/zone + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/e2e-az-name + operator: In + values: + - e2e-az1 + - e2e-az2 diff --git a/samples/mongodb/podspec/sharded-cluster-podspec.yaml b/samples/mongodb/podspec/sharded-cluster-podspec.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a6b3e6a37af772e36ae98f8467cf844458fe0556 --- /dev/null +++ b/samples/mongodb/podspec/sharded-cluster-podspec.yaml @@ -0,0 +1,77 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-sharded-cluster +spec: + shardCount: 2 + mongodsPerShardCount: 3 + mongosCount: 2 + configServerCount: 3 + version: 4.0.0-ent + service: my-service + + # Indicates featureCompatibilityVersion. This attribute will make the data + # format to persist in a particular version, maybe older, allowing for + # future downgrades if necessary. + featureCompatibilityVersion: "3.6" + + # Please Note: The default Kubernetes cluster domain is `cluster.local`. + # If your cluster has been configured with another domain, you can specify it + # with the `clusterDomain` attribute. + # clusterDomain: mycompany.net + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + type: ShardedCluster + + persistent: true + configSrvPodSpec: + cpu: '0.5' + # note: it's important to always specify memory otherwise wired tiger cache will be calculated incorrectly and + # monitoring tools will report the size of Kubernetes node instead of the real size of the container + memory: 512M + + # if "persistence" element is omitted then Operator uses the default size (5G) for mounting single Persistent Volume + # for config server + + # For podAffinity and nodeAffinity see Kubernetes Docs + # https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + podAntiAffinityTopologyKey: kubernetes.io/hostname + podAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: security + operator: In + values: + - S1 + topologyKey: failure-domain.beta.kubernetes.io/zone + mongosPodSpec: + cpu: '0.8' + memory: 1G + podAntiAffinityTopologyKey: rackId + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + preference: + matchExpressions: + - key: another-node-label-key + operator: In + values: + - another-node-label-value + shardPodSpec: + cpu: '0.6' + memory: 3G + persistence: + multiple: + # if the child of "multiple" is omitted then the default size will be used. + # 16G for "data", 1G for "journal", 3Gb for "logs" + data: + storage: 20G + logs: + storage: 4G + storageClass: standard + podAntiAffinityTopologyKey: kubernetes.io/hostname diff --git a/samples/mongodb/podspec/standalone-podspec.yaml b/samples/mongodb/podspec/standalone-podspec.yaml new file mode 100644 index 0000000000000000000000000000000000000000..af8d042e7a519e69d308a54a19317dc8af373d87 --- /dev/null +++ b/samples/mongodb/podspec/standalone-podspec.yaml @@ -0,0 +1,60 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-standalone +spec: + version: 4.0.0-ent + service: my-service + + # Indicates featureCompatibilityVersion. This attribute will make the data + # format to persist in a particular version, maybe older, allowing for + # future downgrades if necessary. + featureCompatibilityVersion: "4.0" + + # Please Note: The default Kubernetes cluster domain is `cluster.local`. + # If your cluster has been configured with another domain, you can specify it + # with the `clusterDomain` attribute. + # clusterDomain: mycompany.net + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + type: Standalone + + persistent: true + podSpec: + cpu: '0.25' + # note: it's important to always specify memory otherwise wired tiger cache will be calculated incorrectly and + # monitoring tools will report the size of Kubernetes node instead of the real size of the container + memory: 512M + # "single" persistence allows to mount different directories to single Persistent Volume + persistence: + single: + storage: 12G + storageClass: standard + labelSelector: + matchExpressions: + - {key: environment, operator: In, values: [dev]} + + # For podAffinity and nodeAffinity see Kubernetes Docs + # https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + podAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: security + operator: In + values: + - S1 + topologyKey: failure-domain.beta.kubernetes.io/zone + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/e2e-az-name + operator: In + values: + - e2e-az1 + - e2e-az2 diff --git a/samples/mongodb/project.yaml b/samples/mongodb/project.yaml new file mode 100644 index 0000000000000000000000000000000000000000..19067373996db4b4aef3bf8d9b379824eb158549 --- /dev/null +++ b/samples/mongodb/project.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: my-project +data: + projectName: My Ops/Cloud Manager Project + baseUrl: http://my-ops-cloud-manager-url + + # Optional parameters + + # If orgId is omitted a new organization will be created, with the same name as the Project. + orgId: my-org-id diff --git a/samples/mongodb/tls/replica-set/replica-set-tls.yaml b/samples/mongodb/tls/replica-set/replica-set-tls.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b51bd86bcf6d1a3f05b7d46c4f9eb8d177d42c73 --- /dev/null +++ b/samples/mongodb/tls/replica-set/replica-set-tls.yaml @@ -0,0 +1,39 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-tls-enabled-rs +spec: + type: ReplicaSet + + members: 3 + version: 4.0.4-ent + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + + # look into `replica-set-persistent-volumes.yaml` for an example on how to use + # Kubernetes Persistent Volumes in your MDB deployment. + persistent: false + + # This will create a TLS enabled Replica Set, which means that all the traffic + # between members of the Replica Set and clients, will be encrypted using TLS + # certificates. These certificates will be generated on the fly by the operator + # using the Kubernetes CA. + # Please refer to Kubernetes TLS Documentation on how to approve these certs: + # + # https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/ + # + security: + tls: + enabled: true + + # The default TLS mode is 'requireTLS' but it can be customized using the + # the `additionalMongodConfig` structure. Please find more information here: + # https://docs.mongodb.com/manual/reference/configuration-options/#net.ssl.mode + additionalMongodConfig: + net: + ssl: + mode: "preferSSL" diff --git a/samples/mongodb/tls/sharded-cluster/sharded-cluster-tls.yaml b/samples/mongodb/tls/sharded-cluster/sharded-cluster-tls.yaml new file mode 100644 index 0000000000000000000000000000000000000000..144f60b7db183310fbfd17c80bb6ff5f43d55f79 --- /dev/null +++ b/samples/mongodb/tls/sharded-cluster/sharded-cluster-tls.yaml @@ -0,0 +1,33 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-sharded-cluster +spec: + type: ShardedCluster + + shardCount: 2 + mongodsPerShardCount: 3 + mongosCount: 2 + configServerCount: 3 + + version: 4.0.6-ent + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + + persistent: false + + # This will create a TLS enabled Sharded Cluster, which means that + # all the traffic between Shards and clients will be encrypted using + # TLS certificates. These certificates will be generated on the fly + # by the operator using the Kubernetes CA. Please refer to + # Kubernetes TLS Documentation on how to approve these certs: + # + # https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/ + # + security: + tls: + enabled: true diff --git a/samples/mongodb/tls/standalone/standalone-tls.yaml b/samples/mongodb/tls/standalone/standalone-tls.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2868704f0b8fb8dc5bfe87fd3fff27f38a9d8dde --- /dev/null +++ b/samples/mongodb/tls/standalone/standalone-tls.yaml @@ -0,0 +1,27 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDB +metadata: + name: my-tls-standalone +spec: + version: 4.0.0-ent + + opsManager: + configMapRef: + name: my-project + credentials: my-credentials + type: Standalone + + persistent: true + + # This will create a TLS enabled Standalone which means that the + # traffic will be encrypted using TLS certificates. These + # certificates will be generated on the fly by the operatror using + # the Kubernetes CA. + # Please refer to Kubernetes TLS Documentation on how to approve these certs: + # + # https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/ + # + security: + tls: + enabled: true diff --git a/samples/ops-manager/ops-manager-appdb-agent-startup-parameters.yaml b/samples/ops-manager/ops-manager-appdb-agent-startup-parameters.yaml new file mode 100644 index 0000000000000000000000000000000000000000..185373026b598aaf96fcf204ace73f4193bdd757 --- /dev/null +++ b/samples/ops-manager/ops-manager-appdb-agent-startup-parameters.yaml @@ -0,0 +1,33 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDBOpsManager +metadata: + name: ops-manager +spec: + # the number of Ops Manager instances to run. Set to value bigger + # than 1 to get high availability and upgrades without downtime + replicas: 3 + + # the version of Ops Manager distro to use + version: 4.4.1 + + # optional. Specify the custom cluster domain of the Kubernetes cluster if it's different from the default one ('cluster.local'). + # This affects the urls generated by the Operator. + # This field is also used for Application Database url + clusterDomain: mycompany.net + + # the name of the secret containing admin user credentials. + # Either remove the secret or change the password using Ops Manager UI after the Ops Manager + # resource is created! + adminCredentials: ops-manager-admin-secret + + # the application database backing Ops Manager. Replica Set is the only supported type + # Application database has the SCRAM-SHA authentication mode always enabled + applicationDatabase: + members: 3 + persistent: true + # optional. Allows to pass custom flags that will be used + # when launching the mongodb agent. All values must be strings + agent: + startupOptions: + serverSelectionTimeoutSeconds: "20" diff --git a/samples/ops-manager/ops-manager-backup.yaml b/samples/ops-manager/ops-manager-backup.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6aa24778e81911098398e9f1e0b78dfc0c00eab2 --- /dev/null +++ b/samples/ops-manager/ops-manager-backup.yaml @@ -0,0 +1,55 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDBOpsManager +metadata: + name: ops-manager-backup +spec: + replicas: 1 + version: 4.4.1 + adminCredentials: ops-manager-admin-secret + + # optional. Enabled by default + # Allows to configure backup in Ops Manager + backup: + enabled: true + # optional. Configured by default if backup is enabled. + # Configures Head db storage parameters + headDB: + # optional. Default storage is 30G + storage: 50G + # optional + labelSelector: + matchLabels: + app: "my-app" + # Configures the list of Oplog Store Configs + opLogStores: + - name: oplog1 + # reference to MongoDB Custom Resource. The Operator watches changes in it and updates Oplog configuration + # in Ops Manager + mongodbResourceRef: + name: om-mongodb-oplog + # optional. Specify if Oplog database has SCRAM-SHA authentication enabled + mongodbUserRef: + name: admin-user + # Configures the list of S3 Snapshot Configs. Application database is used as a database for S3 metadata + # by default + # Note, that either S3 Snapshot or Blockstore config needs to be specified to backup MongoDB deployments + s3Stores: + - name: s3store1 + # the name of the secret which contains aws credentials + s3SecretRef: + name: my-aws-creds + s3BucketEndpoint: s3.us-east-1.amazonaws.com + s3BucketName: my-bucket-name + pathStyleAccessEnabled: true + # Configures the list of Blockstore Configs + blockStores: + - name: blockStore1 + # reference to MongoDB Custom Resource. The Operator watches changes in it and updates Blockstore configuration + # in Ops Manager + mongodbResourceRef: + name: my-mongodb-blockstore + + applicationDatabase: + members: 3 + version: 4.2.6-ent diff --git a/samples/ops-manager/ops-manager-external.yaml b/samples/ops-manager/ops-manager-external.yaml new file mode 100644 index 0000000000000000000000000000000000000000..eaf24fb5cd54a99d05520b3d316e6358e8bb5034 --- /dev/null +++ b/samples/ops-manager/ops-manager-external.yaml @@ -0,0 +1,36 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDBOpsManager +metadata: + name: ops-manager-external +spec: + replicas: 1 + version: 4.4.1 + adminCredentials: ops-manager-admin-secret + + configuration: + # set this property to allow Ops Manager to manage deployments outside of + # Kubernetes cluster. This must be equal to an externally connectible DNS + mms.centralUrl: http:// + + # optional. Disabled by default. Creates an additional service to make Ops Manager reachable from + # outside of the Kubernetes cluster. + externalConnectivity: + # LoadBalancer|NodePort + type: LoadBalancer + # optional. Corresponds to NodePort port + port: 30100 + # optional + loadBalancerIP: 123.456.789 + # optional + externalTrafficPolicy: Local + # optional + # For more information, read https://kubernetes.io/docs/concepts/services-networking/service/ about + # what kind of annotations you can use, based on your Cloud provider. + annotations: + service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012 + + applicationDatabase: + members: 3 + version: 4.2.6-ent + persistent: true diff --git a/samples/ops-manager/ops-manager-ignore-ui-setup.yaml b/samples/ops-manager/ops-manager-ignore-ui-setup.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5658b806a65acaf7745bb45f517b0422805f2840 --- /dev/null +++ b/samples/ops-manager/ops-manager-ignore-ui-setup.yaml @@ -0,0 +1,27 @@ +apiVersion: mongodb.com/v1 +kind: MongoDBOpsManager +metadata: + name: ops-manager-ignore-ui +spec: + replicas: 1 + version: 4.4.1 + adminCredentials: ops-manager-admin-secret + + configuration: + # passing mms.ignoreInitialUiSetup=true allows to avoid the setup wizard in Ops Manager. Note, that + # this requires to set some mandatory configuration properties, see + # https://docs.opsmanager.mongodb.com/current/reference/configuration/index.html#mms.ignoreInitialUiSetup + mms.ignoreInitialUiSetup: "true" + automation.versions.source: mongodb + mms.adminEmailAddr: support@example.com + mms.fromEmailAddr: support@example.com + mms.replyToEmailAddr: support@example.com + mms.mail.hostname: email-smtp.us-east-1.amazonaws.com + mms.mail.port: "465" + mms.mail.ssl: "true" + mms.mail.transport: smtp + mms.minimumTLSVersion: TLSv1.2 + + applicationDatabase: + members: 3 + diff --git a/samples/ops-manager/ops-manager-local-mode-bincontainer.yaml b/samples/ops-manager/ops-manager-local-mode-bincontainer.yaml new file mode 100644 index 0000000000000000000000000000000000000000..931c8ad883150eea19188716d8096054e6c17a6e --- /dev/null +++ b/samples/ops-manager/ops-manager-local-mode-bincontainer.yaml @@ -0,0 +1,59 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDBOpsManager +metadata: + name: ops-manager-localmode +spec: + replicas: 1 + version: 4.4.1 + adminCredentials: ops-manager-admin-secret + + # Local Mode must be configured so Ops Manger does not download any binaries from + # the internet. Only the binaries present will be available for the agents. + configuration: + automation.versions.source: local + + statefulSet: + spec: + template: + spec: + volumes: + - name: mongodb-versions + persistentVolumeClaim: + claimName: mongodb-versions-claim + containers: + - name: mongodb-ops-manager + volumeMounts: + - name: mongodb-versions + mountPath: /mongodb-ops-manager/mongodb-releases + + initContainers: + - name: mongodb-ops-manager-db-binaries-rhel7 + # Redirect this to IronBank + image: quay.io/mongodb/mongodb-enterprise/mongodb-ops-manager/mongodb-ops-manager-db-binaries-rhel7:4.2.8 + command: + - cp + - -a + - /binaries/* + - /mongodb-ops-manager/mongodb-releases/ + volumeMounts: + - name: mongodb-versions + mountPath: /mongodb-ops-manager/mongodb-releases + + + + applicationDatabase: + members: 3 + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mongodb-versions-claim +spec: + storageClassName: gp2 + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 3Gi diff --git a/samples/ops-manager/ops-manager-local-mode.yaml b/samples/ops-manager/ops-manager-local-mode.yaml new file mode 100644 index 0000000000000000000000000000000000000000..90178d21792db7a2f6de15cb0b7d8ea7e85d9613 --- /dev/null +++ b/samples/ops-manager/ops-manager-local-mode.yaml @@ -0,0 +1,40 @@ +apiVersion: mongodb.com/v1 +kind: MongoDBOpsManager +metadata: + name: ops-manager-localmode +spec: + replicas: 2 + version: 4.4.1 + adminCredentials: ops-manager-admin-secret + configuration: + # this enables local mode in Ops Manager + automation.versions.source: local + + statefulSet: + spec: + # the Persistent Volume Claim will be created for each Ops Manager Pod + volumeClaimTemplates: + - metadata: + name: mongodb-versions + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 20G + template: + spec: + containers: + - name: mongodb-ops-manager + volumeMounts: + - name: mongodb-versions + # this is the directory in each Pod where all MongoDB + # archives must be put + mountPath: /mongodb-ops-manager/mongodb-releases + + + backup: + enabled: false + + applicationDatabase: + members: 3 + persistent: true diff --git a/samples/ops-manager/ops-manager-non-root.yaml b/samples/ops-manager/ops-manager-non-root.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d725b7f9f2c05c285a87c9e9791d7173d16a384b --- /dev/null +++ b/samples/ops-manager/ops-manager-non-root.yaml @@ -0,0 +1,27 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDBOpsManager +metadata: + name: ops-manager +spec: + replicas: 1 + version: 4.4.1 + + adminCredentials: ops-manager-admin-secret + + applicationDatabase: + members: 3 + version: 4.2.6-ent + persistent: true + + + # The statefulSet entry will modify the way the StatefulSet holding the + # Ops Manager and Backup Daemon Pods will be created. In this case we can + # specify a non-default SecurityContext. + statefulSet: + spec: + template: + spec: + securityContext: + fsGroup: 5000 + runAsUser: 5000 diff --git a/samples/ops-manager/ops-manager-pod-spec.yaml b/samples/ops-manager/ops-manager-pod-spec.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cf4d88c08a4b76124b797e8e73372c2fca112895 --- /dev/null +++ b/samples/ops-manager/ops-manager-pod-spec.yaml @@ -0,0 +1,73 @@ +apiVersion: mongodb.com/v1 +kind: MongoDBOpsManager +metadata: + name: ops-manager-pod-spec +spec: + replicas: 1 + version: 4.4.1 + adminCredentials: ops-manager-admin-secret + configuration: + mms.testUtil.enabled: "true" + backup: + enabled: true + statefulSet: + spec: + template: + spec: + hostAliases: + - ip: "1.2.3.4" + hostnames: ["hostname"] + containers: + - name: mongodb-backup-daemon + resources: + requests: + cpu: '0.50' + memory: 4500M + + statefulSet: + spec: + template: + metadata: + annotations: + key1: value1 + spec: + volumes: + - name: mongod-binaries-volume + # replace this with a real persistent volume + emptyDir: {} + containers: + - name: mongodb-ops-manager + volumeMounts: + - mountPath: /mongodb-ops-manager/mongodb-releases/ + name: mongod-binaries-volume + resources: + limits: + cpu: '0.70' + memory: 6G + tolerations: + - key: "key" + operator: "Exists" + effect: "NoSchedule" + + applicationDatabase: + members: 3 + version: 4.2.6-ent + podSpec: + cpu: '0.25' + memory: 350M + persistence: + single: + storage: 1G + podTemplate: + spec: + # This container will be added to each pod as a sidecar + containers: + - name: appdb-sidecar + image: busybox + command: ["sleep"] + args: [ "infinity" ] + resources: + limits: + cpu: "1" + requests: + cpu: 500m diff --git a/samples/ops-manager/ops-manager-scram.yaml b/samples/ops-manager/ops-manager-scram.yaml new file mode 100644 index 0000000000000000000000000000000000000000..085bfe265b50d7aafb86862afc4aeb411de8c3ce --- /dev/null +++ b/samples/ops-manager/ops-manager-scram.yaml @@ -0,0 +1,26 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDBOpsManager +metadata: + name: ops-manager-scram +spec: + replicas: 1 + version: 4.4.1 + adminCredentials: ops-manager-admin-secret + + # the application database backing Ops Manager. Replica Set is the only supported type + # Application database has the SCRAM-SHA authentication mode always enabled + applicationDatabase: + members: 3 + # it's possible to omit 'version' completely - the bundled MongoDB binary will be used in this case + # and no MongoDB binary will be downloaded from the Internet + # version: 4.2.2-ent + persistent: true + podSpec: + cpu: '0.25' + # optional. Specifies the secret which contains the password used to connect to the database + # If not specified - the Operator will generate a random password + passwordSecretKeyRef: + name: my-password-secret + # optional, default is "password" + key: password-key diff --git a/samples/ops-manager/ops-manager-tls.yaml b/samples/ops-manager/ops-manager-tls.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b4625c8118078733beadb70e6975ffcbd0ee7d5a --- /dev/null +++ b/samples/ops-manager/ops-manager-tls.yaml @@ -0,0 +1,37 @@ +apiVersion: mongodb.com/v1 +kind: MongoDBOpsManager +metadata: + name: ops-manager-tls +spec: + replicas: 1 + version: 4.4.1 + adminCredentials: ops-manager-admin-secret + + configuration: + # Local/hybrid mode is necessary when Ops Manager has TLS with custom CA enabled as Agents running in MongoDB + # containers cannot download from the Internet in this case and need to download directly from Ops Manager + automation.versions.source: local + + security: + # enables TLS for Ops Manager allowing it to serve traffic over HTTPS + tls: + # secret containing the TLS certificate signed by known or custom CA. The secret must have a key "server.pem" + # and value of .pem file containing private key and TLS certificate + secretRef: certs-for-ops-manager + + backup: + enabled: false + + applicationDatabase: + members: 3 + version: 4.2.6-ent + security: + # enables TLS mode for application database Replica Set + tls: + # optional, ConfigMap containing custom CA certificate + # Will be used by Ops Manager to establish secure connection to application database + ca: issuer-ca-config-map + # secret containing the TLS certificate signed by known or custom CA. The secret must have a key "server.pem" + # and value of .pem file containing private key and TLS certificate + secretRef: certs-for-appdb + diff --git a/samples/ops-manager/ops-manager.yaml b/samples/ops-manager/ops-manager.yaml new file mode 100644 index 0000000000000000000000000000000000000000..dd3f64931aab73ea3aabc053a4f13b802ebc75c9 --- /dev/null +++ b/samples/ops-manager/ops-manager.yaml @@ -0,0 +1,41 @@ +--- +apiVersion: mongodb.com/v1 +kind: MongoDBOpsManager +metadata: + name: ops-manager +spec: + # the number of Ops Manager instances to run. Set to value bigger + # than 1 to get high availability and upgrades without downtime + replicas: 3 + + # the version of Ops Manager distro to use + version: 4.4.1 + + # optional. Specify the custom cluster domain of the Kubernetes cluster if it's different from the default one ('cluster.local'). + # This affects the urls generated by the Operator. + # This field is also used for Application Database url + clusterDomain: mycompany.net + + # the name of the secret containing admin user credentials. + # Either remove the secret or change the password using Ops Manager UI after the Ops Manager + # resource is created! + adminCredentials: ops-manager-admin-secret + + # optional. The Ops Manager configuration. All the values must be of type string + configuration: + mms.fromEmailAddr: "admin@thecompany.com" + + # the application database backing Ops Manager. Replica Set is the only supported type + # Application database has the SCRAM-SHA authentication mode always enabled + applicationDatabase: + members: 3 + # optional. Configures the version of MongoDB used as an application database. + # The bundled MongoDB binary will be used if omitted and no download from the Internet will happen + version: 4.2.6-ent + persistent: true + # optional. Allows to pass custom MongoDB process configuration + additionalMongodConfig: + operationProfiling: + mode: slowOp + podSpec: + cpu: '0.25' diff --git a/support/certificate_rotation.sh b/support/certificate_rotation.sh new file mode 100755 index 0000000000000000000000000000000000000000..bc2242200c676b7a00cda62c8d420209d25c44e2 --- /dev/null +++ b/support/certificate_rotation.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash + +# +# certificate_rotation.sh +# +# WARNING: This script is provided as a guide-only and it is not meant +# to be used in production environment. +# +# Use this script as a guide on how to rotate TLS certificates on a +# MongoDB Resource. During this process there will be no downtime on +# the Mdb resource. +# + +# +# shellcheck disable=SC2119 +# shellcheck disable=SC2039 +# + +usage() { + local script_name + script_name=$(basename "${0}") + echo "Usage:" + echo "${script_name} " +} + +if [ -z "${2}" ]; then + usage + exit 1 +fi + +namespace="${1}" +mdb_resource_name="${2}" +mdb_resource_type=$(kubectl -n "${namespace}" get "mdb/${mdb_resource_name}" -o jsonpath='{.spec.type}') +mdb_resource_members=$(kubectl -n "${namespace}" get "mdb/${mdb_resource_name}" -o jsonpath='{.spec.members}') +mdb_resource_members=$(("${mdb_resource_members}" - 1)) + +if [[ $mdb_resource_type != "ReplicaSet" ]]; then + echo "Only Replica Set TLS certificates are supported as of now." + exit 1 +fi + +echo "Removing existing CSRs if they still exist." +for i in $(seq 0 ${mdb_resource_members}); do + kubectl delete "csr/${mdb_resource_name}-$i.${namespace}" || true +done + +echo "Removing the 'Secret' object holding the current certificates and private keys." +kubectl -n "${namespace}" delete "secret/${mdb_resource_name}-cert" + +timestamp=$(date --rfc-3339=ns) +echo "Triggering a reconciliation for the Operator to notice the missing certs." +kubectl -n "${namespace}" patch "mdb/${mdb_resource_name}" --type='json' \ + -p='[{"op": "add", "path": "/metadata/annotations/timestamp", "value": "'"${timestamp}"'"}]' + +echo "Wait until the operator recreates the CSRs." +while true; do + all_created=0 + for i in $(seq 0 "${mdb_resource_members}"); do + if ! kubectl get "csr/${mdb_resource_name}-$i.${namespace}" -o name > /dev/null ; then + all_created=1 + fi + done + if [[ $all_created != 0 ]]; then + sleep 10 + else + break + fi +done + +echo "CSRs have been generated. Approving certificates." +for i in $(seq 0 ${mdb_resource_members}); do + kubectl certificate approve "${mdb_resource_name}-$i.${namespace}" +done + +echo "A this point, the operator should take the new certificates and generate the Secret." +while ! kubectl -n "${namespace}" get "secret/${mdb_resource_name}-cert" &> /dev/null; do + printf "." + sleep 10 +done + +echo "Secret with certificates has been created, proceeding with a rolling restart of the Mdb resource" +kubectl -n "${namespace}" rollout restart sts "${mdb_resource_name}" + +echo "The Mdb resource is being restarted now, it should take a few minutes to reach Running state again." diff --git a/support/mdb_operator_diagnostic_data.sh b/support/mdb_operator_diagnostic_data.sh new file mode 100755 index 0000000000000000000000000000000000000000..a970e41b5ef3fe126617ea6d0e62363259d185f8 --- /dev/null +++ b/support/mdb_operator_diagnostic_data.sh @@ -0,0 +1,207 @@ +#!/usr/bin/env bash + +set -Eeou pipefail + +# +# mdb_operator_diagnostic_data.sh +# +# Use this script to gather data about your MongoDB Enterprise Kubernetes Operator +# and the MongoDB Resources deployed with it. +# + +# +# shellcheck disable=SC2119 +# shellcheck disable=SC2039 +# + +usage() { + local script_name + script_name=$(basename "${0}") + echo "Usage:" + echo "${script_name} [] [--private]" +} + +contains() { + local e match=$1 + shift + for e; do [[ "$e" == "$match" ]] && return 0; done + return 1 +} + +if [ -z "${2}" ]; then + usage + exit 1 +fi + +namespace="${1}" +mdb_resource="${2}" +operator_name="${3:-mongodb-enterprise-operator}" +current_date="$(date +%Y-%m-%d_%H_%M)" + +contains "--private" "$@" +private_mode=$? + +log_dir="logs_${current_date}" +mkdir -p "${log_dir}" &> /dev/null + + +if ! kubectl get "namespace/${namespace}" &> /dev/null; then + echo "Error fetching namespace. Make sure name ${namespace} for Namespace is correct." + exit 1 +fi + +if ! kubectl -n "${namespace}" get "mdb/${mdb_resource}" &> /dev/null; then + echo "Error fetching the MongoDB resource. Make sure the ${mdb_resource} is correct." + exit 1 +fi + +if ! kubectl -n "${namespace}" get "deployment/${operator_name}" &> /dev/null; then + echo "Error fetching the MongoDB Operator Deployment. Make sure the deployment/${operator_name} exist and it is running." + exit 1 +fi + +if ! kubectl -n "${namespace}" get om -o wide &> /dev/null; then + echo "Error fetching the MongoDB OpsManager Resource." +fi + + +if [ ${private_mode} == 0 ]; then + echo "+ Running on private mode. Make sure you don't share the results of this run outside your organization." +fi + +echo "++ Versions" +mdb_operator_pod=$(kubectl -n "${namespace}" get pods -l "controller=${operator_name}" -o name | cut -d'/' -f 2) +echo "+ Operator Pod: pod/${mdb_operator_pod}" + +mdb_operator_filename="operator.yaml" +echo "+ Saving Operator Deployment into ${mdb_operator_filename}" +kubectl -n "${namespace}" get "deployment/${operator_name}" -o yaml > "${log_dir}/${mdb_operator_filename}" + +echo "+ Kubernetes Version Reported by kubectl" +kubectl version + +if type oc &> /dev/null; then + echo "+ Kubernetes Version Reported by oc" + oc version +fi + +operator_logs_filename="${operator_name}_${current_date}.logs" +echo "+ Saving Operator logs to file ${operator_logs_filename}" +kubectl -n "${namespace}" logs "deployment/${operator_name}" > "${log_dir}/${operator_logs_filename}" + +database_container_pretty_name=$(kubectl -n "${namespace}" exec -it "${mdb_resource}-0" -- cat /etc/*release | grep "PRETTY_NAME" | cut -d'=' -f 2) +operator_container_pretty_name=$(kubectl -n "${namespace}" exec -it "${mdb_operator_pod}" -- cat /etc/*release | grep "PRETTY_NAME" | cut -d'=' -f 2) +echo "+ Operator is running on: ${operator_container_pretty_name}" +echo "+ Database is running on: ${database_container_pretty_name}" + +echo "++ Kubernetes Cluster Ecosystem" +echo "+ Kubectl Cluster Information" +kubectl cluster-info + +if [ ${private_mode} == 0 ]; then + kubectl_cluster_info_filename="kubectl_cluster_info_${current_date}.logs" + echo "+ Saving Cluster Info to file ${kubectl_cluster_info_filename} (this might take a few minutes)" + kubectl cluster-info dump | gzip > "${log_dir}/${kubectl_cluster_info_filename}.gz" +else + echo "= Skipping Kubectl cluster information dump, use --private to enable." +fi + +kubectl_sc_dump_filename="kubectl_storage_class_${current_date}.yaml" +kubectl get storageclass -o yaml > "${log_dir}/${kubectl_sc_dump_filename}" + +nodes_filename="nodes.yaml" +echo "+ Nodes" +kubectl get nodes + +echo "+ Saving Nodes full state to ${nodes_filename}" +kubectl get nodes -o yaml > "${log_dir}/${nodes_filename}" + +echo "++ MongoDB Resource Running Environment" +crd_filename="crd_mdb.yaml" +echo "+ Saving MDB Customer Resource Definition into ${crd_filename}" +kubectl -n "${namespace}" get crd/mongodb.mongodb.com -o yaml > "${crd_filename}" + +project_filename="project.yaml" +mdb_resource_name="mdb/${mdb_resource}" +project_name=$(kubectl -n "${namespace}" get "${mdb_resource_name}" -o jsonpath='{.spec.project}') +credentials_name=$(kubectl -n "${namespace}" get "${mdb_resource_name}" -o jsonpath='{.spec.credentials}') + +resource_filename="mdb_object_${mdb_resource}.yaml" +echo "+ MongoDB Resource Status" +kubectl -n "${namespace}" get "${mdb_resource_name}" -o yaml > "${log_dir}/${resource_filename}" + +echo "+ Saving Project YAML file to ${project_filename}" +kubectl -n "${namespace}" get "configmap/${project_name}" -o yaml > "${log_dir}/${project_filename}" + +credentials_user=$(kubectl -n "${namespace}" get "secret/${credentials_name}" -o jsonpath='{.data.user}' | base64 --decode) +echo "+ User configured is (credentials.user): ${credentials_user}" + +echo "= To get the Secret Public API Key use: kubectl -n ${namespace} get secret/${credentials_name} -o jsonpath='{.data.publicApiKey}' | base64 --decode)" + +statefulset_filename="statefulset.yaml" +echo "+ Saving StatefulSet state to ${statefulset_filename}" +kubectl -n "${namespace}" get "sts/${mdb_resource}" -o yaml > "${log_dir}/${statefulset_filename}" + +echo "+ Deployment Pods" +kubectl -n "${namespace}" get pods | grep -E "^${mdb_resource}-[0-9]+" + +echo "+ Saving Pods state to ${mdb_resource}-N.logs" +pods_in_namespace=$(kubectl -n "${namespace}" get pods -o name | cut -d'/' -f 2 | grep -E "^${mdb_resource}-[0-9]+") +for pod in ${pods_in_namespace}; do + kubectl -n "${namespace}" logs "${pod}" > "${log_dir}/${pod}.log" + kubectl -n "${namespace}" get event --field-selector "involvedObject.name=${pod}" > "${log_dir}/${pod}_events.log" +done + +echo "+ Persistent Volumes" +kubectl -n "${namespace}" get pv + +echo "+ Persistent Volume Claims" +kubectl -n "${namespace}" get pvc + +pv_filename="persistent_volumes.yaml" +echo "+ Saving Persistent Volumes state to ${pv_filename}" +kubectl -n "${namespace}" get pv -o yaml > "${log_dir}/${pv_filename}" + +pvc_filename="persistent_volume_claims.yaml" +echo "+ Saving Persistent Volumes Claims state to ${pvc_filename}" +kubectl -n "${namespace}" get pvc -o yaml > "${log_dir}/${pvc_filename}" + +services_filename="services.yaml" +echo "+ Services" +kubectl -n "${namespace}" get services + +echo "+ Saving Services state to ${services_filename}" +kubectl -n "${namespace}" get services -o yaml > "${log_dir}/${services_filename}" + +echo "+ Saving Events for the Namespace" +kubectl -n "${namespace}" get events > "${log_dir}/events.log" + +echo "+ Certificates (no private keys are captured)" +csr_filename="csr.text" +kubectl get csr | grep "${namespace}" +echo "+ Saving Certificate state into ${csr_filename}" +kubectl describe "$(kubectl get csr -o name | grep "${namespace}")" + +echo "++ MongoDBUser Resource Status" +mdbusers_filename="mdbu.yaml" +kubectl -n "${namespace}" get mdbu +echo "+ Saving MongoDBUsers to ${mdbusers_filename}" +kubectl -n "${namespace}" get mdbu > "${log_dir}/${mdbusers_filename}" + +crdu_filename="crd_mdbu.yaml" +echo "+ Saving MongoDBUser Customer Resource Definition into ${crdu_filename}" +kubectl -n "${namespace}" get crd/mongodbusers.mongodb.com -o yaml > "${log_dir}/${crdu_filename}" + +ops_manager_filename="ops_manager.yaml" +echo "+ Saving OpsManager Status" +kubectl -n "${namespace}" get om -o wide +echo "+ Saving OpsManager Status to ${ops_manager_filename}" +kubectl -n "${namespace}" get om -o yaml > "${log_dir}/${ops_manager_filename}" + +echo "++ Compressing files" +compressed_logs_filename="${namespace}__${mdb_resource}__${current_date}.tar.gz" +tar -czf "${compressed_logs_filename}" -C "${log_dir}" . + +echo "- All logs have been captured and compressed into the file ${compressed_logs_filename}." +echo "- If support is needed, please attach this file to an email to provide you with a better support experience." +echo "- If there are additional logs that your organization is capturing, they should be made available in case of a support request."