k8s

package
v0.0.0-...-7028f9c Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConditionAccepted     = "Accepted"
	ConditionProgrammed   = "Programmed"
	ConditionConflicted   = "Conflicted"
	ConditionPending      = "Pending"
	ConditionResolvedRefs = "ResolvedRefs"

	ListenerReasonTooManyCertRefs = "TooManyCertificateRefs"
	ListenerReasonKafkaConflict   = "TooManyKafkaListeners"

	ParamsReasonLicenseNotFound = "LicenseNotFound"
	ReasonNoConflict            = "NoConflicts"

	ReasonGroupNotFound = "GroupNotFound"

	ConditionStatusTrue  = "True"
	ConditionStatusFalse = "False"
)
View Source
const (
	DefaultCPURequest         = "200m"
	DefaultCPULimit           = "500m"
	DefaultMemRequest         = "256Mi"
	DefaultMemLimit           = "512Mi"
	DefaultConfigVolumeName   = "config"
	UserConfigVolumeName      = "user-config"
	DefaultLicenseVolumeName  = "license"
	DefaultConfigFileEntry    = "gravitee.yml"
	DefaultLogConfigFileEntry = "logback.xml"
	UserConfigFileEntry       = "user.yml"
	DefaultProbePort          = 18082

	GatewayConfigMapPrefix     = "gio-gw-config-"
	PEMRegistryConfigMapPrefix = "gio-pem-registry-"

	GatewayContainerName        = "gateway"
	DefaultGatewayImage         = "graviteeio/apim-gateway"
	DefaultGatewayConfigPath    = "/opt/graviteeio-gateway/config/"
	DefaultGatewayLogConfigFile = DefaultGatewayConfigPath + DefaultLogConfigFileEntry
	DefaultGatewayConfigFile    = DefaultGatewayConfigPath + DefaultConfigFileEntry
	UserGatewayConfigFile       = DefaultGatewayConfigPath + "user.yml"

	DefaultLicenseMountPath = "/opt/graviteeio-gateway/license"

	InstanceLabelKey  = "app.kubernetes.io/instance"
	ComponentLabelKey = "app.kubernetes.io/component"
	VersionLabelKey   = "app.kubernetes.io/version"
	NameLabelKey      = "app.kubernetes.io/name"
	PartOfLabelKey    = "app.kubernetes.io/part-of"
	ManagedByLabelKey = "app.kubernetes.io/managed-by"

	ManagedByLabelValue            = "gko.gravitee.io"
	PartOfLabelValue               = "apim.gravitee.io"
	GatewayComponentLabelValue     = "gateway"
	HTTPRouteComponentlabelValue   = "http-route"
	PEMRegistryComponentLabelValue = "kubernetes-pem-registry"
)
View Source
const (
	GwAPIv1HTTPRouteKind = "HTTPRoute"
	GwAPIv1GatewayKind   = "Gateway"
	CoreV1ServiceKind    = "Service"
	CoreV1SecretKind     = "Secret"
	GwAPIv1APIVersion    = "gateway.networking.k8s.io/v1"

	GraviteeAPIVersion     = "gravitee.io/v1alpha1"
	GraviteeKafkaRouteKind = "KafkaRoute"

	ServiceURIPattern = "http://%s.%s.svc.cluster.local:%d"
)

Variables

