Coder Social home page Coder Social logo

Comments (5)

mruoss avatar mruoss commented on June 1, 2024 1

This func is exactly what I was looking for.

Ok, glad it's so easy then. :)

Perhaps adding to the documentation will prevent others from making this mistake.

I'll gladly clarify the docs. This is a part that Cory implemented and documented and I've never gone over it. Once you're too deep you don't look at those "first step" docs anymore.

Leaving this open for now.

from k8s.

mruoss avatar mruoss commented on June 1, 2024 1

Decided to improve the @moduledoc and @doc of K8s.Conn. I think it's the first place people look (right @znorris?)

from k8s.

mruoss avatar mruoss commented on June 1, 2024

Hi @znorris

Have you seen the usage guide on connections?

Since you're writing "in cluster", I'm assuming you're using k8s inside a pod and are trying to access resources inside the same cluster this pod is running in. If that's the case, all you need is to have RBAC set up correctly for the pod's service account and call K8s.Conn.from_service_account/1 to get a %K8s.Conn{} struct used to connect to the cluster.

Given RBAC is set up accordingly, the following code would get a list of namespaces of the cluster this code is running in:

{:ok, conn} = K8s.Conn.from_service_account()

{:ok, namespace_list} = 
  K8s.Client.list("v1", "Namespace")
  |> K8s.Client.put_conn(conn)
  |> K8s.Client.run()

I'm a bit confused on why you've mentioned workload identity. Running inside GKE you would use workload identity to authenticate as a Google Service Account in order to access Google Cloud resources, e.g. Google Cloud Storage etc. But that's not what this library is used for.

Unless we're talking about the use case where your code is running in a GitHub workflow, trying to access the GKE cluster using federated workload identity. Is that it?

from k8s.

znorris avatar znorris commented on June 1, 2024

@mruoss Thanks for your quick reply. I'm doing too many things at once and erroneously conflated workload identity.

I did read all if it several times. However, it wasn't clear to me that this was the in cluster configuration as I've never used the service account directory before. Perhaps adding to the documentation will prevent others from making this mistake.

This func is exactly what I was looking for.

from k8s.

znorris avatar znorris commented on June 1, 2024

Thank you @mruoss, very helpful.

from k8s.

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.