Skip to content

Commit

Permalink
[release 1.11] Introduce Applications Aware Quota (#2777)
Browse files Browse the repository at this point in the history
Add the AAQ deployment and custom resource.

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
  • Loading branch information
nunnatsa authored Jan 30, 2024
1 parent d0236b9 commit a3bc1c7
Show file tree
Hide file tree
Showing 83 changed files with 17,370 additions and 102 deletions.
24 changes: 22 additions & 2 deletions api/v1beta1/hyperconverged_types.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package v1beta1

import (
openshiftconfigv1 "github.com/openshift/api/config/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

openshiftconfigv1 "github.com/openshift/api/config/v1"

v1 "kubevirt.io/api/core/v1"
aaqv1alpha1 "kubevirt.io/applications-aware-quota/staging/src/kubevirt.io/applications-aware-quota-api/pkg/apis/core/v1alpha1"
cdiv1beta1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
sdkapi "kubevirt.io/controller-lifecycle-operator-sdk/api"
)
Expand Down Expand Up @@ -227,6 +227,9 @@ type HyperConvergedSpec struct {
// Those bindings can be used when defining virtual machine interfaces.
// +optional
NetworkBinding map[string]v1.InterfaceBindingPlugin `json:"networkBinding,omitempty"`

// ApplicationAwareConfig set the AAQ configurations
ApplicationAwareConfig *ApplicationAwareConfigurations `json:"applicationAwareConfig,omitempty"`
}

// CertRotateConfigCA contains the tunables for TLS certificates.
Expand Down Expand Up @@ -718,6 +721,23 @@ type DataImportCronTemplateStatus struct {
Status DataImportCronStatus `json:"status,omitempty"`
}

// ApplicationAwareConfigurations holds the AAQ configurations
// +k8s:openapi-gen=true
type ApplicationAwareConfigurations struct {
// VmiCalcConfigName determine how resource allocation will be done with ApplicationsResourceQuota.
// allowed values are: VmiPodUsage, VirtualResources, DedicatedVirtualResources or IgnoreVmiCalculator
// +kubebuilder:validation:Enum=VmiPodUsage;VirtualResources;DedicatedVirtualResources;IgnoreVmiCalculator
// +kubebuilder:default=DedicatedVirtualResources
VmiCalcConfigName *aaqv1alpha1.VmiCalcConfigName `json:"vmiCalcConfigName,omitempty"`

// NamespaceSelector determines in which namespaces scheduling gate will be added to pods..
NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"`

// EnableClusterAppsResourceQuota if set to true, allows creation and management of ClusterAppsResourceQuota
// +kubebuilder:default=false
EnableClusterAppsResourceQuota bool `json:"enableClusterAppsResourceQuota,omitempty"`
}

const (
ConditionAvailable = "Available"

Expand Down
32 changes: 32 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

44 changes: 43 additions & 1 deletion api/v1beta1/zz_generated.openapi.go

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

3 changes: 3 additions & 0 deletions automation/release-bumper/release-bumper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function get_current_versions {
["HPPO"]=""
["HPP"]=""
["MTQ"]=""
["AAQ"]=""
["KUBEVIRT_CONSOLE_PLUGIN"]=""
["KUBEVIRT_CONSOLE_PROXY"]=""
["NODE_DRIVER_REG"]=""
Expand All @@ -100,6 +101,7 @@ function get_updated_versions {
["HPPO"]="kubevirt/hostpath-provisioner-operator"
["HPP"]="kubevirt/hostpath-provisioner"
["MTQ"]="kubevirt/managed-tenant-quota"
["AAQ"]="kubevirt/applications-aware-quota"
["KUBEVIRT_CONSOLE_PLUGIN"]="kubevirt-ui/kubevirt-plugin"
["KUBEVIRT_CONSOLE_PROXY"]="kubevirt-ui/kubevirt-apiserver-proxy"
["NODE_DRIVER_REG"]="kubernetes-csi/node-driver-registrar"
Expand All @@ -114,6 +116,7 @@ function get_updated_versions {
["NETWORK_ADDONS"]="kubevirt/cluster-network-addons-operator"
["SSP"]="kubevirt.io/ssp-operator/api"
["MTQ"]="kubevirt.io/managed-tenant-quota"
["AAQ"]="kubevirt.io/applications-aware-quota"
)

UPDATED_VERSIONS=()
Expand Down
2 changes: 2 additions & 0 deletions cmd/hyperconverged-cluster-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (

networkaddonsv1 "github.com/kubevirt/cluster-network-addons-operator/pkg/apis/networkaddonsoperator/v1"
kubevirtcorev1 "kubevirt.io/api/core/v1"
aaqv1alpha1 "kubevirt.io/applications-aware-quota/staging/src/kubevirt.io/applications-aware-quota-api/pkg/apis/core/v1alpha1"
cdiv1beta1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
mtqv1alpha1 "kubevirt.io/managed-tenant-quota/staging/src/kubevirt.io/managed-tenant-quota-api/pkg/apis/core/v1alpha1"
sspv1beta2 "kubevirt.io/ssp-operator/api/v1beta2"
Expand Down Expand Up @@ -82,6 +83,7 @@ var (
operatorsapiv2.AddToScheme,
imagev1.Install,
mtqv1alpha1.AddToScheme,
aaqv1alpha1.AddToScheme,
}
)

Expand Down
67 changes: 67 additions & 0 deletions config/crd/bases/hco.kubevirt.io_hyperconvergeds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,73 @@ spec:
disableSerialConsoleLog: true
description: HyperConvergedSpec defines the desired state of HyperConverged
properties:
applicationAwareConfig:
description: ApplicationAwareConfig set the AAQ configurations
properties:
enableClusterAppsResourceQuota:
default: false
description: EnableClusterAppsResourceQuota if set to true, allows
creation and management of ClusterAppsResourceQuota
type: boolean
namespaceSelector:
description: NamespaceSelector determines in which namespaces
scheduling gate will be added to pods..
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
items:
description: A label selector requirement is a selector
that contains values, a key, and an operator that relates
the key and values.
properties:
key:
description: key is the label key that the selector
applies to.
type: string
operator:
description: operator represents a key's relationship
to a set of values. Valid operators are In, NotIn,
Exists and DoesNotExist.
type: string
values:
description: values is an array of string values. If
the operator is In or NotIn, the values array must
be non-empty. If the operator is Exists or DoesNotExist,
the values array must be empty. This array is replaced
during a strategic merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A
single {key,value} in the matchLabels map is equivalent
to an element of matchExpressions, whose key field is "key",
the operator is "In", and the values array contains only
"value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
vmiCalcConfigName:
default: DedicatedVirtualResources
description: 'VmiCalcConfigName determine how resource allocation
will be done with ApplicationsResourceQuota. allowed values
are: VmiPodUsage, VirtualResources, DedicatedVirtualResources
or IgnoreVmiCalculator'
enum:
- VmiPodUsage
- VirtualResources
- DedicatedVirtualResources
- IgnoreVmiCalculator
type: string
type: object
certConfig:
default:
ca:
Expand Down
14 changes: 8 additions & 6 deletions controllers/commontestutils/testUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"context"
"fmt"

mtqv1alpha1 "kubevirt.io/managed-tenant-quota/staging/src/kubevirt.io/managed-tenant-quota-api/pkg/apis/core/v1alpha1"

"github.com/go-logr/logr"
. "github.com/onsi/ginkgo/v2" //nolint dot-imports
. "github.com/onsi/gomega" //nolint dot-imports
Expand All @@ -30,14 +28,17 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"

networkaddonsv1 "github.com/kubevirt/cluster-network-addons-operator/pkg/apis/networkaddonsoperator/v1"
"github.com/kubevirt/hyperconverged-cluster-operator/api"
hcov1beta1 "github.com/kubevirt/hyperconverged-cluster-operator/api/v1beta1"
"github.com/kubevirt/hyperconverged-cluster-operator/controllers/common"
"github.com/kubevirt/hyperconverged-cluster-operator/pkg/components"
kubevirtcorev1 "kubevirt.io/api/core/v1"
aaqv1alpha1 "kubevirt.io/applications-aware-quota/staging/src/kubevirt.io/applications-aware-quota-api/pkg/apis/core/v1alpha1"
cdiv1beta1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
sdkapi "kubevirt.io/controller-lifecycle-operator-sdk/api"
mtqv1alpha1 "kubevirt.io/managed-tenant-quota/staging/src/kubevirt.io/managed-tenant-quota-api/pkg/apis/core/v1alpha1"
sspv1beta2 "kubevirt.io/ssp-operator/api/v1beta2"

"github.com/kubevirt/hyperconverged-cluster-operator/api"
hcov1beta1 "github.com/kubevirt/hyperconverged-cluster-operator/api/v1beta1"
"github.com/kubevirt/hyperconverged-cluster-operator/controllers/common"
"github.com/kubevirt/hyperconverged-cluster-operator/pkg/components"
)

// Name and Namespace of our primary resource
Expand Down Expand Up @@ -163,6 +164,7 @@ func GetScheme() *runtime.Scheme {
openshiftconfigv1.Install,
mtqv1alpha1.AddToScheme,
csvv1alpha1.AddToScheme,
aaqv1alpha1.AddToScheme,
} {
Expect(f(testScheme)).ToNot(HaveOccurred())
}
Expand Down
2 changes: 2 additions & 0 deletions controllers/hyperconverged/hyperconverged_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
hcoutil "github.com/kubevirt/hyperconverged-cluster-operator/pkg/util"
"github.com/kubevirt/hyperconverged-cluster-operator/version"
kubevirtcorev1 "kubevirt.io/api/core/v1"
aaqv1alpha1 "kubevirt.io/applications-aware-quota/staging/src/kubevirt.io/applications-aware-quota-api/pkg/apis/core/v1alpha1"
cdiv1beta1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
mtqv1alpha1 "kubevirt.io/managed-tenant-quota/staging/src/kubevirt.io/managed-tenant-quota-api/pkg/apis/core/v1alpha1"
sspv1beta2 "kubevirt.io/ssp-operator/api/v1beta2"
Expand Down Expand Up @@ -180,6 +181,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler, ci hcoutil.ClusterInfo) er
&cdiv1beta1.CDI{},
&networkaddonsv1.NetworkAddonsConfig{},
&mtqv1alpha1.MTQ{},
&aaqv1alpha1.AAQ{},
&schedulingv1.PriorityClass{},
&corev1.ConfigMap{},
&corev1.Service{},
Expand Down
18 changes: 16 additions & 2 deletions controllers/hyperconverged/hyperconverged_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ var _ = Describe("HyperconvergedController", func() {
EnableManagedTenantQuota: ptr.To(true),
}

hco.Spec.ApplicationAwareConfig = &hcov1beta1.ApplicationAwareConfigurations{}

ci := hcoutil.GetClusterInfo()
cl := commontestutils.InitClient([]client.Object{hcoNamespace, hco, ci.GetCSV()})
monitoringReconciler := alerts.NewMonitoringReconciler(ci, cl, commontestutils.NewEventEmitterMock(), commontestutils.GetScheme())
Expand Down Expand Up @@ -332,14 +334,24 @@ var _ = Describe("HyperconvergedController", func() {
foundResource),
).ToNot(HaveOccurred())
// Check conditions
Expect(foundResource.Status.RelatedObjects).To(HaveLen(23))

Expect(foundResource.Status.RelatedObjects).To(HaveLen(24))

expectedRef := corev1.ObjectReference{
Kind: "MTQ",
Name: "mtq-kubevirt-hyperconverged",
APIVersion: "mtq.kubevirt.io/v1alpha1",
ResourceVersion: "1",
}
Expect(foundResource.Status.RelatedObjects).To(ContainElement(expectedRef))

expectedRef = corev1.ObjectReference{
Kind: "AAQ",
Name: "aaq-kubevirt-hyperconverged",
APIVersion: "aaq.kubevirt.io/v1alpha1",
ResourceVersion: "1",
}
Expect(foundResource.Status.RelatedObjects).To(ContainElement(expectedRef))
})

It("should find all managed resources", func() {
Expand Down Expand Up @@ -1360,8 +1372,10 @@ var _ = Describe("HyperconvergedController", func() {
_ = os.Setenv(hcoutil.SspVersionEnvV, newComponentVersion)
expected.ssp.Status.ObservedVersion = newComponentVersion

expected.hco.Status.Conditions = origConditions
_ = os.Setenv(hcoutil.MtqVersionEnvV, newComponentVersion)
_ = os.Setenv(hcoutil.AaqVersionEnvV, newComponentVersion)

expected.hco.Status.Conditions = origConditions
})

It("Should update OperatorCondition Upgradeable to False", func() {
Expand Down
Loading

0 comments on commit a3bc1c7

Please sign in to comment.