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

Add host, cluster_ca_certificate and token attributes of cloud_project_kube resource #325

Closed
FlorentPoinsaut opened this issue Oct 13, 2022 · 2 comments · Fixed by #378
Closed
Labels
Product: Managed Kubernetes Service Status: Coming Soon The feature will hit GA usually in less than 2 months Type: Feature new feature, improvement

Comments

@FlorentPoinsaut
Copy link

Affected Resource

  • cloud_project_kube

Expected Behavior

The resource cloud_project_kube should have host, cluster_ca_certificate and token attributes to use the kubernetes provider without have to create a local file.

resource "ovh_cloud_project_kube" "k8s" {
  name    = "cluster"
  region  = "SBG"
  version = "1.23"
}

provider "kubernetes" {
  host                   = ovh_cloud_project_kube.k8s.apiserver_url
  cluster_ca_certificate = base64decode(ovh_cloud_project_kube.k8s.cluster_ca_cert)
  token                  = ovh_cloud_project_kube.k8s.token
}

Actual Behavior

We have to create a local file to use the kubernetes provider.

resource "ovh_cloud_project_kube" "k8s" {
  name    = "cluster"
  region  = "SBG"
  version = "1.23"
}

resource "local_sensitive_file" "kubeconfig" {
  content  = ovh_cloud_project_kube.k8s.kubeconfig
  filename = "${path.module}/.kube/kubeconfig"
}

provider "kubectl" {
  config_path = local_sensitive_file.kubeconfig.filename
}

Reference

@sylvainmetayer
Copy link

sylvainmetayer commented Oct 21, 2022

Hi,

While I agree that it would be better to have these attributes directly as attributes from the resource, you can use the following workaround to avoid creating a local file.

provider "kubernetes" {
  host                   = yamldecode(ovh_cloud_project_kube.cluster.kubeconfig).clusters[0].cluster.server
  cluster_ca_certificate = base64decode(yamldecode(ovh_cloud_project_kube.cluster.kubeconfig).clusters[0].cluster.certificate-authority-data)
  client_certificate     = base64decode(yamldecode(ovh_cloud_project_kube.cluster.kubeconfig).users[0].user.client-certificate-data)
  client_key             = base64decode(yamldecode(ovh_cloud_project_kube.cluster.kubeconfig).users[0].user.client-key-data)
}

@FlorentPoinsaut FlorentPoinsaut moved this to 🏗 In progress in @FlorentPoinsaut's backlog Oct 25, 2022
@FlorentPoinsaut FlorentPoinsaut moved this from 🏗 In progress to 📋 Backlog in @FlorentPoinsaut's backlog Oct 25, 2022
@FlorentPoinsaut
Copy link
Author

Hi,

Thanks a lot @sylvainmetayer! It works like a charm!

@yomovh yomovh added Type: Feature new feature, improvement Product: Managed Kubernetes Service Status: Coming Soon The feature will hit GA usually in less than 2 months labels Jan 20, 2023
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in @FlorentPoinsaut's backlog Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Product: Managed Kubernetes Service Status: Coming Soon The feature will hit GA usually in less than 2 months Type: Feature new feature, improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants