Skip to content

Commit 2a07961

Browse files
committed
Adding flags for different TLS levels resulting in diffeerent quarkus env vars
Signed-off-by: Matthias Wessendorf <[email protected]>
1 parent 14676df commit 2a07961

File tree

3 files changed

+33
-22
lines changed

3 files changed

+33
-22
lines changed

pkg/reconciler/integration/sink/integrationsink.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, sink *sinks.IntegrationS
9393
}
9494
}
9595

96-
_, err := r.reconcileDeployment(ctx, sink)
96+
_, err := r.reconcileDeployment(ctx, sink, featureFlags)
9797
if err != nil {
9898
logging.FromContext(ctx).Errorw("Error reconciling Pod", zap.Error(err))
9999
return err
@@ -117,9 +117,9 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, sink *sinks.IntegrationS
117117
return newReconciledNormal(sink.Namespace, sink.Name)
118118
}
119119

120-
func (r *Reconciler) reconcileDeployment(ctx context.Context, sink *sinks.IntegrationSink) (*v1.Deployment, error) {
120+
func (r *Reconciler) reconcileDeployment(ctx context.Context, sink *sinks.IntegrationSink, featureFlags feature.Flags) (*v1.Deployment, error) {
121121

122-
expected := resources.MakeDeploymentSpec(sink)
122+
expected := resources.MakeDeploymentSpec(sink, featureFlags)
123123
deployment, err := r.deploymentLister.Deployments(sink.Namespace).Get(expected.Name)
124124
if apierrors.IsNotFound(err) {
125125
deployment, err = r.kubeClientSet.AppsV1().Deployments(sink.Namespace).Create(ctx, expected, metav1.CreateOptions{})

pkg/reconciler/integration/sink/resources/container_image.go

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2323
"k8s.io/apimachinery/pkg/util/intstr"
2424
commonv1a1 "knative.dev/eventing/pkg/apis/common/integration/v1alpha1"
25+
"knative.dev/eventing/pkg/apis/feature"
2526
"knative.dev/eventing/pkg/apis/sinks/v1alpha1"
2627
"knative.dev/eventing/pkg/reconciler/integration"
2728
"knative.dev/pkg/kmeta"
@@ -34,7 +35,7 @@ var sinkImageMap = map[string]string{
3435
"aws-sns": "gcr.io/knative-nightly/aws-sns-sink:latest",
3536
}
3637

37-
func MakeDeploymentSpec(sink *v1alpha1.IntegrationSink) *appsv1.Deployment {
38+
func MakeDeploymentSpec(sink *v1alpha1.IntegrationSink, featureFlags feature.Flags) *appsv1.Deployment {
3839
t := true
3940

4041
deploy := &appsv1.Deployment{
@@ -86,7 +87,7 @@ func MakeDeploymentSpec(sink *v1alpha1.IntegrationSink) *appsv1.Deployment {
8687
Protocol: corev1.ProtocolTCP,
8788
Name: "https",
8889
}},
89-
Env: makeEnv(sink),
90+
Env: makeEnv(sink, featureFlags),
9091
VolumeMounts: []corev1.VolumeMount{
9192
{
9293
Name: CertificateName(sink),
@@ -138,26 +139,32 @@ func MakeService(sink *v1alpha1.IntegrationSink) *corev1.Service {
138139
}
139140
}
140141

141-
func DeploymentName(sink *v1alpha1.IntegrationSink) string {
142-
return kmeta.ChildName(sink.Name, "-deployment")
143-
}
144-
145-
func makeEnv(sink *v1alpha1.IntegrationSink) []corev1.EnvVar {
142+
func makeEnv(sink *v1alpha1.IntegrationSink, featureFlags feature.Flags) []corev1.EnvVar {
146143
var envVars []corev1.EnvVar
147144

148-
//QUARKUS_HTTP_SSL_CERTIFICATE_FILES=/mount/certs/server.crt
149-
//QUARKUS_HTTP_SSL_CERTIFICATE_KEY-FILES=/mount/certs/server.key
145+
// Transport encryption environment variables
146+
if !featureFlags.IsDisabledTransportEncryption() {
147+
envVars = append(envVars, []corev1.EnvVar{
148+
{
149+
Name: "QUARKUS_HTTP_SSL_CERTIFICATE_FILES",
150+
Value: "/etc/" + CertificateName(sink) + "/tls.crt",
151+
},
152+
{
153+
Name: "QUARKUS_HTTP_SSL_CERTIFICATE_KEY-FILES",
154+
Value: "/etc/" + CertificateName(sink) + "/tls.key",
155+
},
156+
}...)
157+
}
150158

151-
envVars = append(envVars, []corev1.EnvVar{
152-
{
153-
Name: "QUARKUS_HTTP_SSL_CERTIFICATE_FILES",
154-
Value: "/etc/" + CertificateName(sink) + "/tls.crt",
155-
},
156-
{
157-
Name: "QUARKUS_HTTP_SSL_CERTIFICATE_KEY-FILES",
158-
Value: "/etc/" + CertificateName(sink) + "/tls.key",
159-
},
160-
}...)
159+
// No HTTP with strict TLS
160+
if featureFlags.IsStrictTransportEncryption() {
161+
envVars = append(envVars, []corev1.EnvVar{
162+
{
163+
Name: "QUARKUS_HTTP_INSECURE_REQUESTS",
164+
Value: "disabled",
165+
},
166+
}...)
167+
}
161168

162169
// Log environment variables
163170
if sink.Spec.Log != nil {

pkg/reconciler/integration/sink/resources/names.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ import (
2424
func CertificateName(sink *v1alpha1.IntegrationSink) string {
2525
return kmeta.ChildName(sink.Name, "-server-tls")
2626
}
27+
28+
func DeploymentName(sink *v1alpha1.IntegrationSink) string {
29+
return kmeta.ChildName(sink.Name, "-deployment")
30+
}

0 commit comments

Comments
 (0)