kubernetes.v0: gopkg.in/kubernetes/kubernetes.v0/pkg/serviceaccount Index | Files

package serviceaccount

import "gopkg.in/kubernetes/kubernetes.v0/pkg/serviceaccount"

Package serviceaccount provides implementations to manage service accounts and service account tokens

Index

Package Files

doc.go jwt.go serviceaccounts_controller.go tokengetter.go tokens_controller.go

Constants

const (
    ServiceAccountUsernamePrefix    = "system:serviceaccount"
    ServiceAccountUsernameSeparator = ":"

    Issuer = "kubernetes/serviceaccount"

    SubjectClaim            = "sub"
    IssuerClaim             = "iss"
    ServiceAccountNameClaim = "kubernetes.io/serviceaccount/service-account.name"
    ServiceAccountUIDClaim  = "kubernetes.io/serviceaccount/service-account.uid"
    SecretNameClaim         = "kubernetes.io/serviceaccount/secret.name"
    NamespaceClaim          = "kubernetes.io/serviceaccount/namespace"
)

func JWTTokenAuthenticator Uses

func JWTTokenAuthenticator(keys []*rsa.PublicKey, lookup bool, getter ServiceAccountTokenGetter) authenticator.Token

JWTTokenAuthenticator authenticates tokens as JWT tokens produced by JWTTokenGenerator Token signatures are verified using each of the given public keys until one works (allowing key rotation) If lookup is true, the service account and secret referenced as claims inside the token are retrieved and verified with the provided ServiceAccountTokenGetter

func MakeUsername Uses

func MakeUsername(namespace, name string) string

MakeUsername generates a username from the given namespace and ServiceAccount name. The resulting username can be passed to SplitUsername to extract the original namespace and ServiceAccount name.

func ReadPrivateKey Uses

func ReadPrivateKey(file string) (*rsa.PrivateKey, error)

ReadPrivateKey is a helper function for reading an rsa.PrivateKey from a PEM-encoded file

func ReadPublicKey Uses

func ReadPublicKey(file string) (*rsa.PublicKey, error)

ReadPublicKey is a helper function for reading an rsa.PublicKey from a PEM-encoded file Reads public keys from both public and private key files

func SplitUsername Uses

func SplitUsername(username string) (string, string, error)

SplitUsername returns the namespace and ServiceAccount name embedded in the given username, or an error if the username is not a valid name produced by MakeUsername

type ServiceAccountTokenGetter Uses

type ServiceAccountTokenGetter interface {
    GetServiceAccount(namespace, name string) (*api.ServiceAccount, error)
    GetSecret(namespace, name string) (*api.Secret, error)
}

ServiceAccountTokenGetter defines functions to retrieve a named service account and secret

func NewGetterFromClient Uses

func NewGetterFromClient(c client.Interface) ServiceAccountTokenGetter

NewGetterFromClient returns a ServiceAccountTokenGetter that uses the specified client to retrieve service accounts and secrets. The client should NOT authenticate using a service account token the returned getter will be used to retrieve, or recursion will result.

func NewGetterFromEtcdHelper Uses

func NewGetterFromEtcdHelper(helper tools.EtcdHelper) ServiceAccountTokenGetter

NewGetterFromEtcdHelper returns a ServiceAccountTokenGetter that uses the specified helper to retrieve service accounts and secrets.

func NewGetterFromRegistries Uses

func NewGetterFromRegistries(serviceAccounts serviceaccount.Registry, secrets secret.Registry) ServiceAccountTokenGetter

NewGetterFromRegistries returns a ServiceAccountTokenGetter that uses the specified registries to retrieve service accounts and secrets.

type ServiceAccountsController Uses

type ServiceAccountsController struct {
    // contains filtered or unexported fields
}

ServiceAccountsController manages ServiceAccount objects inside Namespaces

func NewServiceAccountsController Uses

func NewServiceAccountsController(cl client.Interface, options ServiceAccountsControllerOptions) *ServiceAccountsController

NewServiceAccountsController returns a new *ServiceAccountsController.

func (*ServiceAccountsController) Run Uses

func (e *ServiceAccountsController) Run()

Runs controller loops and returns immediately

func (*ServiceAccountsController) Stop Uses

func (e *ServiceAccountsController) Stop()

Stop gracefully shuts down this controller

type ServiceAccountsControllerOptions Uses

type ServiceAccountsControllerOptions struct {
    // Names is the set of service account names to ensure exist in every namespace
    Names util.StringSet

    // ServiceAccountResync is the interval between full resyncs of ServiceAccounts.
    // If non-zero, all service accounts will be re-listed this often.
    // Otherwise, re-list will be delayed as long as possible (until the watch is closed or times out).
    ServiceAccountResync time.Duration

    // NamespaceResync is the interval between full resyncs of Namespaces.
    // If non-zero, all namespaces will be re-listed this often.
    // Otherwise, re-list will be delayed as long as possible (until the watch is closed or times out).
    NamespaceResync time.Duration
}

ServiceAccountsControllerOptions contains options for running a ServiceAccountsController

func DefaultServiceAccountsControllerOptions Uses

func DefaultServiceAccountsControllerOptions() ServiceAccountsControllerOptions

type TokenGenerator Uses

type TokenGenerator interface {
    // GenerateToken generates a token which will identify the given ServiceAccount.
    // The returned token will be stored in the given (and yet-unpersisted) Secret.
    GenerateToken(serviceAccount api.ServiceAccount, secret api.Secret) (string, error)
}

func JWTTokenGenerator Uses

func JWTTokenGenerator(key *rsa.PrivateKey) TokenGenerator

JWTTokenGenerator returns a TokenGenerator that generates signed JWT tokens, using the given privateKey. privateKey is a PEM-encoded byte array of a private RSA key. JWTTokenAuthenticator()

type TokensController Uses

type TokensController struct {
    // contains filtered or unexported fields
}

TokensController manages ServiceAccountToken secrets for ServiceAccount objects

func NewTokensController Uses

func NewTokensController(cl client.Interface, options TokensControllerOptions) *TokensController

NewTokensController returns a new *TokensController.

func (*TokensController) Run Uses

func (e *TokensController) Run()

Runs controller loops and returns immediately

func (*TokensController) Stop Uses

func (e *TokensController) Stop()

Stop gracefully shuts down this controller

type TokensControllerOptions Uses

type TokensControllerOptions struct {
    // TokenGenerator is the generator to use to create new tokens
    TokenGenerator TokenGenerator
    // ServiceAccountResync is the time.Duration at which to fully re-list service accounts.
    // If zero, re-list will be delayed as long as possible
    ServiceAccountResync time.Duration
    // SecretResync is the time.Duration at which to fully re-list secrets.
    // If zero, re-list will be delayed as long as possible
    SecretResync time.Duration
    // This CA will be added in the secretes of service accounts
    RootCA []byte
}

TokensControllerOptions contains options for the TokensController

Package serviceaccount imports 27 packages (graph). Updated 2016-07-25. Refresh now. Tools for package owners.