Skip to content

Commit

Permalink
reflect ingress and lb class to remote clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
aleoli authored and adamjensenbot committed Dec 19, 2023
1 parent 908a32b commit a328a04
Show file tree
Hide file tree
Showing 29 changed files with 487 additions and 76 deletions.
20 changes: 20 additions & 0 deletions apis/sharing/v1alpha1/resourceoffer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ type StorageType struct {
Default bool `json:"default,omitempty"`
}

// IngressType defines the type of ingress offered by a resource offer.
type IngressType struct {
// IngressClassName indicates the name of the ingress class.
IngressClassName string `json:"ingressClassName"`
// Default indicates whether this ingress class is the default ingress class for Liqo.
Default bool `json:"default,omitempty"`
}

// LoadBalancerType defines the type of load balancer offered by a resource offer.
type LoadBalancerType struct {
// LoadBalancerClassName indicates the name of the load balancer class.
LoadBalancerClassName string `json:"loadBalancerClassName"`
// Default indicates whether this load balancer class is the default load balancer class for Liqo.
Default bool `json:"default,omitempty"`
}

// ResourceOfferSpec defines the desired state of ResourceOffer.
type ResourceOfferSpec struct {
// ClusterID is the identifier of the cluster that is sending this ResourceOffer.
Expand All @@ -53,6 +69,10 @@ type ResourceOfferSpec struct {
WithdrawalTimestamp *metav1.Time `json:"withdrawalTimestamp,omitempty"`
// StorageClasses contains the list of the storage classes offered by the cluster.
StorageClasses []StorageType `json:"storageClasses,omitempty"`
// IngressClasses contains the list of the ingress classes offered by the cluster.
IngressClasses []IngressType `json:"ingressClasses,omitempty"`
// LoadBalancerClasses contains the list of the load balancer classes offered by the cluster.
LoadBalancerClasses []LoadBalancerType `json:"loadBalancerClasses,omitempty"`
}

// OfferPhase describes the phase of the ResourceOffer.
Expand Down
40 changes: 40 additions & 0 deletions apis/sharing/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions apis/virtualkubelet/v1alpha1/virtualnode_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ type VirtualNodeSpec struct {
Labels map[string]string `json:"labels,omitempty"`
// StorageClasses contains the list of the storage classes offered by the cluster.
StorageClasses []sharingv1alpha1.StorageType `json:"storageClasses,omitempty"`
// IngressClasses contains the list of the ingress classes offered by the cluster.
IngressClasses []sharingv1alpha1.IngressType `json:"ingressClasses,omitempty"`
// LoadBalancerClasses contains the list of the load balancer classes offered by the cluster.
LoadBalancerClasses []sharingv1alpha1.LoadBalancerType `json:"loadBalancerClasses,omitempty"`
}

// VirtualNodeConditionType represents different conditions that a virtualNode could assume.
Expand Down
10 changes: 10 additions & 0 deletions apis/virtualkubelet/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion cmd/liqo-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ func main() {
var kubeletMetricsEnabled bool
var labelsNotReflected argsutils.StringList
var annotationsNotReflected argsutils.StringList
var ingressClasses argsutils.ClassNameList
var loadBalancerClasses argsutils.ClassNameList

webhookPort := flag.Uint("webhook-port", 9443, "The port the webhook server binds to")
metricsAddr := flag.String("metrics-address", ":8080", "The address the metric endpoint binds to")
Expand Down Expand Up @@ -157,6 +159,8 @@ func main() {
offerUpdateThreshold := argsutils.Percentage{}
flag.Var(&offerUpdateThreshold, "offer-update-threshold-percentage",
"The threshold (in percentage) of resources quantity variation which triggers a ResourceOffer update")
flag.Var(&ingressClasses, "ingress-classes", "List of ingress classes offered by the cluster. Example: \"nginx;default,traefik\"")
flag.Var(&loadBalancerClasses, "load-balancer-classes", "List of load balancer classes offered by the cluster. Example:\"metallb;default\"")

// Virtual-kubelet parameters
kubeletImage := flag.String("kubelet-image", "ghcr.io/liqotech/virtual-kubelet", "The image of the virtual kubelet to be deployed")
Expand Down Expand Up @@ -412,7 +416,8 @@ func main() {
}
}
offerUpdater := resourceRequestOperator.NewOfferUpdater(ctx, mgr.GetClient(), clusterIdentity,
clusterLabels.StringMap, monitor, uint(offerUpdateThreshold.Val), *realStorageClassName, *enableStorage)
clusterLabels.StringMap, monitor, uint(offerUpdateThreshold.Val), *realStorageClassName, *enableStorage,
ingressClasses, loadBalancerClasses)
resourceRequestReconciler = &resourceRequestOperator.ResourceRequestReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Expand Down
5 changes: 5 additions & 0 deletions cmd/virtual-kubelet/root/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ func InstallFlags(flags *pflag.FlagSet, o *Opts) {
flags.BoolVar(&o.EnableStorage, "enable-storage", false, "Enable the Liqo storage reflection")
flags.StringVar(&o.VirtualStorageClassName, "virtual-storage-class-name", "liqo", "Name of the virtual storage class")
flags.StringVar(&o.RemoteRealStorageClassName, "remote-real-storage-class-name", "", "Name of the real storage class to use for the actual volumes")
flags.BoolVar(&o.EnableIngress, "enable-ingress", false, "Enable the Liqo ingress reflection")
flags.StringVar(&o.RemoteRealIngressClassName, "remote-real-ingress-class-name", "", "Name of the real ingress class to use for the actual ingress")
flags.BoolVar(&o.EnableLoadBalancer, "enable-load-balancer", false, "Enable the Liqo load balancer reflection")
flags.StringVar(&o.RemoteRealLoadBalancerClassName, "remote-real-load-balancer-class-name", "",
"Name of the real load balancer class to use for the actual load balancer")
flags.BoolVar(&o.EnableMetrics, "metrics-enabled", false, "Enable the metrics server")
flags.StringVar(&o.MetricsAddress, "metrics-address", ":8080", "The address to listen to for metrics requests")
flags.StringVar(&o.HomeAPIServerHost, "home-api-server-host", "",
Expand Down
16 changes: 10 additions & 6 deletions cmd/virtual-kubelet/root/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,16 @@ type Opts struct {
NodeExtraAnnotations argsutils.StringMap
NodeExtraLabels argsutils.StringMap

EnableAPIServerSupport bool
EnableStorage bool
VirtualStorageClassName string
RemoteRealStorageClassName string
EnableMetrics bool
MetricsAddress string
EnableAPIServerSupport bool
EnableStorage bool
VirtualStorageClassName string
RemoteRealStorageClassName string
EnableIngress bool
RemoteRealIngressClassName string
EnableLoadBalancer bool
RemoteRealLoadBalancerClassName string
EnableMetrics bool
MetricsAddress string

HomeAPIServerHost string
HomeAPIServerPort string
Expand Down
14 changes: 9 additions & 5 deletions cmd/virtual-kubelet/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,15 @@ func runRootCommand(ctx context.Context, c *Opts) error {

ReflectorsConfigs: reflectorsConfigs,

EnableAPIServerSupport: c.EnableAPIServerSupport,
EnableStorage: c.EnableStorage,
VirtualStorageClassName: c.VirtualStorageClassName,
RemoteRealStorageClassName: c.RemoteRealStorageClassName,
EnableMetrics: c.EnableMetrics,
EnableAPIServerSupport: c.EnableAPIServerSupport,
EnableStorage: c.EnableStorage,
VirtualStorageClassName: c.VirtualStorageClassName,
RemoteRealStorageClassName: c.RemoteRealStorageClassName,
EnableIngress: c.EnableIngress,
RemoteRealIngressClassName: c.RemoteRealIngressClassName,
EnableLoadBalancer: c.EnableLoadBalancer,
RemoteRealLoadBalancerClassName: c.RemoteRealLoadBalancerClassName,
EnableMetrics: c.EnableMetrics,

HomeAPIServerHost: c.HomeAPIServerHost,
HomeAPIServerPort: c.HomeAPIServerPort,
Expand Down
2 changes: 2 additions & 0 deletions deployments/liqo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,14 @@
| reflection.endpointslice.workers | int | `10` | The number of workers used for the endpointslices reflector. Set 0 to disable the reflection of endpointslices. |
| reflection.event.type | string | `"DenyList"` | The type of reflection used for the events reflector. Ammitted values: "DenyList", "AllowList". |
| reflection.event.workers | int | `3` | The number of workers used for the events reflector. Set 0 to disable the reflection of events. |
| reflection.ingress.ingressClasses | list | `[]` | List of ingress classes that will be shown to remote clusters. If empty, ingress class will be reflected as-is. Example: ingressClasses: - name: nginx default: true - name: traefik |
| reflection.ingress.type | string | `"DenyList"` | The type of reflection used for the ingresses reflector. Ammitted values: "DenyList", "AllowList". |
| reflection.ingress.workers | int | `3` | The number of workers used for the ingresses reflector. Set 0 to disable the reflection of ingresses. |
| reflection.persistentvolumeclaim.workers | int | `3` | The number of workers used for the persistentvolumeclaims reflector. Set 0 to disable the reflection of persistentvolumeclaims. |
| reflection.pod.workers | int | `10` | The number of workers used for the pods reflector. Set 0 to disable the reflection of pods. |
| reflection.secret.type | string | `"DenyList"` | The type of reflection used for the secrets reflector. Ammitted values: "DenyList", "AllowList". |
| reflection.secret.workers | int | `3` | The number of workers used for the secrets reflector. Set 0 to disable the reflection of secrets. |
| reflection.service.loadBalancerClasses | list | `[]` | List of load balancer classes that will be shown to remote clusters. If empty, load balancer classes will be reflected as-is. Example: loadBalancerClasses: - name: public default: true - name: internal |
| reflection.service.type | string | `"DenyList"` | The type of reflection used for the services reflector. Ammitted values: "DenyList", "AllowList". |
| reflection.service.workers | int | `3` | The number of workers used for the services reflector. Set 0 to disable the reflection of services. |
| reflection.serviceaccount.workers | int | `3` | The number of workers used for the serviceaccounts reflector. Set 0 to disable the reflection of serviceaccounts. |
Expand Down
38 changes: 38 additions & 0 deletions deployments/liqo/crds/sharing.liqo.io_resourceoffers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,50 @@ spec:
type: integer
type: object
type: array
ingressClasses:
description: IngressClasses contains the list of the ingress classes
offered by the cluster.
items:
description: IngressType defines the type of ingress offered by
a resource offer.
properties:
default:
description: Default indicates whether this ingress class is
the default ingress class for Liqo.
type: boolean
ingressClassName:
description: IngressClassName indicates the name of the ingress
class.
type: string
required:
- ingressClassName
type: object
type: array
labels:
additionalProperties:
type: string
description: Labels contains the label to be added to the virtual
node.
type: object
loadBalancerClasses:
description: LoadBalancerClasses contains the list of the load balancer
classes offered by the cluster.
items:
description: LoadBalancerType defines the type of load balancer
offered by a resource offer.
properties:
default:
description: Default indicates whether this load balancer class
is the default load balancer class for Liqo.
type: boolean
loadBalancerClassName:
description: LoadBalancerClassName indicates the name of the
load balancer class.
type: string
required:
- loadBalancerClassName
type: object
type: array
nodeName:
description: NodeName is the exact name that the virtual node will
have. One and only one of NodeName and NodeNamePrefix must be set.
Expand Down
38 changes: 38 additions & 0 deletions deployments/liqo/crds/virtualkubelet.liqo.io_virtualnodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,25 @@ spec:
type: integer
type: object
type: array
ingressClasses:
description: IngressClasses contains the list of the ingress classes
offered by the cluster.
items:
description: IngressType defines the type of ingress offered by
a resource offer.
properties:
default:
description: Default indicates whether this ingress class is
the default ingress class for Liqo.
type: boolean
ingressClassName:
description: IngressClassName indicates the name of the ingress
class.
type: string
required:
- ingressClassName
type: object
type: array
kubeconfigSecretRef:
description: KubeconfigSecretRef contains the reference to the secret
containing the kubeconfig to access the remote cluster.
Expand All @@ -108,6 +127,25 @@ spec:
description: Labels contains the labels to be added to the virtual
node.
type: object
loadBalancerClasses:
description: LoadBalancerClasses contains the list of the load balancer
classes offered by the cluster.
items:
description: LoadBalancerType defines the type of load balancer
offered by a resource offer.
properties:
default:
description: Default indicates whether this load balancer class
is the default load balancer class for Liqo.
type: boolean
loadBalancerClassName:
description: LoadBalancerClassName indicates the name of the
load balancer class.
type: string
required:
- loadBalancerClassName
type: object
type: array
offloadingPatch:
description: OffloadingPatch contains the information to target a
groups of node on the remote cluster.
Expand Down
15 changes: 15 additions & 0 deletions deployments/liqo/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,21 @@ Concatenates a values list into a string in the form "--commandName=val1,val2"
- {{ trimSuffix "," $res }}
{{- end -}}

{{/*
Concatenates a values list into a string in the form "--commandName=val1;default,val2"
*/}}
{{- define "liqo.concatenateListDefault" -}}
{{- $res := print .commandName "=" -}}
{{- range $val := .list -}}
{{- $res = print $res $val.name -}}
{{- if $val.default -}}
{{- $res = print $res ";default" -}}
{{- end -}}
{{- $res = print $res "," -}}
{{- end -}}
- {{ trimSuffix "," $res }}
{{- end -}}

{{/*
Get the liqo clusterID ConfigMap name
*/}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ spec:
- --real-storage-class-name={{ .Values.storage.realStorageClassName }}
- --storage-namespace={{ .Values.storage.storageNamespace }}
{{- end }}
{{- $d := dict "commandName" "--ingress-classes" "list" .Values.reflection.ingress.ingressClasses }}
{{- include "liqo.concatenateListDefault" $d | nindent 10 }}
{{- $d := dict "commandName" "--load-balancer-classes" "list" .Values.reflection.service.loadBalancerClasses }}
{{- include "liqo.concatenateListDefault" $d | nindent 10 }}
{{- if .Values.controllerManager.config.enableResourceEnforcement }}
- --enable-resource-enforcement
{{- end }}
Expand Down
14 changes: 14 additions & 0 deletions deployments/liqo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ reflection:
workers: 3
# -- The type of reflection used for the services reflector. Ammitted values: "DenyList", "AllowList".
type: DenyList
# -- List of load balancer classes that will be shown to remote clusters. If empty, load balancer classes will be reflected as-is.
# Example:
# loadBalancerClasses:
# - name: public
# default: true
# - name: internal
loadBalancerClasses: []
endpointslice:
# -- The number of workers used for the endpointslices reflector. Set 0 to disable the reflection of endpointslices.
workers: 10
Expand All @@ -73,6 +80,13 @@ reflection:
workers: 3
# -- The type of reflection used for the ingresses reflector. Ammitted values: "DenyList", "AllowList".
type: DenyList
# -- List of ingress classes that will be shown to remote clusters. If empty, ingress class will be reflected as-is.
# Example:
# ingressClasses:
# - name: nginx
# default: true
# - name: traefik
ingressClasses: []
configmap:
# -- The number of workers used for the configmaps reflector. Set 0 to disable the reflection of configmaps.
workers: 3
Expand Down

0 comments on commit a328a04

Please sign in to comment.