Skip to content
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

use new encryption flags from https://github.com/knative/networking/pull/858 #14379

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require (
k8s.io/utils v0.0.0-20230209194617-a36077c30491
knative.dev/caching v0.0.0-20230927121431-da42414936d9
knative.dev/hack v0.0.0-20230926181829-f2f9b6f91263
knative.dev/networking v0.0.0-20230927121431-c1cae210daec
knative.dev/networking v0.0.0-20231002132535-463dc388389e
knative.dev/pkg v0.0.0-20231002125759-1860700f6ffe
sigs.k8s.io/yaml v1.3.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -929,10 +929,10 @@ knative.dev/caching v0.0.0-20230927121431-da42414936d9 h1:4VatxDY+XTd4ZnmGviV7SB
knative.dev/caching v0.0.0-20230927121431-da42414936d9/go.mod h1:HMAUIHPcIhEUWaSWzTj8eLDrTFa9gkLD6gtrlZ098Jw=
knative.dev/hack v0.0.0-20230926181829-f2f9b6f91263 h1:e6r9J1YopzSh6tDCpyKhVBfRUlZ2r0KRo9wupRjdRF4=
knative.dev/hack v0.0.0-20230926181829-f2f9b6f91263/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q=
knative.dev/networking v0.0.0-20230927121431-c1cae210daec h1:FuApkAE1QhvChCQDR3yziqdsZ+LiEM0ZxTdI0qKIMrA=
knative.dev/networking v0.0.0-20230927121431-c1cae210daec/go.mod h1:U9yqeTf2NtTY5aexYLbE4LAoIt/FAsnoERbnejJKlgI=
knative.dev/pkg v0.0.0-20231002125759-1860700f6ffe h1:hjBKTt3k7dtsC3LMRXDicPtM0HwERGsJ6CkWVOcts2E=
knative.dev/pkg v0.0.0-20231002125759-1860700f6ffe/go.mod h1:PxnS8ZnVtC0S+An+NEhrpzWt6k9hedDNt659Gu5EtJk=
knative.dev/networking v0.0.0-20231002132535-463dc388389e h1:IifOH0ZKyU+QtY97+GUoopC+vyFMlee6cOw+wxK7cxc=
knative.dev/networking v0.0.0-20231002132535-463dc388389e/go.mod h1:U9yqeTf2NtTY5aexYLbE4LAoIt/FAsnoERbnejJKlgI=
pgregory.net/rapid v1.0.0 h1:iQaM2w5PZ6xvt6x7hbd7tiDS+nk7YPp5uCaEba+T/F4=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/autoscaling/config/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestStoreImmutableConfig(t *testing.T) {
config := store.Load()
config.Autoscaler.MaxScaleUpRate = 100.0
config.Deployment.ProgressDeadline = 3 * time.Minute
config.Network.DataplaneTrust = netcfg.TrustMinimal
config.Network.SystemInternalTLS = netcfg.EncryptionEnabled
newConfig := store.Load()

if newConfig.Autoscaler.MaxScaleUpRate == 100.0 {
Expand All @@ -76,7 +76,7 @@ func TestStoreImmutableConfig(t *testing.T) {
t.Error("Deployment config is not immutable")
}

if newConfig.Network.DataplaneTrust != netcfg.TrustDisabled {
if newConfig.Network.SystemInternalTLS != netcfg.EncryptionDisabled {
t.Error("Network config is not immutable")
}
}
3 changes: 1 addition & 2 deletions pkg/reconciler/autoscaling/kpa/kpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"go.uber.org/zap"

nv1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1"
netcfg "knative.dev/networking/pkg/config"
"knative.dev/pkg/logging"
pkgmetrics "knative.dev/pkg/metrics"
"knative.dev/pkg/ptr"
Expand Down Expand Up @@ -129,7 +128,7 @@ func (c *Reconciler) ReconcileKind(ctx context.Context, pa *autoscalingv1alpha1.
// When activator CA is enabled, force activator always in path.
// TODO: This is a temporary state and to be fixed.
// See also issues/11906 and issues/12797.
case config.FromContext(ctx).Network.DataplaneTrust != netcfg.TrustDisabled:
case config.FromContext(ctx).Network.SystemInternalTLSEnabled():
mode = nv1alpha1.SKSOperationModeProxy

// If the want == -1 and PA is inactive that implies the autoscaler
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/autoscaling/kpa/kpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func initialScaleZeroASConfig() *autoscalerconfig.Config {

func activatorCertsNetConfig() *netcfg.Config {
nc, _ := netcfg.NewConfigFromMap(map[string]string{
netcfg.DataplaneTrustKey: "minimal",
netcfg.SystemInternalTLSKey: "enabled",
})
return nc
}
Expand All @@ -140,7 +140,7 @@ func defaultConfig() *config.Config {
deployment.ProgressDeadlineKey: progressDeadline.String(),
})
networkConfig, _ := netcfg.NewConfigFromMap(map[string]string{
netcfg.DataplaneTrustKey: "disabled",
netcfg.SystemInternalTLSKey: "disabled",
})

return &config.Config{
Expand Down
5 changes: 2 additions & 3 deletions pkg/reconciler/route/resources/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (

"knative.dev/networking/pkg/apis/networking"
netv1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1"
netcfg "knative.dev/networking/pkg/config"
netheader "knative.dev/networking/pkg/http/header"
ingress "knative.dev/networking/pkg/ingress"
"knative.dev/pkg/kmeta"
Expand Down Expand Up @@ -150,7 +149,7 @@ func makeIngressSpec(
return netv1alpha1.IngressSpec{}, err
}
rule := makeIngressRule(domains, r.Namespace,
visibility, tc.Targets[name], ro.RolloutsByTag(name), networkConfig.DataplaneTrust != netcfg.TrustDisabled)
visibility, tc.Targets[name], ro.RolloutsByTag(name), networkConfig.SystemInternalTLSEnabled())
if featuresConfig.TagHeaderBasedRouting == apicfg.Enabled {
if rule.HTTP.Paths[0].AppendHeaders == nil {
rule.HTTP.Paths[0].AppendHeaders = make(map[string]string, 1)
Expand All @@ -172,7 +171,7 @@ func makeIngressSpec(
// Since names are sorted `DefaultTarget == ""` is the first one,
// so just pass the subslice.
rule.HTTP.Paths = append(
makeTagBasedRoutingIngressPaths(r.Namespace, tc, ro, networkConfig.DataplaneTrust != netcfg.TrustDisabled, names[1:]), rule.HTTP.Paths...)
makeTagBasedRoutingIngressPaths(r.Namespace, tc, ro, networkConfig.SystemInternalTLSEnabled(), names[1:]), rule.HTTP.Paths...)
} else {
// If a request is routed by a tag-attached hostname instead of the tag header,
// the request may not have the tag header "Knative-Serving-Tag",
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/route/resources/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,6 @@ func testContextWithHTTPOption() context.Context {

func testContextWithActivatorCA() context.Context {
cfg := testConfig()
cfg.Network.DataplaneTrust = netcfg.TrustMinimal
cfg.Network.SystemInternalTLS = netcfg.EncryptionEnabled
return config.ToContext(context.Background(), cfg)
}
2 changes: 1 addition & 1 deletion pkg/reconciler/route/resources/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func testConfig() *config.Config {
DefaultIngressClass: "test-ingress-class",
DomainTemplate: netcfg.DefaultDomainTemplate,
TagTemplate: netcfg.DefaultTagTemplate,
DataplaneTrust: netcfg.TrustDisabled,
SystemInternalTLS: netcfg.EncryptionDisabled,
},
Features: &apiConfig.Features{
MultiContainer: apiConfig.Disabled,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ function install() {

if (( ENABLE_TLS )); then
echo "Patch to config-network to enable internal encryption"
toggle_feature dataplane-trust minimal config-network
toggle_feature system-internal-tls Enabled config-network
if [[ "$INGRESS_CLASS" == "kourier.ingress.networking.knative.dev" ]]; then
echo "Point Kourier local gateway to custom server certificates"
toggle_feature cluster-cert-secret server-certs config-kourier
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/autoscale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ func TestTargetBurstCapacity(t *testing.T) {
}

// TODO: Remove this when "activator always stay in path" is eliminated.
dataplaneTrustMode := cm.Data[netcfg.DataplaneTrustKey]
if (dataplaneTrustMode != "" && !strings.EqualFold(dataplaneTrustMode, string(netcfg.TrustDisabled))) || strings.EqualFold(cm.Data[netcfg.InternalEncryptionKey], "true") {
if systemInternalTLS, ok := cm.Data[netcfg.SystemInternalTLSKey]; ok && !strings.EqualFold(systemInternalTLS, string(netcfg.EncryptionDisabled)) {
t.Skip("Skipping TestTargetBurstCapacity as activator always stay in path.")
}

Expand Down
77 changes: 37 additions & 40 deletions vendor/knative.dev/networking/config/config-network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ metadata:
app.kubernetes.io/component: networking
app.kubernetes.io/version: devel
annotations:
knative.dev/example-checksum: "cfad3b9a"
knative.dev/example-checksum: "b2698fe8"
data:
_example: |
################################
Expand Down Expand Up @@ -73,7 +73,7 @@ data:
# namespace-wildcard-cert-selector: {}
#
# Useful labels include the "kubernetes.io/metadata.name" label to
# avoid provisioning a certifcate for the "kube-system" namespaces.
# avoid provisioning a certificate for the "kube-system" namespaces.
# Use the following selector to match pre-1.0 behavior of using
# "networking.knative.dev/disableWildcardCert" to exclude namespaces:
#
Expand Down Expand Up @@ -114,16 +114,45 @@ data:
# domain-template above to determine the full URL for the tag.
tag-template: "{{.Tag}}-{{.Name}}"

# Controls whether TLS certificates are automatically provisioned and
# installed in the Knative ingress to terminate external TLS connection.
# 1. Enabled: enabling auto-TLS feature.
# 2. Disabled: disabling auto-TLS feature.
# auto-tls is deprecated and replaced by external-domain-tls
auto-tls: "Disabled"

# Controls whether TLS certificates are automatically provisioned and
# installed in the Knative ingress to terminate TLS connections
# for cluster external domains (like: app.example.com)
# - Enabled: enables the TLS certificate provisioning feature for cluster external domains.
# - Disabled: disables the TLS certificate provisioning feature for cluster external domains.
external-domain-tls: "Disabled"

# Controls weather TLS certificates are automatically provisioned and
# installed in the Knative ingress to terminate TLS connections
# for cluster local domains (like: app.namespace.svc.cluster.local)
# - Enabled: enables the TLS certificate provisioning feature for cluster cluster-local domains.
# - Disabled: disables the TLS certificate provisioning feature for cluster cluster local domains.
# NOTE: This flag is in an alpha state and is mostly here to enable internal testing
# for now. Use with caution.
cluster-local-domain-tls: "Disabled"

# internal-encryption is deprecated and replaced by system-internal-tls
internal-encryption: "false"

# system-internal-tls controls weather TLS encryption is used for connections between
# the internal components of Knative:
# - ingress to activator
# - ingress to queue-proxy
# - activator to queue-proxy
#
# Possible values for this flag are:
# - Enabled: enables the TLS certificate provisioning feature for cluster cluster-local domains.
# - Disabled: disables the TLS certificate provisioning feature for cluster cluster local domains.
# NOTE: This flag is in an alpha state and is mostly here to enable internal testing
# for now. Use with caution.
system-internal-tls: "Disabled"

# Controls the behavior of the HTTP endpoint for the Knative ingress.
# It requires auto-tls to be enabled.
# 1. Enabled: The Knative ingress will be able to serve HTTP connection.
# 2. Redirected: The Knative ingress will send a 301 redirect for all
# - Enabled: The Knative ingress will be able to serve HTTP connection.
# - Redirected: The Knative ingress will send a 301 redirect for all
# http connections, asking the clients to use HTTPS.
#
# "Disabled" option is deprecated.
Expand Down Expand Up @@ -172,35 +201,3 @@ data:
# fronting Knative with an external loadbalancer that deals with TLS termination and
# Knative doesn't know about that otherwise.
default-external-scheme: "http"

# internal-encryption is deprecated and replaced by dataplane-trust and controlplane-trust
# internal-encryption indicates whether internal traffic is encrypted or not.
#
# NOTE: This flag is in an alpha state and is mostly here to enable internal testing
# for now. Use with caution.
internal-encryption: "false"

# dataplane-trust indicates the level of trust established in the knative data-plane.
# dataplane-trust = "disabled" (the default) - uses no encryption for internal data plane traffic
# Using any other value ensures that the following traffic is encrypted using TLS:
# - ingress to activator
# - ingress to queue-proxy
# - activator to queue-proxy
#
# dataplane-trust = "minimal" ensures data messages are encrypted, Kingress authenticate that the receiver is a Ksvc
# dataplane-trust = "enabled" same as "minimal" and in addition, Kingress authenticate that Ksvc is at the correct namespace
# dataplane-trust = "mutual" same as "enabled" and in addition, Ksvc authenticate that the messages come from the Kingress
# dataplane-trust = "identity" same as "mutual" with Kingress adding a trusted sender identity to the message
#
# NOTE: This flag is in an alpha state and is mostly here to enable internal testing for now. Use with caution.
dataplane-trust: "disabled"

# controlplane-trust indicates the level of trust established in the knative control-plane.
# controlplane-trust = "disabled" (the default) - uses no encryption for internal control plane traffic
# Using any other value ensures that control traffic is encrypted using TLS.
#
# controlplane-trust = "enabled" ensures control messages are encrypted using TLS (client authenticate the server)
# controlplane-trust = "mutual" ensures control messages are encrypted using mTLS (client and server authenticate each other)
#
# NOTE: This flag is in an alpha state and is mostly here to enable internal testing for now. Use with caution.
controlplane-trust: "disabled"
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var (
IngressClassAnnotationKey,
CertificateClassAnnotationKey,
DisableAutoTLSAnnotationKey,
DisableExternalDomainTLSAnnotationKey,
HTTPOptionAnnotationKey,

IngressClassAnnotationAltKey,
Expand Down
21 changes: 18 additions & 3 deletions vendor/knative.dev/networking/pkg/apis/networking/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,17 @@ const (

// DisableAutoTLSAnnotationKey is the annotation key attached to a Knative Service/DomainMapping
// to indicate that AutoTLS should not be enabled for it.
// Deprecated: use DisableExternalDomainTLSAnnotationKey instead.
DisableAutoTLSAnnotationKey = PublicGroupName + "/disableAutoTLS"

// DisableAutoTLSAnnotationAltKey is an alternative casing to DisableAutoTLSAnnotationKey
// Deprecated: use DisableExternalDomainTLSAnnotationKey instead.
DisableAutoTLSAnnotationAltKey = PublicGroupName + "/disable-auto-tls"

// DisableExternalDomainTLSAnnotationKey is the annotation key attached to a Knative Service/DomainMapping
// to indicate that external-domain-tls should not be enabled for it.
DisableExternalDomainTLSAnnotationKey = PublicGroupName + "/disable-external-domain-tls"

// HTTPOptionAnnotationKey is the annotation key attached to a Knative Service/DomainMapping
// to indicate the HTTP option of it.
HTTPOptionAnnotationKey = PublicGroupName + "/httpOption"
Expand Down Expand Up @@ -130,9 +136,15 @@ var (
CertificateClassAnnotationAltKey,
}

DisableAutoTLSAnnotation = kmap.KeyPriority{
// Deprecated: use DisableExternalDomainTLSAnnotation instead.
DisableAutoTLSAnnotation = DisableExternalDomainTLSAnnotation

DisableExternalDomainTLSAnnotation = kmap.KeyPriority{
// backward compatibility
DisableAutoTLSAnnotationKey,
DisableAutoTLSAnnotationAltKey,

DisableExternalDomainTLSAnnotationKey,
}

HTTPProtocolAnnotation = kmap.KeyPriority{
Expand All @@ -153,6 +165,9 @@ func GetHTTPProtocol(annotations map[string]string) (val string) {
return HTTPProtocolAnnotation.Value(annotations)
}

func GetDisableAutoTLS(annotations map[string]string) (val string) {
return DisableAutoTLSAnnotation.Value(annotations)
// Deprecated: use GetDisableExternalDomainTLS instead.
var GetDisableAutoTLS = GetDisableExternalDomainTLS

func GetDisableExternalDomainTLS(annotations map[string]string) (val string) {
return DisableExternalDomainTLSAnnotation.Value(annotations)
}
44 changes: 21 additions & 23 deletions vendor/knative.dev/networking/pkg/certificates/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,39 @@ import "strings"

const (
Organization = "knative.dev"
//nolint:all

// nolint:all
LegacyFakeDnsName = "data-plane." + Organization
//nolint:all
// Deprecated: FakeDnsName is deprecated. Please use the DataPlaneRoutingName or DataPlaneUserName function.
FakeDnsName = LegacyFakeDnsName
dataPlaneUserPrefix = "kn-user-"
dataPlaneRoutingPrefix = "kn-routing-"
ControlPlaneName = "kn-control"

//These keys are meant to line up with cert-manager, see
//https://cert-manager.io/docs/usage/certificate/#additional-certificate-output-formats

// nolint:all
// Deprecated: FakeDnsName is deprecated.
// Please use the DataPlaneRoutingSAN for calls to the Activator
// and the DataPlaneUserSAN function for calls to a Knative-Service via Queue-Proxy.
FakeDnsName = LegacyFakeDnsName

dataPlaneUserPrefix = "kn-user-"
DataPlaneRoutingSAN = "kn-routing"

// These keys are meant to line up with cert-manager, see
// https://cert-manager.io/docs/usage/certificate/#additional-certificate-output-formats
CaCertName = "ca.crt"
CertName = "tls.crt"
PrivateKeyName = "tls.key"

//These should be able to be deprecated some time in the future when the new names are fully adopted
// These should be able to be deprecated some time in the future when the new names are fully adopted
// #nosec
// Deprecated: please use CaCertName instead.
SecretCaCertKey = "ca-cert.pem"
// #nosec
// Deprecated: please use CertName instead.
SecretCertKey = "public-cert.pem"
// #nosec
// Deprecated: please use PrivateKeyName instead.
SecretPKKey = "private-key.pem"
)

// DataPlaneRoutingName constructs a san for a data-plane-routing certificate
// Accepts a routingId - a unique identifier used as part of the san (default is "0" used when an empty routingId is provided)
func DataPlaneRoutingName(routingID string) string {
if routingID == "" {
routingID = "0"
}
return dataPlaneRoutingPrefix + strings.ToLower(routingID)
}

// DataPlaneUserName constructs a san for a data-plane-user certificate
// Accepts a namespace - the namespace for which the certificate was created
func DataPlaneUserName(namespace string) string {
// DataPlaneUserSAN constructs a SAN for a data-plane-user certificate in the
// target namespace of a Knative Service.
func DataPlaneUserSAN(namespace string) string {
return dataPlaneUserPrefix + strings.ToLower(namespace)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package sample
package reconciler

import (
"bytes"
Expand Down Expand Up @@ -43,9 +43,6 @@ const (
expirationInterval = time.Hour * 24 * 30 // 30 days
rotationThreshold = 24 * time.Hour

// certificates used by control elements such as autoscaler, ingress controller
controlPlaneSecretType = "control-plane"

// certificates used by trusted data routing elements such as activator, ingress gw
dataPlaneRoutingSecretType = "data-plane-routing"

Expand Down Expand Up @@ -105,14 +102,10 @@ func (r *reconciler) ReconcileKind(ctx context.Context, secret *corev1.Secret) p
// Reconcile the provided secret
var sans []string
switch secret.Labels[r.secretTypeLabelName] {
case controlPlaneSecretType:
sans = []string{certificates.ControlPlaneName, certificates.LegacyFakeDnsName}
case dataPlaneRoutingSecretType:
routingID := secret.Labels[secretRoutingID]
san := certificates.DataPlaneRoutingName(routingID)
sans = []string{san, certificates.LegacyFakeDnsName}
sans = []string{certificates.DataPlaneRoutingSAN, certificates.LegacyFakeDnsName}
case dataPlaneUserSecretType:
sans = []string{certificates.DataPlaneUserName(secret.Namespace), certificates.LegacyFakeDnsName}
sans = []string{certificates.DataPlaneUserSAN(secret.Namespace), certificates.LegacyFakeDnsName}
case dataPlaneDeprecatedSecretType:
sans = []string{certificates.LegacyFakeDnsName}
default:
Expand Down
Loading