Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Platform] Add API for Kubernetes provider configuration discovery #8371

Merged
merged 1 commit into from
Jun 10, 2021

Conversation

bhavin192
Copy link
Contributor

@bhavin192 bhavin192 commented May 10, 2021

  • This API tries to fetch the details which can be used to pre-fill the data during Kubernetes provider creation (should work on OpenShift or Tanzu as well). The returned JSON is similar to what we use for the create call. Please refer this issue for more details: [Platform] [k8s] Simplified k8s provider config for deploying into the same cluster as YW #7394
  • Use blank string for KUBECONFIG if kubeconfig file is not provided. This allows us to in-cluster credentials (ServiceAccount) when running in the same cluster as of the target cluster. Can be used to simplify the current flow later, we won't need a separate kubeconfig in that case.
  • Finds out the region and AZ based on node annotations.
  • Takes the pull secret name and the storage class name from app config.

Scenarios tested:

  • Ran platform inside Kubernetes, curl the API, it returns the expected JSON.
  • Tested all the failure scenarios like missing config, no permissions to get secret, nodes etc.

A sample output:

{
  "code": "kubernetes",
  "name": null,
  "active": true,
  "config": {
    "KUBECONFIG_IMAGE_PULL_SECRET_NAME": "yugabyte-k8s-pull-secret",
    "KUBECONFIG_PULL_SECRET_NAME": "yugabyte-k8s-pull-secret",
    "KUBECONFIG_PULL_SECRET_CONTENT": "{\"apiVersion\":\"v1\",\"data\":{\".dockerconfigjson\":\"removed==\"},\"kind\":\"Secret\",\"metadata\":{\"annotations\":{},\"name\":\"yugabyte-k8s-pull-secret\"},\"type\":\"kubernetes.io/dockerconfigjson\"}"
  },
  "region": null,
  "regionList": [
    {
      "code": "asia-south1",
      "name": null,
      "latitude": 0.0,
      "longitude": 0.0,
      "zoneList": [
        {
          "code": "asia-south1-a",
          "name": "asia-south1-a",
          "config": {
            "STORAGE_CLASS": "standard"
          }
        },
        {
          "code": "asia-south1-c",
          "name": "asia-south1-c",
          "config": {
            "STORAGE_CLASS": "standard"
          }
        }
      ],
      "config": null
    }
  ]
}

Open Questions

  • Should the API endpoint as well as the methods be called something like /customers/:cUUID/providers/kubernetes_discovery?

This PR is backend part for the #7394

@bhavin192 bhavin192 requested review from iSignal and Arnav15 May 10, 2021 10:12
bhavin192 added a commit to bhavin192/yugabyte-charts that referenced this pull request May 12, 2021
This adds the two new configuration options required by the Kubernetes
discovery API which is introduced in
yugabyte/yugabyte-db#8371

Test plan:
- Upgraded existing Helm release, the API works as expected.

Signed-off-by: Bhavin Gandhi <bhavin7392@gmail.com>
@iSignal iSignal requested a review from jvigil-yugabyte May 19, 2021 23:06
Copy link
Contributor

@iSignal iSignal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Do update the Test Plan for the PR description with a sample response and the test environment.

Most of the comments are about code organization.

@bhavin192 bhavin192 force-pushed the k8s-provider-creation branch 5 times, most recently from cf46eb4 to fa0d1d3 Compare May 28, 2021 13:41
@bhavin192 bhavin192 force-pushed the k8s-provider-creation branch from fa0d1d3 to 2f3463c Compare June 4, 2021 12:33
- This API tries to fetch the details which can be used to pre-fill
  the data during Kubernetes provider creation (should work on OpenShift
  or Tanzu as well). The returned JSON is similar to what we use for the
  create call. Please refer this issue for more details:
  yugabyte#7394
- Use blank string for KUBECONFIG if kubeconfig file is not
  provided. This allows us to in-cluster credentials (ServiceAccount)
  when running in the same cluster as of the target cluster. Can be used
  to simplify the current flow later, we won't need a separate
  kubeconfig in that case.
