Skip to content

Commit

Permalink
Designate the apps.kubevirt.io/component label for KubeVirt components.
Browse files Browse the repository at this point in the history
Exposes relationship label "apps.kubevirt.io/component " to HCO via the KubeVirt CR,
set it's default value to be `kubevirt`.

Signed-off-by: Barak Mordehai <[email protected]>
  • Loading branch information
Barakmor1 committed Nov 17, 2021
1 parent debf29e commit 6b9cc63
Show file tree
Hide file tree
Showing 11 changed files with 28,559 additions and 3 deletions.
4 changes: 4 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -12548,6 +12548,10 @@
"description": "The namespace Prometheus is deployed in Defaults to openshift-monitor",
"type": "string"
},
"productComponent": {
"description": "Designate the apps.kubevirt.io/component label for KubeVirt components. Useful if KubeVirt is included as part of a product. If ProductComponent is not specified, the component label will be omitted.",
"type": "string"
},
"productName": {
"description": "Designate the apps.kubevirt.io/part-of label for KubeVirt components. Useful if KubeVirt is included as part of a product. If ProductName is not specified, the part-of label will be omitted.",
"type": "string"
Expand Down
12 changes: 12 additions & 0 deletions manifests/generated/kv-resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,12 @@ spec:
monitorNamespace:
description: The namespace Prometheus is deployed in Defaults to openshift-monitor
type: string
productComponent:
description: Designate the apps.kubevirt.io/component label for KubeVirt
components. Useful if KubeVirt is included as part of a product.
If ProductComponent is not specified, the component label will be
omitted. TODO set this label with default value kubevirt.
type: string
productName:
description: Designate the apps.kubevirt.io/part-of label for KubeVirt
components. Useful if KubeVirt is included as part of a product.
Expand Down Expand Up @@ -3255,6 +3261,12 @@ spec:
monitorNamespace:
description: The namespace Prometheus is deployed in Defaults to openshift-monitor
type: string
productComponent:
description: Designate the apps.kubevirt.io/component label for KubeVirt
components. Useful if KubeVirt is included as part of a product.
If ProductComponent is not specified, the component label will be
omitted. TODO set this label with default value kubevirt.
type: string
productName:
description: Designate the apps.kubevirt.io/part-of label for KubeVirt
components. Useful if KubeVirt is included as part of a product.
Expand Down
3 changes: 3 additions & 0 deletions pkg/virt-operator/kubevirt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2740,6 +2740,9 @@ func injectMetadata(objectMeta *metav1.ObjectMeta, config *util.KubeVirtDeployme
objectMeta.Annotations[v1.KubeVirtGenerationAnnotation] = "1"

objectMeta.Labels[v1.AppComponentLabel] = v1.AppComponent
if config.GetProductComponent() != "" {
objectMeta.Labels[v1.AppComponentLabel] = config.GetProductComponent()
}
}

func shouldExpectHCOConditions(kv *v1.KubeVirt, available k8sv1.ConditionStatus, progressing k8sv1.ConditionStatus, degraded k8sv1.ConditionStatus) {
Expand Down
4 changes: 4 additions & 0 deletions pkg/virt-operator/resource/apply/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ func injectOperatorMetadata(kv *v1.KubeVirt, objectMeta *metav1.ObjectMeta, vers
}
objectMeta.Labels[v1.AppComponentLabel] = v1.AppComponent

if kv.Spec.ProductComponent != "" && util.IsValidLabel(kv.Spec.ProductComponent) {
objectMeta.Labels[v1.AppComponentLabel] = kv.Spec.ProductComponent
}

objectMeta.Labels[v1.ManagedByLabel] = v1.ManagedByLabelOperatorValue

if objectMeta.Annotations == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,12 @@ var CRDsValidation map[string]string = map[string]string{
monitorNamespace:
description: The namespace Prometheus is deployed in Defaults to openshift-monitor
type: string
productComponent:
description: Designate the apps.kubevirt.io/component label for KubeVirt
components. Useful if KubeVirt is included as part of a product. If ProductComponent
is not specified, the component label will be omitted. TODO set this label
with default value kubevirt.
type: string
productName:
description: Designate the apps.kubevirt.io/part-of label for KubeVirt components.
Useful if KubeVirt is included as part of a product. If ProductName is
Expand Down
11 changes: 8 additions & 3 deletions pkg/virt-operator/util/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ const (
DefaultMonitorAccount = "prometheus-k8s"

// lookup keys in AdditionalProperties
ImagePrefixKey = "imagePrefix"
ProductNameKey = "productName"
ProductVersionKey = "productVersion"
ImagePrefixKey = "imagePrefix"
ProductNameKey = "productName"
ProductComponentKey = "productComponent"
ProductVersionKey = "productVersion"

// the regex used to parse the operator image
operatorImageRegex = "^(.*)/(.*)virt-operator([@:].*)?$"
Expand Down Expand Up @@ -435,6 +436,10 @@ func (c *KubeVirtDeploymentConfig) GetVerbosity() string {
return "2"
}

func (c *KubeVirtDeploymentConfig) GetProductComponent() string {
return c.AdditionalProperties[ProductComponentKey]
}

func (c *KubeVirtDeploymentConfig) GetProductName() string {
return c.AdditionalProperties[ProductNameKey]
}
Expand Down
6 changes: 6 additions & 0 deletions staging/src/kubevirt.io/api/core/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,12 @@ type KubeVirtSpec struct {
// If ProductName is not specified, the part-of label will be omitted.
ProductName string `json:"productName,omitempty"`

// Designate the apps.kubevirt.io/component label for KubeVirt components.
// Useful if KubeVirt is included as part of a product.
// If ProductComponent is not specified, the component label will be omitted.
//TODO set this label with default value kubevirt.
ProductComponent string `json:"productComponent,omitempty"`

// holds kubevirt configurations.
// same as the virt-configMap
Configuration KubeVirtConfiguration `json:"configuration,omitempty"`
Expand Down

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

7 changes: 7 additions & 0 deletions staging/src/kubevirt.io/client-go/api/openapi_generated.go

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

15 changes: 15 additions & 0 deletions staging/src/kubevirt.io/client-go/apis/core/v1/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["openapi_generated.go"],
importpath = "kubevirt.io/client-go/apis/core/v1",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//vendor/k8s.io/kube-openapi/pkg/common:go_default_library",
],
)
Loading

0 comments on commit 6b9cc63

Please sign in to comment.