Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add labels to cronjob pod template #707

Merged
merged 3 commits into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ sigs.k8s.io/controller-runtime v0.2.0 h1:5gL30PXOisGZl+Osi4CmLhvMUj77BO3wJeouKF2
sigs.k8s.io/controller-runtime v0.2.0/go.mod h1:ZHqrRDZi3f6BzONcvlUxkqCKgwasGk5FZrnSv9TVZF4=
sigs.k8s.io/controller-tools v0.2.0 h1:AmQ/0JKBJAjyAiPAkrAf9QW06jkx2lc5hpxMjamsFpw=
sigs.k8s.io/controller-tools v0.2.0/go.mod h1:8t/X+FVWvk6TaBcsa+UKUBbn7GMtvyBKX30SGl4em6Y=
sigs.k8s.io/controller-tools v0.2.1 h1:HoCik83vXOpPi7KSJWdPRmiGntyOzK0v0BTV4U+pl8o=
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
sigs.k8s.io/testing_frameworks v0.1.1 h1:cP2l8fkA3O9vekpy5Ks8mmA0NW/F7yBdXf8brkWhVrs=
sigs.k8s.io/testing_frameworks v0.1.1/go.mod h1:VVBKrHmJ6Ekkfz284YKhQePcdycOzNH9qL6ht1zEr/U=
Expand Down
17 changes: 9 additions & 8 deletions pkg/cronjob/es_index_cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ func CreateEsIndexCleaner(jaeger *v1.Jaeger) *batchv1beta1.CronJob {
"sidecar.istio.io/inject": "false",
"linkerd.io/inject": "disabled",
},
Labels: map[string]string{
"app": "jaeger",
"app.kubernetes.io/name": name,
"app.kubernetes.io/instance": jaeger.Name,
"app.kubernetes.io/component": "cronjob-es-index-cleaner",
"app.kubernetes.io/part-of": "jaeger",
"app.kubernetes.io/managed-by": "jaeger-operator",
},
}

commonSpec := util.Merge([]v1.JaegerCommonSpec{jaeger.Spec.Storage.EsIndexCleaner.JaegerCommonSpec, jaeger.Spec.JaegerCommonSpec, baseCommonSpec})
Expand All @@ -53,14 +61,7 @@ func CreateEsIndexCleaner(jaeger *v1.Jaeger) *batchv1beta1.CronJob {
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: jaeger.Namespace,
Labels: map[string]string{
"app": "jaeger",
"app.kubernetes.io/name": name,
"app.kubernetes.io/instance": jaeger.Name,
"app.kubernetes.io/component": "cronjob-es-index-cleaner",
"app.kubernetes.io/part-of": "jaeger",
"app.kubernetes.io/managed-by": "jaeger-operator",
},
Labels: commonSpec.Labels,
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: jaeger.APIVersion,
Expand Down
3 changes: 3 additions & 0 deletions pkg/cronjob/es_index_cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ func TestEsIndexCleanerLabels(t *testing.T) {
assert.Equal(t, "operator", cjob.Spec.JobTemplate.Spec.Template.Labels["name"])
assert.Equal(t, "world", cjob.Spec.JobTemplate.Spec.Template.Labels["hello"])
assert.Equal(t, "false", cjob.Spec.JobTemplate.Spec.Template.Labels["another"])

// Check if the labels of cronjob pod template equal to the labels of cronjob.
assert.Equal(t, cjob.ObjectMeta.Labels, cjob.Spec.JobTemplate.Spec.Template.ObjectMeta.Labels)
}

func TestEsIndexCleanerResources(t *testing.T) {
Expand Down
17 changes: 9 additions & 8 deletions pkg/cronjob/spark_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ func CreateSparkDependencies(jaeger *v1.Jaeger) *batchv1beta1.CronJob {
"sidecar.istio.io/inject": "false",
"linkerd.io/inject": "disabled",
},
Labels: map[string]string{
"app": "jaeger",
"app.kubernetes.io/name": name,
"app.kubernetes.io/instance": jaeger.Name,
"app.kubernetes.io/component": "cronjob-es-index-cleaner",
"app.kubernetes.io/part-of": "jaeger",
"app.kubernetes.io/managed-by": "jaeger-operator",
},
}

commonSpec := util.Merge([]v1.JaegerCommonSpec{jaeger.Spec.Storage.Dependencies.JaegerCommonSpec, jaeger.Spec.JaegerCommonSpec, baseCommonSpec})
Expand All @@ -61,14 +69,7 @@ func CreateSparkDependencies(jaeger *v1.Jaeger) *batchv1beta1.CronJob {
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: jaeger.Namespace,
Labels: map[string]string{
"app": "jaeger",
"app.kubernetes.io/name": name,
"app.kubernetes.io/instance": jaeger.Name,
"app.kubernetes.io/component": "cronjob-spark-dependencies",
"app.kubernetes.io/part-of": "jaeger",
"app.kubernetes.io/managed-by": "jaeger-operator",
},
Labels: commonSpec.Labels,
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: jaeger.APIVersion,
Expand Down
3 changes: 3 additions & 0 deletions pkg/cronjob/spark_dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ func TestDependenciesLabels(t *testing.T) {
assert.Equal(t, "operator", cjob.Spec.JobTemplate.Spec.Template.Labels["name"])
assert.Equal(t, "world", cjob.Spec.JobTemplate.Spec.Template.Labels["hello"])
assert.Equal(t, "false", cjob.Spec.JobTemplate.Spec.Template.Labels["another"])

// Check if the labels of cronjob pod template equal to the labels of cronjob.
assert.Equal(t, cjob.ObjectMeta.Labels, cjob.Spec.JobTemplate.Spec.Template.ObjectMeta.Labels)
}

func TestSparkDependenciesResources(t *testing.T) {
Expand Down