View Source
var (
	DefaultReplicas         int32 = 1
	DefaultVolumeSourceMode int32 = 420
)
View Source
var (
	GwAPIv1Group  = gwAPIv1.Group(gwAPIv1.GroupVersion.Group)
	GraviteeGroup = gwAPIv1.Group(v1alpha1.GroupVersion.Group)
)
View Source
var ConfigVolumeMount = coreV1.VolumeMount{
	Name:      DefaultConfigVolumeName,
	MountPath: DefaultGatewayConfigFile,
	SubPath:   DefaultConfigFileEntry,
	ReadOnly:  true,
}
View Source
var DefaultConfigVolumeSource = coreV1.VolumeSource{
	ConfigMap: &coreV1.ConfigMapVolumeSource{
		DefaultMode:          &DefaultVolumeSourceMode,
		LocalObjectReference: coreV1.LocalObjectReference{},
	},
}
View Source
var DefaultGatewayConfigMap = &coreV1.ConfigMap{
	ObjectMeta: metaV1.ObjectMeta{},
	Data:       map[string]string{},
}
View Source
var DefaultGatewayConfigVolume = coreV1.Volume{
	Name:         DefaultConfigVolumeName,
	VolumeSource: DefaultConfigVolumeSource,
}
View Source
var DefaultGatewayContainer = coreV1.Container{
	Image:           DefaultGatewayImage,
	ImagePullPolicy: coreV1.PullIfNotPresent,
	Name:            GatewayContainerName,
	LivenessProbe:   DefaultLivenessProbe,
	ReadinessProbe:  DefaultReadinessProbe,
	StartupProbe:    DefaultStartupProbe,
	VolumeMounts:    []coreV1.VolumeMount{},
	Ports:           []coreV1.ContainerPort{},
	Resources:       *DefaultResources,
}
View Source
var DefaultGatewayDeployment = &appV1.Deployment{
	ObjectMeta: metaV1.ObjectMeta{},
	Spec:       *DefaultGatewayDeploymentSpec,
}
View Source
var DefaultGatewayDeploymentSpec = &appV1.DeploymentSpec{
	Replicas: &DefaultReplicas,
	Selector: &metaV1.LabelSelector{},
	Template: coreV1.PodTemplateSpec{
		Spec: *DefaultGatewayPodSpec,
	},
}
View Source
var DefaultGatewayPodSpec = &coreV1.PodSpec{
	Containers: []coreV1.Container{
		DefaultGatewayContainer,
	},
	Resources: DefaultResources,
	Volumes:   []coreV1.Volume{},
}
View Source
var DefaultGatewayPodTemplate = &coreV1.PodTemplateSpec{
	ObjectMeta: metaV1.ObjectMeta{},
	Spec:       *DefaultGatewayPodSpec,
}
View Source
var DefaultLicenseConfigVolume = coreV1.Volume{
	Name:         DefaultLicenseVolumeName,
	VolumeSource: DefaultLicenseVolumeSource,
}
View Source
var DefaultLicenseVolumeSource = coreV1.VolumeSource{
	Secret: &coreV1.SecretVolumeSource{
		DefaultMode: &DefaultVolumeSourceMode,
	},
}
View Source
var DefaultLivenessProbe = &coreV1.Probe{
	FailureThreshold: 300000,
	PeriodSeconds:    5,
	SuccessThreshold: 1,
	TimeoutSeconds:   2,
	ProbeHandler: coreV1.ProbeHandler{
		HTTPGet: &coreV1.HTTPGetAction{
			HTTPHeaders: []coreV1.HTTPHeader{
				{Name: "Authorization", Value: "Basic YWRtaW46YWRtaW4="},
			},
			Path:   "/_node/health?probes=http-server",
			Port:   intstr.FromInt32(DefaultProbePort),
			Scheme: "HTTP",
		},
	},
}
View Source
var DefaultPEMRegistryConfigMap = &coreV1.ConfigMap{
	ObjectMeta: metaV1.ObjectMeta{},
	Data:       map[string]string{},
}
View Source
var DefaultReadinessProbe = &coreV1.Probe{
	FailureThreshold: 2,
	PeriodSeconds:    10,
	SuccessThreshold: 1,
	TimeoutSeconds:   2,
	ProbeHandler: coreV1.ProbeHandler{
		HTTPGet: &coreV1.HTTPGetAction{
			HTTPHeaders: []coreV1.HTTPHeader{
				{Name: "Authorization", Value: "Basic YWRtaW46YWRtaW4="},
			},
			Path:   "/_node/health?probes=http-server",
			Port:   intstr.FromInt32(DefaultProbePort),
			Scheme: "HTTP",
		},
	},
}
View Source
var DefaultService = &coreV1.Service{
	ObjectMeta: metaV1.ObjectMeta{},
	Spec:       *DefaultServiceSpec,
}
View Source
var DefaultServiceSpec = &coreV1.ServiceSpec{
	Ports: []coreV1.ServicePort{},
	Type:  coreV1.ServiceTypeLoadBalancer,
}
View Source
var DefaultStartupProbe = &coreV1.Probe{
	FailureThreshold:    100,
	InitialDelaySeconds: 5,
	PeriodSeconds:       2,
	SuccessThreshold:    1,
	TimeoutSeconds:      2,
	ProbeHandler: coreV1.ProbeHandler{
		HTTPGet: &coreV1.HTTPGetAction{
			HTTPHeaders: []coreV1.HTTPHeader{
				{Name: "Authorization", Value: "Basic YWRtaW46YWRtaW4="},
			},
			Path:   "/_node/health?probes=http-server",
			Port:   intstr.FromInt32(DefaultProbePort),
			Scheme: "HTTP",
		},
	},
}
View Source
var LicenseVolumeMount = coreV1.VolumeMount{
	Name:      DefaultLicenseVolumeName,
	MountPath: DefaultLicenseMountPath,
	ReadOnly:  true,
}
View Source
var LogConfigVolumeMount = coreV1.VolumeMount{
	Name:      DefaultConfigVolumeName,
	MountPath: DefaultGatewayLogConfigFile,
	SubPath:   DefaultLogConfigFileEntry,
	ReadOnly:  true,
}
View Source
var ProtocolToServerType = map[gwAPIv1.ProtocolType]string{
	gwAPIv1.HTTPProtocolType:  "http",
	gwAPIv1.HTTPSProtocolType: "http",
}
View Source
var UserConfigVolumeMount = coreV1.VolumeMount{
	Name:      UserConfigVolumeName,
	MountPath: UserGatewayConfigFile,
	SubPath:   UserConfigFileEntry,
	ReadOnly:  true,
}
View Source
var UserGatewayConfigVolume = coreV1.Volume{
	Name:         UserConfigVolumeName,
	VolumeSource: DefaultConfigVolumeSource,
}

