traffic

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SHADOW_FINALIZER          = "kuadrant.dev/shadow_cleanup"
	ANNOTATION_IS_GLBC_SHADOW = "kuadrant.dev/is_shadow_route"
)
View Source
const (
	ReconcileStatusStop ReconcileStatus = iota
	ReconcileStatusContinue

	ANNOTATION_TRAFFIC_KEY              = "kuadrant.dev/traffic-key"
	ANNOTATION_TRAFFIC_KIND             = "kuadrant.dev/traffic-kind"
	ANNOTATION_CERTIFICATE_STATE        = "kuadrant.dev/certificate-status"
	ANNOTATION_HCG_HOST                 = "kuadrant.dev/host.generated"
	ANNOTATION_HEALTH_CHECK_PREFIX      = "kuadrant.experimental/health-"
	ANNOTATION_HCG_CUSTOM_HOST_REPLACED = "kuadrant.dev/custom-hosts-status.removed"
	ANNOTATION_PENDING_CUSTOM_HOSTS     = "kuadrant.dev/pendingCustomHosts"
	LABEL_HAS_PENDING_HOSTS             = "kuadrant.dev/hasPendingCustomHosts"
	FINALIZER_CASCADE_CLEANUP           = "kuadrant.dev/cascade-cleanup"
)

Variables

View Source
var (
	ErrInvalidAccessObject  = fmt.Errorf("not a valid traffic object type (expected: ingress or route)")
	ErrGeneratedHostMissing = fmt.Errorf("generated host annotation '%v' was expected but was not present", ANNOTATION_HCG_HOST)
)
View Source
var (
	IngressObjectTimeToAdmission = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Name: "glbc_ingress_managed_object_time_to_admission",
			Help: "Duration of the ingress object admission",
			Buckets: []float64{
				1 * time.Second.Seconds(),
				5 * time.Second.Seconds(),
				10 * time.Second.Seconds(),
				15 * time.Second.Seconds(),
				30 * time.Second.Seconds(),
				45 * time.Second.Seconds(),
				1 * time.Minute.Seconds(),
				2 * time.Minute.Seconds(),
				5 * time.Minute.Seconds(),
			},
		})

	TlsCertificateRequestCount = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "glbc_tls_certificate_pending_request_count",
			Help: "GLBC TLS certificate pending request count",
		},
		[]string{
			issuerLabel,
		},
	)

	// TlsCertificateRequestTotal is a prometheus counter metrics which holds the total
	// number of TLS certificate requests.
	TlsCertificateRequestTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "glbc_tls_certificate_request_total",
			Help: "GLBC TLS certificate total number of requests",
		},
		[]string{
			issuerLabel,
			resultLabel,
		},
	)

	// TlsCertificateIssuanceDuration is a prometheus metric which records the duration
	// of TLS certificate issuance.
	TlsCertificateIssuanceDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name: "glbc_tls_certificate_issuance_duration_seconds",
			Help: "GLBC TLS certificate issuance duration",
			Buckets: []float64{
				1 * time.Second.Seconds(),
				5 * time.Second.Seconds(),
				10 * time.Second.Seconds(),
				15 * time.Second.Seconds(),
				30 * time.Second.Seconds(),
				45 * time.Second.Seconds(),
				1 * time.Minute.Seconds(),
				2 * time.Minute.Seconds(),
				5 * time.Minute.Seconds(),
			},
		},
		[]string{
			issuerLabel,
			resultLabel,
		},
	)

	// TlsCertificateRequestErrors is a prometheus counter metrics which holds the total
	// number of failed TLS certificate requests.
	TlsCertificateRequestErrors = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "glbc_tls_certificate_request_errors_total",
			Help: "GLBC TLS certificate total number of request errors",
		},

		[]string{
			issuerLabel,
		},
	)
)

Functions

func CertificateAddedHandler

func CertificateAddedHandler(cert *certman.Certificate)

CertificateAddedHandler is used as an event handler for certificates

func CertificateDeletedHandler

func CertificateDeletedHandler(cert *certman.Certificate)

CertificateDeletedHandler is used as an event handler

func CertificateName

func CertificateName(accessor Interface) string

func CertificateSecretFilter

