beacon-biosignals / K8sClusterManagers.jl

A Julia cluster manager for Kubernetes
Other
31 stars 5 forks source link

Determine namespace inside of pod #22

Closed omus closed 3 years ago

omus commented 3 years ago

I discovered when reading https://kubernetes.io/docs/tasks/run-application/access-api-from-pod/#without-using-a-proxy that the service account directory inside a pod contains a "namespace" file containing the name of the pod's namespace. This PR means that K8sClusterManagers.jl users no longer need to specify the namespace when running inside of a pod which avoids mistakes which can lead to: https://github.com/beacon-biosignals/K8sClusterManagers.jl/issues/12

omus commented 3 years ago

This is the future iteration as mentioned in: https://github.com/beacon-biosignals/K8sClusterManagers.jl/pull/19#issuecomment-819054045

omus commented 3 years ago

I'll note that the tests which use kubectl config may possibly fail if the NAMESPACE_FILE is present on the system running the tests. The way to avoid this would be to patch current_namespace for these tests but I'm not sure it's worth doing that. I'll think about this more before merging.

omus commented 3 years ago

I now believe it makes the most sense to use kubectl config first. This allows the namespace set there to take priority over the namespace used within the pod. I'm not sure in what use case this would be useful for but this allows for the most flexibility.

Additionally, I'll split the internals of current_namespace into pod_namespace and current_config_namespace which allows for better re-use.

codecov-commenter commented 3 years ago

Codecov Report

Merging #22 (ecd94a6) into main (f407f17) will increase coverage by 5.13%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #22      +/-   ##
==========================================
+ Coverage   35.57%   40.70%   +5.13%     
==========================================
  Files           2        2              
  Lines         104      113       +9     
==========================================
+ Hits           37       46       +9     
  Misses         67       67              
Impacted Files Coverage Δ
src/K8sClusterManagers.jl 83.33% <ø> (ø)
src/native_driver.jl 35.64% <100.00%> (+6.29%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f407f17...ecd94a6. Read the comment docs.