Functions

func AddAnnotation

func AddAnnotation(o client.Object, key, value string)

func AddSuccessfulConditions

func AddSuccessfulConditions(obj core.ConditionAwareObject)

func BuildGatewayTag

func BuildGatewayTag(gw *gateway.Gateway) string

func BuildTag

func BuildTag(namespace, name string) string

func CreateOrUpdate

func CreateOrUpdate(ctx context.Context, obj client.Object, fns ...util.MutateFn) error

func Delete

func Delete[T client.Object](ctx context.Context, obj T) error

func DeployGateway

func DeployGateway(
	ctx context.Context,
	gw *gateway.Gateway,
	params *v1alpha1.GatewayClassParameters,
) error

func ErrorToCondition

func ErrorToCondition(obj client.Object, err error)

func FindListenerIndexBySectionName

func FindListenerIndexBySectionName(gw *gwAPIv1.Gateway, sectionName gwAPIv1.SectionName) int

func GIOPemRegistryLabels

func GIOPemRegistryLabels(gwName string) map[string]string

func GetClient

func GetClient() client.Client

func GetCondition

func GetCondition(obj core.ConditionAware, conditionType string) *metav1.Condition

func GetHTTPHosts

func GetHTTPHosts(route *gwAPIv1.HTTPRoute, gw *gwAPIv1.Gateway, ref gwAPIv1.ParentReference) []string

func GetHTTPHostsForListenerAndRoute

func GetHTTPHostsForListenerAndRoute(httpRoute *gwAPIv1.HTTPRoute, listener gwAPIv1.Listener) []string

func GetKafkaListener

func GetKafkaListener(gw *gwAPIv1.Gateway) *gwAPIv1.Listener

func GetKafkaListenerStatus

func GetKafkaListenerStatus(gw *gateway.Gateway) *gwAPIv1.ListenerStatus

func GetLatest

func GetLatest[T client.Object](ctx context.Context, obj T) error

func GetMatchingGatewayLabels

func GetMatchingGatewayLabels(obj client.Object) map[string]string

func GetRefNs

func GetRefNs(referer client.Object, ns string) string

func GetSupportedRouteKinds

func GetSupportedRouteKinds(listener gwAPIv1.Listener) []gwAPIv1.RouteGroupKind

func GwAPIv1GatewayLabels

func GwAPIv1GatewayLabels(gwName string) map[string]string

func GwAPIv1HTTPRouteLabels

func GwAPIv1HTTPRouteLabels(routeNAme string) map[string]string

func HasGatewayClassParameters

