digitalocean / terraform-provider-digitalocean

Terraform DigitalOcean provider
https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs
Mozilla Public License 2.0
503 stars 270 forks source link

Feat: Allow a list of one-click apps to install on Kubernetes cluster. #575

Open Digital-Shane opened 3 years ago

Digital-Shane commented 3 years ago

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v0.14.5

Affected Resource(s)

Terraform Configuration Files

Example:

resource "digitalocean_kubernetes_cluster" "cluster" {
  name   = "cluster"
  region = "nyc1"
  version = "1.20.2-do.0"
  tags    = []
  one_click_apps = ["nginx-ingress-controller", "monitoring-stack"]

  node_pool {
    name = "worker-pool"
    size       = "s-2vcpu-2gb"
    node_count = 2
  }
}

Expected Behavior

The resource should install the provided list of one-click apps. The list of apps would be restricted to those under the Kubernetes category.

The nginx app documentation seems to imply this is possible in the UI, but I'm not sure because the text and command in that section seem to only create the Kubernetes cluster. If I can find the correct endpoint to create an app on the Kubernetes cluster a null provisioner can be a workaround, but managing everything through the provider is preferred.

Actual Behavior

What actually happened?

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

andrewsomething commented 3 years ago

This is not currently supported via Terraform. You can find the docs for the API endpoint here:

https://developers.digitalocean.com/documentation/v2/#install-kubernetes-1-click-applications

curl -X POST -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"addon_slugs": ["nginx-ingress-controller", "monitoring-stack"], "cluster_uuid": "$CLUSTER_UUID"}' \
  "https://api.digitalocean.com/v2/1-clicks/kubernetes"

One thing to note is that while 1-Click apps can be added to a cluster via the API, it is not currently possible to remove them or list the ones that have been installed already via the API. So the feature does not fit very well with Terraform's state management as it is currently implemented.

Digital-Shane commented 3 years ago

Thanks for getting back to me so quickly, Andrew!

That API should work well for my use case. Primarily, I want to make sure those installs are automated without me entering the UI. That will make it immensely easier to restore a full cluster during disaster recovery. The only case I'd want to remove nginx and Prometheus would be during a full cluster teardown, so ongoing tracking is less of a concern

I do think a complete implementation through a terraform resource or input to the cluster would be useful for others though. You might want to consider the feature when your backlog allows.

Thanks again!