https://github.com/coryodaniel/k8s_conf
Parse Kubernetes' config files and generate HTTP headers/options for authenticating to the k8s API.
https://github.com/coryodaniel/k8s_conf
Last synced: about 1 year ago
JSON representation
Parse Kubernetes' config files and generate HTTP headers/options for authenticating to the k8s API.
- Host: GitHub
- URL: https://github.com/coryodaniel/k8s_conf
- Owner: coryodaniel
- License: mit
- Created: 2018-12-19T20:33:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-26T19:10:57.000Z (over 7 years ago)
- Last Synced: 2025-03-24T05:34:43.805Z (about 1 year ago)
- Language: Elixir
- Homepage:
- Size: 29.3 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# K8s.Conf
K8s.Conf is **deprecated** and has been merged into [`k8s` elixir client](https://github.com/coryodaniel/k8s).
[K8s.Conf](https://hexdocs.pm/k8s_conf/readme.html) parses Kubernetes config files and generates HTTP headers and options for authenticating to the Kubernetes API.
[](https://travis-ci.org/coryodaniel/k8s_conf)
[](https://coveralls.io/github/coryodaniel/k8s_conf?branch=master)
[](https://hex.pm/packages/k8s_conf)
[](https://hexdocs.pm/k8s_conf/)

## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `k8s_conf` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:k8s_conf, "~> 0.1.0"}
]
end
```
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/k8s_conf](https://hexdocs.pm/k8s_conf).
## Usage
```elixir
# Defaults to 'current-context', optionally set cluster, context, or user
# opts = [
# user: "alt-user",
# cluster: "alt-cluster",
# context: "alt-context"
# ]
opts = []
config = K8s.Conf.from_file("~/.kube/config", opts)
# Optionally load from a service account
# config = K8s.Conf.from_service_account()
http_request_options = K8s.Conf.RequestOptions.generate(config)
[header: headers, ssl_options: ssl_options] = http_request_options
# Add headers and SSL options to HTTP library of choice
```
### Adding authorization providers
```elixir
config :k8s_conf, providers: [My.Custom.Provider]
```
Providers are checked in order, the first to return an authorization struct wins.
Custom providers are processed before default providers.
See [Certicate](lib/k8s/conf/auth/certificate.ex) and [Token](lib/k8s/conf/auth/token.ex) for protocol and behavior implementations.