Skip to content

Commit

Permalink
add kafkaSecretName for collector and ingester
Browse files Browse the repository at this point in the history
  • Loading branch information
luohua13 committed May 27, 2022
1 parent 0077e52 commit b6fbf34
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apis/v1/jaeger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ type JaegerCollectorSpec struct {
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Strategy"
Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"`
KafkaSecretName string `json:"kafkaSecretName"`
}

// JaegerIngesterSpec defines the options to be used when deploying the ingester
Expand All @@ -460,7 +461,11 @@ type JaegerIngesterSpec struct {
Config FreeForm `json:"config,omitempty"`

// +optional
<<<<<<< HEAD:apis/v1/jaeger_types.go
Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"`
=======
KafkaSecretName string `json:"kafkaSecretName"`
>>>>>>> c953130e (add kafkaSecretName for collector and ingester):pkg/apis/jaegertracing/v1/jaeger_types.go
}

// JaegerAgentSpec defines the options to be used when deploying the agent
Expand Down
10 changes: 10 additions & 0 deletions pkg/deployment/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ func (c *Collector) Get() *appsv1.Deployment {
// to Kafka, and the storage options will be used in the Ingester instead
if c.jaeger.Spec.Strategy == v1.DeploymentStrategyStreaming {
storageType = v1.JaegerKafkaStorage
storageType = "kafka"
if len(c.jaeger.Spec.Collector.KafkaSecretName) > 0 {
envFromSource = append(envFromSource, corev1.EnvFromSource{
SecretRef: &corev1.SecretEnvSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: c.jaeger.Spec.Collector.KafkaSecretName,
},
},
})
}
}
options := allArgs(c.jaeger.Spec.Collector.Options,
c.jaeger.Spec.Storage.Options.Filter(storageType.OptionsPrefix()))
Expand Down
12 changes: 12 additions & 0 deletions pkg/deployment/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ func TestCollectorImagePullSecrets(t *testing.T) {
assert.Equal(t, pullSecret, dep.Spec.Template.Spec.ImagePullSecrets[0].Name)
}

func TestCollectorKafkaSecrets(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "kafka-instance"})
secret := "mysecret"
jaeger.Spec.Strategy = v1.DeploymentStrategyStreaming
jaeger.Spec.Collector.KafkaSecretName = secret

collector := NewCollector(jaeger)
dep := collector.Get()

assert.Equal(t, "mysecret", dep.Spec.Template.Spec.Containers[0].EnvFrom[0].SecretRef.LocalObjectReference.Name)
}

func TestCollectorImagePullPolicy(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestCollectorImagePullPolicy"})
const pullPolicy = corev1.PullPolicy("Always")
Expand Down
10 changes: 10 additions & 0 deletions pkg/deployment/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ func (i *Ingester) Get() *appsv1.Deployment {
})
}

if len(i.jaeger.Spec.Ingester.KafkaSecretName) > 0 {
envFromSource = append(envFromSource, corev1.EnvFromSource{
SecretRef: &corev1.SecretEnvSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: i.jaeger.Spec.Ingester.KafkaSecretName,
},
},
})
}

options := allArgs(i.jaeger.Spec.Ingester.Options,
i.jaeger.Spec.Storage.Options.Filter(i.jaeger.Spec.Storage.Type.OptionsPrefix()))

Expand Down
11 changes: 11 additions & 0 deletions pkg/deployment/ingester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ func TestIngeterImagePullSecrets(t *testing.T) {
assert.Equal(t, pullSecret, dep.Spec.Template.Spec.ImagePullSecrets[0].Name)
}

func TestIngesterKafkaSecrets(t *testing.T) {
jaeger := newIngesterJaeger("TestIngesterKafkaSecrets")
secret := "mysecret"
jaeger.Spec.Storage.SecretName = secret

ingester := NewIngester(jaeger)
dep := ingester.Get()

assert.Equal(t, "mysecret", dep.Spec.Template.Spec.Containers[0].EnvFrom[0].SecretRef.LocalObjectReference.Name)
}

func TestIngesterImagePullPolicy(t *testing.T) {
jaeger := newIngesterJaeger("TestIngesterImagePullPolicy")
const pullPolicy = corev1.PullPolicy("Always")
Expand Down

0 comments on commit b6fbf34

Please sign in to comment.