func CertificateSecretFilter(obj interface{}) bool

CertificateSecretFilter

func InitMetrics

func InitMetrics(provider tls.Provider)

func IsDomainVerified

func IsDomainVerified(host string, dvs []v1.DomainVerification) bool

IsDomainVerified will take the host and recursively remove subdomains searching for a matching domainverification that is verified. Until either a match is found, or the subdomains run out.

func IsInvalidAccessObjectError

func IsInvalidAccessObjectError(err error) bool

func IsMissingGeneratedHostError

func IsMissingGeneratedHostError(err error) bool

func TLSSecretName

func TLSSecretName(accessor Interface) string

TLSSecretName returns the name for the secret in the end user namespace

Types

type CertificateReconciler

type CertificateReconciler struct {
	CreateCertificate    func(ctx context.Context, mapper tls.CertificateRequest) error
	DeleteCertificate    func(ctx context.Context, mapper tls.CertificateRequest) error
	GetCertificateSecret func(ctx context.Context, request tls.CertificateRequest) (*corev1.Secret, error)
	UpdateCertificate    func(ctx context.Context, request tls.CertificateRequest) error
	GetCertificateStatus func(ctx context.Context, request tls.CertificateRequest) (tls.CertStatus, error)
	CopySecret           func(ctx context.Context, workspace logicalcluster.Name, namespace string, s *corev1.Secret) error
	GetSecret            func(ctx context.Context, name, namespace string, cluster logicalcluster.Name) (*corev1.Secret, error)
	DeleteSecret         func(ctx context.Context, workspace logicalcluster.Name, namespace, name string) error
	Log                  logr.Logger
}

func (*CertificateReconciler) GetName

func (r *CertificateReconciler) GetName() string

func (*CertificateReconciler) Reconcile

func (r *CertificateReconciler) Reconcile(ctx context.Context, accessor Interface) (ReconcileStatus, error)

type CreateOrUpdateTraffic

type CreateOrUpdateTraffic func(ctx context.Context, i Interface) error

type DeleteTraffic

type DeleteTraffic func(ctx context.Context, i Interface) error

type DnsReconciler

type DnsReconciler struct {
	DeleteDNS        func(ctx context.Context, accessor Interface) error
	GetDNS           func(ctx context.Context, accessor Interface) (*v1.DNSRecord, error)
	CreateDNS        func(ctx context.Context, dns *v1.DNSRecord) (*v1.DNSRecord, error)
	UpdateDNS        func(ctx context.Context, dns *v1.DNSRecord) (*v1.DNSRecord, error)
	WatchHost        func(ctx context.Context, key interface{}, host string) bool
	ForgetHost       func(key interface{}, host string)
	ListHostWatchers func(key interface{}) []dns.RecordWatcher
	DNSLookup        func(ctx context.Context, host string) ([]dns.HostAddress, error)
	Log              logr.Logger
}

func (*DnsReconciler) GetName

func (r *DnsReconciler) GetName() string

func (*DnsReconciler) Reconcile

func (r *DnsReconciler) Reconcile(ctx context.Context, accessor Interface) (ReconcileStatus, error)

type Enqueue

type Enqueue bool

func CertificateUpdatedHandler

func CertificateUpdatedHandler(oldCert, newCert *certman.Certificate) Enqueue

CertificateUpdatedHandler is used as an event handler for certificates

type HostReconciler

type HostReconciler struct {
	ManagedDomain          string
	Log                    logr.Logger
	KuadrantClient         kuadrantclientv1.ClusterInterface
	GetDomainVerifications func(ctx context.Context, accessor Interface) (*v1.DomainVerificationList, error)
	CreateOrUpdateTraffic  CreateOrUpdateTraffic
	DeleteTraffic          DeleteTraffic
}

func (*HostReconciler) GetName

func (r *HostReconciler) GetName() string

func (*HostReconciler) Reconcile

func (r *HostReconciler) Reconcile(ctx context.Context, accessor Interface) (ReconcileStatus, error)

type Ingress

type Ingress struct {
	*networkingv1.Ingress
}

func NewIngress

func NewIngress(i *networkingv1.Ingress) *Ingress

func (*Ingress) AddTLS

