kubecontroller

package
v1.4.12 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CRDStatusToNCRequest

func CRDStatusToNCRequest(crdStatus v1alpha.NodeNetworkConfigStatus) (cns.CreateNetworkContainerRequest, error)

CRDStatusToNCRequest translates a crd status to createnetworkcontainer request

func GetKubeConfig

func GetKubeConfig() (*rest.Config, error)

GetKubeConfig precedence * --kubeconfig flag pointing at a file at this cmd line * KUBECONFIG environment variable pointing at a file * In-cluster config if running in cluster * $HOME/.kube/config if exists

func New

func New(cfg Config) (*requestController, error)

New builds a requestController struct given a reference to CNS's HTTPRestService state.

Types

type APIDirectClient

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

APIDirectClient is a direct client to a kubernetes API server

func NewAPIDirectClient

func NewAPIDirectClient(kubeconfig *rest.Config) (*APIDirectClient, error)

NewAPIDirectClient creates a new APIDirectClient

func (*APIDirectClient) ListPods

func (apiClient *APIDirectClient) ListPods(ctx context.Context, namespace, node string) (*corev1.PodList, error)

ListPods lists all pods in the given namespace and node

type CRDDirectClient

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

CRDDirectClient is a direct client to CRDs in the API Server.

func NewCRDDirectClient

func NewCRDDirectClient(kubeconfig *rest.Config, groupVersion *schema.GroupVersion) (*CRDDirectClient, error)

NewCRDDirectClient creates a new direct crd client to the api server

func (*CRDDirectClient) Get

func (crdClient *CRDDirectClient) Get(ctx context.Context, name, namespace, typeName string) (*v1alpha.NodeNetworkConfig, error)

Get gets a crd

type Config added in v1.4.4

type Config struct {
	// InitializeFromCNI whether or not to initialize CNS state from k8s/CRDs
	InitializeFromCNI  bool
	KubeConfig         *rest.Config
	MetricsBindAddress string
	Service            *restserver.HTTPRestService
}

Config has crdRequestController options

type CrdReconciler

type CrdReconciler struct {
	KubeClient      KubeClient
	NodeName        string
	CNSClient       cnsclient.APIClient
	IPAMPoolMonitor cns.IPAMPoolMonitor
}

CrdReconciler watches for CRD status changes

func (*CrdReconciler) Reconcile

func (r *CrdReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error)

Reconcile is called on CRD status changes

func (*CrdReconciler) SetupWithManager

func (r *CrdReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager Sets up the reconciler with a new manager, filtering using NodeNetworkConfigFilter

type DirectAPIClient

type DirectAPIClient interface {
	ListPods(ctx context.Context, namespace, node string) (*corev1.PodList, error)
}

DirectAPIClient is an interface to talk directly with API Server without cache

type DirectCRDClient

type DirectCRDClient interface {
	Get(ctx context.Context, name, namespace, typeName string) (*v1alpha.NodeNetworkConfig, error)
}

DirectCRDClient is an interface to get CRDs directly, without cache

type KubeClient

type KubeClient interface {
	Get(ctx context.Context, key client.ObjectKey, obj client.Object) error
	Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
}

KubeClient is an interface that talks to the API server

type NodeNetworkConfigFilter

type NodeNetworkConfigFilter struct {
	predicate.Funcs
	// contains filtered or unexported fields
}

func (NodeNetworkConfigFilter) Create

Only process create events if CRD name equals this host's name

func (NodeNetworkConfigFilter) Delete

Delete is a noop filter to ignore all delete events. TODO: Decide what deleting crd means with DNC

func (NodeNetworkConfigFilter) Update

Returns true if request is to be processed by Reconciler Checks that old generation equals new generation because status changes don't change generation number

Jump to

Keyboard shortcuts

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