Skip to content

Commit

Permalink
Merge e007726 into cb33f0a
Browse files Browse the repository at this point in the history
  • Loading branch information
pavolloffay authored Sep 21, 2023
2 parents cb33f0a + e007726 commit 2244b01
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 64 deletions.
2 changes: 2 additions & 0 deletions pkg/cronjob/es_index_cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"strconv"
"strings"

"github.com/operator-framework/operator-lib/proxy"
"github.com/spf13/viper"
batchv1 "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1"
Expand All @@ -30,6 +31,7 @@ func CreateEsIndexCleaner(jaeger *v1.Jaeger) runtime.Object {

envFromSource := util.CreateEnvsFromSecret(jaeger.Spec.Storage.SecretName)
envs := EsScriptEnvVars(jaeger.Spec.Storage.Options)
envs = append(envs, proxy.ReadProxyVarsFromEnv()...)
if val, ok := jaeger.Spec.Storage.Options.StringMap()["es.use-aliases"]; ok && strings.EqualFold(val, "true") {
envs = append(envs, corev1.EnvVar{Name: "ROLLOVER", Value: "true"})
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/cronjob/es_rollover.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"strconv"
"time"

"github.com/operator-framework/operator-lib/proxy"
"github.com/spf13/viper"
"k8s.io/apimachinery/pkg/runtime"

batchv1 "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"

v1 "github.com/jaegertracing/jaeger-operator/apis/v1"
"github.com/jaegertracing/jaeger-operator/pkg/account"
Expand Down Expand Up @@ -97,6 +97,7 @@ func rollover(jaeger *v1.Jaeger) runtime.Object {

func createTemplate(name, action string, jaeger *v1.Jaeger, envs []corev1.EnvVar) *corev1.PodTemplateSpec {
envFromSource := util.CreateEnvsFromSecret(jaeger.Spec.Storage.SecretName)
envs = append(envs, proxy.ReadProxyVarsFromEnv()...)
baseCommonSpec := v1.JaegerCommonSpec{
Annotations: map[string]string{
"prometheus.io/scrape": "false",
Expand Down
8 changes: 4 additions & 4 deletions pkg/cronjob/spark_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import (
"strconv"
"strings"

"k8s.io/apimachinery/pkg/runtime"

"github.com/operator-framework/operator-lib/proxy"
"github.com/spf13/viper"
batchv1 "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/spf13/viper"
"k8s.io/apimachinery/pkg/runtime"

v1 "github.com/jaegertracing/jaeger-operator/apis/v1"
"github.com/jaegertracing/jaeger-operator/pkg/account"
Expand All @@ -35,6 +34,7 @@ func CreateSparkDependencies(jaeger *v1.Jaeger) runtime.Object {
{Name: "JAVA_OPTS", Value: jaeger.Spec.Storage.Dependencies.JavaOpts},
}
envVars = append(envVars, getStorageEnvs(jaeger.Spec.Storage)...)
envVars = append(envVars, proxy.ReadProxyVarsFromEnv()...)

envFromSource := util.CreateEnvsFromSecret(jaeger.Spec.Storage.SecretName)

Expand Down
2 changes: 2 additions & 0 deletions pkg/deployment/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strconv"
"strings"

"github.com/operator-framework/operator-lib/proxy"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -148,6 +149,7 @@ func (a *Agent) Get() *appsv1.DaemonSet {
Image: util.ImageName(a.jaeger.Spec.Agent.Image, "jaeger-agent-image"),
Name: "jaeger-agent-daemonset",
Args: args,
Env: proxy.ReadProxyVarsFromEnv(),
Ports: []corev1.ContainerPort{
{
ContainerPort: zkCompactTrft,
Expand Down
7 changes: 4 additions & 3 deletions pkg/deployment/all_in_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import (
"sort"
"strconv"

"github.com/jaegertracing/jaeger-operator/pkg/autodetect"
"github.com/jaegertracing/jaeger-operator/pkg/storage"

"github.com/operator-framework/operator-lib/proxy"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"

v1 "github.com/jaegertracing/jaeger-operator/apis/v1"
"github.com/jaegertracing/jaeger-operator/pkg/account"
"github.com/jaegertracing/jaeger-operator/pkg/autodetect"
"github.com/jaegertracing/jaeger-operator/pkg/config/ca"
"github.com/jaegertracing/jaeger-operator/pkg/config/sampling"
"github.com/jaegertracing/jaeger-operator/pkg/config/tls"
configmap "github.com/jaegertracing/jaeger-operator/pkg/config/ui"
"github.com/jaegertracing/jaeger-operator/pkg/service"
"github.com/jaegertracing/jaeger-operator/pkg/storage"
"github.com/jaegertracing/jaeger-operator/pkg/util"
)

Expand Down Expand Up @@ -152,6 +152,7 @@ func (a *AllInOne) Get() *appsv1.Deployment {
Value: strconv.FormatBool(jaegerDisabled),
},
}
envVars = append(envVars, proxy.ReadProxyVarsFromEnv()...)

ports := []corev1.ContainerPort{
{
Expand Down
2 changes: 2 additions & 0 deletions pkg/deployment/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"sort"
"strconv"

"github.com/operator-framework/operator-lib/proxy"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -137,6 +138,7 @@ func (c *Collector) Get() *appsv1.Deployment {
Value: ":9411",
},
}
envVars = append(envVars, proxy.ReadProxyVarsFromEnv()...)

ports := []corev1.ContainerPort{
{
Expand Down
19 changes: 12 additions & 7 deletions pkg/deployment/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"sort"
"strconv"

"github.com/operator-framework/operator-lib/proxy"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -124,6 +125,13 @@ func (i *Ingester) Get() *appsv1.Deployment {
nodeSelector = i.jaeger.Spec.Ingester.NodeSelector
}

envVars := []corev1.EnvVar{
{
Name: "SPAN_STORAGE_TYPE",
Value: string(i.jaeger.Spec.Storage.Type),
},
}
envVars = append(envVars, proxy.ReadProxyVarsFromEnv()...)
deployment := &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Expand Down Expand Up @@ -155,13 +163,10 @@ func (i *Ingester) Get() *appsv1.Deployment {
Spec: corev1.PodSpec{
ImagePullSecrets: i.jaeger.Spec.ImagePullSecrets,
Containers: []corev1.Container{{
Image: util.ImageName(i.jaeger.Spec.Ingester.Image, "jaeger-ingester-image"),
Name: "jaeger-ingester",
Args: options,
Env: []corev1.EnvVar{{
Name: "SPAN_STORAGE_TYPE",
Value: string(i.jaeger.Spec.Storage.Type),
}},
Image: util.ImageName(i.jaeger.Spec.Ingester.Image, "jaeger-ingester-image"),
Name: "jaeger-ingester",
Args: options,
Env: envVars,
VolumeMounts: commonSpec.VolumeMounts,
EnvFrom: envFromSource,
Ports: []corev1.ContainerPort{
Expand Down
37 changes: 20 additions & 17 deletions pkg/deployment/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"sort"
"strconv"

"github.com/operator-framework/operator-lib/proxy"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -120,6 +121,21 @@ func (q *Query) Get() *appsv1.Deployment {
nodeSelector = q.jaeger.Spec.Query.NodeSelector
}

envVars := []corev1.EnvVar{
{
Name: "SPAN_STORAGE_TYPE",
Value: string(q.jaeger.Spec.Storage.Type),
},
{
Name: "METRICS_STORAGE_TYPE",
Value: string(q.jaeger.Spec.Query.MetricsStorage.Type),
},
{
Name: "JAEGER_DISABLED",
Value: strconv.FormatBool(jaegerDisabled),
},
}
envVars = append(envVars, proxy.ReadProxyVarsFromEnv()...)
deployment := &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Expand Down Expand Up @@ -152,23 +168,10 @@ func (q *Query) Get() *appsv1.Deployment {
Spec: corev1.PodSpec{
ImagePullSecrets: q.jaeger.Spec.ImagePullSecrets,
Containers: []corev1.Container{{
Image: util.ImageName(q.jaeger.Spec.Query.Image, "jaeger-query-image"),
Name: "jaeger-query",
Args: options,
Env: []corev1.EnvVar{
{
Name: "SPAN_STORAGE_TYPE",
Value: string(q.jaeger.Spec.Storage.Type),
},
{
Name: "METRICS_STORAGE_TYPE",
Value: string(q.jaeger.Spec.Query.MetricsStorage.Type),
},
{
Name: "JAEGER_DISABLED",
Value: strconv.FormatBool(jaegerDisabled),
},
},
Image: util.ImageName(q.jaeger.Spec.Query.Image, "jaeger-query-image"),
Name: "jaeger-query",
Args: options,
Env: envVars,
VolumeMounts: commonSpec.VolumeMounts,
EnvFrom: envFromSource,
Ports: []corev1.ContainerPort{
Expand Down
2 changes: 2 additions & 0 deletions pkg/inject/oauth_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"sort"
"strings"

"github.com/operator-framework/operator-lib/proxy"
"github.com/spf13/viper"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -111,6 +112,7 @@ func getOAuthProxyContainer(jaeger *v1.Jaeger) corev1.Container {
},
},
Resources: commonSpec.Resources,
Env: proxy.ReadProxyVarsFromEnv(),
}
}

Expand Down
39 changes: 21 additions & 18 deletions pkg/inject/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strconv"
"strings"

"github.com/operator-framework/operator-lib/proxy"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/intstr"
Expand Down Expand Up @@ -209,6 +210,25 @@ func getJaeger(name string, jaegers *v1.JaegerList) *v1.Jaeger {

func container(jaeger *v1.Jaeger, dep *appsv1.Deployment, agentIdx int) corev1.Container {
args := jaeger.Spec.Agent.Options.ToArgs()
envs := []corev1.EnvVar{
{
Name: envVarPodName,
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.name",
},
},
},
{
Name: envVarHostIP,
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "status.hostIP",
},
},
},
}
envs = append(envs, proxy.ReadProxyVarsFromEnv()...)

// we only add the grpc host if we are adding the reporter type and there's no explicit value yet
if len(util.FindItem("--reporter.grpc.host-port=", args)) == 0 {
Expand Down Expand Up @@ -275,24 +295,7 @@ func container(jaeger *v1.Jaeger, dep *appsv1.Deployment, agentIdx int) corev1.C
Image: util.ImageName(jaeger.Spec.Agent.Image, "jaeger-agent-image"),
Name: "jaeger-agent",
Args: args,
Env: []corev1.EnvVar{
{
Name: envVarPodName,
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.name",
},
},
},
{
Name: envVarHostIP,
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "status.hostIP",
},
},
},
},
Env: envs,
Ports: []corev1.ContainerPort{
{
ContainerPort: zkCompactTrft,
Expand Down
6 changes: 3 additions & 3 deletions pkg/storage/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type ElasticsearchDeployment struct {
}

func (ed *ElasticsearchDeployment) injectArguments(container *corev1.Container) {
container.Args = append(container.Args, fmt.Sprintf("--es.server-urls=https://%s:9200", ed.Jaeger.Spec.Storage.Elasticsearch.Name))
container.Args = append(container.Args, fmt.Sprintf("--es.server-urls=https://%s.%s.svc.cluster.local:9200", ed.Jaeger.Spec.Storage.Elasticsearch.Name, ed.Jaeger.Namespace))
if util.FindItem("--es.tls=", container.Args) == "" && util.FindItem("--es.tls.enabled=", container.Args) == "" {
container.Args = append(container.Args, "--es.tls.enabled=true")
}
Expand All @@ -75,7 +75,7 @@ func (ed *ElasticsearchDeployment) injectArguments(container *corev1.Container)
calculateReplicaShards(ed.Jaeger.Spec.Storage.Elasticsearch.RedundancyPolicy, int(ed.Jaeger.Spec.Storage.Elasticsearch.NodeCount))))
}
if strings.EqualFold(util.FindItem("--es-archive.enabled", container.Args), "--es-archive.enabled=true") {
container.Args = append(container.Args, fmt.Sprintf("--es-archive.server-urls=https://%s:9200", ed.Jaeger.Spec.Storage.Elasticsearch.Name))
container.Args = append(container.Args, fmt.Sprintf("--es-archive.server-urls=https://%s.%s.svc.cluster.local:9200", ed.Jaeger.Spec.Storage.Elasticsearch.Name, ed.Jaeger.Namespace))
if util.FindItem("--es-archive.tls=", container.Args) == "" && util.FindItem("--es-archive.tls.enabled=", container.Args) == "" {
container.Args = append(container.Args, "--es-archive.tls.enabled=true")
}
Expand Down Expand Up @@ -134,7 +134,7 @@ func (ed *ElasticsearchDeployment) InjectSecretsConfiguration(p *corev1.PodSpec)
// we assume jaeger containers are first
if len(p.Containers) > 0 {
// the size of arguments array should be always 2
p.Containers[0].Args[1] = fmt.Sprintf("https://%s:9200", ed.Jaeger.Spec.Storage.Elasticsearch.Name)
p.Containers[0].Args[1] = fmt.Sprintf("https://%s.%s.svc.cluster.local:9200", ed.Jaeger.Spec.Storage.Elasticsearch.Name, ed.Jaeger.Namespace)
p.Containers[0].Env = append(p.Containers[0].Env,
corev1.EnvVar{Name: "ES_TLS_ENABLED", Value: "true"},
corev1.EnvVar{Name: "ES_TLS_CA", Value: ed.getCertCaPath()},
Expand Down
Loading

0 comments on commit 2244b01

Please sign in to comment.