k8scontext

package
v0.0.0-...-17967aa Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// IsNetworkingV1PackageSupported is flag that indicates whether networking/v1beta ingress should be used instead.
	IsNetworkingV1PackageSupported bool

	// IsInMultiClusterMode is a flag to indicate that AGIC should monitor MutliCluster CRDs
	IsInMultiClusterMode bool
)

Functions

func SupportsNetworkingPackage

func SupportsNetworkingPackage(client clientset.Interface) bool

SupportsNetworkingPackage checks if the package "k8s.io/api/networking/v1" is available or not and if Ingress V1 is supported (k8s >= v1.19.0) https://kubernetes.io/blog/2021/07/14/upcoming-changes-in-kubernetes-1-22/#what-to-do

Types

type CacheCollection

type CacheCollection struct {
	Endpoints                                   cache.Store
	Ingress                                     cache.Store
	IngressClass                                cache.Store
	Pods                                        cache.Store
	Secret                                      cache.Store
	Service                                     cache.Store
	Namespaces                                  cache.Store
	AzureIngressManagedLocation                 cache.Store
	AzureIngressProhibitedTarget                cache.Store
	AzureApplicationGatewayBackendPool          cache.Store
	AzureApplicationGatewayRewrite              cache.Store
	AzureApplicationGatewayInstanceUpdateStatus cache.Store
	MultiClusterService                         cache.Store
	MultiClusterIngress                         cache.Store
	IstioGateway                                cache.Store
	IstioVirtualService                         cache.Store
}

CacheCollection : all the listers from the informers.

type Context

type Context struct {
	Caches                 *CacheCollection
	CertificateSecretStore SecretsKeeper

	Work chan events.Event

	CacheSynced chan interface{}

	MetricStore metricstore.MetricStore
	// contains filtered or unexported fields
}

Context : cache and listener for k8s resources.

func NewContext

func NewContext(kubeClient kubernetes.Interface, crdClient versioned.Interface, multiClusterCrdClient multicluster_versioned.Interface, istioCrdClient istio_versioned.Interface, namespaces []string, resyncPeriod time.Duration, metricStore metricstore.MetricStore, envVariables environment.EnvVariables) *Context

NewContext creates a context based on a Kubernetes client instance.

func (*Context) GetAGICPod

func (c *Context) GetAGICPod(envVariables environment.EnvVariables) *v1.Pod

GetAGICPod returns the pod with specified name and namespace

func (*Context) GetBackendPool

func (c *Context) GetBackendPool(backendPoolName string) (*agpoolv1beta1.AzureApplicationGatewayBackendPool, error)

GetBackendPool returns backend pool with specified name

func (*Context) GetEndpointsByService

func (c *Context) GetEndpointsByService(serviceKey string) (*v1.Endpoints, error)

GetEndpointsByService returns the endpoints associated with a specific service.

func (*Context) GetEndpointsForVirtualService

func (c *Context) GetEndpointsForVirtualService(virtualService v1alpha3.VirtualService) v1.EndpointsList

GetEndpointsForVirtualService returns a list of Endpoints associated with a Virtual Service

func (*Context) GetGateways

func (c *Context) GetGateways() []*v1alpha3.Gateway

GetGateways returns all Istio Gateways that are annotated.

func (*Context) GetInfrastructureResourceGroupID

func (c *Context) GetInfrastructureResourceGroupID() (azure.SubscriptionID, azure.ResourceGroup, error)

GetInfrastructureResourceGroupID returns the subscription and resource group name of the underling infrastructure. This uses ProviderID which is ID of the node assigned by the cloud provider in the format: <ProviderName>://<ProviderSpecificNodeID>

func (*Context) GetInstanceUpdateStatus

func (c *Context) GetInstanceUpdateStatus(instanceUpdateStatusName string) (*aginstv1beta1.AzureApplicationGatewayInstanceUpdateStatus, error)

GetInstanceUpdateStatus returns update status from when Application Gateway instances update backend pool addresses

func (*Context) GetProhibitedTarget

func (c *Context) GetProhibitedTarget(namespace string, targetName string) *prohibitedv1.AzureIngressProhibitedTarget

GetProhibitedTarget returns prohibited target with specified name and namespace

func (*Context) GetRewriteRuleSetCustomResource

func (c *Context) GetRewriteRuleSetCustomResource(namespace string, name string) (*agrewritev1beta1.AzureApplicationGatewayRewrite, error)

GetRewriteRuleSetCustomResource returns rewrite with specified name and namespace

func (*Context) GetSecret

func (c *Context) GetSecret(secretKey string) *v1.Secret

GetSecret returns the secret identified by the key

func (*Context) GetService

func (c *Context) GetService(serviceKey string) *v1.Service

GetService returns the service identified by the key.

func (*Context) GetVirtualServicesForGateway

func (c *Context) GetVirtualServicesForGateway(gateway v1alpha3.Gateway) []*v1alpha3.VirtualService

