Details
-
Improvement
-
Status: Done
-
Medium
-
Resolution: Done
-
None
-
None
-
None
-
3
-
Yes
-
Yes
-
Yes
-
[obsolete] Server Integrations
Description
User story:
As a user I want to be able to call DBaaS endpoints with as few as possible parameters.
UI/UX:
Acceptance criteria:
- Resource parameters are optional
- Image field is optional
- Params field is optional
- Name field is optional
Out of scope:
- Returning the values used by default or at least the cluster name
Details:
With this new implementation, the only mandatory field is the Kubernetes cluster name. All other fields are optional and in case they are not specified, the API will set these defaults:
Cluster Size = 3
Default CPUM = 1000
Memory Bytes = 200,0000,000 (2 Gb)
Disk Size = 2,500,0000,000 (25 Gb)
Cluster Size = 3
Default CPUM = 1000
MemoryBytes = 2000000000 (2 Gb)
Disk Size = 25000000000 (25 Gb)
Proxy Default CpuM = 1000
Proxy Default Memory Bytes = 2000000000 (2 Gb)
The image used to start the instance is taken from the version service. It is the higher recommended version for that K8 cluster version.
The DB cluster name, if is not provided, will be *pxc* or *psmdb* + the database server version + 4 digits random number.
How to test
Here are the steps to test this using Minikibe and the command line.
1. Start minikube
minikube start --cpus=2 --nodes=3 --kubernetes-version=v1.22.0
2. Start PMM server docker image
export IMAGE='perconalab/pmm-server-fb:PR-2493-5ba22b6'
docker pull ${IMAGE}
docker run -d \
-p 80:80 \
-p 443:443 \
--name pmm-server \
--network minikube \
-e PERCONA_TEST_DBAAS=1 \
-e PERCONA_TEST_VERSION_SERVICE_URL=https://check-dev.percona.com/versions/v1 \
${IMAGE}
3. Get Docker container IP and set it as PMM server public address using the API
IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pmm-server) curl -X POST "http://localhost/v1/Settings/Change" -H "accept: application/json" -u "admin:admin" -H "Content-Type: application/json" -d "{ \"pmm_public_address\": \"${IP}\", \"enable_dbaas\": true}"
4. Get minikube config and create a new Kubernetes cluster
KUBECONFIG=$(minikube kubectl -- config view --flatten --minify | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g') curl -X POST "http://localhost/v1/management/DBaaS/Kubernetes/Register" -H "accept: application/json" -u "admin:admin" -d "{ \"kubernetes_cluster_name\": \"my_cluster\", \"kube_auth\": { \"kubeconfig\": \"${KUBECONFIG}\" }}"
5. Create a PXC cluster using minimum parameters in the API call
curl -X POST "http://localhost/v1/management/DBaaS/PXCCluster/Create" \ -H "accept: application/json" \ -u "admin:admin" \ -H "Content-Type: application/json" \ -d "{ \"kubernetes_cluster_name\": \"my_cluster\", \"name\": \"my-pxc-cluster\", \"expose\": true}"
6. Create a PSMDB cluster using minimum parameters in the API call
curl -X POST "http://localhost/v1/management/DBaaS/PSMDBCluster/Create" \ -H "accept: application/json" \ -u "admin:admin" \ -H "Content-Type: application/json" \ -d "{ \"kubernetes_cluster_name\": \"my_cluster\", \"expose\": true}"
List the DB cluster to check they are being created:
curl -X POST "http://localhost/v1/management/DBaaS/DBClusters/List" -H "accept: application/json" -u "admin:admin" -H "Content-Type: application/json" -d "{ \"kubernetes_cluster_name\": \"my_cluster\"}"
Example output:
{ "pxc_clusters": [ { "name": "my-pxc-cluster", "state": "DB_CLUSTER_STATE_CHANGING", "operation": { "message": "haproxy: haproxy: back-off 5m0s restarting failed container=haproxy pod=my-pxc-cluster-haproxy-0_default(a5be2b76-d8a8-43cc-ae07-a6aa87dd41e4); ", "total_steps": 6 }, "params": { "cluster_size": 3, "pxc": { "compute_resources": { "cpu_m": 1000, "memory_bytes": "2000000000" }, "disk_size": "25000000000" }, "haproxy": { "compute_resources": { "cpu_m": 1000, "memory_bytes": "2000000000" } } }, "installed_image": "percona/percona-xtradb-cluster:8.0.25-15.1" } ], "psmdb_clusters": [ { "name": "psmdb-5-0-4-3-9038", "state": "DB_CLUSTER_STATE_CHANGING", "operation": { "total_steps": 9 }, "params": { "cluster_size": 3, "replicaset": { "compute_resources": { "cpu_m": 1000, "memory_bytes": "2000000000" }, "disk_size": "25000000000" } }, "installed_image": "percona/percona-server-mongodb:5.0.4-3" } ] }