Uploaded image for project: 'Percona Monitoring and Management'
  1. Percona Monitoring and Management
  2. PMM-6457

Basic pmm-managed API - DB Cluster

    XMLWordPrintable

    Details

    • Story Points:
      0.5
    • Sprint:
      Platform Sprint 25, Platform Sprint 26, Platform Sprint 27
    • Needs Review:
      Yes
    • Needs QA:
      Yes

      Description

      https://confluence.percona.com/display/PMM/dbaas-controller#dbaas-controller-PMMAPIs

      https://github.com/percona/pmm/pull/549

      Implement XtraDB service API methods by calling matching dbaas-controller methods.

       

      How to test:

       ** 1. setup DBaaS local env: https://confluence.percona.com/display/PMM/DBaaS+local+setup

      2. Run pmm-server from FB: https://github.com/Percona-Lab/pmm-submodules/pull/1124

          Ex.: 

      docker run -d -p 80:80 -p 443:443 --name pmm-server perconalab/pmm-server-fb:PR-1124-8f30ce1

       

      3. start dbaas-controller in pmm-server.

         Ex.: 

      docker exec pmm-server /usr/sbin/dbaas-controller 

       

       

      4. replace swagger.json with a new one that includes API endpoints that are not public yet (please find new swagger.json in attachment).

        Ex.: 

      docker cp swagger.json pmm-server:/usr/share/pmm-server/swagger/swagger.json 

       

       

      5. Create kubeconfig:

        5.1 Fetch the name of the secrets used by the service account

         

      als@mbp pmm % kubectl describe serviceAccounts percona-xtradb-cluster-operator
      Name:                percona-xtradb-cluster-operator
      Namespace:           default
      Labels:              <none>
      Annotations:         kubectl.kubernetes.io/last-applied-configuration:
                             {"apiVersion":"v1","kind":"ServiceAccount","metadata":{"annotations":{},"name":"percona-xtradb-cluster-operator","namespace":"default"}}
      Image pull secrets:  <none>
      Mountable secrets:   percona-xtradb-cluster-operator-token-67x6w
      Tokens:              percona-xtradb-cluster-operator-token-67x6w
      Events:              <none>
      als@mbp pmm % 
      

       

      5.2 Fetch the token from the secret. Use Mountable secrets from the prev output

       

      als@mbp pmm % kubectl describe secrets percona-xtradb-cluster-operator-token-67x6w
      Name:         percona-xtradb-cluster-operator-token-67x6w
      Namespace:    default
      Labels:       <none>
      Annotations:  kubernetes.io/service-account.name: percona-xtradb-cluster-operator
                    kubernetes.io/service-account.uid: fe452326-8d40-48f3-aa9f-4176fdb8071d
      
      
      Type:  kubernetes.io/service-account-token
      
      
      Data
      ====
      ca.crt:     1066 bytes
      namespace:  7 bytes
      token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IjVTaldmTUVBV0Q3TGJxRU5Yd0JrSjIwcHZmbnJpSE1ITmtVeExRbFlBZ3cifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6InBlcmNvbmEteHRyYWRiLWNsdXN0ZXItb3BlcmF0b3ItdG9rZW4tNjd4NnciLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoicGVyY29uYS14dHJhZGItY2x1c3Rlci1vcGVyYXRvciIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6ImZlNDUyMzI2LThkNDAtNDhmMy1hYTlmLTQxNzZmZGI4MDcxZCIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpkZWZhdWx0OnBlcmNvbmEteHRyYWRiLWNsdXN0ZXItb3BlcmF0b3IifQ.sNgEhuP4JnJOaakv1y010AYX2WpNgBxz_mUY1muL4pYiAyahy9UNDDdp0oItHqb4u2uF3RVtWcobs_Ih3KCDSpYyhupN2ZxXoTnA4heh7kbOJjDXQ6LFWLg7mS6xtq3AZXUQHoLdnF9pHsRR8bCcyILAo8FaRxNkR6_kEsAed1AsATqse_Vo3HiNWQAJCy5ZqstWlvgIz8D5Zq5kNQm8IePUoVUklHwVj3hGkZhMHo-HLJEhQIQyzH9xRyZWGNIfCjD13psdHwuc57UPANuU8bDDIYEWqGDs7nocgvv4W7gcVaH2s7Cm2LxJ20Udl2lOQcKQZmETOJ5ADRqNraKS9Q
      als@mbp pmm % 
      

      5.3 Get the certificate info for the cluster

       

       

      als@mbp pmm % kubectl config view --flatten --minify
      apiVersion: v1
      clusters:
      - cluster:
          certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM1ekNDQWMrZ0F3SUJBZ0lCQVRBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwdGFXNXAKYTNWaVpVTkJNQjRYRFRJd01EY3dNVEE1TWpNek5Wb1hEVE13TURZek1EQTVNak16TlZvd0ZURVRNQkVHQTFVRQpBeE1LYldsdWFXdDFZbVZEUVRDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBT3ROCm9wWmJ3TnFhWVphNHBGeDNMdFRacGxqcTNpdXQzalY3cmNCRi9zaEtGbDV1TDlVZEFvWWtlazZ0cHhXV0tOWVEKQkN6V2V4Z2NwaHdRaWVObDhVTDZNelVFRnVDV2RtSWNLWXkzdkVIaVBMVnMwNERmY0ZjYm96R2ZMVmNPMDN2SQpLK3pRWUVhcUNjMFBXZHE3d2xpNzJBTHI2WXpzWkxxb28xTEZqUzZ3SEEzN0dpN2RmUmN1RUM2YXhrWGxHUVArCjRZOTl1UEVKdzRLQ1VmcmdsT1hNanpRaloyaW5DK3hXSGdDZHkwQzVCYlF3a3h2cVZ2ZWgxQXR2aDZzbkRveW8KL3FVT1ZMbkRQRTUyQVhUNTJNeGlnTktrNFQyYmRCeW1DVkg5cFFCVVBCUklrY0FSUFdUUDZndHdoZUZYWGQ1OApnSW1xTEVJbi9hUzgrQzV2UXRzQ0F3RUFBYU5DTUVBd0RnWURWUjBQQVFIL0JBUURBZ0trTUIwR0ExVWRKUVFXCk1CUUdDQ3NHQVFVRkJ3TUNCZ2dyQmdFRkJRY0RBVEFQQmdOVkhSTUJBZjhFQlRBREFRSC9NQTBHQ1NxR1NJYjMKRFFFQkN3VUFBNElCQVFCOC8yZzQ3Q2pyM2txVmQrc0k0N2paSjB6Q3N6NlFjK2l3bURBOEtJZmpSSlZpbHZZVwpVVEFreTNhbTNTcTAyUlBqTFVSb3FjZGkrSUFjNzA0SlgvdFVLa0pTdHNxUUF0R1FWem5jZ01hSXk0YmNId0x4Cm1IQlUvMWEyMW0xYWRCQnBhbVc3WW1SaHJLcm95cGtaOW9ORVdxY2s5SEZKNkNzSkVNd0R0Rzg3ZlJ3bWc2TzQKMG5weEhaWTR1bk1BU1EreVVqWkV5Qy9xRDlIU290N083T3hEM2U2YkhZMC9CMGE5OWphSlpvczgvTy9QbEE0ZwpVdDRrSXBId3hMOUlCWnZkMnAxRGF6RU9LQXJneHVUOGh3Q2pCWnlYY3lTaHdqQTY2SkFOZU9XYzE5SVNDS0huCjBrdWNOS3orbldHZnU4d3hoRk43dFh0UWVPaWZpUlJ2bW9obQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
          server: https://192.168.64.10:8443
        name: minikube
      contexts:
      - context:
          cluster: minikube
          user: minikube
        name: minikube
      current-context: minikube
      kind: Config
      preferences: {}
      users:
      - name: minikube
        user:
          client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURBRENDQWVpZ0F3SUJBZ0lCQWpBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwdGFXNXAKYTNWaVpVTkJNQjRYRFRJd01Ea3lNREUwTXpnek5Gb1hEVEl4TURreU1URTBNemd6TkZvd01URVhNQlVHQTFVRQpDaE1PYzNsemRHVnRPbTFoYzNSbGNuTXhGakFVQmdOVkJBTVREVzFwYm1scmRXSmxMWFZ6WlhJd2dnRWlNQTBHCkNTcUdTSWIzRFFFQkFRVUFBNElCRHdBd2dnRUtBb0lCQVFDbFdQRmJOMmIvdklRUFVpZndrMTlkeDM3UkR1bWsKOU1UNW5TWC9DdWlPYUdxVFMzTDcvNWJ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QpMM3RyYWJDVUJ0OEhzQXF3ZVpWd3Q3QXRwT1ZJS2RreWJ2UWp1OVZTcVZzb0E5TlFTNE09Ci0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==
      

       

       

          

       

      5.5 Create a kubeconfig file

      From the steps above, you should have the following pieces of information

      • token
      • certificate-authority-data
        -server

      Create a file called kubeconfig.yaml paste this content on to it

       

      apiVersion: v1
      kind: Config
      users:
      - name: percona-xtradb-cluster-operator
        user:
          token: <replace this with token info>
      clusters:
      - cluster:
          certificate-authority-data: <replace this with certificate-authority-data info>
          server: <replace this with server info>
        name: self-hosted-cluster
      contexts:
      - context:
          cluster: self-hosted-cluster
          user: percona-xtradb-cluster-operator
        name: percona-xtradb-cluster-context
      current-context: percona-xtradb-cluster-context
      

       

      Replace the placeholder above with the information gathered so far

      replace the token
      replace the certificate-authority-data
      replace the server

      5.6 Convert YAML to JSON minimize (remove new lines and indentations) it. Use https://www.convertjson.com/yaml-to-json.htm or similar.

      Ex.:

       

      5.7 Escape double quotes in json https://www.freeformatter.com/json-escape.html

      so you will have something like :

       

      {\"apiVersion\":\"v1\",\"kind\":\"Config\",\"users\":[{\"name\":\"percona-xtradb-cluster-operator\",\"user\":{\"token\":\"eyJhbGciOiJSUzI1NiIsImtpZC......\"}}],\"clusters\":[{\"cluster\":{\"certificate-authority-data\":\"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0....==\",\"server\":\"https:\/\/192.168.64.10:8443\"},\"name\":\"self-hosted-cluster\"}],\"contexts\":[{\"context\":{\"cluster\":\"self-hosted-cluster\",\"user\":\"percona-xtradb-cluster-operator\"},\"name\":\"svcs-acct-context\"}],\"current-context\":\"svcs-acct-context\"}
      

      save it to kubekonfig.json.min

       

      6. Navigate to Swagger UI Kubernetes/RegisterKubernetesCluster   http://localhost/swagger/#/Kubernetes/RegisterKubernetesCluster

      and register k8s cluster. Fill in fields kubernetes_cluster_name und  kube_auth with your values.

       

       

      7. play with XtraDBCluster endpoints. Please note: Update is not implemented in dbaas-controller yet.

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              andrii.skomorokhov Andrii Skomorokhov
              Reporter:
              alexey.palazhchenko Alexey Palazhchenko (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 3 hours, 30 minutes
                  3h 30m

                    Smart Checklist