Comments (2)
That should be possible. A pod typically uses the service account token made available to it. If the kubernetes configuration is set to mount the token, it should be available at the path /var/run/secrets/kubernetes.io/serviceaccount/token
inside the container. The other pieces if information you would need to connect are the namespace and CA certificate to validate the conenction. They should also be mounted into the container. So to summarize, the mounted locations to look at are:
/var/run/secrets/kubernetes.io/serviceaccount/namespace
: for namespace/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
: for CA certificate/var/run/secrets/kubernetes.io/serviceaccount/token
: for the authentication token
Then the code to connect to the API server should look like:
ns_mount = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
cacert_mount = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
token_mount = "/var/run/secrets/kubernetes.io/serviceaccount/token"
api_server = "https://kubernetes.default.svc"
# the cluster cacert should be installed at appropriate place in the pod instead of this
# NetworkOptions.jl has instructions on how to deal with certificates
ENV["JULIA_NO_VERIFY_HOSTS"] = "kubernetes.default.svc"
using Kuber
ctx = KuberContext()
token = string(readchomp(token_mount))
ns = string(readchomp(ns_mount))
set_server(ctx, api_server; headers=Dict("Authorization" => "Bearer " * token))
Kuber.set_ns(ctx, ns)
Kuber.set_api_versions!(ctx);
# ctx is now ready to use with Kuber.jl APIs
# ensure the serviceaccount token has enough permissions to execute the APIs
from kuber.jl.
Thank you very much! I will try it out soon. Close this issue for now; will reopen if I have further questions :) Thank you for this awesome project!
from kuber.jl.
Related Issues (11)
- Can not install on Windows HOT 1
- Cannot re-use `KuberContext` after Internal Server Error HOT 1
- Use the updated Kubernetes specification
- TagBot trigger issue HOT 16
- Broken link to the Tutorial
- Generate and deploy Docs
- Support watch APIs HOT 1
- Handle CRDs when generating code
- Setting `PropagationPolicy` HOT 2
- `watch` does not work for cluster wide resources HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kuber.jl.