Documentation ¶
Overview ¶
Package forge groups the methods used to forge the Kubernetes object definitions for the reflection logic.
Index ¶
- Constants
- Variables
- func ApplyOptions() metav1.ApplyOptions
- func EndpointSliceLabels() labels.Set
- func EndpointToBeReflected(endpoint *discoveryv1beta1.Endpoint) bool
- func FilterIngressAnnotations(local map[string]string) map[string]string
- func Init(localClusterID, remoteClusterID, nodeName, nodeIP string)
- func IsEndpointSliceManagedByReflection(obj metav1.Object) bool
- func IsReflected(obj metav1.Object) bool
- func LocalConfigMapName(remote string) string
- func LocalContainerStats(metrics *metricsv1beta1.ContainerMetrics, start, now metav1.Time) statsv1alpha1.ContainerStats
- func LocalContainersStats(metrics []metricsv1beta1.ContainerMetrics, start, now metav1.Time) []statsv1alpha1.ContainerStats
- func LocalNodeStats(pods []statsv1alpha1.PodStats) *statsv1alpha1.Summary
- func LocalPod(local, remote *corev1.Pod, translator PodIPTranslator, restarts int32) *corev1.Pod
- func LocalPodOffloadedLabel(local *corev1.Pod) (*corev1apply.PodApplyConfiguration, bool)
- func LocalPodStats(pod *corev1.Pod, metrics *metricsv1beta1.PodMetrics) statsv1alpha1.PodStats
- func LocalPodStatus(remote *corev1.PodStatus, translator PodIPTranslator, restarts int32) corev1.PodStatus
- func LocalRejectedPod(local *corev1.Pod, phase corev1.PodPhase, reason string) *corev1.Pod
- func LocalRejectedPodStatus(local *corev1.PodStatus, phase corev1.PodPhase, reason string) corev1.PodStatus
- func ReflectedLabelSelector() labels.Selector
- func ReflectionLabels() labels.Set
- func RemoteConfigMap(local *corev1.ConfigMap, targetNamespace string) *corev1apply.ConfigMapApplyConfiguration
- func RemoteConfigMapName(local string) string
- func RemoteContainerEnvVariables(envs []corev1.EnvVar, saName string) []corev1.EnvVar
- func RemoteContainers(containers []corev1.Container, saName string) []corev1.Container
- func RemoteEndpointSlice(local *discoveryv1beta1.EndpointSlice, targetNamespace string, ...) *discoveryv1beta1apply.EndpointSliceApplyConfiguration
- func RemoteEndpointSliceEndpoints(locals []discoveryv1beta1.Endpoint, translator EndpointTranslator) []*discoveryv1beta1apply.EndpointApplyConfiguration
- func RemoteEndpointSlicePorts(locals []discoveryv1beta1.EndpointPort) []*discoveryv1beta1apply.EndpointPortApplyConfiguration
- func RemoteHostAliases(aliases []corev1.HostAlias, ...) []corev1.HostAlias
- func RemoteIngress(local *netv1.Ingress, targetNamespace string) *netv1apply.IngressApplyConfiguration
- func RemoteIngressBackend(local *netv1.IngressBackend) *netv1apply.IngressBackendApplyConfiguration
- func RemoteIngressHTTP(local *netv1.HTTPIngressRuleValue) *netv1apply.HTTPIngressRuleValueApplyConfiguration
- func RemoteIngressPaths(local []netv1.HTTPIngressPath) []*netv1apply.HTTPIngressPathApplyConfiguration
- func RemoteIngressRules(local []netv1.IngressRule) []*netv1apply.IngressRuleApplyConfiguration
- func RemoteIngressService(local *netv1.IngressServiceBackend) *netv1apply.IngressServiceBackendApplyConfiguration
- func RemoteIngressSpec(local *netv1.IngressSpec) *netv1apply.IngressSpecApplyConfiguration
- func RemoteIngressTLS(local []netv1.IngressTLS) []*netv1apply.IngressTLSApplyConfiguration
- func RemoteKind(kind string) string
- func RemoteObjectMeta(local, remote *metav1.ObjectMeta) metav1.ObjectMeta
- func RemoteObjectReference(ref *corev1.ObjectReference) *corev1apply.ObjectReferenceApplyConfiguration
- func RemotePodSpec(local, remote *corev1.PodSpec, saSecretRetriever SASecretRetriever, ...) corev1.PodSpec
- func RemoteSecret(local *corev1.Secret, targetNamespace string) *corev1apply.SecretApplyConfiguration
- func RemoteService(local *corev1.Service, targetNamespace string) *corev1apply.ServiceApplyConfiguration
- func RemoteServicePorts(locals []corev1.ServicePort, forceRemoteNodePort bool) []*corev1apply.ServicePortApplyConfiguration
- func RemoteServiceSpec(local *corev1.ServiceSpec, forceRemoteNodePort bool) *corev1apply.ServiceSpecApplyConfiguration
- func RemoteShadowPod(local *corev1.Pod, remote *vkv1alpha1.ShadowPod, targetNamespace string, ...) *vkv1alpha1.ShadowPod
- func RemoteTolerations(inputTolerations []corev1.Toleration) []corev1.Toleration
- func RemoteTypedLocalObjectReference(local *corev1.TypedLocalObjectReference) *corev1apply.TypedLocalObjectReferenceApplyConfiguration
- func RemoteVolumes(volumes []corev1.Volume, saSecretRetriever func() string) []corev1.Volume
- func SumContainerStats(stats []statsv1alpha1.ContainerStats, ...) *uint64
- func SumPodStats(stats []statsv1alpha1.PodStats, retriever func(statsv1alpha1.PodStats) uint64) *uint64
- type EndpointTranslator
- type KubernetesServiceIPGetter
- type PodIPTranslator
- type SASecretRetriever
Constants ¶
const ( // LiqoOriginClusterIDKey is the key of a label identifying the origin cluster of a reflected resource. LiqoOriginClusterIDKey = "virtualkubelet.liqo.io/origin" // LiqoDestinationClusterIDKey is the key of a label identifying the destination cluster of a reflected resource. LiqoDestinationClusterIDKey = "virtualkubelet.liqo.io/destination" )
const ( // PodOffloadingBackoffReason -> the reason assigned to pods rejected by the virtual kubelet before offloading has started. PodOffloadingBackoffReason = "OffloadingBackoff" // PodOffloadingAbortedReason -> the reason assigned to pods rejected by the virtual kubelet after offloading has started. PodOffloadingAbortedReason = "OffloadingAborted" // ServiceAccountVolumeName is the prefix name that will be added to volumes that mount ServiceAccount secrets. // This constant is taken from kubernetes/kubernetes (plugin/pkg/admission/serviceaccount/admission.go). ServiceAccountVolumeName = "kube-api-access-" )
const EndpointSliceManagedBy = "endpointslice.reflection.liqo.io"
EndpointSliceManagedBy -> The manager associated with the reflected EndpointSlices.
const ReflectionFieldManager = "reflection.liqo.io"
ReflectionFieldManager -> The name associated with the fields modified by virtual kubelet reflection.
const RootCAConfigMapName = "kube-root-ca.crt"
RootCAConfigMapName is the name of the configmap containing the root CA.
Variables ¶
var ( // LocalClusterID -> the cluster ID associated with the local cluster. LocalClusterID string // RemoteClusterID -> the cluster ID associated with the remote cluster. RemoteClusterID string // LiqoNodeName -> the name of the node associated with the current virtual-kubelet. LiqoNodeName string // LiqoNodeIP -> the local IP of the node associated with the current virtual-kubelet. LiqoNodeIP string // StartTime -> the instant in time the forging logic has been started. StartTime time.Time // KubernetesServicePort -> the port of the kubernetes.default service. KubernetesServicePort string )
Functions ¶
func ApplyOptions ¶ added in v0.3.1
func ApplyOptions() metav1.ApplyOptions
ApplyOptions returns the apply options configured for object reflection.
func EndpointSliceLabels ¶ added in v0.3.1
EndpointSliceLabels returns the labels assigned to the reflected EndpointSlices.
func EndpointToBeReflected ¶ added in v0.3.1
func EndpointToBeReflected(endpoint *discoveryv1beta1.Endpoint) bool
EndpointToBeReflected filters out the endpoints targeting pods already running on the remote cluster.
func FilterIngressAnnotations ¶ added in v0.5.0
FilterIngressAnnotations filters the ingress annotations to be reflected, removing the ingress class annotation.
func Init ¶ added in v0.3.2
func Init(localClusterID, remoteClusterID, nodeName, nodeIP string)
Init initializes the forging logic.
func IsEndpointSliceManagedByReflection ¶ added in v0.3.1
IsEndpointSliceManagedByReflection returns whether the EndpointSlice is managed by the reflection logic.
func IsReflected ¶ added in v0.3.1
IsReflected returns whether the current object has been reflected from the local to the remote cluster.
func LocalConfigMapName ¶ added in v0.5.0
LocalConfigMapName returns the local configmap name corresponding to a remote one, accounting for the root CA.
func LocalContainerStats ¶ added in v0.3.2
func LocalContainerStats(metrics *metricsv1beta1.ContainerMetrics, start, now metav1.Time) statsv1alpha1.ContainerStats
LocalContainerStats forges the metric stats for a container of a local pod.
func LocalContainersStats ¶ added in v0.3.2
func LocalContainersStats(metrics []metricsv1beta1.ContainerMetrics, start, now metav1.Time) []statsv1alpha1.ContainerStats
LocalContainersStats forges the metric stats for the containers of a local pod.
func LocalNodeStats ¶ added in v0.3.2
func LocalNodeStats(pods []statsv1alpha1.PodStats) *statsv1alpha1.Summary
LocalNodeStats forges the summary stats for the node managed by the virtual kubelet.
func LocalPod ¶ added in v0.3.2
LocalPod forges the object meta and status of the local pod, given the remote one.
func LocalPodOffloadedLabel ¶ added in v0.4.0
func LocalPodOffloadedLabel(local *corev1.Pod) (*corev1apply.PodApplyConfiguration, bool)
LocalPodOffloadedLabel forges the apply patch to add the appropriate label to the offloaded pod.
func LocalPodStats ¶ added in v0.3.2
func LocalPodStats(pod *corev1.Pod, metrics *metricsv1beta1.PodMetrics) statsv1alpha1.PodStats
LocalPodStats forges the metric stats for a local pod managed by the virtual kubelet.
func LocalPodStatus ¶ added in v0.3.2
func LocalPodStatus(remote *corev1.PodStatus, translator PodIPTranslator, restarts int32) corev1.PodStatus
LocalPodStatus forges the status of the local pod, given the remote one.
func LocalRejectedPod ¶ added in v0.3.2
LocalRejectedPod forges the status of a local rejected pod.
func LocalRejectedPodStatus ¶ added in v0.3.2
func LocalRejectedPodStatus(local *corev1.PodStatus, phase corev1.PodPhase, reason string) corev1.PodStatus
LocalRejectedPodStatus forges the status of the local rejected pod.
func ReflectedLabelSelector ¶ added in v0.3.1
ReflectedLabelSelector returns a label selector matching the objects reflected from the local to the remote cluster.
func ReflectionLabels ¶ added in v0.3.1
ReflectionLabels returns the labels assigned to the objects reflected from the local to the remote cluster.
func RemoteConfigMap ¶ added in v0.3.2
func RemoteConfigMap(local *corev1.ConfigMap, targetNamespace string) *corev1apply.ConfigMapApplyConfiguration
RemoteConfigMap forges the apply patch for the reflected configmap, given the local one.
func RemoteConfigMapName ¶ added in v0.5.0
RemoteConfigMapName forges the name for the reflected configmap, remapping the one of the root CA to prevent collisions.
func RemoteContainerEnvVariables ¶ added in v0.5.0
RemoteContainerEnvVariables forges the environment variables to enable offloaded containers to contact back the local API server, instead of the remote one. In addition, it also hardcodes the service account name in case it was retrieved from the pod spec, as it is not reflected remotely.
func RemoteContainers ¶ added in v0.4.0
RemoteContainers forges the containers for a reflected pod, appropriately adding the environment variables to enable the offloaded containers to contact back the local API server, instead of the remote one.
func RemoteEndpointSlice ¶ added in v0.3.1
func RemoteEndpointSlice(local *discoveryv1beta1.EndpointSlice, targetNamespace string, translator EndpointTranslator) *discoveryv1beta1apply.EndpointSliceApplyConfiguration
RemoteEndpointSlice forges the apply patch for the reflected endpointslice, given the local one.
func RemoteEndpointSliceEndpoints ¶ added in v0.3.1
func RemoteEndpointSliceEndpoints(locals []discoveryv1beta1.Endpoint, translator EndpointTranslator) []*discoveryv1beta1apply.EndpointApplyConfiguration
RemoteEndpointSliceEndpoints forges the apply patch for the endpoints of the reflected endpointslice, given the local ones.
func RemoteEndpointSlicePorts ¶ added in v0.3.1
func RemoteEndpointSlicePorts(locals []discoveryv1beta1.EndpointPort) []*discoveryv1beta1apply.EndpointPortApplyConfiguration
RemoteEndpointSlicePorts forges the apply patch for the ports of the reflected endpointslice, given the local ones.
func RemoteHostAliases ¶ added in v0.5.0
func RemoteHostAliases(aliases []corev1.HostAlias, kubernetesServiceIPRetriever KubernetesServiceIPGetter) []corev1.HostAlias
RemoteHostAliases forges the host aliases to override the IP address associated with the kubernetes.default service to enable offloaded containers to contact back the local API server, instead of the remote one.
func RemoteIngress ¶ added in v0.5.0
func RemoteIngress(local *netv1.Ingress, targetNamespace string) *netv1apply.IngressApplyConfiguration
RemoteIngress forges the apply patch for the reflected ingress, given the local one.
func RemoteIngressBackend ¶ added in v0.5.0
func RemoteIngressBackend(local *netv1.IngressBackend) *netv1apply.IngressBackendApplyConfiguration
RemoteIngressBackend forges the apply patch for the backend of the reflected ingress, given the local one.
func RemoteIngressHTTP ¶ added in v0.5.0
func RemoteIngressHTTP(local *netv1.HTTPIngressRuleValue) *netv1apply.HTTPIngressRuleValueApplyConfiguration
RemoteIngressHTTP forges the apply patch for the HTTPIngressRuleValue of the reflected ingress, given the local one.
func RemoteIngressPaths ¶ added in v0.5.0
func RemoteIngressPaths(local []netv1.HTTPIngressPath) []*netv1apply.HTTPIngressPathApplyConfiguration
RemoteIngressPaths forges the apply patch for the paths of the reflected ingress, given the local ones.
func RemoteIngressRules ¶ added in v0.5.0
func RemoteIngressRules(local []netv1.IngressRule) []*netv1apply.IngressRuleApplyConfiguration
RemoteIngressRules forges the apply patch for the rules of the reflected ingress, given the local ones.
func RemoteIngressService ¶ added in v0.5.0
func RemoteIngressService(local *netv1.IngressServiceBackend) *netv1apply.IngressServiceBackendApplyConfiguration
RemoteIngressService forges the apply patch for the service of the reflected ingress, given the local one.
func RemoteIngressSpec ¶ added in v0.5.0
func RemoteIngressSpec(local *netv1.IngressSpec) *netv1apply.IngressSpecApplyConfiguration
RemoteIngressSpec forges the apply patch for the specs of the reflected ingress, given the local one. It expects the local object to be a deepcopy, as it is mutated.
func RemoteIngressTLS ¶ added in v0.5.0
func RemoteIngressTLS(local []netv1.IngressTLS) []*netv1apply.IngressTLSApplyConfiguration
RemoteIngressTLS forges the apply patch for the TLS configs of the reflected ingress, given the local ones.
func RemoteKind ¶ added in v0.3.1
RemoteKind prepends "Remote" to a kind name, to identify remote objects.
func RemoteObjectMeta ¶ added in v0.3.2
func RemoteObjectMeta(local, remote *metav1.ObjectMeta) metav1.ObjectMeta
RemoteObjectMeta merges the remote and local ObjectMeta for a reflected object.
func RemoteObjectReference ¶ added in v0.3.1
func RemoteObjectReference(ref *corev1.ObjectReference) *corev1apply.ObjectReferenceApplyConfiguration
RemoteObjectReference forges the apply patch for a reflected RemoteObjectReference.
func RemotePodSpec ¶ added in v0.3.2
func RemotePodSpec(local, remote *corev1.PodSpec, saSecretRetriever SASecretRetriever, kubernetesServiceIPRetriever KubernetesServiceIPGetter) corev1.PodSpec
RemotePodSpec forges the specs of the reflected pod specs, given the local ones. It expects the local and remote objects to be deepcopies, as they are mutated.
func RemoteSecret ¶ added in v0.3.2
func RemoteSecret(local *corev1.Secret, targetNamespace string) *corev1apply.SecretApplyConfiguration
RemoteSecret forges the apply patch for the reflected secret, given the local one.
func RemoteService ¶ added in v0.3.1
func RemoteService(local *corev1.Service, targetNamespace string) *corev1apply.ServiceApplyConfiguration
RemoteService forges the apply patch for the reflected service, given the local one.
func RemoteServicePorts ¶ added in v0.3.1
func RemoteServicePorts(locals []corev1.ServicePort, forceRemoteNodePort bool) []*corev1apply.ServicePortApplyConfiguration
RemoteServicePorts forges the apply patch for the ports of the reflected service, given the local ones.
func RemoteServiceSpec ¶ added in v0.3.1
func RemoteServiceSpec(local *corev1.ServiceSpec, forceRemoteNodePort bool) *corev1apply.ServiceSpecApplyConfiguration
RemoteServiceSpec forges the apply patch for the specs of the reflected service, given the local ones. It expects the local object to be a deepcopy, as it is mutated.
func RemoteShadowPod ¶ added in v0.3.2
func RemoteShadowPod(local *corev1.Pod, remote *vkv1alpha1.ShadowPod, targetNamespace string, saSecretRetriever SASecretRetriever, kubernetesServiceIPRetriever KubernetesServiceIPGetter) *vkv1alpha1.ShadowPod
RemoteShadowPod forges the reflected shadowpod, given the local one.
func RemoteTolerations ¶ added in v0.3.2
func RemoteTolerations(inputTolerations []corev1.Toleration) []corev1.Toleration
RemoteTolerations forges the tolerations for a reflected pod.
func RemoteTypedLocalObjectReference ¶ added in v0.5.0
func RemoteTypedLocalObjectReference(local *corev1.TypedLocalObjectReference) *corev1apply.TypedLocalObjectReferenceApplyConfiguration
RemoteTypedLocalObjectReference forges the apply patch for a reflected TypedLocalObjectReference.
func RemoteVolumes ¶ added in v0.4.0
RemoteVolumes forges the volumes for a reflected pod, appropriately modifying the one related to the service account.
func SumContainerStats ¶ added in v0.3.2
func SumContainerStats(stats []statsv1alpha1.ContainerStats, retriever func(statsv1alpha1.ContainerStats) uint64) *uint64
SumContainerStats returns the sum of the container stats, given a metric retriever.
func SumPodStats ¶ added in v0.3.2
func SumPodStats(stats []statsv1alpha1.PodStats, retriever func(statsv1alpha1.PodStats) uint64) *uint64
SumPodStats returns the sum of the pod stats, given a metric retriever.
Types ¶
type EndpointTranslator ¶ added in v0.3.1
EndpointTranslator defines the function to translate between local and remote endpoint addresses.
type KubernetesServiceIPGetter ¶ added in v0.5.0
type KubernetesServiceIPGetter func() string
KubernetesServiceIPGetter defines the function to get the remapped IP associated with the local kubernetes.default service.
type PodIPTranslator ¶ added in v0.3.2
PodIPTranslator defines the function to translate between remote and local IP addresses.
type SASecretRetriever ¶ added in v0.5.0
SASecretRetriever defines the function to retrieve the secret associated with a given service account.