Skip to content

Commit

Permalink
Use subpath for inbox server
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Sep 6, 2024
1 parent 33b95df commit cabcfdb
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 57 deletions.
19 changes: 14 additions & 5 deletions apis/installer/v1alpha1/inbox_server_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,18 @@ type InboxServerSpec struct {
}

type DnsSpec struct {
Domain string `json:"domain"`
EmailDomain string `json:"emailDomain"`
TargetIPs []string `json:"targetIPs"`
}

type JamesSpec struct {
ReplicaJmapInstanceCount int `json:"replicaJmapInstanceCount"`
ReplicaImapSmtpInstanceCount int `json:"replicaImapSmtpInstanceCount"`
Image string `json:"image"`
Env JamesEnv `json:"env"`
TLS TLSSpec `json:"tls"`
ReplicaJmapInstanceCount int `json:"replicaJmapInstanceCount"`
ReplicaImapSmtpInstanceCount int `json:"replicaImapSmtpInstanceCount"`
Image string `json:"image"`
Env JamesEnv `json:"env"`
TLS TLSSpec `json:"tls"`
Secret *JamesSecret `json:"secret,omitempty"`
}

type JamesEnv struct {
Expand All @@ -112,6 +114,13 @@ type JamesEnv struct {
JamesResources core.ResourceRequirements `json:"jamesResources"`
}

type JamesSecret struct {
AdminJWTPublicKey string `json:"adminJWTPublicKey"`
JwtPublicKey string `json:"jwtPublicKey"`
JwtPrivateKey string `json:"jwtPrivateKey"`
DkimPrivateKey string `json:"dkimPrivateKey"`
}

type GlowrootSpec struct {
Enabled bool `json:"enabled"`
}
Expand Down
20 changes: 20 additions & 0 deletions apis/installer/v1alpha1/zz_generated.deepcopy.go

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

5 changes: 3 additions & 2 deletions charts/inbox-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ The following table lists the configurable parameters of the `inbox-server` char

| Parameter | Description | Default |
|-------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------|
| dns.emailDomain | # Default domain for all emailing components jmapUrl: "jmap.example.com" adminUrl: "admin.example.com" smtpHostname: "smtp.example.com" | <code>"example.com"</code> |
| dns.domain | # Default domain for all emailing components jmapUrl: "jmap.example.com" adminUrl: "admin.example.com" smtpHostname: "smtp.example.com" | <code>"example.com"</code> |
| dns.emailDomain | in ip mode, the emailDomain is ace.internal, otherwise same as domain | <code>"example.com"</code> |
| dns.targetIPs | | <code>[]</code> |
| james.replicaJmapInstanceCount | | <code>1</code> |
| james.replicaImapSmtpInstanceCount | | <code>1</code> |
Expand Down Expand Up @@ -132,7 +133,7 @@ The following table lists the configurable parameters of the `inbox-server` char
Specify each parameter using the `--set key=value[,key=value]` argument to `helm upgrade -i`. For example:

```bash
$ helm upgrade -i inbox-server appscode/inbox-server -n monitoring --create-namespace --version=v2024.5.3 --set dns.emailDomain="example.com"
$ helm upgrade -i inbox-server appscode/inbox-server -n monitoring --create-namespace --version=v2024.5.3 --set dns.domain="example.com"
```

Alternatively, a YAML file that specifies the values for the parameters can be provided while
Expand Down
32 changes: 7 additions & 25 deletions charts/inbox-server/templates/james/james-admin-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@
{{- $fullName := printf "%s-admin" (include "inbox-server.fullname" .) -}}
{{- $svcPort := 8000 -}}

{{- if and .Values.adminIngress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.adminIngress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.adminIngress.annotations "kubernetes.io/ingress.class" .Values.adminIngress.className}}
{{- end }}
{{- end }}

{{- if and (not (hasKey .Values.adminIngress.annotations "external-dns.alpha.kubernetes.io/target")) .Values.dns.targetIPs }}
{{- $_ := set .Values.adminIngress.annotations "external-dns.alpha.kubernetes.io/target" (join "," .Values.dns.targetIPs)}}
{{- end }}
{{- $_ := set .Values.ingress.annotations "nginx.ingress.kubernetes.io/use-regex" "true" }}
{{- $_ := set .Values.ingress.annotations "nginx.ingress.kubernetes.io/rewrite-target" "/$2" }}

{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
Expand All @@ -30,31 +20,23 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.adminIngress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
{{- if .Values.adminIngress.className }}
ingressClassName: {{ .Values.adminIngress.className }}
{{- end }}
{{- if .Values.adminIngress.tls }}
tls:
- hosts:
- inbox-admin.{{ .Values.dns.emailDomain }}
- hosts: {{ list .Values.dns.domain | compact | toJson }}
{{- toYaml .Values.adminIngress.tls | nindent 4 }}
{{- end }}
rules:
- host: inbox-admin.{{ .Values.dns.emailDomain }}
- host: {{ .Values.dns.domain }}
http:
paths:
- path: /
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
pathType: Prefix
{{- end }}
- path: /inbox-admin(/|$)(.*)
pathType: ImplementationSpecific
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
32 changes: 7 additions & 25 deletions charts/inbox-server/templates/james/jmap-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@
{{- $fullName := printf "%s-jmap" (include "inbox-server.fullname" .) -}}
{{- $svcPort := 80 -}}

{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}

{{- if and (not (hasKey .Values.ingress.annotations "external-dns.alpha.kubernetes.io/target")) .Values.dns.targetIPs }}
{{- $_ := set .Values.ingress.annotations "external-dns.alpha.kubernetes.io/target" (join "," .Values.dns.targetIPs)}}
{{- end }}
{{- $_ := set .Values.ingress.annotations "nginx.ingress.kubernetes.io/use-regex" "true" }}
{{- $_ := set .Values.ingress.annotations "nginx.ingress.kubernetes.io/rewrite-target" "/$2" }}

{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
Expand All @@ -30,31 +20,23 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
{{- if .Values.ingress.className }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
- hosts:
- jmap.{{ .Values.dns.emailDomain }}
- hosts: {{ list .Values.dns.domain | compact | toJson }}
{{- toYaml .Values.ingress.tls | nindent 4 }}
{{- end }}
rules:
- host: jmap.{{ .Values.dns.emailDomain }}
- host: {{ .Values.dns.domain }}
http:
paths:
- path: /
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
pathType: Prefix
{{- end }}
- path: /jmap(/|$)(.*)
pathType: ImplementationSpecific
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
19 changes: 19 additions & 0 deletions charts/inbox-server/values.openapiv3_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1065,13 +1065,16 @@ properties:
type: object
dns:
properties:
domain:
type: string
emailDomain:
type: string
targetIPs:
items:
type: string
type: array
required:
- domain
- emailDomain
- targetIPs
type: object
Expand Down Expand Up @@ -1221,6 +1224,22 @@ properties:
type: integer
replicaJmapInstanceCount:
type: integer
secret:
properties:
adminJWTPublicKey:
type: string
dkimPrivateKey:
type: string
jwtPrivateKey:
type: string
jwtPublicKey:
type: string
required:
- adminJWTPublicKey
- dkimPrivateKey
- jwtPrivateKey
- jwtPublicKey
type: object
tls:
properties:
secretName:
Expand Down
2 changes: 2 additions & 0 deletions charts/inbox-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ dns:
# jmapUrl: "jmap.example.com"
# adminUrl: "admin.example.com"
# smtpHostname: "smtp.example.com"
domain: "example.com"
# in ip mode, the emailDomain is ace.internal, otherwise same as domain
emailDomain: "example.com"
targetIPs: []

Expand Down

0 comments on commit cabcfdb

Please sign in to comment.