Skip to content

Commit

Permalink
use URI Scheme HTTPS when tls flag is provided (grafana#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sashank Agarwal authored Aug 27, 2021
1 parent 2a89113 commit ad2e079
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
20 changes: 20 additions & 0 deletions internal/manifests/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,22 @@ func configureGatewayMetricsPKI(podSpec *corev1.PodSpec) error {
fmt.Sprintf("--tls.healthchecks.server-ca-file=%s", path.Join(gateway.LokiGatewayTLSDir, "ca")),
},
}
uriSchemeContainerSpec := corev1.Container{
ReadinessProbe: &corev1.Probe{
Handler: corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Scheme: corev1.URISchemeHTTPS,
},
},
},
LivenessProbe: &corev1.Probe{
Handler: corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Scheme: corev1.URISchemeHTTPS,
},
},
},
}

if err := mergo.Merge(podSpec, secretVolumeSpec, mergo.WithAppendSlice); err != nil {
return kverrors.Wrap(err, "failed to merge volumes")
Expand All @@ -299,5 +315,9 @@ func configureGatewayMetricsPKI(podSpec *corev1.PodSpec) error {
return kverrors.Wrap(err, "failed to merge container")
}

if err := mergo.Merge(&podSpec.Containers[0], uriSchemeContainerSpec, mergo.WithOverride); err != nil {
return kverrors.Wrap(err, "failed to merge container")
}

return nil
}
21 changes: 20 additions & 1 deletion internal/manifests/service_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package manifests

import (
"github.com/ViaQ/logerr/kverrors"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand Down Expand Up @@ -141,6 +140,22 @@ func configureServiceMonitorPKI(podSpec *corev1.PodSpec, serviceName string) err
"-server.http-tls-key-path=/etc/proxy/secrets/tls.key",
},
}
uriSchemeContainerSpec := corev1.Container{
ReadinessProbe: &corev1.Probe{
Handler: corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Scheme: corev1.URISchemeHTTPS,
},
},
},
LivenessProbe: &corev1.Probe{
Handler: corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Scheme: corev1.URISchemeHTTPS,
},
},
},
}

if err := mergo.Merge(podSpec, secretVolumeSpec, mergo.WithAppendSlice); err != nil {
return kverrors.Wrap(err, "failed to merge volumes")
Expand All @@ -150,5 +165,9 @@ func configureServiceMonitorPKI(podSpec *corev1.PodSpec, serviceName string) err
return kverrors.Wrap(err, "failed to merge container")
}

if err := mergo.Merge(&podSpec.Containers[0], uriSchemeContainerSpec, mergo.WithOverride); err != nil {
return kverrors.Wrap(err, "failed to merge container")
}

return nil
}

0 comments on commit ad2e079

Please sign in to comment.