func (a *Ingress) AddTLS(host string, secret *corev1.Secret)

func (*Ingress) GetDNSTargets

func (a *Ingress) GetDNSTargets(ctx context.Context, dnsLookup dnsLookupFunc) (map[logicalcluster.Name]map[string]dns.Target, error)

func (*Ingress) GetHosts

func (a *Ingress) GetHosts() []string

func (*Ingress) GetKind

func (a *Ingress) GetKind() string

func (*Ingress) GetLogicalCluster

func (a *Ingress) GetLogicalCluster() logicalcluster.Name

func (*Ingress) GetNamespaceName

func (a *Ingress) GetNamespaceName() types.NamespacedName

func (*Ingress) GetSpec

func (a *Ingress) GetSpec() interface{}

func (*Ingress) GetSyncTargets

func (a *Ingress) GetSyncTargets() []string

func (*Ingress) ProcessCustomHosts

func (*Ingress) RemoveTLS

func (a *Ingress) RemoveTLS(hosts []string)

func (*Ingress) SetDNSLBHost

func (a *Ingress) SetDNSLBHost(host string)

func (*Ingress) String

func (a *Ingress) String() string

func (*Ingress) TMCEnabed

func (a *Ingress) TMCEnabed() bool

TMCEnabed this is a very temporary solution to allow us to work with both advanced and none advanced scheduling clusters. IT SHOULD BE REMOVED ASAP

func (*Ingress) Transform

func (a *Ingress) Transform(old Interface) error

type Interface

type Interface interface {
	runtime.Object
	metav1.Object
	GetKind() string
	GetHosts() []string
	SetDNSLBHost(string)
	Transform(previous Interface) error
	GetDNSTargets(ctx context.Context, dnsLookup dnsLookupFunc) (map[logicalcluster.Name]map[string]dns.Target, error)
	GetLogicalCluster() logicalcluster.Name
	GetNamespaceName() types.NamespacedName
	AddTLS(host string, secret *corev1.Secret)
	RemoveTLS(host []string)
	ProcessCustomHosts(context.Context, *v1.DomainVerificationList, CreateOrUpdateTraffic, DeleteTraffic) error
	GetSyncTargets() []string
	GetSpec() interface{}
	TMCEnabed() bool
}

type Pending

type Pending struct {
	Rules []networkingv1.IngressRule `json:"rules"`
}

type ReconcileStatus

type ReconcileStatus int

type Reconciler

type Reconciler interface {
	Reconcile(ctx context.Context, accessor Interface) (ReconcileStatus, error)
	GetName() string
}

type Route

type Route struct {
	*routev1.Route
}

func NewRoute

func NewRoute(r *routev1.Route) *Route

func (*Route) AddTLS

func (a *Route) AddTLS(host string, secret *corev1.Secret)

func (*Route) GetDNSTargets

func (a *Route) GetDNSTargets(ctx context.Context, dnsLookup dnsLookupFunc) (map[logicalcluster.Name]map[string]dns.Target, error)

func (*Route) GetHosts

func (a *Route) GetHosts() []string

func (*Route) GetKind

func (a *Route) GetKind() string

func (*Route) GetLogicalCluster

func (a *Route) GetLogicalCluster() logicalcluster.Name

func (*Route) GetNamespaceName

func (a *Route) GetNamespaceName() types.NamespacedName

func (*Route) GetSpec

func (a *Route) GetSpec() interface{}

func (*Route) GetSyncTargets

func (a *Route) GetSyncTargets() []string

func (*Route) ProcessCustomHosts

func (a *Route) ProcessCustomHosts(ctx context.Context, dvs *v1.DomainVerificationList, createOrUpdate CreateOrUpdateTraffic, delete DeleteTraffic) error

func (*Route) RemoveTLS

func (a *Route) RemoveTLS(hosts []string)

func (*Route) SetDNSLBHost

func (a *Route) SetDNSLBHost(lbHost string)

func (*Route) String

func (a *Route) String() string

func (*Route) TMCEnabed

func (a *Route) TMCEnabed() bool

func (*Route) Transform

func (a *Route) Transform(previous Interface) error

Jump to

Keyboard shortcuts

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