definitions

package
v0.14.13 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: Apache-2.0, MIT Imports: 9 Imported by: 1

Documentation

Overview

Package definitions provides type definitions, parsing, marshaling and validation for Kubernetes resources used by Skipper.

Index

Constants

View Source
const (
	ServiceBackend = eskip.LBBackend + 1 + iota
)

adding Kubernetes specific backend types here. To be discussed. The main reason is to differentiate between service and external, in a way where we can also use the current global option to decide whether the service should then be converted to LB. Or shall we expect the route group already contain the pod endpoints, and ignore the global option for skipper? --> As CRD we have to lookup endpoints ourselves, maybe via kube.go

Variables

This section is empty.

Functions

func GetHostsFromIngressRulesV1 added in v0.13.198

func GetHostsFromIngressRulesV1(ing *IngressV1Item) []string

func ValidateIngress

func ValidateIngress(_ *IngressItem) error

TODO: implement once IngressItem has a validate method ValidateIngress is a no-op

func ValidateIngressV1 added in v0.13.149

func ValidateIngressV1(_ *IngressV1Item) error

TODO: implement once IngressItem has a validate method ValidateIngressV1 is a no-op

func ValidateIngresses

func ValidateIngresses(ingressList IngressList) error

ValidateIngresses is a no-op

func ValidateIngressesV1 added in v0.13.149

func ValidateIngressesV1(ingressList IngressV1List) error

ValidateIngresses is a no-op

func ValidateRouteGroup

func ValidateRouteGroup(rg *RouteGroupItem) error

ValidateRouteGroup validates a RouteGroupItem

func ValidateRouteGroups

func ValidateRouteGroups(rl *RouteGroupList) error

ValidateRouteGroups validates a RouteGroupList

Types

type Backend

type Backend struct {
	ServiceName string      `json:"serviceName"`
	ServicePort BackendPort `json:"servicePort"`
	// Traffic field used for custom traffic weights, but not part of the ingress spec.
	Traffic float64
	// number of True predicates to add to support multi color traffic switching
	NoopCount int
}

func (Backend) String

func (b Backend) String() string

type BackendPort

type BackendPort struct {
	Value interface{}
}

func (BackendPort) MarshalJSON

func (p BackendPort) MarshalJSON() ([]byte, error)

func (BackendPort) Name

func (p BackendPort) Name() (string, bool)

func (BackendPort) Number

func (p BackendPort) Number() (int, bool)

func (BackendPort) String

func (p BackendPort) String() string

func (*BackendPort) UnmarshalJSON

func (p *BackendPort) UnmarshalJSON(value []byte) error

type BackendPortV1 added in v0.13.149

type BackendPortV1 struct {
	Name   string `json:"name"`
	Number int    `json:"number"`
}

func (BackendPortV1) String added in v0.13.149

func (p BackendPortV1) String() string

type BackendReference

type BackendReference struct {
	// BackendName references the skipperBackend by name
	BackendName string `json:"backendName"`

	// Weight defines the traffic weight, if there are 2 or more
	// default backends
	Weight int `json:"weight"`
}

type BackendV1 added in v0.13.149

type BackendV1 struct {
	Service Service `json:"service,omitempty"` // can be nil, because of TypedLocalObjectReference

	// Traffic field used for custom traffic weights, but not part of the ingress spec.
	Traffic float64
	// number of True predicates to add to support multi color traffic switching
	NoopCount int
}

BackendV1 https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#ingressbackend-v1-networking-k8s-io

type HTTPRule

type HTTPRule struct {
	Paths []*PathRule `json:"paths"`
}

type HTTPRuleV1 added in v0.13.149

type HTTPRuleV1 struct {
	Paths []*PathRuleV1 `json:"paths"`
}

type IngressItem

type IngressItem struct {
	Metadata *Metadata    `json:"metadata"`
	Spec     *IngressSpec `json:"spec"`
}

type IngressList

type IngressList struct {
	Items []*IngressItem `json:"items"`
}

func ParseIngressJSON

func ParseIngressJSON(d []byte) (IngressList, error)

ParseIngressJSON parse JSON into an IngressList

func ParseIngressYAML

func ParseIngressYAML(d []byte) (IngressList, error)

ParseIngressYAML parse YAML into an IngressList

type IngressSpec

type IngressSpec struct {
	DefaultBackend *Backend `json:"backend"`
	Rules          []*Rule  `json:"rules"`
}

IngressSpec is the v1beta1

type IngressV1Item added in v0.13.149

type IngressV1Item struct {
	Metadata *Metadata      `json:"metadata"`
	Spec     *IngressV1Spec `json:"spec"`
}

type IngressV1List added in v0.13.149

type IngressV1List struct {
	Items []*IngressV1Item `json:"items"`
}

func ParseIngressV1JSON added in v0.13.149

func ParseIngressV1JSON(d []byte) (IngressV1List, error)

ParseIngressV1JSON parse JSON into an IngressV1List

func ParseIngressV1YAML added in v0.13.149

func ParseIngressV1YAML(d []byte) (IngressV1List, error)

ParseIngressV1YAML parse YAML into an IngressV1List

type IngressV1Spec added in v0.13.149

type IngressV1Spec struct {
	DefaultBackend   *BackendV1 `json:"defaultBackend,omitempty"`
	IngressClassName string     `json:"ingressClassName,omitempty"`
	Rules            []*RuleV1  `json:"rules"`
	IngressTLS       []*TLSV1   `json:"tls,omitempty"`
}

