Skip to content

Commit

Permalink
add mini tls delegation chart
Browse files Browse the repository at this point in the history
  • Loading branch information
louiseschmidtgen committed Jun 10, 2024
1 parent a19d225 commit af0e7bb
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 4 deletions.
23 changes: 23 additions & 0 deletions k8s/manifests/charts/ck-ingress-tls/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions k8s/manifests/charts/ck-ingress-tls/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: ck-ingress-tls
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: projectcontour.io/v1
kind: TLSCertificateDelegation
metadata:
name: ck-ingress-tls-delegation
namespace: projectcontour-root
spec:
delegations:
- secretName: {{ .Values.defaultTLSSecret}}
targetNamespaces:
- "*"
4 changes: 4 additions & 0 deletions k8s/manifests/charts/ck-ingress-tls/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Default values for ck-ingress.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
defaultTLSSecret: ""
22 changes: 18 additions & 4 deletions src/k8s/pkg/k8sd/features/contour/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ func ApplyIngress(ctx context.Context, snap snap.Snap, ingress types.Ingress, ne
var values map[string]any
if ingress.GetEnabled() {
values = map[string]any{
"envoy-service-namespace": "projectcontour",
"envoy-service-namespace": "projectcontour", //TODO: Can we remove this?
"envoy-service-name": "envoy",
// "tls": map[string]any{
// "envoy-client-certificate": ingress.GetDefaultTLSSecret(), //TODO: I think this is wrong
// },
}
}

Expand All @@ -49,6 +46,23 @@ func ApplyIngress(ctx context.Context, snap snap.Snap, ingress types.Ingress, ne
if err := rolloutRestartContour(ctx, snap, 3); err != nil {
return fmt.Errorf("failed to rollout restart contour to apply ingress: %w", err)
}

// Install the delegation resource for the default TLS secret.
// The default TLS secret is created by the user created,
// and gets set via k8s set defaultTLSSecret=bananas.
if ingress.GetDefaultTLSSecret() != "" {
values = map[string]any{
"defaultTLSSecret": ingress.GetDefaultTLSSecret(),
}
if _, err := m.Apply(ctx, chartDefaultTLS, helm.StatePresent, values); err != nil {
return fmt.Errorf("failed to install the delegation resource for default TLS secret: %w", err)
}
} else {
if _, err := m.Apply(ctx, chartDefaultTLS, helm.StateDeleted, nil); err != nil {
return fmt.Errorf("failed to uninstall the delegation resource for default TLS secret: %w", err)
}
}

return nil
}

Expand Down

0 comments on commit af0e7bb

Please sign in to comment.