Skip to content

Commit

Permalink
Add pod affinity to cassandraCreateSchema (#1475)
Browse files Browse the repository at this point in the history
* add cassandraCreateSchema affinity

Signed-off-by: Chase Kiefer <[email protected]>

* add cassandraCreateSchema affinity

Signed-off-by: Chase Kiefer <[email protected]>

Co-authored-by: Juraci Paixão Kröhling <[email protected]>
  • Loading branch information
chasekiefer and jpkrohling authored Jul 2, 2021
1 parent c49f0cd commit bd71dfd
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 0 deletions.
262 changes: 262 additions & 0 deletions deploy/crds/jaegertracing.io_jaegers_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7004,6 +7004,268 @@ spec:
properties:
cassandraCreateSchema:
properties:
affinity:
properties:
nodeAffinity:
properties:
preferredDuringSchedulingIgnoredDuringExecution:
items:
properties:
preference:
properties:
matchExpressions:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchFields:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
type: object
weight:
format: int32
type: integer
required:
- preference
- weight
type: object
type: array
requiredDuringSchedulingIgnoredDuringExecution:
properties:
nodeSelectorTerms:
items:
properties:
matchExpressions:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchFields:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
type: object
type: array
required:
- nodeSelectorTerms
type: object
type: object
podAffinity:
properties:
preferredDuringSchedulingIgnoredDuringExecution:
items:
properties:
podAffinityTerm:
properties:
labelSelector:
properties:
matchExpressions:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
type: object
type: object
namespaces:
items:
type: string
type: array
topologyKey:
type: string
required:
- topologyKey
type: object
weight:
format: int32
type: integer
required:
- podAffinityTerm
- weight
type: object
type: array
requiredDuringSchedulingIgnoredDuringExecution:
items:
properties:
labelSelector:
properties:
matchExpressions:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
type: object
type: object
namespaces:
items:
type: string
type: array
topologyKey:
type: string
required:
- topologyKey
type: object
type: array
type: object
podAntiAffinity:
properties:
preferredDuringSchedulingIgnoredDuringExecution:
items:
properties:
podAffinityTerm:
properties:
labelSelector:
properties:
matchExpressions:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
type: object
type: object
namespaces:
items:
type: string
type: array
topologyKey:
type: string
required:
- topologyKey
type: object
weight:
format: int32
type: integer
required:
- podAffinityTerm
- weight
type: object
type: array
requiredDuringSchedulingIgnoredDuringExecution:
items:
properties:
labelSelector:
properties:
matchExpressions:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
type: object
type: object
namespaces:
items:
type: string
type: array
topologyKey:
type: string
required:
- topologyKey
type: object
type: array
type: object
type: object
datacenter:
type: string
enabled:
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/jaegertracing/v1/jaeger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ type JaegerCassandraCreateSchemaSpec struct {
// +optional
Timeout string `json:"timeout,omitempty"`

// +optional
Affinity *v1.Affinity `json:"affinity,omitempty"`

// +optional
TTLSecondsAfterFinished *int32 `json:"ttlSecondsAfterFinished,omitempty"`
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/jaegertracing/v1/zz_generated.deepcopy.go

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

7 changes: 7 additions & 0 deletions pkg/apis/jaegertracing/v1/zz_generated.openapi.go

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

1 change: 1 addition & 0 deletions pkg/storage/cassandra_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func cassandraDeps(jaeger *v1.Jaeger) []batchv1.Job {
},
Spec: corev1.PodSpec{
ActiveDeadlineSeconds: podTimeout,
Affinity: jaeger.Spec.Storage.CassandraCreateSchema.Affinity,
SecurityContext: jaeger.Spec.SecurityContext,
Containers: []corev1.Container{{
Image: util.ImageName(jaeger.Spec.Storage.CassandraCreateSchema.Image, "jaeger-cassandra-schema-image"),
Expand Down
12 changes: 12 additions & 0 deletions pkg/storage/cassandra_dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,15 @@ func TestCassandraCreateSchemaSecret(t *testing.T) {
assert.Len(t, b, 1)
assert.Equal(t, secret, b[0].Spec.Template.Spec.Containers[0].EnvFrom[0].SecretRef.LocalObjectReference.Name)
}

func TestCassandraCreateSchemaAffinity(t *testing.T) {
expectedAffinity := &corev1.Affinity{}

jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestCassandraCreateSchemaAffinity"})
jaeger.Spec.Storage.CassandraCreateSchema.Affinity = expectedAffinity

b := cassandraDeps(jaeger)

assert.Len(t, b, 1)
assert.Equal(t, expectedAffinity, b[0].Spec.Template.Spec.Affinity)
}

0 comments on commit bd71dfd

Please sign in to comment.