func HasGatewayClassParameters(gw *gwAPIv1.GatewayClass, params *v1alpha1.GatewayClassParameters) bool

func HasGraviteeLicense

func HasGraviteeLicense(params *v1alpha1.GatewayClassParameters) bool

func HasGraviteeYAML

func HasGraviteeYAML(params *v1alpha1.GatewayClassParameters) bool

func HasHTTPListenerAtIndex

func HasHTTPListenerAtIndex(gw *gwAPIv1.Gateway, index int) bool

func HasHTTPRouteOwner

func HasHTTPRouteOwner(ownerRefs []metaV1.OwnerReference) bool

func HasHTTPSupport

func HasHTTPSupport(listener gwAPIv1.Listener) bool

func HasHafkaListener

func HasHafkaListener(gw *gateway.Gateway) bool

func HasIntersectingHostName

func HasIntersectingHostName(route *gwAPIv1.HTTPRoute, gw *gwAPIv1.Gateway, ref gwAPIv1.ParentReference) bool

func HasIntersectingHostNameAtIndex

func HasIntersectingHostNameAtIndex(route *gwAPIv1.HTTPRoute, gw *gwAPIv1.Gateway, index int) bool

func HasKafkaEnabled

func HasKafkaEnabled(params *v1alpha1.GatewayClassParameters) bool

func HasUnresolvedRefs

func HasUnresolvedRefs(obj core.ConditionAware) bool

func IsAccepted

func IsAccepted(obj core.ConditionAware) bool

func IsAttachedHTTPRoute

func IsAttachedHTTPRoute(
	ctx context.Context,
	gw *gwAPIv1.Gateway,
	listener gwAPIv1.Listener,
	route gwAPIv1.HTTPRoute,
) (bool, error)

func IsAttachedKafkaRoute

func IsAttachedKafkaRoute(
	gw *gwAPIv1.Gateway,
	listener gwAPIv1.Listener,
	route v1alpha1.KafkaRoute,
) bool

func IsConflicted

func IsConflicted(obj core.ConditionAware) bool

func IsGatewayComponent

func IsGatewayComponent(obj client.Object) bool

func IsGatewayDependent

func IsGatewayDependent(gw *gateway.Gateway, obj client.Object) bool

func IsGatewayKind

func IsGatewayKind(ref gwAPIv1.ParentReference) bool

func IsGatewayRef

func IsGatewayRef(gw *gwAPIv1.Gateway, ref gwAPIv1.ParentReference) bool

func IsGrantedReference

func IsGrantedReference(ctx context.Context, from client.Object, to gwAPIv1.ObjectReference) (bool, error)

func IsGraviteeIngress

func IsGraviteeIngress(ingress *netV1.Ingress) bool

func IsKafkaListener

func IsKafkaListener(listener gwAPIv1.Listener) bool

func IsKafkaListenerStatus

func IsKafkaListenerStatus(listener gwAPIv1.ListenerStatus) bool

func IsKafkaRouteKind

func IsKafkaRouteKind(routeKind gwAPIv1.RouteGroupKind) bool

func IsListenerRef

func IsListenerRef(
	gw *gwAPIv1.Gateway,
	listener gwAPIv1.Listener,
	ref gwAPIv1.ParentReference,
) bool

func IsResolved

func IsResolved(obj core.ConditionAware) bool

func IsSecretRef

func IsSecretRef(secret *coreV1.Secret, ref gwAPIv1.SecretObjectReference) bool

func IsServiceKind

func IsServiceKind(ref gwAPIv1.BackendObjectReference) bool

func MapConditions

func MapConditions(conditionsSlice []metav1.Condition) map[string]metav1.Condition

func NsPtrToStr

func NsPtrToStr(ns *gwAPIv1.Namespace) string

func RegisterClient

func RegisterClient(c client.Client)

func ResolveGateway

func ResolveGateway(
	ctx context.Context,
	routeMeta metav1.ObjectMeta,
	ref gwAPIv1.ParentReference,
) (*gwAPIv1.Gateway, error)

func ResolveRouteHostnames

func ResolveRouteHostnames(ctx context.Context, route *gwAPIv1.HTTPRoute) []string

func SetCondition

func SetCondition(obj core.ConditionAware, condition *metav1.Condition)

func SetConditions

func SetConditions(obj client.Object, conditions []metav1.Condition)

func SupportsRouteNamespace

func SupportsRouteNamespace(
	ctx context.Context,
	gw *gwAPIv1.Gateway,
	ref gwAPIv1.ParentReference,
	route *gwAPIv1.HTTPRoute,
) (bool, error)

func Update

func Update[T client.Object](ctx context.Context, objNew T) error

func UpdateStatus

func UpdateStatus[T client.Object](ctx context.Context, objNew T) error

Types

type ConditionBuilder

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

func NewAcceptedConditionBuilder

func NewAcceptedConditionBuilder(generation int64) *ConditionBuilder

func NewConditionBuilder

func NewConditionBuilder(cType string) *ConditionBuilder

func NewGatewayProgrammedConditionBuilder

func NewGatewayProgrammedConditionBuilder(generation int64) *ConditionBuilder

func NewHTTPRoutePathConflictedConditionBuilder

func NewHTTPRoutePathConflictedConditionBuilder(generation int64) *ConditionBuilder

func NewListenerConflictedConditionBuilder

func NewListenerConflictedConditionBuilder(generation int64) *ConditionBuilder

func NewListenerProgrammedConditionBuilder

func NewListenerProgrammedConditionBuilder(generation int64) *ConditionBuilder

func NewResolvedRefsConditionBuilder

func NewResolvedRefsConditionBuilder(generation int64) *ConditionBuilder

func (*ConditionBuilder) Accept

func (b *ConditionBuilder) Accept(msg string) *ConditionBuilder

func (*ConditionBuilder) Build

func (b *ConditionBuilder) Build() *metav1.Condition

func (*ConditionBuilder) Message

func (b *ConditionBuilder) Message(msg string) *ConditionBuilder

func (*ConditionBuilder) ObservedGeneration

func (b *ConditionBuilder) ObservedGeneration(gen int64) *ConditionBuilder

func (*ConditionBuilder) Program

func (b *ConditionBuilder) Program(msg string) *ConditionBuilder

func (*ConditionBuilder) Reason

func (b *ConditionBuilder) Reason(reason string) *ConditionBuilder

func (*ConditionBuilder) RejectBackendNotFound

func (b *ConditionBuilder) RejectBackendNotFound(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectBackendRefNotPermitted

func (b *ConditionBuilder) RejectBackendRefNotPermitted(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectConflictingPath

func (b *ConditionBuilder) RejectConflictingPath(routeID string) *ConditionBuilder

func (*ConditionBuilder) RejectGroupNotFound

func (b *ConditionBuilder) RejectGroupNotFound(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectInvalidBackendKind

func (b *ConditionBuilder) RejectInvalidBackendKind(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectInvalidCertificateRef

func (b *ConditionBuilder) RejectInvalidCertificateRef(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectInvalidGatewayKind

func (b *ConditionBuilder) RejectInvalidGatewayKind(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectInvalidParameters

func (b *ConditionBuilder) RejectInvalidParameters(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectInvalidRouteKinds

func (b *ConditionBuilder) RejectInvalidRouteKinds(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectLicenseNotFound

func (b *ConditionBuilder) RejectLicenseNotFound(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectListenerRefNotPermitted

func (b *ConditionBuilder) RejectListenerRefNotPermitted(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectListenersNotValid

func (b *ConditionBuilder) RejectListenersNotValid(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectNoMatchingListenerHostname

func (b *ConditionBuilder) RejectNoMatchingListenerHostname(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectNoMatchingParent

func (b *ConditionBuilder) RejectNoMatchingParent(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectNotAllowedByListener

func (b *ConditionBuilder) RejectNotAllowedByListener(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectTooManyCertificateRefs

func (b *ConditionBuilder) RejectTooManyCertificateRefs(msg string) *ConditionBuilder

func (*ConditionBuilder) RejectUnsupportedProtocol

func (b *ConditionBuilder) RejectUnsupportedProtocol(msg string) *ConditionBuilder

func (*ConditionBuilder) ResolveRefs

func (b *ConditionBuilder) ResolveRefs(msg string) *ConditionBuilder

func (*ConditionBuilder) Status

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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