You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2020/07/02 06:50:02 UTC
[camel-k] branch master updated (a393c1e -> e32c617)
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git.
from a393c1e doc: Complete the monitoring documentation
new 83d8470 feat: Integration scale sub-resource works with HPA
new e32c617 chore: Declare an integration label constant
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
addons/master/master.go | 2 +-
addons/threescale/3scale_test.go | 2 +-
deploy/crd-integration.yaml | 3 +++
.../1.1.0-snapshot/integrations.camel.apache.org.crd.yaml | 3 +++
deploy/resources.go | 4 ++--
e2e/support/test_support.go | 2 +-
helm/camel-k/crds/crd-integration.yaml | 3 +++
pkg/apis/camel/v1/integration_types.go | 3 ++-
pkg/apis/camel/v1/integration_types_support.go | 2 ++
pkg/controller/integration/integration_controller.go | 2 +-
pkg/controller/integration/monitor.go | 8 ++++++--
pkg/trait/affinity.go | 4 ++--
pkg/trait/affinity_test.go | 4 ++--
pkg/trait/cron.go | 2 +-
pkg/trait/deployment.go | 6 +++---
pkg/trait/deployment_test.go | 2 +-
pkg/trait/gc.go | 4 ++--
pkg/trait/ingress_test.go | 4 ++--
pkg/trait/knative_service.go | 2 +-
pkg/trait/openapi.go | 2 +-
pkg/trait/prometheus.go | 6 +++---
pkg/trait/prometheus_test.go | 8 ++++----
pkg/trait/route.go | 2 +-
pkg/trait/route_test.go | 4 ++--
pkg/trait/service.go | 4 ++--
pkg/trait/trait_types.go | 6 +++---
pkg/util/kubernetes/collection.go | 6 +++---
pkg/util/kubernetes/conditions.go | 2 +-
pkg/util/kubernetes/log/util.go | 2 +-
29 files changed, 60 insertions(+), 44 deletions(-)
[camel-k] 01/02: feat: Integration scale sub-resource works with HPA
Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 83d84704f370fcaf424bdff923e26479d4ebf775
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Wed Jul 1 17:24:39 2020 +0200
feat: Integration scale sub-resource works with HPA
---
deploy/crd-integration.yaml | 3 +++
.../1.1.0-snapshot/integrations.camel.apache.org.crd.yaml | 3 +++
deploy/resources.go | 4 ++--
helm/camel-k/crds/crd-integration.yaml | 3 +++
pkg/apis/camel/v1/integration_types.go | 3 ++-
pkg/controller/integration/monitor.go | 6 +++++-
6 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/deploy/crd-integration.yaml b/deploy/crd-integration.yaml
index 18d0e57..0366bde 100644
--- a/deploy/crd-integration.yaml
+++ b/deploy/crd-integration.yaml
@@ -46,6 +46,7 @@ spec:
scope: Namespaced
subresources:
scale:
+ labelSelectorPath: .status.selector
specReplicasPath: .spec.replicas
statusReplicasPath: .status.replicas
status: {}
@@ -323,6 +324,8 @@ spec:
type: string
runtimeVersion:
type: string
+ selector:
+ type: string
version:
type: string
type: object
diff --git a/deploy/olm-catalog/camel-k-dev/1.1.0-snapshot/integrations.camel.apache.org.crd.yaml b/deploy/olm-catalog/camel-k-dev/1.1.0-snapshot/integrations.camel.apache.org.crd.yaml
index 18d0e57..0366bde 100644
--- a/deploy/olm-catalog/camel-k-dev/1.1.0-snapshot/integrations.camel.apache.org.crd.yaml
+++ b/deploy/olm-catalog/camel-k-dev/1.1.0-snapshot/integrations.camel.apache.org.crd.yaml
@@ -46,6 +46,7 @@ spec:
scope: Namespaced
subresources:
scale:
+ labelSelectorPath: .status.selector
specReplicasPath: .spec.replicas
statusReplicasPath: .status.replicas
status: {}
@@ -323,6 +324,8 @@ spec:
type: string
runtimeVersion:
type: string
+ selector:
+ type: string
version:
type: string
type: object
diff --git a/deploy/resources.go b/deploy/resources.go
index 8909f03..573461f 100644
--- a/deploy/resources.go
+++ b/deploy/resources.go
@@ -140,9 +140,9 @@ var assets = func() http.FileSystem {
"/crd-integration.yaml": &vfsgen۰CompressedFileInfo{
name: "crd-integration.yaml",
modTime: time.Time{},
- uncompressedSize: 11558,
+ uncompressedSize: 11649,
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x5a\x4f\x73\xe2\x38\x16\xbf\xfb\x53\xbc\x0a\x87\x9e\xa9\x0a\xb0\x3d\x73\xd9\x62\x4f\x2c\x9d\xd4\xb2\x9d\x26\x29\xa0\x67\xaa\x8f\xc2\x7e\x18\x6d\x64\x49\x2b\xc9\x90\xec\xd6\x7e\xf7\xad\x27\xd9\xc6\x06\x9b\x10\xd2\x5d\x53\x35\x15\xdf\xb0\xa4\xf7\xe7\xf7\xfe\xea\x99\x1e\xf4\xbf\xdf\x13\xf5\xe0\x8e\xc7\x28\x2d\x26\xe0\x14\xb8\x0d\xc2\x58\xb3\x78\x83\xb0\x50\x6b\xb7\x63\x06\xe1\x56\xe5\x32\x61\x8e\x2b\x09\x3f\x8d\x17\x [...]
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x1a\x4d\x6f\xe3\xb8\xf5\xae\x5f\xf1\x10\x1f\x66\x17\x88\xed\xce\xee\xa5\x70\x4f\xae\x27\x41\xdd\xc9\x38\x81\xe5\xd9\xc5\x1c\x69\xe9\x59\x66\x43\x91\x2a\x49\xd9\x49\x8b\xfe\xf7\xe2\x91\x92\x2c\xc9\x92\xe3\x38\x33\x58\x60\x11\xdd\x2c\xbe\xef\x6f\x3e\x79\x00\xc3\xef\xf7\x04\x03\xb8\xe3\x11\x4a\x83\x31\x58\x05\x76\x8b\x30\xcd\x58\xb4\x45\x08\xd5\xc6\xee\x99\x46\xb8\x55\xb9\x8c\x99\xe5\x4a\xc2\x4f\xd3\xf0\xf6\x67\xc8\x [...]
},
"/operator-deployment.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-deployment.yaml",
diff --git a/helm/camel-k/crds/crd-integration.yaml b/helm/camel-k/crds/crd-integration.yaml
index 18d0e57..0366bde 100644
--- a/helm/camel-k/crds/crd-integration.yaml
+++ b/helm/camel-k/crds/crd-integration.yaml
@@ -46,6 +46,7 @@ spec:
scope: Namespaced
subresources:
scale:
+ labelSelectorPath: .status.selector
specReplicasPath: .spec.replicas
statusReplicasPath: .status.replicas
status: {}
@@ -323,6 +324,8 @@ spec:
type: string
runtimeVersion:
type: string
+ selector:
+ type: string
version:
type: string
type: object
diff --git a/pkg/apis/camel/v1/integration_types.go b/pkg/apis/camel/v1/integration_types.go
index d32acba..9596eb2 100644
--- a/pkg/apis/camel/v1/integration_types.go
+++ b/pkg/apis/camel/v1/integration_types.go
@@ -57,6 +57,7 @@ type IntegrationStatus struct {
Conditions []IntegrationCondition `json:"conditions,omitempty"`
Version string `json:"version,omitempty"`
Replicas *int32 `json:"replicas,omitempty"`
+ Selector string `json:"selector,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
}
@@ -65,7 +66,7 @@ type IntegrationStatus struct {
// +genclient
// +kubebuilder:resource:path=integrations,scope=Namespaced,shortName=it
// +kubebuilder:subresource:status
-// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas
+// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector
// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phase`,description="The integration phase"
// +kubebuilder:printcolumn:name="Kit",type=string,JSONPath=`.status.kit`,description="The integration kit"
// +kubebuilder:printcolumn:name="Replicas",type=integer,JSONPath=`.status.replicas`,description="The number of pods"
diff --git a/pkg/controller/integration/monitor.go b/pkg/controller/integration/monitor.go
index 4cea23e..d350614 100644
--- a/pkg/controller/integration/monitor.go
+++ b/pkg/controller/integration/monitor.go
@@ -58,7 +58,7 @@ func (action *monitorAction) Handle(ctx context.Context, integration *v1.Integra
integration.Status.Digest = hash
integration.Status.Phase = v1.IntegrationPhaseInitialization
- if integration.Spec.Profile != v1.TraitProfile("") {
+ if integration.Spec.Profile != "" {
integration.Status.Profile = integration.Spec.Profile
}
integration.Status.Version = defaults.Version
@@ -72,6 +72,10 @@ func (action *monitorAction) Handle(ctx context.Context, integration *v1.Integra
return nil, err
}
+ // Enforce the scale sub-resource label selector
+ // It is used by the HPA that queries the scale sub-resource endpoint to list the pods owned by the integration
+ integration.Status.Selector = "camel.apache.org/integration=" + integration.Name
+
// Check replicas
replicaSets := &appsv1.ReplicaSetList{}
err = action.client.List(ctx, replicaSets,
[camel-k] 02/02: chore: Declare an integration label constant
Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit e32c61722cf9a4b0af18738cfe393ac3f9e2ff32
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Wed Jul 1 17:59:29 2020 +0200
chore: Declare an integration label constant
---
addons/master/master.go | 2 +-
addons/threescale/3scale_test.go | 2 +-
e2e/support/test_support.go | 2 +-
pkg/apis/camel/v1/integration_types_support.go | 2 ++
pkg/controller/integration/integration_controller.go | 2 +-
pkg/controller/integration/monitor.go | 4 ++--
pkg/trait/affinity.go | 4 ++--
pkg/trait/affinity_test.go | 4 ++--
pkg/trait/cron.go | 2 +-
pkg/trait/deployment.go | 6 +++---
pkg/trait/deployment_test.go | 2 +-
pkg/trait/gc.go | 4 ++--
pkg/trait/ingress_test.go | 4 ++--
pkg/trait/knative_service.go | 2 +-
pkg/trait/openapi.go | 2 +-
pkg/trait/prometheus.go | 6 +++---
pkg/trait/prometheus_test.go | 8 ++++----
pkg/trait/route.go | 2 +-
pkg/trait/route_test.go | 4 ++--
pkg/trait/service.go | 4 ++--
pkg/trait/trait_types.go | 6 +++---
pkg/util/kubernetes/collection.go | 6 +++---
pkg/util/kubernetes/conditions.go | 2 +-
pkg/util/kubernetes/log/util.go | 2 +-
24 files changed, 43 insertions(+), 41 deletions(-)
diff --git a/addons/master/master.go b/addons/master/master.go
index a88d90c..e9ca949 100644
--- a/addons/master/master.go
+++ b/addons/master/master.go
@@ -109,7 +109,7 @@ func (t *masterTrait) Configure(e *trait.Environment) (bool, error) {
}
if t.LabelKey == nil {
- val := "camel.apache.org/integration"
+ val := v1.IntegrationLabel
t.LabelKey = &val
}
diff --git a/addons/threescale/3scale_test.go b/addons/threescale/3scale_test.go
index ccdd126..149a4e8 100644
--- a/addons/threescale/3scale_test.go
+++ b/addons/threescale/3scale_test.go
@@ -95,7 +95,7 @@ func createEnvironment(t *testing.T) (*corev1.Service, *trait.Environment) {
svc := corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
- "camel.apache.org/integration": "test",
+ v1.IntegrationLabel: "test",
},
},
}
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 6454bd0..6f76aba 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -257,7 +257,7 @@ func IntegrationPod(ns string, name string) func() *corev1.Pod {
err := TestClient.List(TestContext, &lst,
k8sclient.InNamespace(ns),
k8sclient.MatchingLabels{
- "camel.apache.org/integration": name,
+ v1.IntegrationLabel: name,
})
if err != nil {
panic(err)
diff --git a/pkg/apis/camel/v1/integration_types_support.go b/pkg/apis/camel/v1/integration_types_support.go
index d16394c..dd848f0 100644
--- a/pkg/apis/camel/v1/integration_types_support.go
+++ b/pkg/apis/camel/v1/integration_types_support.go
@@ -25,6 +25,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
+const IntegrationLabel = "camel.apache.org/integration"
+
// NewIntegration --
func NewIntegration(namespace string, name string) Integration {
return Integration{
diff --git a/pkg/controller/integration/integration_controller.go b/pkg/controller/integration/integration_controller.go
index 96f4e1e..8170a37 100644
--- a/pkg/controller/integration/integration_controller.go
+++ b/pkg/controller/integration/integration_controller.go
@@ -175,7 +175,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
var requests []reconcile.Request
labels := rs.GetLabels()
- integrationName, ok := labels["camel.apache.org/integration"]
+ integrationName, ok := labels[v1.IntegrationLabel]
if ok {
requests = append(requests, reconcile.Request{
NamespacedName: types.NamespacedName{
diff --git a/pkg/controller/integration/monitor.go b/pkg/controller/integration/monitor.go
index d350614..2b55f59 100644
--- a/pkg/controller/integration/monitor.go
+++ b/pkg/controller/integration/monitor.go
@@ -74,14 +74,14 @@ func (action *monitorAction) Handle(ctx context.Context, integration *v1.Integra
// Enforce the scale sub-resource label selector
// It is used by the HPA that queries the scale sub-resource endpoint to list the pods owned by the integration
- integration.Status.Selector = "camel.apache.org/integration=" + integration.Name
+ integration.Status.Selector = v1.IntegrationLabel + "=" + integration.Name
// Check replicas
replicaSets := &appsv1.ReplicaSetList{}
err = action.client.List(ctx, replicaSets,
k8sclient.InNamespace(integration.Namespace),
k8sclient.MatchingLabels{
- "camel.apache.org/integration": integration.Name,
+ v1.IntegrationLabel: integration.Name,
})
if err != nil {
return nil, err
diff --git a/pkg/trait/affinity.go b/pkg/trait/affinity.go
index 3ab91b3..5c65a4a 100644
--- a/pkg/trait/affinity.go
+++ b/pkg/trait/affinity.go
@@ -162,7 +162,7 @@ func (t *affinityTrait) addPodAffinity(e *Environment, deployment *appsv1.Deploy
if t.PodAffinity {
labelSelectorRequirements = append(labelSelectorRequirements, metav1.LabelSelectorRequirement{
- Key: "camel.apache.org/integration",
+ Key: v1.IntegrationLabel,
Operator: metav1.LabelSelectorOpIn,
Values: []string{
e.Integration.Name,
@@ -218,7 +218,7 @@ func (t *affinityTrait) addPodAntiAffinity(e *Environment, deployment *appsv1.De
if t.PodAntiAffinity {
labelSelectorRequirements = append(labelSelectorRequirements, metav1.LabelSelectorRequirement{
- Key: "camel.apache.org/integration",
+ Key: v1.IntegrationLabel,
Operator: metav1.LabelSelectorOpIn,
Values: []string{
e.Integration.Name,
diff --git a/pkg/trait/affinity_test.go b/pkg/trait/affinity_test.go
index 506b2f3..18dcf7f 100644
--- a/pkg/trait/affinity_test.go
+++ b/pkg/trait/affinity_test.go
@@ -98,7 +98,7 @@ func TestApplyPodAntiAffinityLabelsDoesSucceed(t *testing.T) {
assert.ElementsMatch(t, [1]string{"value"}, userRequirement.Values)
assert.NotNil(t, podAntiAffinity.RequiredDuringSchedulingIgnoredDuringExecution[0].LabelSelector.MatchExpressions[1])
integrationRequirement := podAntiAffinity.RequiredDuringSchedulingIgnoredDuringExecution[0].LabelSelector.MatchExpressions[1]
- assert.Equal(t, "camel.apache.org/integration", integrationRequirement.Key)
+ assert.Equal(t, v1.IntegrationLabel, integrationRequirement.Key)
assert.Equal(t, metav1.LabelSelectorOpIn, integrationRequirement.Operator)
assert.ElementsMatch(t, [1]string{"integration-name"}, integrationRequirement.Values)
}
@@ -119,7 +119,7 @@ func TestApplyPodAffinityLabelsDoesSucceed(t *testing.T) {
assert.Equal(t, metav1.LabelSelectorOpDoesNotExist, userRequirement.Operator)
assert.NotNil(t, podAffinity.RequiredDuringSchedulingIgnoredDuringExecution[0].LabelSelector.MatchExpressions[1])
integrationRequirement := podAffinity.RequiredDuringSchedulingIgnoredDuringExecution[0].LabelSelector.MatchExpressions[1]
- assert.Equal(t, "camel.apache.org/integration", integrationRequirement.Key)
+ assert.Equal(t, v1.IntegrationLabel, integrationRequirement.Key)
assert.Equal(t, metav1.LabelSelectorOpIn, integrationRequirement.Operator)
assert.ElementsMatch(t, [1]string{"integration-name"}, integrationRequirement.Values)
}
diff --git a/pkg/trait/cron.go b/pkg/trait/cron.go
index 3f740b1..fd7f264 100644
--- a/pkg/trait/cron.go
+++ b/pkg/trait/cron.go
@@ -258,7 +258,7 @@ func (t *cronTrait) Apply(e *Environment) error {
func (t *cronTrait) getCronJobFor(e *Environment) *v1beta1.CronJob {
labels := map[string]string{
- "camel.apache.org/integration": e.Integration.Name,
+ v1.IntegrationLabel: e.Integration.Name,
}
annotations := make(map[string]string)
diff --git a/pkg/trait/deployment.go b/pkg/trait/deployment.go
index a56ec06..f7a048b 100644
--- a/pkg/trait/deployment.go
+++ b/pkg/trait/deployment.go
@@ -155,7 +155,7 @@ func (t *deploymentTrait) getDeploymentFor(e *Environment) *appsv1.Deployment {
Name: e.Integration.Name,
Namespace: e.Integration.Namespace,
Labels: map[string]string{
- "camel.apache.org/integration": e.Integration.Name,
+ v1.IntegrationLabel: e.Integration.Name,
},
Annotations: annotations,
},
@@ -163,13 +163,13 @@ func (t *deploymentTrait) getDeploymentFor(e *Environment) *appsv1.Deployment {
Replicas: e.Integration.Spec.Replicas,
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
- "camel.apache.org/integration": e.Integration.Name,
+ v1.IntegrationLabel: e.Integration.Name,
},
},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
- "camel.apache.org/integration": e.Integration.Name,
+ v1.IntegrationLabel: e.Integration.Name,
},
Annotations: annotations,
},
diff --git a/pkg/trait/deployment_test.go b/pkg/trait/deployment_test.go
index 9798e72..2d5a838 100644
--- a/pkg/trait/deployment_test.go
+++ b/pkg/trait/deployment_test.go
@@ -152,7 +152,7 @@ func createNominalDeploymentTest() (*deploymentTrait, *Environment) {
Name: "integration-name",
Namespace: "namespace",
Labels: map[string]string{
- "camel.apache.org/integration": "integration-name",
+ v1.IntegrationLabel: "integration-name",
},
},
Spec: appsv1.DeploymentSpec{
diff --git a/pkg/trait/gc.go b/pkg/trait/gc.go
index 5823b13..bcd3e43 100644
--- a/pkg/trait/gc.go
+++ b/pkg/trait/gc.go
@@ -114,7 +114,7 @@ func (t *garbageCollectorTrait) Apply(e *Environment) error {
// Label the resource with the current integration generation
labels["camel.apache.org/generation"] = generation
// Make sure the integration label is set
- labels["camel.apache.org/integration"] = env.Integration.Name
+ labels[v1.IntegrationLabel] = env.Integration.Name
resource.SetLabels(labels)
})
return nil
@@ -125,7 +125,7 @@ func (t *garbageCollectorTrait) Apply(e *Environment) error {
}
func (t *garbageCollectorTrait) garbageCollectResources(e *Environment) {
- integration, _ := labels.NewRequirement("camel.apache.org/integration", selection.Equals, []string{e.Integration.Name})
+ integration, _ := labels.NewRequirement(v1.IntegrationLabel, selection.Equals, []string{e.Integration.Name})
generation, err := labels.NewRequirement("camel.apache.org/generation", selection.LessThan, []string{strconv.FormatInt(e.Integration.GetGeneration(), 10)})
if err != nil {
t.L.ForIntegration(e.Integration).Errorf(err, "cannot determine generation requirement")
diff --git a/pkg/trait/ingress_test.go b/pkg/trait/ingress_test.go
index 390efac..4536d02 100644
--- a/pkg/trait/ingress_test.go
+++ b/pkg/trait/ingress_test.go
@@ -181,14 +181,14 @@ func createNominalIngressTest() (*ingressTrait, *Environment) {
Name: "service-name",
Namespace: "namespace",
Labels: map[string]string{
- "camel.apache.org/integration": "integration-name",
+ v1.IntegrationLabel: "integration-name",
"camel.apache.org/service.type": v1.ServiceTypeUser,
},
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{},
Selector: map[string]string{
- "camel.apache.org/integration": "integration-name",
+ v1.IntegrationLabel: "integration-name",
},
},
},
diff --git a/pkg/trait/knative_service.go b/pkg/trait/knative_service.go
index bea1513..ed84f5d 100644
--- a/pkg/trait/knative_service.go
+++ b/pkg/trait/knative_service.go
@@ -262,7 +262,7 @@ func (t *knativeServiceTrait) ControllerStrategySelectorOrder() int {
func (t *knativeServiceTrait) getServiceFor(e *Environment) *serving.Service {
labels := map[string]string{
- "camel.apache.org/integration": e.Integration.Name,
+ v1.IntegrationLabel: e.Integration.Name,
}
annotations := make(map[string]string)
diff --git a/pkg/trait/openapi.go b/pkg/trait/openapi.go
index 43895d4..99d94bc 100644
--- a/pkg/trait/openapi.go
+++ b/pkg/trait/openapi.go
@@ -257,7 +257,7 @@ func (t *openAPITrait) createNewOpenAPIConfigMap(e *Environment, resource v1.Res
Name: generatedContentName,
Namespace: e.Integration.Namespace,
Labels: map[string]string{
- "camel.apache.org/integration": e.Integration.Name,
+ v1.IntegrationLabel: e.Integration.Name,
},
Annotations: map[string]string{
"camel.apache.org/source.language": string(v1.LanguageXML),
diff --git a/pkg/trait/prometheus.go b/pkg/trait/prometheus.go
index cffb4f4..ecee2a2 100644
--- a/pkg/trait/prometheus.go
+++ b/pkg/trait/prometheus.go
@@ -222,7 +222,7 @@ func (t *prometheusTrait) getServiceMonitorFor(e *Environment) (*monitoringv1.Se
if err != nil {
return nil, err
}
- labels["camel.apache.org/integration"] = e.Integration.Name
+ labels[v1.IntegrationLabel] = e.Integration.Name
smt := monitoringv1.ServiceMonitor{
TypeMeta: metav1.TypeMeta{
@@ -237,7 +237,7 @@ func (t *prometheusTrait) getServiceMonitorFor(e *Environment) (*monitoringv1.Se
Spec: monitoringv1.ServiceMonitorSpec{
Selector: metav1.LabelSelector{
MatchLabels: map[string]string{
- "camel.apache.org/integration": e.Integration.Name,
+ v1.IntegrationLabel: e.Integration.Name,
},
},
Endpoints: []monitoringv1.Endpoint{
@@ -266,7 +266,7 @@ func (t *prometheusTrait) getJmxExporterConfigMapOrAdd(e *Environment) string {
Name: defaultName,
Namespace: e.Integration.Namespace,
Labels: map[string]string{
- "camel.apache.org/integration": e.Integration.Name,
+ v1.IntegrationLabel: e.Integration.Name,
},
},
Data: map[string]string{
diff --git a/pkg/trait/prometheus_test.go b/pkg/trait/prometheus_test.go
index 6eb6db5..6fb6e92 100644
--- a/pkg/trait/prometheus_test.go
+++ b/pkg/trait/prometheus_test.go
@@ -128,14 +128,14 @@ func TestApplyPrometheusTraitWithServiceDoesSucceed(t *testing.T) {
Name: "service-name",
Namespace: "namespace",
Labels: map[string]string{
- "camel.apache.org/integration": "integration-name",
+ v1.IntegrationLabel: "integration-name",
"camel.apache.org/service.type": v1.ServiceTypeUser,
},
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{},
Selector: map[string]string{
- "camel.apache.org/integration": "integration-name",
+ v1.IntegrationLabel: "integration-name",
},
},
})
@@ -162,8 +162,8 @@ func TestPrometheusTraitGetServiceMonitor(t *testing.T) {
assert.Equal(t, "monitoring.coreos.com/v1", serviceMonitor.APIVersion)
assert.Equal(t, "integration-name", serviceMonitor.Name)
assert.Equal(t, "integration-namespace", serviceMonitor.Namespace)
- assert.Equal(t, "integration-name", serviceMonitor.Labels["camel.apache.org/integration"])
- assert.Equal(t, "integration-name", serviceMonitor.Spec.Selector.MatchLabels["camel.apache.org/integration"])
+ assert.Equal(t, "integration-name", serviceMonitor.Labels[v1.IntegrationLabel])
+ assert.Equal(t, "integration-name", serviceMonitor.Spec.Selector.MatchLabels[v1.IntegrationLabel])
assert.Len(t, serviceMonitor.Spec.Endpoints, 1)
assert.Equal(t, "prometheus", serviceMonitor.Spec.Endpoints[0].Port)
}
diff --git a/pkg/trait/route.go b/pkg/trait/route.go
index 7a866b5..9962823 100644
--- a/pkg/trait/route.go
+++ b/pkg/trait/route.go
@@ -127,7 +127,7 @@ func (t *routeTrait) Apply(e *Environment) error {
Name: t.service.Name,
Namespace: t.service.Namespace,
Labels: map[string]string{
- "camel.apache.org/integration": e.Integration.Name,
+ v1.IntegrationLabel: e.Integration.Name,
},
},
Spec: routev1.RouteSpec{
diff --git a/pkg/trait/route_test.go b/pkg/trait/route_test.go
index bba96d2..71fb0d6 100644
--- a/pkg/trait/route_test.go
+++ b/pkg/trait/route_test.go
@@ -77,14 +77,14 @@ func createTestRouteEnvironment(t *testing.T, name string) *Environment {
Name: name,
Namespace: "test-ns",
Labels: map[string]string{
- "camel.apache.org/integration": name,
+ v1.IntegrationLabel: name,
"camel.apache.org/service.type": v1.ServiceTypeUser,
},
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{},
Selector: map[string]string{
- "camel.apache.org/integration": name,
+ v1.IntegrationLabel: name,
},
},
},
diff --git a/pkg/trait/service.go b/pkg/trait/service.go
index 8f31e3d..30e3cf8 100644
--- a/pkg/trait/service.go
+++ b/pkg/trait/service.go
@@ -135,13 +135,13 @@ func getServiceFor(e *Environment) *corev1.Service {
Name: e.Integration.Name,
Namespace: e.Integration.Namespace,
Labels: map[string]string{
- "camel.apache.org/integration": e.Integration.Name,
+ v1.IntegrationLabel: e.Integration.Name,
},
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{},
Selector: map[string]string{
- "camel.apache.org/integration": e.Integration.Name,
+ v1.IntegrationLabel: e.Integration.Name,
},
},
}
diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go
index 6352c7a..eeeedd5 100644
--- a/pkg/trait/trait_types.go
+++ b/pkg/trait/trait_types.go
@@ -355,7 +355,7 @@ func (e *Environment) ComputeApplicationProperties() *corev1.ConfigMap {
Name: e.Integration.Name + "-application-properties",
Namespace: e.Integration.Namespace,
Labels: map[string]string{
- "camel.apache.org/integration": e.Integration.Name,
+ v1.IntegrationLabel: e.Integration.Name,
"camel.apache.org/properties.type": "application",
},
},
@@ -393,7 +393,7 @@ func (e *Environment) ComputeConfigMaps() []runtime.Object {
Name: e.Integration.Name + "-user-properties",
Namespace: e.Integration.Namespace,
Labels: map[string]string{
- "camel.apache.org/integration": e.Integration.Name,
+ v1.IntegrationLabel: e.Integration.Name,
"camel.apache.org/properties.type": "user",
},
},
@@ -418,7 +418,7 @@ func (e *Environment) ComputeConfigMaps() []runtime.Object {
Name: fmt.Sprintf("%s-source-%03d", e.Integration.Name, i),
Namespace: e.Integration.Namespace,
Labels: map[string]string{
- "camel.apache.org/integration": e.Integration.Name,
+ v1.IntegrationLabel: e.Integration.Name,
},
Annotations: map[string]string{
"camel.apache.org/source.language": string(s.InferLanguage()),
diff --git a/pkg/util/kubernetes/collection.go b/pkg/util/kubernetes/collection.go
index d4b6140..bbfb5d2 100644
--- a/pkg/util/kubernetes/collection.go
+++ b/pkg/util/kubernetes/collection.go
@@ -124,7 +124,7 @@ func (c *Collection) GetDeploymentForIntegration(integration *v1.Integration) *a
}
return c.GetDeployment(func(d *appsv1.Deployment) bool {
- return d.ObjectMeta.Labels["camel.apache.org/integration"] == integration.Name
+ return d.ObjectMeta.Labels[v1.IntegrationLabel] == integration.Name
})
}
@@ -208,7 +208,7 @@ func (c *Collection) GetUserServiceForIntegration(integration *v1.Integration) *
}
return c.GetService(func(s *corev1.Service) bool {
return s.ObjectMeta.Labels != nil &&
- s.ObjectMeta.Labels["camel.apache.org/integration"] == integration.Name &&
+ s.ObjectMeta.Labels[v1.IntegrationLabel] == integration.Name &&
s.ObjectMeta.Labels["camel.apache.org/service.type"] == v1.ServiceTypeUser
})
}
@@ -219,7 +219,7 @@ func (c *Collection) GetServiceForIntegration(integration *v1.Integration) *core
return nil
}
return c.GetService(func(s *corev1.Service) bool {
- return s.ObjectMeta.Labels != nil && s.ObjectMeta.Labels["camel.apache.org/integration"] == integration.Name
+ return s.ObjectMeta.Labels != nil && s.ObjectMeta.Labels[v1.IntegrationLabel] == integration.Name
})
}
diff --git a/pkg/util/kubernetes/conditions.go b/pkg/util/kubernetes/conditions.go
index bb8e3c4..88e5465 100644
--- a/pkg/util/kubernetes/conditions.go
+++ b/pkg/util/kubernetes/conditions.go
@@ -50,7 +50,7 @@ func MirrorReadyCondition(ctx context.Context, c client.Client, it *v1.Integrati
func mirrorReadyConditionFromReplicaSet(ctx context.Context, c client.Client, it *v1.Integration) {
list := appsv1.ReplicaSetList{}
opts := runtimeclient.MatchingLabels{
- "camel.apache.org/integration": it.Name,
+ v1.IntegrationLabel: it.Name,
}
if err := c.List(ctx, &list, opts, runtimeclient.InNamespace(it.Namespace)); err != nil {
setReadyConditionError(it, err)
diff --git a/pkg/util/kubernetes/log/util.go b/pkg/util/kubernetes/log/util.go
index bd72a94..5539d13 100644
--- a/pkg/util/kubernetes/log/util.go
+++ b/pkg/util/kubernetes/log/util.go
@@ -30,7 +30,7 @@ import (
// Print prints integrations logs to the stdout
func Print(ctx context.Context, client kubernetes.Interface, integration *v1.Integration, out io.Writer) error {
- scraper := NewSelectorScraper(client, integration.Namespace, integration.Name, "camel.apache.org/integration="+integration.Name)
+ scraper := NewSelectorScraper(client, integration.Namespace, integration.Name, v1.IntegrationLabel+"="+integration.Name)
reader := scraper.Start(ctx)
if _, err := io.Copy(out, ioutil.NopCloser(reader)); err != nil {