Skip to content

Commit

Permalink
feat: make optional the service
Browse files Browse the repository at this point in the history
  • Loading branch information
apetrovYa committed Feb 8, 2024
1 parent 4b28710 commit 7901313
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ should they need to keep track of the set of backends themselves.
Ref: https://kubernetes.io/docs/concepts/services-networking/service/
*/}}
{{- if .Values.include -}}
{{- if or .Values.service.ports .Values.service.additionalPorts }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -35,3 +36,4 @@ spec:
type: {{ include "app.serviceType" . }}
ports: {{- include "app.servicePorts" . | nindent 4 }}
{{- end -}}
{{- end -}}
40 changes: 37 additions & 3 deletions charts/kubernetes-stateful-chart/tests/service/manifest_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ tests:
- it: should be created by default
asserts:
- hasDocuments:
count: 1
- isKind:
of: Service
count: 0
- it: should not be created if the current application is not included
set:
include: false
Expand All @@ -17,6 +15,10 @@ tests:
- it: should allow to set a custom name
set:
service.name: "custom-name"
service.ports:
- name: api
port: 8080
targetPort: 8080
asserts:
- matchRegex:
path: metadata.name
Expand Down Expand Up @@ -58,27 +60,43 @@ tests:
- it: should allow to implement a ClusterIP type of service without additional service ports
set:
service.type: "ClusterIP"
service.ports:
- name: api
port: 8080
targetPort: 8080
asserts:
- matchRegex:
path: spec.type
pattern: ClusterIP
- it: should allow to implement a NodePort type of service
set:
service.type: "NodePort"
service.ports:
- name: api
port: 8080
targetPort: 8080
asserts:
- matchRegex:
path: spec.type
pattern: NodePort
- it: should allow to implement a public LoadBalancer type of service
set:
service.type: "LoadBalancer"
service.ports:
- name: api
port: 8080
targetPort: 8080
asserts:
- matchRegex:
path: spec.type
pattern: LoadBalancer
- it: should allow to implement a public LoadBalancer type of service with labels and annotations
set:
service.type: "LoadBalancer"
service.ports:
- name: api
port: 8080
targetPort: 8080
service.labels:
label_one: one
label_two: two
Expand Down Expand Up @@ -130,6 +148,10 @@ tests:
- it: should allow to implement a private LoadBalancer type of service for GCP
set:
service.type: "LoadBalancer"
service.ports:
- name: api
port: 8080
targetPort: 8080
service.additionalAnnotations:
cloud.google.com/load-balancer-type: "Internal"
asserts:
Expand All @@ -144,6 +166,10 @@ tests:
- it: should allow to implement a private LoadBalancer type of service for AWS
set:
service.type: "LoadBalancer"
service.ports:
- name: api
port: 8080
targetPort: 8080
service.additionalAnnotations:
service.beta.kubernetes.io/aws-load-balancer-internal: "true"
asserts:
Expand All @@ -158,6 +184,10 @@ tests:
- it: should allow to implement a private LoadBalancer type of service for AWS with SSL offloading
set:
service.type: "LoadBalancer"
service.ports:
- name: api
port: 8080
targetPort: 8080
service.additionalAnnotations:
service.beta.kubernetes.io/aws-load-balancer-internal: "true"
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012
Expand All @@ -178,6 +208,10 @@ tests:
- it: should allow to implement a private LoadBalancer type of service for Azure
set:
service.type: "LoadBalancer"
service.ports:
- name: api
port: 8080
targetPort: 8080
service.additionalAnnotations:
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
asserts:
Expand Down
4 changes: 2 additions & 2 deletions charts/kubernetes-stateful-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ name: ""
##
image:
registry: "docker.io"
repository: "bitnami/nginx"
tag: "1.24.0-debian-11-r159"
repository: "docker/whalesay"
tag: "latest"
## imagePullPolicy policy
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
##
Expand Down

0 comments on commit 7901313

Please sign in to comment.