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

feat: expose the HTTP port in the service #62

Merged
merged 3 commits into from
Apr 25, 2024
Merged
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
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,14 @@ chart and deletes the release.
| redisDependencyEnabled | bool | `true` | Install redis as a depending chart |
| replicaCount | int | `2` | If autoscaling is disabled this will define the number of pods to run |
| service.annotations | object | `{}` | Annotations to add to the service |
| service.name | string | `"https"` | Configure passbolt service port name |
| service.port | int | `443` | Configure passbolt service port |
| service.targetPort | int | `443` | Configure passbolt service targetPort |
| service.ports | object | `{"http":{"name":"http","port":80,"targetPort":80},"https":{"name":"https","port":443,"targetPort":443}}` | Configure the service ports |
| service.ports.http.name | string | `"http"` | Configure passbolt HTTP service port name |
| service.ports.http.port | int | `80` | Configure passbolt HTTP service port |
| service.ports.http.targetPort | int | `80` | Configure passbolt HTTP service targetPort |
| service.ports.https | object | `{"name":"https","port":443,"targetPort":443}` | Configure the HTTPS port |
| service.ports.https.name | string | `"https"` | Configure passbolt HTTPS service port name |
| service.ports.https.port | int | `443` | Configure passbolt HTTPS service port |
| service.ports.https.targetPort | int | `443` | Configure passbolt HTTPS service targetPort |
| service.type | string | `"ClusterIP"` | Configure passbolt service type |
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
Expand Down
2 changes: 1 addition & 1 deletion templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "passbolt-library.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "passbolt-library.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
echo http://$SERVICE_IP:{{ .Values.service.ports.http.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "passbolt-library.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
Expand Down
4 changes: 2 additions & 2 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ spec:
imagePullPolicy: {{ .Values.app.image.pullPolicy }}
ports:
- name: https
containerPort: {{ .Values.service.targetPort }}
containerPort: {{ .Values.service.ports.https.targetPort }}
protocol: TCP
- name: http
containerPort: 80
containerPort: {{ .Values.service.ports.http.targetPort }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
Expand Down
2 changes: 1 addition & 1 deletion templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{- $action := "common" -}}
{{- $Name := include "passbolt-library.fullname" . -}}
{{- $fullName := printf "%s-%s-%s" $Name $type $action -}}
{{- $svcPort := .Values.service.port -}}
{{- $svcPort := .Values.service.ports.http.port -}}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
Expand Down
10 changes: 7 additions & 3 deletions templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ metadata:
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port | default 443 }}
targetPort: {{ .Values.service.targetPort | default 443 }}
- port: {{ .Values.service.ports.https.port | default 443 }}
targetPort: {{ .Values.service.ports.https.targetPort | default 443 }}
protocol: TCP
name: {{ .Values.service.name | default "https" }}
name: {{ .Values.service.ports.https.name | default "https" }}
- port: {{ .Values.service.ports.http.port | default 80 }}
targetPort: {{ .Values.service.ports.http.targetPort | default 80 }}
protocol: TCP
name: {{ .Values.service.ports.http.name | default "http" }}
selector:
{{- include "passbolt-library.selectorLabels" . | nindent 4 }}
20 changes: 11 additions & 9 deletions tests/deployment_http_port_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@ release:
values:
- values-test.yaml
tests:
- it: should match port with the one in values
- it: should match ports with the ones in values
templates:
- deployment.yaml
set:
service.targetPort: 5000
redis.auth.enabled: true
redis.replica.replicaCount: 2
autoscaling.enabled: false
app.cache.redis.sentinelProxy.enabled: false
app.cache.redis.sentinelProxy.image.repository: haproxy
app.cache.redis.sentinelProxy.image.tag: latest
service.ports.https.targetPort: 5443
service.ports.http.targetPort: 5080
asserts:
- contains:
path: spec.template.spec.containers[0].ports
content:
name: https
containerPort: 5000
containerPort: 5443
count: 1
any: true
- contains:
path: spec.template.spec.containers[0].ports
content:
name: http
containerPort: 5080
count: 1
any: true
21 changes: 21 additions & 0 deletions tests/ingress_service_port_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
suite: ingress service port
release:
name: test
values:
- values-test.yaml
tests:
- it: should set the port of the backend to the configured HTTP port
templates:
- ingress.yaml
set:
service.ports.http.port: 5080
ingress.enabled: true
asserts:
- isSubset:
path: spec.rules[0].http.paths[0].backend.service
content:
name: test-passbolt
port:
number: 5080
any: true
36 changes: 36 additions & 0 deletions tests/service_http_port_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
suite: service ports
release:
name: test
values:
- values-test.yaml
tests:
- it: should match ports with the ones in values
templates:
- service.yaml
set:
service.ports.https.port: 5443
service.ports.https.targetPort: 5443
service.ports.https.name: myhttps
service.ports.http.port: 5080
service.ports.http.targetPort: 5080
service.ports.http.name: myhttp
asserts:
- contains:
path: spec.ports
content:
port: 5443
targetPort: 5443
protocol: TCP
name: myhttps
count: 1
any: true
- contains:
path: spec.ports
content:
port: 5080
targetPort: 5080
protocol: TCP
name: myhttp
count: 1
any: true
23 changes: 17 additions & 6 deletions tests/values-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,25 @@ podSecurityContext: {}
service:
# -- Configure passbolt service type
type: ClusterIP
# -- Configure passbolt service port
port: 443
# -- Configure passbolt service targetPort
targetPort: 443
# -- Configure passbolt service port name
name: https
# -- Annotations to add to the service
annotations: {}
# -- Configure the service ports
ports:
# -- Configure the HTTPS port
https:
# -- Configure passbolt HTTPS service port
port: 443
# -- Configure passbolt HTTPS service targetPort
targetPort: 443
# -- Configure passbolt HTTPS service port name
name: https
http:
# -- Configure passbolt HTTP service port
port: 80
# -- Configure passbolt HTTP service targetPort
targetPort: 80
# -- Configure passbolt HTTP service port name
name: http

ingress:
# -- Enable passbolt ingress
Expand Down
23 changes: 17 additions & 6 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,25 @@ podSecurityContext:
service:
# -- Configure passbolt service type
type: ClusterIP
# -- Configure passbolt service port
port: 443
# -- Configure passbolt service targetPort
targetPort: 443
# -- Configure passbolt service port name
name: https
# -- Annotations to add to the service
annotations: {}
# -- Configure the service ports
ports:
# -- Configure the HTTPS port
https:
# -- Configure passbolt HTTPS service port
port: 443
# -- Configure passbolt HTTPS service targetPort
targetPort: 443
# -- Configure passbolt HTTPS service port name
name: https
http:
# -- Configure passbolt HTTP service port
port: 80
# -- Configure passbolt HTTP service targetPort
targetPort: 80
# -- Configure passbolt HTTP service port name
name: http

tls:
# -- Generates a secret with a self-signed cerfificate that is injected on ingress and passbolt container
Expand Down