IngressSpecV1 https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#ingressspec-v1-networking-k8s-io

type Metadata

type Metadata struct {
	Namespace   string            `json:"namespace"`
	Name        string            `json:"name"`
	Created     time.Time         `json:"creationTimestamp"`
	Uid         string            `json:"uid"`
	Annotations map[string]string `json:"annotations"`
	Labels      map[string]string `json:"labels"`
}

func (*Metadata) ToResourceID

func (meta *Metadata) ToResourceID() ResourceID

type PathRule

type PathRule struct {
	Path    string   `json:"path"`
	Backend *Backend `json:"backend"`
}

type PathRuleV1 added in v0.13.149

type PathRuleV1 struct {
	Path     string     `json:"path"`
	PathType string     `json:"pathType"`
	Backend  *BackendV1 `json:"backend"`
}

PathRuleV1 https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#httpingresspath-v1-networking-k8s-io

type ResourceID

type ResourceID struct {
	Namespace string
	Name      string
}

type RouteGroupItem

type RouteGroupItem struct {
	Metadata *Metadata       `json:"metadata"`
	Spec     *RouteGroupSpec `json:"spec"`
}

type RouteGroupList

type RouteGroupList struct {
	Items []*RouteGroupItem `json:"items"`
}

func ParseRouteGroupsJSON

func ParseRouteGroupsJSON(d []byte) (RouteGroupList, error)

ParseRouteGroupsJSON parses a json list of RouteGroups into RouteGroupList

func ParseRouteGroupsYAML

func ParseRouteGroupsYAML(d []byte) (RouteGroupList, error)

ParseRouteGroupsYAML parses a YAML list of RouteGroups into RouteGroupList

type RouteGroupSpec

type RouteGroupSpec struct {
	// Hosts specifies the host headers, that will be matched for
	// all routes created by this route group. No hosts mean
	// catchall.
	Hosts []string `json:"hosts,omitempty"`

	// Backends specify the list of backends that can be
	// referenced from routes or DefaultBackends.
	Backends []*SkipperBackend `json:"backends"`

	// DefaultBackends should be in most cases only one default
	// backend which is applied to all routes, if no override was
	// added to a route. A special case is Traffic Switching which
	// will have more than one default backend definition.
	DefaultBackends []*BackendReference `json:"defaultBackends,omitempty"`

	// Routes specifies the list of route based on path, method
	// and predicates. It defaults to catchall, if there are no
	// routes.
	Routes []*RouteSpec `json:"routes,omitempty"`
}

func (*RouteGroupSpec) UniqueHosts

func (rg *RouteGroupSpec) UniqueHosts() []string

type RouteSpec

type RouteSpec struct {
	// Path specifies Path predicate, only one of Path or PathSubtree is allowed
	Path string `json:"path,omitempty"`

	// PathSubtree specifies PathSubtree predicate, only one of Path or PathSubtree is allowed
	PathSubtree string `json:"pathSubtree,omitempty"`

	// PathRegexp can be added additionally
	PathRegexp string `json:"pathRegexp,omitempty"`

	// Backends specifies the list of backendReference that should
	// be applied to override the defaultBackends
	Backends []*BackendReference `json:"backends,omitempty"`

	// Filters specifies the list of filters applied to the RouteSpec
	Filters []string `json:"filters,omitempty"`

	// Predicates specifies the list of predicates applied to the RouteSpec
	Predicates []string `json:"predicates,omitempty"`

	// Methods defines valid HTTP methods for the specified RouteSpec
	Methods []string `json:"methods,omitempty"`
}

func (*RouteSpec) UniqueMethods

func (r *RouteSpec) UniqueMethods() []string

type Rule

type Rule struct {
	Host string    `json:"host"`
	Http *HTTPRule `json:"http"`
}

type RuleV1 added in v0.13.149

type RuleV1 struct {
	Host string      `json:"host"`
	Http *HTTPRuleV1 `json:"http"`
}

type Service added in v0.13.149

type Service struct {
	Name string        `json:"name"`
	Port BackendPortV1 `json:"port"`
}

Service https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#ingressservicebackend-v1-networking-k8s-io

type SkipperBackend

type SkipperBackend struct {
	// Name is the backendName that can be referenced as backendReference
	Name string

	// Type is the parsed backend type
	Type eskip.BackendType

	// Address is required for Type network. Address follows the
	// URL spec without path, query and fragment. For example
	// https://user:password@example.org
	Address string

	// ServiceName is required for Type service
	ServiceName string

	// ServicePort is required for Type service
	ServicePort int

	// Algorithm is required for Type lb
	Algorithm loadbalancer.Algorithm

	// Endpoints is required for Type lb
	Endpoints []string
	// contains filtered or unexported fields
}

SkipperBackend is the type safe version of skipperBackendParser

func (*SkipperBackend) UnmarshalJSON

func (sb *SkipperBackend) UnmarshalJSON(value []byte) error

UnmarshalJSON creates a new skipperBackend, safe to be called on nil pointer

type TLSV1 added in v0.13.198

type TLSV1 struct {
	Hosts      []string `json:"hosts"`
	SecretName string   `json:"secretName"`
}

Jump to

Keyboard shortcuts

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