Documentation ¶
Overview ¶
TODO: consider moving it to a more generic package.
Index ¶
Constants ¶
View Source
const ( KubeAPIQPS = 20.0 KubeAPIBurst = 30 KubeconfigSecretDataKey = "kubeconfig" )
Variables ¶
View Source
var KubeconfigGetterForCluster = func(c *federation_v1beta1.Cluster) clientcmd.KubeconfigGetter { return func() (*clientcmdapi.Config, error) { secretRefName := "" if c.Spec.SecretRef != nil { secretRefName = c.Spec.SecretRef.Name } else { glog.Infof("didnt find secretRef for cluster %s. Trying insecure access", c.Name) } return KubeconfigGetterForSecret(secretRefName)() } }
This is to inject a different kubeconfigGetter in tests. We dont use the standard one which calls NewInCluster in tests to avoid having to setup service accounts and mount files with secret tokens.
View Source
var KubeconfigGetterForSecret = func(secretName string) clientcmd.KubeconfigGetter { return func() (*clientcmdapi.Config, error) { var data []byte if secretName != "" { namespace := os.Getenv("POD_NAMESPACE") if namespace == "" { return nil, fmt.Errorf("unexpected: POD_NAMESPACE env var returned empty string") } client, err := client.NewInCluster() if err != nil { return nil, fmt.Errorf("error in creating in-cluster client: %s", err) } data = []byte{} var secret *api.Secret err = wait.PollImmediate(1*time.Second, getSecretTimeout, func() (bool, error) { secret, err = client.Secrets(namespace).Get(secretName) if err == nil { return true, nil } glog.Warningf("error in fetching secret: %s", err) return false, nil }) if err != nil { return nil, fmt.Errorf("timed out waiting for secret: %s", err) } if secret == nil { return nil, fmt.Errorf("unexpected: received null secret %s", secretName) } ok := false data, ok = secret.Data[KubeconfigSecretDataKey] if !ok { return nil, fmt.Errorf("secret does not have data with key: %s", KubeconfigSecretDataKey) } } return clientcmd.Load(data) } }
KubeconfigGettterForSecret is used to get the kubeconfig from the given secret.
Functions ¶
func BuildClusterConfig ¶
func BuildClusterConfig(c *federation_v1beta1.Cluster) (*restclient.Config, error)
Types ¶
type DelayingDeliverer ¶ added in v1.4.0
type DelayingDeliverer struct {
// contains filtered or unexported fields
}
A structure that pushes the items to the target channel at a given time.
func NewDelayingDeliverer ¶ added in v1.4.0
func NewDelayingDeliverer(targetChannel chan *DelayingDelivererItem) *DelayingDeliverer
func (*DelayingDeliverer) DeliverAt ¶ added in v1.4.0
func (d *DelayingDeliverer) DeliverAt(key string, value interface{}, deliveryTime time.Time)
func (*DelayingDeliverer) Stop ¶ added in v1.4.0
func (d *DelayingDeliverer) Stop()
type DelayingDelivererItem ¶ added in v1.4.0
type DelayingDelivererItem struct { // Key under which the value was added to deliverer. Key string // Value of the item. Value interface{} // When the item should be delivered. DeliveryTime time.Time }
DelayingDelivererItem is structure delivered by DelayingDeliverer to the target channel.
Click to show internal directories.
Click to hide internal directories.