-
Notifications
You must be signed in to change notification settings - Fork 344
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
Token propagation E2E tests. #581
Changes from all commits
750e826
853b677
f100fc9
233cfd4
93df3af
0bb2711
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,9 @@ import ( | |
"github.com/jaegertracing/jaeger-operator/pkg/util" | ||
) | ||
|
||
// #nosec G101 (CWE-798): Potential hardcoded credentials | ||
const defaultProxySecret = "ncNDoqLGrayxXzxTn5ANbOXZp3qXd0LA" | ||
|
||
// OAuthProxy injects an appropriate proxy into the given deployment | ||
func OAuthProxy(jaeger *v1.Jaeger, dep *appsv1.Deployment) *appsv1.Deployment { | ||
if jaeger.Spec.Ingress.Security != v1.IngressSecurityOAuthProxy { | ||
|
@@ -33,17 +36,26 @@ func OAuthProxy(jaeger *v1.Jaeger, dep *appsv1.Deployment) *appsv1.Deployment { | |
return dep | ||
} | ||
|
||
func getOAuthProxyContainer(jaeger *v1.Jaeger) corev1.Container { | ||
func proxyInitArguments(jaeger *v1.Jaeger) []string { | ||
secret, err := util.GenerateProxySecret() | ||
if err != nil { | ||
jaeger.Logger().WithError(err).Warnf("Error generating secret: %s, fallback to fixed secret", secret) | ||
secret = defaultProxySecret | ||
} | ||
args := []string{ | ||
"--cookie-secret=SECRET", | ||
fmt.Sprintf("--cookie-secret=%s", secret), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This generates secrets containing chars like "+" and "/". How are they translated into the final YAML? Do they cause any troubles? I don't think it does, but it's good to have positive confirmation (and perhaps a test). Example of random strings I got from this code locally:
|
||
"--https-address=:8443", | ||
fmt.Sprintf("--openshift-service-account=%s", account.OAuthProxyAccountNameFor(jaeger)), | ||
"--provider=openshift", | ||
"--tls-cert=/etc/tls/private/tls.crt", | ||
"--tls-key=/etc/tls/private/tls.key", | ||
"--upstream=http://localhost:16686", | ||
} | ||
return args | ||
} | ||
|
||
func getOAuthProxyContainer(jaeger *v1.Jaeger) corev1.Container { | ||
args := proxyInitArguments(jaeger) | ||
volumeMounts := []corev1.VolumeMount{{ | ||
MountPath: "/etc/tls/private", | ||
Name: service.GetTLSSecretNameForQueryService(jaeger), | ||
|
@@ -65,6 +77,8 @@ func getOAuthProxyContainer(jaeger *v1.Jaeger) corev1.Container { | |
args = append(args, fmt.Sprintf("--openshift-delegate-urls=%s", jaeger.Spec.Ingress.Openshift.DelegateUrls)) | ||
} | ||
|
||
args = append(args, jaeger.Spec.Ingress.Options.ToArgs()...) | ||
|
||
sort.Strings(args) | ||
|
||
commonSpec := util.Merge([]v1.JaegerCommonSpec{jaeger.Spec.Ingress.JaegerCommonSpec, jaeger.Spec.JaegerCommonSpec}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,55 @@ type ElasticsearchDeployment struct { | |
Secrets []corev1.Secret | ||
} | ||
|
||
func (ed *ElasticsearchDeployment) injectArguments(container *corev1.Container) { | ||
container.Args = append(container.Args, "--es.server-urls="+elasticsearchURL) | ||
if util.FindItem("--es.tls=", container.Args) == "" { | ||
container.Args = append(container.Args, "--es.tls=true") | ||
} | ||
container.Args = append(container.Args, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't these options be added only if |
||
"--es.tls.ca="+caPath, | ||
"--es.tls.cert="+certPath, | ||
"--es.tls.key="+keyPath) | ||
|
||
if util.FindItem("--es.timeout", container.Args) == "" { | ||
container.Args = append(container.Args, "--es.timeout=15s") | ||
} | ||
if util.FindItem("--es.num-shards", container.Args) == "" { | ||
// taken from https://github.com/openshift/cluster-logging-operator/blob/32b69e8bcf61a805e8f3c45c664a3c08d1ee62d5/vendor/github.com/openshift/elasticsearch-operator/pkg/k8shandler/configmaps.go#L38 | ||
// every ES node is a data node | ||
container.Args = append(container.Args, fmt.Sprintf("--es.num-shards=%d", ed.Jaeger.Spec.Storage.Elasticsearch.NodeCount)) | ||
} | ||
if util.FindItem("--es.num-replicas", container.Args) == "" { | ||
container.Args = append(container.Args, fmt.Sprintf("--es.num-replicas=%d", | ||
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, | ||
"--es-archive.server-urls="+elasticsearchURL, | ||
) | ||
if util.FindItem("--es-archive.tls=", container.Args) == "" { | ||
container.Args = append(container.Args, "--es-archive.tls=true") | ||
} | ||
container.Args = append(container.Args, | ||
"--es-archive.tls.ca="+caPath, | ||
"--es-archive.tls.cert="+certPath, | ||
"--es-archive.tls.key="+keyPath, | ||
) | ||
if util.FindItem("--es-archive.timeout", container.Args) == "" { | ||
container.Args = append(container.Args, "--es-archive.timeout=15s") | ||
} | ||
if util.FindItem("--es-archive.num-shards", container.Args) == "" { | ||
// taken from https://github.com/openshift/cluster-logging-operator/blob/32b69e8bcf61a805e8f3c45c664a3c08d1ee62d5/vendor/github.com/openshift/elasticsearch-operator/pkg/k8shandler/configmaps.go#L38 | ||
// every ES node is a data node | ||
container.Args = append(container.Args, fmt.Sprintf("--es-archive.num-shards=%d", ed.Jaeger.Spec.Storage.Elasticsearch.NodeCount)) | ||
} | ||
if util.FindItem("--es-archive.num-replicas", container.Args) == "" { | ||
container.Args = append(container.Args, fmt.Sprintf("--es-archive.num-replicas=%d", | ||
calculateReplicaShards(ed.Jaeger.Spec.Storage.Elasticsearch.RedundancyPolicy, int(ed.Jaeger.Spec.Storage.Elasticsearch.NodeCount)))) | ||
} | ||
} | ||
} | ||
|
||
// InjectStorageConfiguration changes the given spec to include ES-related command line options | ||
func (ed *ElasticsearchDeployment) InjectStorageConfiguration(p *corev1.PodSpec) { | ||
p.Volumes = append(p.Volumes, corev1.Volume{ | ||
|
@@ -50,45 +99,7 @@ func (ed *ElasticsearchDeployment) InjectStorageConfiguration(p *corev1.PodSpec) | |
}) | ||
// we assume jaeger containers are first | ||
if len(p.Containers) > 0 { | ||
p.Containers[0].Args = append(p.Containers[0].Args, | ||
"--es.server-urls="+elasticsearchURL, | ||
"--es.tls=true", | ||
"--es.tls.ca="+caPath, | ||
"--es.tls.cert="+certPath, | ||
"--es.tls.key="+keyPath) | ||
if util.FindItem("--es.timeout", p.Containers[0].Args) == "" { | ||
p.Containers[0].Args = append(p.Containers[0].Args, "--es.timeout=15s") | ||
} | ||
if util.FindItem("--es.num-shards", p.Containers[0].Args) == "" { | ||
// taken from https://github.com/openshift/cluster-logging-operator/blob/32b69e8bcf61a805e8f3c45c664a3c08d1ee62d5/vendor/github.com/openshift/elasticsearch-operator/pkg/k8shandler/configmaps.go#L38 | ||
// every ES node is a data node | ||
p.Containers[0].Args = append(p.Containers[0].Args, fmt.Sprintf("--es.num-shards=%d", ed.Jaeger.Spec.Storage.Elasticsearch.NodeCount)) | ||
} | ||
if util.FindItem("--es.num-replicas", p.Containers[0].Args) == "" { | ||
p.Containers[0].Args = append(p.Containers[0].Args, fmt.Sprintf("--es.num-replicas=%d", | ||
calculateReplicaShards(ed.Jaeger.Spec.Storage.Elasticsearch.RedundancyPolicy, int(ed.Jaeger.Spec.Storage.Elasticsearch.NodeCount)))) | ||
} | ||
if strings.EqualFold(util.FindItem("--es-archive.enabled", p.Containers[0].Args), "--es-archive.enabled=true") { | ||
p.Containers[0].Args = append(p.Containers[0].Args, | ||
"--es-archive.server-urls="+elasticsearchURL, | ||
"--es-archive.tls=true", | ||
"--es-archive.tls.ca="+caPath, | ||
"--es-archive.tls.cert="+certPath, | ||
"--es-archive.tls.key="+keyPath, | ||
) | ||
if util.FindItem("--es-archive.timeout", p.Containers[0].Args) == "" { | ||
p.Containers[0].Args = append(p.Containers[0].Args, "--es-archive.timeout=15s") | ||
} | ||
if util.FindItem("--es-archive.num-shards", p.Containers[0].Args) == "" { | ||
// taken from https://github.com/openshift/cluster-logging-operator/blob/32b69e8bcf61a805e8f3c45c664a3c08d1ee62d5/vendor/github.com/openshift/elasticsearch-operator/pkg/k8shandler/configmaps.go#L38 | ||
// every ES node is a data node | ||
p.Containers[0].Args = append(p.Containers[0].Args, fmt.Sprintf("--es-archive.num-shards=%d", ed.Jaeger.Spec.Storage.Elasticsearch.NodeCount)) | ||
} | ||
if util.FindItem("--es-archive.num-replicas", p.Containers[0].Args) == "" { | ||
p.Containers[0].Args = append(p.Containers[0].Args, fmt.Sprintf("--es-archive.num-replicas=%d", | ||
calculateReplicaShards(ed.Jaeger.Spec.Storage.Elasticsearch.RedundancyPolicy, int(ed.Jaeger.Spec.Storage.Elasticsearch.NodeCount)))) | ||
} | ||
} | ||
ed.injectArguments(&p.Containers[0]) | ||
p.Containers[0].VolumeMounts = append(p.Containers[0].VolumeMounts, corev1.VolumeMount{ | ||
Name: volumeName, | ||
ReadOnly: true, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @kevinearls