- Finds out the region and AZ based on node annotations.
- Takes the pull secret name and the storage class name from app config.

Scenarios tested:

- Ran platform inside Kubernetes, curl the API, it returns the
  expected JSON.
- Tested all the failure scenarios like missing config, no permissions
  to get secret, nodes etc.

This PR is backend part for the yugabyte#7394

Signed-off-by: Bhavin Gandhi <bhavin7392@gmail.com>
@bhavin192 bhavin192 force-pushed the k8s-provider-creation branch from 2f3463c to c0fcd57 Compare June 7, 2021 06:26
@bhavin192 bhavin192 requested a review from iSignal June 8, 2021 12:25
Copy link
Contributor

@iSignal iSignal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Sorry for the delay, github PRs don't get put back in the "review" list unless you re-request the review.

@bhavin192 bhavin192 merged commit d29f73f into yugabyte:master Jun 10, 2021
@bhavin192 bhavin192 deleted the k8s-provider-creation branch June 10, 2021 05:21
@@ -168,7 +168,8 @@ libraryDependencies ++= Seq(
"com.fasterxml.jackson.core" % "jackson-core" % "2.10.5",
"com.jayway.jsonpath" % "json-path" % "2.4.0",
"commons-io" % "commons-io" % "2.8.0",
"commons-codec" % "commons-codec" % "1.15"
"commons-codec" % "commons-codec" % "1.15",
"org.apache.commons" % "commons-collections4" % "4.4"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already use guava that has all the necessary collection required by this change.
Can you please use guava and not add yet another dependency?
@bhavin192

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I wasn't aware of that. I will work on removing that and using guava. I will create a new PR shortly.

bhavin192 added a commit to yugabyte/charts that referenced this pull request Jun 11, 2021
This adds the two new configuration options required by the Kubernetes
discovery API which is introduced in
yugabyte/yugabyte-db#8371

Test plan:
- Upgraded existing Helm release, the API works as expected.

Signed-off-by: Bhavin Gandhi <bhavin7392@gmail.com>
bhavin192 added a commit to bhavin192/yugabyte-db that referenced this pull request Jun 11, 2021
This is a follow up change from yugabyte#8371

Scenarios tested:
- Ran platform inside Kubernetes, curl the API, it returns the expected JSON.

Signed-off-by: Bhavin Gandhi <bhavin7392@gmail.com>
bhavin192 added a commit that referenced this pull request Jun 11, 2021
This is a follow up change from #8371

Scenarios tested:
- Ran platform inside Kubernetes, curl the API, it returns the expected JSON.

Signed-off-by: Bhavin Gandhi <bhavin7392@gmail.com>
bhavin192 added a commit to bhavin192/yugabyte-db that referenced this pull request Dec 22, 2021
c0b9786 changed the behavior of
az.setConfig and added az.updateConfig. This change uses the correct
method to add `{"KUBECONFIG": ""}` to the existing configuration
instead of overwriting the whole AZ configuration.

This was missed when I rebased
yugabyte#8371 against latest
changes.

Fixes yugabyte#10860

Signed-off-by: Bhavin Gandhi <bhavin7392@gmail.com>
bhavin192 added a commit that referenced this pull request Feb 10, 2022
…10928)

c0b9786 changed the behavior of
az.setConfig and added az.updateConfig. This change uses the correct
method to add `{"KUBECONFIG": ""}` to the existing configuration
instead of overwriting the whole AZ configuration.

This was missed when I rebased
#8371 against latest
changes.

Fixes #10860

Signed-off-by: Bhavin Gandhi <bhavin7392@gmail.com>
jayant07-yb pushed a commit to jayant07-yb/yugabyte-db that referenced this pull request Mar 8, 2022
…ugabyte#10928)

c0b9786 changed the behavior of
az.setConfig and added az.updateConfig. This change uses the correct
method to add `{"KUBECONFIG": ""}` to the existing configuration
instead of overwriting the whole AZ configuration.

This was missed when I rebased
yugabyte#8371 against latest
changes.

Fixes yugabyte#10860

Signed-off-by: Bhavin Gandhi <bhavin7392@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants