Documentation
¶
Index ¶
- Constants
- Variables
- func AnnotateConfigMapWithKongPluginInstallation(cm *corev1.ConfigMap, kpi operatorv1alpha1.KongPluginInstallation)
- func AnnotateObjWithHash[T any](obj client.Object, toHash T) error
- func CalculateHash[T any](obj T) (string, error)
- func ClusterCertificateVolume(certSecretName string) corev1.Volume
- func ClusterCertificateVolumeMount() corev1.VolumeMount
- func DefaultDataPlaneResources() *corev1.ResourceRequirements
- func EnsureNetworkPolicyIsUpdated(existing *v1.NetworkPolicy, generated *v1.NetworkPolicy) bool
- func GenerateControlPlaneProbe(endpoint string, port intstr.IntOrString) *corev1.Probe
- func GenerateDataPlaneContainer(image string, pts *corev1.PodTemplateSpec) corev1.Container
- func GenerateDataPlaneReadinessProbe(endpoint string) *corev1.Probe
- func GenerateHPAForDataPlane(dataplane *operatorv1beta1.DataPlane, deploymentName string) (*autoscalingv2.HorizontalPodAutoscaler, error)
- func GenerateNewAdminServiceForDataPlane(dataplane *operatorv1beta1.DataPlane, opts ...ServiceOpt) (*corev1.Service, error)
- func GenerateNewIngressServiceForDataPlane(dataplane *operatorv1beta1.DataPlane, opts ...ServiceOpt) (*corev1.Service, error)
- func GenerateNewRoleForControlPlane(cp *gwtypes.ControlPlane, namespace string, rules []rbacv1.PolicyRule) *rbacv1.Role
- func GenerateNewTLSSecret[T interface{ ... }](owner T, opts ...SecretOpt) *corev1.Secret
- func GeneratePodDisruptionBudgetForDataPlane(dataplane *operatorv1beta1.DataPlane) (*policyv1.PodDisruptionBudget, error)
- func GetDataPlaneIngressServiceName(dataPlane *operatorv1beta1.DataPlane) string
- func GetManagedLabelForOwner(owner metav1.Object) client.MatchingLabels
- func IsContainerResourceEmpty(resources corev1.ResourceRequirements) bool
- func LabelObjectAsControlPlaneManaged(obj metav1.Object)
- func LabelObjectAsDataPlaneManaged(obj metav1.Object)
- func LabelObjectAsKongPluginInstallationManaged(obj metav1.Object)
- func LabelObjectAsKonnectExtensionManaged(obj metav1.Object)
- func ResourceRequirementsEqual(a corev1.ResourceRequirements, b corev1.ResourceRequirements) bool
- func SecretWithLabel(k, v string) func(s *corev1.Secret)
- func SetDefaultsContainer(c *corev1.Container)
- func SetDefaultsPodTemplateSpec(pts *corev1.PodTemplateSpec)
- func SetDefaultsVolume(v *corev1.Volume)
- func SetLabel(obj metav1.Object, key string, value string)
- func SpecHashMatchesAnnotation[T any](spec T, obj client.Object) (bool, error)
- func StrategicMergePatchPodTemplateSpec(base, patch *corev1.PodTemplateSpec) (*corev1.PodTemplateSpec, error)
- func VolumeMountsFromPodTemplateSpecContainerOrNil(pts *corev1.PodTemplateSpec, containerName string) []corev1.VolumeMount
- func VolumesFromPodTemplateSpecOrNil(pts *corev1.PodTemplateSpec) []corev1.Volume
- func WithAnnotation[T client.Object](k, v string) func(d T)
- type ControlPlaneOrDataPlaneOrKonnectExtension
- type Deployment
- type DeploymentOpt
- type SecretOpt
- type ServiceOpt
Constants ¶
const ( // DefaultDataPlaneCPURequest is the default DataPlane CPU request. DefaultDataPlaneCPURequest = "100m" // DefaultDataPlaneCPULimit is the default DataPlane CPU limit. DefaultDataPlaneCPULimit = "1000m" // DefaultDataPlaneMemoryRequest is the default DataPlane memory request. DefaultDataPlaneMemoryRequest = "20Mi" // DefaultDataPlaneMemoryLimit is the default DataPlane memory limit. DefaultDataPlaneMemoryLimit = "1000Mi" )
const DefaultDataPlaneIngressServiceType = corev1.ServiceTypeLoadBalancer
DefaultDataPlaneIngressServiceType is the default Service type for a DataPlane.
Variables ¶
var DefaultDataPlaneIngressServicePorts = []corev1.ServicePort{ { Name: "http", Protocol: corev1.ProtocolTCP, Port: consts.DefaultHTTPPort, TargetPort: intstr.FromInt(consts.DataPlaneProxyPort), }, { Name: "https", Protocol: corev1.ProtocolTCP, Port: consts.DefaultHTTPSPort, TargetPort: intstr.FromInt(consts.DataPlaneProxySSLPort), }, }
DefaultDataPlaneIngressServicePorts returns the default ServicePorts for a DataPlane.
Functions ¶
func AnnotateConfigMapWithKongPluginInstallation ¶
func AnnotateConfigMapWithKongPluginInstallation(cm *corev1.ConfigMap, kpi operatorv1alpha1.KongPluginInstallation)
AnnotateConfigMapWithKongPluginInstallation ensures that annotation that maps particular ConfigMap with KongPluginInstallation based which it's been populated. Annotation value is in the form `Namespace/Name` of the KongPluginInstallation.
func AnnotateObjWithHash ¶
AnnotateObjWithHash sets the hash of the provided toHash object in the provided obj's annotations.
func CalculateHash ¶
CalculateHash calculates the hash of the given object. It returns the hash as a string.
func ClusterCertificateVolume ¶
ClusterCertificateVolume returns a volume holding a cluster certificate given a Secret holding a certificate.
func ClusterCertificateVolumeMount ¶
func ClusterCertificateVolumeMount() corev1.VolumeMount
ClusterCertificateVolumeMount returns a volume mount for the cluster certificate.
func DefaultDataPlaneResources ¶
func DefaultDataPlaneResources() *corev1.ResourceRequirements
DefaultDataPlaneResources generates a ResourceRequirements with the DataPlane defaults.
func EnsureNetworkPolicyIsUpdated ¶
func EnsureNetworkPolicyIsUpdated( existing *v1.NetworkPolicy, generated *v1.NetworkPolicy, ) bool
EnsureNetworkPolicyIsUpdated checks if the provided network policy needs an update. It comes to a decision by comparing the provided policies' specs. It returns a boolean which indicates whether we need to perform an update. Note that the provided existing policy is updated in place.
func GenerateControlPlaneProbe ¶
func GenerateControlPlaneProbe(endpoint string, port intstr.IntOrString) *corev1.Probe
GenerateControlPlaneProbe generates a controlplane probe that uses the specified endpoint. This is currently used both for readiness and liveness.
func GenerateDataPlaneContainer ¶
func GenerateDataPlaneContainer(image string, pts *corev1.PodTemplateSpec) corev1.Container
GenerateDataPlaneContainer generates a DataPlane container.
func GenerateDataPlaneReadinessProbe ¶
GenerateDataPlaneReadinessProbe generates a dataplane probe that uses the specified endpoint.
func GenerateHPAForDataPlane ¶
func GenerateHPAForDataPlane(dataplane *operatorv1beta1.DataPlane, deploymentName string) ( *autoscalingv2.HorizontalPodAutoscaler, error, )
GenerateHPAForDataPlane generate an HPA for the given DataPlane. The provided deploymentName is the name of the Deployment that the HPA will target using its ScaleTargetRef.
func GenerateNewAdminServiceForDataPlane ¶
func GenerateNewAdminServiceForDataPlane(dataplane *operatorv1beta1.DataPlane, opts ...ServiceOpt) (*corev1.Service, error)
GenerateNewAdminServiceForDataPlane is a helper to generate the headless dataplane admin service
func GenerateNewIngressServiceForDataPlane ¶
func GenerateNewIngressServiceForDataPlane(dataplane *operatorv1beta1.DataPlane, opts ...ServiceOpt) (*corev1.Service, error)
GenerateNewIngressServiceForDataPlane is a helper to generate the dataplane ingress service
func GenerateNewRoleForControlPlane ¶
func GenerateNewRoleForControlPlane( cp *gwtypes.ControlPlane, namespace string, rules []rbacv1.PolicyRule, ) *rbacv1.Role
GenerateNewRoleForControlPlane generates a new Role in provided namespace for provided ControlPlane.
func GenerateNewTLSSecret ¶
func GenerateNewTLSSecret[
T interface {
ControlPlaneOrDataPlaneOrKonnectExtension
client.Object
},
](
owner T, opts ...SecretOpt,
) *corev1.Secret
GenerateNewTLSSecret is a helper to generate a TLS Secret to be used for mutual TLS. It accepts a list of options that can change the generated Secret.
func GeneratePodDisruptionBudgetForDataPlane ¶
func GeneratePodDisruptionBudgetForDataPlane(dataplane *operatorv1beta1.DataPlane) (*policyv1.PodDisruptionBudget, error)
GeneratePodDisruptionBudgetForDataPlane generates a PodDisruptionBudget for the given DataPlane.
func GetDataPlaneIngressServiceName ¶
func GetDataPlaneIngressServiceName(dataPlane *operatorv1beta1.DataPlane) string
GetDataPlaneIngressServiceName fetches the specified name of ingress service of dataplane. If the service name is not specified, it returns an empty string.
func GetManagedLabelForOwner ¶
func GetManagedLabelForOwner(owner metav1.Object) client.MatchingLabels
GetManagedLabelForOwner returns the managed-by labels for the provided owner.
func IsContainerResourceEmpty ¶
func IsContainerResourceEmpty(resources corev1.ResourceRequirements) bool
IsContainerResourceEmpty determines if the provided resource requirements is effectively "empty" in that all fields are unset.
func LabelObjectAsControlPlaneManaged ¶
LabelObjectAsControlPlaneManaged ensures that labels are set on the provided object to signal that it's owned by a ControlPlane resource and that its lifecycle is managed by this operator.
func LabelObjectAsDataPlaneManaged ¶
LabelObjectAsDataPlaneManaged ensures that labels are set on the provided object to signal that it's owned by a DataPlane resource and that its lifecycle is managed by this operator.
func LabelObjectAsKongPluginInstallationManaged ¶
LabelObjectAsKongPluginInstallationManaged ensures that labels are set on the provided object to signal that it's owned by a KongPluginInstallation resource and that its lifecycle is managed by this operator.
func LabelObjectAsKonnectExtensionManaged ¶
LabelObjectAsKonnectExtensionManaged ensures that labels are set on the provided object to signal that it's owned by a KonnectExtension resource and that its lifecycle is managed by this operator.
func ResourceRequirementsEqual ¶
func ResourceRequirementsEqual(a corev1.ResourceRequirements, b corev1.ResourceRequirements) bool
ResourceRequirementsEqual compares two corev1.ResourceRequirements. It is needed because sometimes we get objects with '1000m' and sometimes with '1' set as values and while those 2 are "different", they are the same in value.
func SecretWithLabel ¶
SecretWithLabel adds a label to a Secret.
func SetDefaultsContainer ¶
SetDefaultsContainer sets defaults in the provided Container.
func SetDefaultsPodTemplateSpec ¶
func SetDefaultsPodTemplateSpec(pts *corev1.PodTemplateSpec)
SetDefaultsPodTemplateSpec sets defaults in the provided PodTemplateSpec. This is useful for setting defaults in patches, where the defaults are not applied and we end up with structs that are filled with "zero default values".
The reason for this is that native Kubernetes structs (e.g. `Pod`) define their default values in comments and are applied in the SetDefaults_* functions. To prevent situations where users use fields from the PodTemplateSpec which imply usage of other fields which do not have zero values as defaults (e.g. probe timeouts or SecretVolumeSource default mode) we need to apply the defaults to the patch.
func SetDefaultsVolume ¶
SetDefaultsVolume sets defaults in the provided Volume.
func SpecHashMatchesAnnotation ¶
SpecHashMatchesAnnotation calculates the hash of the given spec and returns boolean indicating whether the hash matches the one in the annotations of the given object.
func StrategicMergePatchPodTemplateSpec ¶
func StrategicMergePatchPodTemplateSpec(base, patch *corev1.PodTemplateSpec) (*corev1.PodTemplateSpec, error)
StrategicMergePatchPodTemplateSpec adds patches to base using a strategic merge patch and iterating by container name, failing on the first error
func VolumeMountsFromPodTemplateSpecContainerOrNil ¶
func VolumeMountsFromPodTemplateSpecContainerOrNil(pts *corev1.PodTemplateSpec, containerName string) []corev1.VolumeMount
VolumeMountsFromPodTemplateSpecContainerOrNil returns volume mounts for a container from a PodTemplateSpec, or nil if the PodTemplateSpec or container is not found.
func VolumesFromPodTemplateSpecOrNil ¶
func VolumesFromPodTemplateSpecOrNil(pts *corev1.PodTemplateSpec) []corev1.Volume
VolumesFromPodTemplateSpecOrNil returns volumes from a PodTemplateSpec, or nil if the PodTemplateSpec or volumes are not found.
func WithAnnotation ¶
WithAnnotation adds an annotation to an object.
Types ¶
type ControlPlaneOrDataPlaneOrKonnectExtension ¶
type ControlPlaneOrDataPlaneOrKonnectExtension interface {
*gwtypes.ControlPlane |
*operatorv1beta1.DataPlane |
*konnectv1alpha2.KonnectExtension
}
ControlPlaneOrDataPlaneOrKonnectExtension is a type that can be either a ControlPlane, a DataPlane or a KonnectExtension. It is used to infer the types that can own secret resources.
type Deployment ¶
type Deployment appsv1.Deployment
Deployment is a wrapper for appsv1.Deployment. It provides additional methods to modify parts of the Deployment, such as to add a Volume or set an environment variable. These "With" methods do not return errors to allow chaining, and may no-op if target subsection is not available or overwrite existing conflicting configuration. If the presence of existing configuration is uncertain, you must check before invoking them.
func ApplyDeploymentUserPatches ¶
func ApplyDeploymentUserPatches( deployment *Deployment, podTemplateSpec *corev1.PodTemplateSpec, ) (*Deployment, error)
ApplyDeploymentUserPatches applies user PodTemplateSpec patches to a Deployment. It returns the existing Deployment if there are no patches.
func GenerateNewDeploymentForDataPlane ¶
func GenerateNewDeploymentForDataPlane( dataplane *operatorv1beta1.DataPlane, dataplaneImage string, opts ...DeploymentOpt, ) (*Deployment, error)
GenerateNewDeploymentForDataPlane generates a new Deployment for the DataPlane.
func (*Deployment) Unwrap ¶
func (d *Deployment) Unwrap() *appsv1.Deployment
Unwrap returns the underlying appsv1.Deployment.
func (*Deployment) WithEnvVar ¶
func (d *Deployment) WithEnvVar(v corev1.EnvVar, container string) *Deployment
WithEnvVar sets an environment variable in a container. It overwrites any existing environment variable with the same name. It takes no action if the container does not exist.
func (*Deployment) WithVolume ¶
func (d *Deployment) WithVolume(v corev1.Volume) *Deployment
WithVolume appends a volume to a Deployment. It overwrites any existing Volume with the same name.
func (*Deployment) WithVolumeMount ¶
func (d *Deployment) WithVolumeMount(v corev1.VolumeMount, container string) *Deployment
WithVolumeMount appends a volume mount to a Deployment's container. It overwrites any existing VolumeMount with the same path. It takes no action if the container does not exist.
type DeploymentOpt ¶
type DeploymentOpt func(*appsv1.Deployment)
DeploymentOpt is an option for Deployment generators.
type ServiceOpt ¶
ServiceOpt is an option function for a Service.
func LabelSelectorFromDataPlaneStatusSelectorServiceOpt ¶
func LabelSelectorFromDataPlaneStatusSelectorServiceOpt(dataplane *operatorv1beta1.DataPlane) ServiceOpt
LabelSelectorFromDataPlaneStatusSelectorServiceOpt returns a ServiceOpt function which will set Service's selector based on provided DataPlane's Status selector field.
func ServicePortsFromDataPlaneIngressOpt ¶
func ServicePortsFromDataPlaneIngressOpt(dataplane *operatorv1beta1.DataPlane) ServiceOpt
ServicePortsFromDataPlaneIngressOpt is a helper to translate the DataPlane service ports field into actual service ports.
func ServiceWithLabel ¶
func ServiceWithLabel(k, v string) ServiceOpt
ServiceWithLabel adds a label to a Service.