Skip to content

Commit

Permalink
add tls support for the ingress
Browse files Browse the repository at this point in the history
  • Loading branch information
test committed Oct 27, 2022
1 parent a694945 commit f367c53
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
16 changes: 16 additions & 0 deletions apis/dash/v1alpha1/dashapplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ type Ingress struct {
// when using PathType with value "Exact" or "Prefix".
// +optional
Path string `json:"path,omitempty"`
// TLS configuration.
// +optional
TLS *IngressTLS `json:"tls,omitempty"`
}

type IngressTLS struct {
// Hosts included in the TLS certificate. The values in
// +optional
Host string `json:"hosts,omitempty"`
// SecretName is the name of the secret used to terminate TLS traffic on
// port 443. Field is left optional to allow TLS routing based on SNI
// hostname alone. If the SNI host in a listener conflicts with the "Host"
// header field used by an IngressRule, the SNI host is used for termination
// and value of the Host header is used for routing.
// +optional
SecretName string `json:"secretName,omitempty" protobuf:"bytes,2,opt,name=secretName"`
}

type DashApplicationStatus struct {
Expand Down
20 changes: 20 additions & 0 deletions apis/dash/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions config/crd/bases/dash.plural.sh_dashapplications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,22 @@ spec:
with a '/' and must be present when using PathType with value
"Exact" or "Prefix".
type: string
tls:
description: TLS configuration.
properties:
hosts:
description: Hosts included in the TLS certificate. The values
in
type: string
secretName:
description: SecretName is the name of the secret used to
terminate TLS traffic on port 443. Field is left optional
to allow TLS routing based on SNI hostname alone. If the
SNI host in a listener conflicts with the "Host" header
field used by an IngressRule, the SNI host is used for termination
and value of the Host header is used for routing.
type: string
type: object
type: object
labels:
additionalProperties:
Expand Down
8 changes: 8 additions & 0 deletions pkg/controller/dash_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ func genIngress(dashApp *dashv1alpha1.DashApplication) *networkingv1.Ingress {
},
},
}
if dashApp.Spec.Ingress.TLS != nil {
ingress.Spec.TLS = []networkingv1.IngressTLS{
{
Hosts: []string{dashApp.Spec.Ingress.TLS.Host},
SecretName: dashApp.Spec.Ingress.TLS.SecretName,
},
}
}

return ingress
}
Expand Down

0 comments on commit f367c53

Please sign in to comment.