GetVirtualServicesForGateway returns the VirtualServices for the provided gateway

func (*Context) IsEndpointReferencedByAnyIngress

func (c *Context) IsEndpointReferencedByAnyIngress(endpoints *v1.Endpoints) bool

IsEndpointReferencedByAnyIngress provides whether an Endpoint is useful i.e. a Endpoint is used by an ingress

func (*Context) IsIngressClass

func (c *Context) IsIngressClass(ing *networking.Ingress) bool

IsIngressClass checks if the Ingress resource can be handled by the Application Gateway ingress controller.

func (*Context) IsIstioGatewayIngress

func (c *Context) IsIstioGatewayIngress(gateway *v1alpha3.Gateway) bool

IsIstioGatewayIngress checks if this gateway should be handled by AGIC or not

func (*Context) IsPodReferencedByAnyIngress

func (c *Context) IsPodReferencedByAnyIngress(pod *v1.Pod) bool

IsPodReferencedByAnyIngress provides whether a POD is useful i.e. a POD is used by an ingress

func (*Context) ListAzureProhibitedTargets

func (c *Context) ListAzureProhibitedTargets() []*prohibitedv1.AzureIngressProhibitedTarget

ListAzureProhibitedTargets returns a list of App Gwy configs, for which AGIC is not allowed to modify config.

func (*Context) ListHTTPIngresses

func (c *Context) ListHTTPIngresses() []*networking.Ingress

ListHTTPIngresses returns a list of all the ingresses for HTTP from cache.

func (*Context) ListIstioGateways

func (c *Context) ListIstioGateways() []*v1alpha3.Gateway

ListIstioGateways returns a list of discovered Istio Gateways

func (*Context) ListIstioVirtualServices

func (c *Context) ListIstioVirtualServices() []*v1alpha3.VirtualService

ListIstioVirtualServices returns a list of discovered Istio Virtual Services

func (*Context) ListPodsByServiceSelector

func (c *Context) ListPodsByServiceSelector(service *v1.Service) []*v1.Pod

ListPodsByServiceSelector returns pods that are associated with a specific service.

func (*Context) ListServices

func (c *Context) ListServices() []*v1.Service

ListServices returns a list of all the Services from cache.

func (*Context) Run

func (c *Context) Run(stopChannel chan struct{}, omitCRDs bool, envVariables environment.EnvVariables) error

Run executes informer collection.

func (*Context) UpdateIngressStatus

func (c *Context) UpdateIngressStatus(ingressToUpdate networking.Ingress, newIP IPAddress) error

UpdateIngressStatus adds IP address in Ingress Status

type IPAddress

type IPAddress string

IPAddress is type for IP address string

type InformerCollection

type InformerCollection struct {
	Endpoints                                   cache.SharedIndexInformer
	Ingress                                     cache.SharedIndexInformer
	IngressClass                                cache.SharedIndexInformer
	Pods                                        cache.SharedIndexInformer
	Secret                                      cache.SharedIndexInformer
	Service                                     cache.SharedIndexInformer
	Namespace                                   cache.SharedIndexInformer
	AzureIngressManagedLocation                 cache.SharedInformer
	AzureIngressProhibitedTarget                cache.SharedInformer
	AzureApplicationGatewayBackendPool          cache.SharedInformer
	AzureApplicationGatewayRewrite              cache.SharedInformer
	AzureApplicationGatewayInstanceUpdateStatus cache.SharedInformer
	MultiClusterService                         cache.SharedInformer
	MultiClusterIngress                         cache.SharedInformer
	IstioGateway                                cache.SharedIndexInformer
	IstioVirtualService                         cache.SharedIndexInformer
}

InformerCollection : all the informers for k8s resources we care about.

type SecretsKeeper

type SecretsKeeper interface {
	GetPfxCertificate(secretKey string) []byte
	ConvertSecret(secretKey string, secret *v1.Secret) error
	// contains filtered or unexported methods
}

SecretsKeeper is the interface definition for secret store

func NewSecretStore

func NewSecretStore(client kubernetes.Interface) SecretsKeeper

NewSecretStore creates a new SecretsKeeper object

type SecretsStore

type SecretsStore struct {
	Client kubernetes.Interface
	Cache  cache.ThreadSafeStore
	// contains filtered or unexported fields
}

SecretsStore maintains a cache of the deployment secrets.

func (*SecretsStore) ConvertSecret

func (s *SecretsStore) ConvertSecret(secretKey string, secret *v1.Secret) error

ConvertSecret converts a secret to a PKCS12.

func (*SecretsStore) GetFromCluster

func (s *SecretsStore) GetFromCluster(secretKey string) ([]byte, error)

func (*SecretsStore) GetPfxCertificate

func (s *SecretsStore) GetPfxCertificate(secretKey string) []byte

GetPfxCertificate returns the certificate for the given secret key.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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