Giter Club home page Giter Club logo

Comments (2)

alita1991 avatar alita1991 commented on May 28, 2024 1

Hi @xunleii, regarding the k3s admin kubeconfig, I was looking for a way to tell rancher to generate a local kubeconfig with the correct context (custom cluster name), but probably this is available only with k3d.

For the second problem, your solution could work, thanks for the feedback.

from terraform-module-k3s.

xunleii avatar xunleii commented on May 28, 2024

Hello,

Sorry, I didn't understand the first part:

I'm looking for a method to set the cluster name in the kubeconfig file of k3s admin, particularly in situations where the kubeconfig is generated by Rancher.

How can the kubeconfig be generated by Rancher using this module?


Apart from this point, my view is that it's an "advanced use" to modify the kubeconfig (even if it's simple) and must be done outside this module. It's entirely possible for the end user to generate a kubeconfig from the values in the kubernetes output, like the following (not tested)

module "k3s" {
  ...
}

local {
  kubeconfig = yamlencode({
    apiVersion      = "v1"
    kind            = "Config"
    current-context = "CLUSTER_NAME"
    contexts = [{
      context = {
        cluster = "CLUSTER_NAME"
        user : "CLUSTER_NAME_ADMIN"
      }
      name = "CLUSTER_NAME"
    }]
    clusters = [{
      cluster = {
        certificate-authority-data = base64encode(module.k3s.kubernetes.cluster_ca_certificate)
        server                     = module.k3s.kubernetes.api_endpoint
      }
      name = "CLUSTER_NAME"
    }]
    users = [{
      user = {
        client-certificate-data : base64encode(module.k3s.kubernetes.client_certificate)
        client-key-data : base64encode(module.k3s.kubernetes.client_key)
      }
      name : "CLUSTER_NAME_ADMIN"
    }]
  })
}

However, is needed to explain how to do this in the documentation.

from terraform-module-k3s.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.