kubernetes

package
v2.11.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package kubernetes provide auth strategy to authenticate, incoming HTTP requests using a Kubernetes Service Account Token. This authentication strategy makes it easy to introduce apps, into a Kubernetes Pod and make Pod authenticate Pod.

Example
st := SetServiceAccountToken("Service Account Token")
cache := libcache.IDLE.NewUnsafe(0)
kube := New(cache, st)
r, _ := http.NewRequest("", "/", nil)
_, err := kube.Authenticate(r.Context(), r)
fmt.Println(err != nil)
Output:

true

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAuthenticateFunc

func GetAuthenticateFunc(opts ...auth.Option) token.AuthenticateFunc

GetAuthenticateFunc return function to authenticate request using kubernetes token review. The returned function typically used with the token strategy.

Example
cache := libcache.IDLE.NewUnsafe(0)
fn := GetAuthenticateFunc()
kube := token.New(fn, cache)
r, _ := http.NewRequest("", "/", nil)
_, err := kube.Authenticate(r.Context(), r)
fmt.Println(err != nil)
Output:

true

func New

func New(c auth.Cache, opts ...auth.Option) auth.Strategy

New return strategy authenticate request using kubernetes token review. New is similar to token.New().

Example
cache := libcache.IDLE.NewUnsafe(0)
kube := New(cache)
r, _ := http.NewRequest("", "/", nil)
_, err := kube.Authenticate(r.Context(), r)
fmt.Println(err != nil)
Output:

true

func SetAPIVersion

func SetAPIVersion(version string) auth.Option

SetAPIVersion sets kuberntess api version. e.g authentication.k8s.io/v1

func SetAddress

func SetAddress(addr string) auth.Option

SetAddress sets kuberntess api server address e.g http://host:port or https://host:port.

func SetAudiences

func SetAudiences(auds []string) auth.Option

SetAudiences sets the list of the identifiers that the resource server presented with the token identifies as.

func SetClientTransport

func SetClientTransport(rt http.RoundTripper) auth.Option

SetClientTransport sets underlying http client transport.

func SetHTTPClient

func SetHTTPClient(c *http.Client) auth.Option

SetHTTPClient sets underlying http client.

func SetServiceAccountToken

func SetServiceAccountToken(token string) auth.Option

SetServiceAccountToken sets kubernetes service account token for token review API.

func SetTLSConfig

func SetTLSConfig(tls *tls.Config) auth.Option

SetTLSConfig sets tls config for kubernetes api.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL