Skip to content

Commit

Permalink
feat(chart): add service.yaml (#253)
Browse files Browse the repository at this point in the history
* feat(chart): add service.yaml

* fix(chart): semverCompare

* fix(chart): schema enum types for ipDualStack setting
  • Loading branch information
sanadhis authored Nov 7, 2024
1 parent 02b2c20 commit 1e8e38c
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 3 deletions.
6 changes: 3 additions & 3 deletions charts/caddy-ingress-controller/templates/loadbalancer.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{- if .Values.minikube }}
# we don't need a loadbalancer for local deployment purposes
{{ else }}
{{- if .Values.loadBalancer.enabled }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -14,7 +12,9 @@ metadata:
{{- include "caddy-ingress-controller.labels" . | nindent 4 }}
spec:
type: "LoadBalancer"
{{- if (semverCompare "<= 1.24.0" .Capabilities.KubeVersion.Version) }}
loadBalancerIP: {{ .Values.loadBalancer.loadBalancerIP }} #Deprecated in Kubernetes v1.24
{{- end }}
externalTrafficPolicy: {{ .Values.loadBalancer.externalTrafficPolicy }}
ports:
- name: http
Expand Down
35 changes: 35 additions & 0 deletions charts/caddy-ingress-controller/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{- if not .Values.loadBalancer.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "caddy-ingress-controller.fullname" . }}
namespace: {{ .Release.Namespace }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "caddy-ingress-controller.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
{{- if .Values.service.ipDualStack.enabled }}
ipFamilies: {{ toYaml .Values.service.ipDualStack.ipFamilies | nindent 4 }}
ipFamilyPolicy: {{ .Values.service.ipDualStack.ipFamilyPolicy }}
{{- end }}
internalTrafficPolicy: {{ .Values.service.internalTrafficPolicy }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
{{- if and (eq .Values.service.type "ClusterIP") .Values.service.clusterIP }}
clusterIP: "{{ .Values.service.clusterIP }}"
{{- end }}
ports:
- name: http
port: 80
protocol: TCP
targetPort: http
- name: https
port: 443
protocol: TCP
targetPort: https
selector:
{{- include "caddy-ingress-controller.selectorLabels" . | nindent 4 }}
{{- end }}
77 changes: 77 additions & 0 deletions charts/caddy-ingress-controller/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,83 @@
}
}
},
"service": {
"$id": "#/properties/service",
"type": "object",
"required": [
"type",
"ipDualStack"
],
"properties": {
"internalTrafficPolicy": {
"$id": "#/properties/service/properties/internalTrafficPolicy",
"type": "string",
"enum": [
"Cluster",
"Local"
]
},
"externalTrafficPolicy": {
"$id": "#/properties/service/properties/externalTrafficPolicy",
"type": "string",
"enum": [
"Cluster",
"Local"
]
},
"annotations": {
"$id": "#/properties/service/properties/annotations",
"type": "object"
},
"type": {
"$id": "#/properties/service/properties/type",
"type": "string",
"enum": [
"ClusterIP",
"NodePort",
"LoadBalancer",
"ExternalName"
]
},
"clusterIP": {
"$id": "#/properties/service/properties/clusterIP",
"type": "string"
},
"ipDualStack": {
"$id": "#/properties/service/properties/name",
"type": "object",
"required": [
"enabled"
],
"properties": {
"enabled": {
"$id": "#/properties/service/properties/ipDualStack/properties/enabled",
"type": "boolean"
},
"ipFamilies": {
"$id": "#/properties/service/properties/ipDualStack/properties/ipFamilies",
"type": "array",
"items": {
"type": "string",
"enum": [
"IPv4",
"IPv6"
]
}
},
"ipFamilyPolicy": {
"$id": "#/properties/service/properties/ipDualStack/properties/ipFamilyPolicy",
"type": "string",
"enum": [
"SingleStack",
"PreferDualStack",
"RequireDualStack"
]
}
}
}
}
},
"serviceAccount": {
"$id": "#/properties/serviceAccount",
"type": "object",
Expand Down
21 changes: 21 additions & 0 deletions charts/caddy-ingress-controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ingressController:
# onDemandAsk:

loadBalancer:
enabled: true
# Deprecated in Kubernetes v1.24
loadBalancerIP:
# Set to 'Local' to maintain the client's IP on inbound connections
Expand All @@ -51,6 +52,26 @@ loadBalancer:
# service.beta.kubernetes.io/aws-load-balancer-eip-allocations:
# service.beta.kubernetes.io/aws-load-balancer-subnets:

service:
# Set to 'Local' to maintain the client's IP on inbound connections
externalTrafficPolicy: Cluster
# Enable internal traffic policy for the service
internalTrafficPolicy: Cluster
annotations: {}
# service.beta.kubernetes.io/aws-load-balancer-type:
# service.beta.kubernetes.io/aws-load-balancer-nlb-target-type:
# service.beta.kubernetes.io/aws-load-balancer-scheme:
# service.beta.kubernetes.io/aws-load-balancer-eip-allocations:
# service.beta.kubernetes.io/aws-load-balancer-subnets:
## Service type
type: ClusterIP
## IP address for type ClusterIP
clusterIP: ""
ipDualStack:
enabled: false
ipFamilies: ["IPv6", "IPv4"]
ipFamilyPolicy: "PreferDualStack"

serviceAccount:
# Specifies whether a service account should be created
create: true
Expand Down

0 comments on commit 1e8e38c

Please sign in to comment.