Skip to content

Commit e292cdd

Browse files
committed
feat: Add host-ip-service chart to support for multiple host configurations to an ingress resource
1 parent d93f0da commit e292cdd

File tree

6 files changed

+244
-0
lines changed

6 files changed

+244
-0
lines changed

charts/host-ip-service/Chart.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v2
2+
description: Helm chart to expose host IP services and generate optional Ingress entries per port.
3+
name: host-ip-service
4+
type: application
5+
version: 0.0.1
6+
annotations:
7+
"helm.sh/schema": values.schema.json

charts/host-ip-service/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# host-ip-service
2+
3+
A flexible Helm chart for exposing host IP services as Kubernetes Services and optionally creating Ingress resources per port.
4+
5+
## Features
6+
7+
- Creates a Kubernetes `Endpoints` and `Service` resource to route traffic to a host IP.
8+
- Optionally exposes each port via `Ingress`, with per-port customization.
9+
- Supports global and per-ingress annotations.
10+
- TLS configuration is supported via `ingress.tls`.
11+
12+
## Values
13+
14+
### Top-level values
15+
16+
| Key | Type | Description | Default |
17+
|-------------------|----------|----------------------------------------|------------------------|
18+
| `namespace` | string | Namespace to deploy resources into | `default` |
19+
| `endpoint.name` | string | Name of the Endpoint and Service | `docker-host` |
20+
| `endpoint.ip` | string | IP address to route traffic to | `172.17.0.1` |
21+
22+
### `endpoint.ports[]`
23+
24+
| Key | Type | Description |
25+
|---------------------------|----------|--------------------------------------|
26+
| `name` | string | Port name |
27+
| `port` | int | Port number |
28+
| `ingress.enabled` | bool | Whether to expose via Ingress |
29+
| `ingress.host` | string | Hostname for Ingress |
30+
| `ingress.path` | string | Path for Ingress |
31+
| `ingress.annotations` | object | Extra annotations for this Ingress |
32+
33+
### `ingress`
34+
35+
| Key | Type | Description |
36+
|------------------------|----------|--------------------------------------|
37+
| `annotations` | object | Global ingress annotations |
38+
| `tls` | list | TLS configuration |
39+
40+
## Example
41+
42+
```yaml
43+
namespace: docker-host
44+
endpoint:
45+
name: docker-host
46+
ip: 172.17.0.1
47+
ports:
48+
- name: gitlab
49+
port: 80
50+
ingress:
51+
enabled: true
52+
host: gitlab.test.com
53+
path: /
54+
annotations:
55+
nginx.ingress.kubernetes.io/proxy-body-size: 50m
56+
57+
ingress:
58+
annotations:
59+
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
60+
nginx.ingress.kubernetes.io/ssl-redirect: "false"
61+
tls:
62+
- secretName: gitlab-tls
63+
hosts:
64+
- gitlab.test.com
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Endpoints
3+
metadata:
4+
name: {{ .Values.endpoint.name }}
5+
namespace: {{ .Values.namespace }}
6+
subsets:
7+
- addresses:
8+
- ip: {{ .Values.endpoint.ip }}
9+
ports:
10+
{{- range .Values.endpoint.ports }}
11+
- name: {{ .name }}
12+
port: {{ .port }}
13+
{{- end }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{- $globalAnnotations := .Values.ingress.annotations | default dict }}
2+
{{- range .Values.endpoint.ports }}
3+
{{- if and .ingress.enabled .ingress.host }}
4+
---
5+
apiVersion: networking.k8s.io/v1
6+
kind: Ingress
7+
metadata:
8+
name: {{ printf "%s-%s" $.Values.endpoint.name .name }}
9+
namespace: {{ $.Values.namespace }}
10+
annotations:
11+
{{- range $k, $v := merge $globalAnnotations (.ingress.annotations | default dict) }}
12+
{{ $k }}: {{ $v | quote }}
13+
{{- end }}
14+
spec:
15+
ingressClassName: {{ .Values.ingress.className | default "nginx" }}
16+
rules:
17+
- host: {{ .ingress.host }}
18+
http:
19+
paths:
20+
- path: {{ .ingress.path }}
21+
pathType: Prefix
22+
backend:
23+
service:
24+
name: {{ $.Values.endpoint.name }}
25+
port:
26+
number: {{ .port }}
27+
{{- if $.Values.ingress.tls }}
28+
tls:
29+
{{- range $.Values.ingress.tls }}
30+
- secretName: {{ .secretName }}
31+
hosts:
32+
{{- range .hosts }}
33+
- {{ . }}
34+
{{- end }}
35+
{{- end }}
36+
{{- end }}
37+
{{- end }}
38+
{{- end }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ .Values.endpoint.name }}
5+
namespace: {{ .Values.namespace }}
6+
spec:
7+
clusterIP: None
8+
ports:
9+
{{- range .Values.endpoint.ports }}
10+
- name: {{ .name }}
11+
port: {{ .port }}
12+
targetPort: {{ .port }}
13+
{{- end }}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Ingress Endpoints Chart Values",
4+
"type": "object",
5+
"properties": {
6+
"namespace": {
7+
"type": "string",
8+
"description": "Namespace where resources are deployed"
9+
},
10+
"endpoint": {
11+
"type": "object",
12+
"description": "Service endpoint configuration",
13+
"properties": {
14+
"name": {
15+
"type": "string",
16+
"description": "The name of the Kubernetes Service"
17+
},
18+
"ip": {
19+
"type": "string",
20+
"description": "The external IP used in Endpoints"
21+
},
22+
"ports": {
23+
"type": "array",
24+
"items": {
25+
"type": "object",
26+
"properties": {
27+
"name": {
28+
"type": "string",
29+
"description": "Port name"
30+
},
31+
"port": {
32+
"type": "integer",
33+
"description": "Port number"
34+
},
35+
"ingress": {
36+
"type": "object",
37+
"description": "Ingress settings for this port",
38+
"properties": {
39+
"enabled": {
40+
"type": "boolean",
41+
"description": "Whether to create an ingress for this port"
42+
},
43+
"host": {
44+
"type": "string",
45+
"description": "Ingress host"
46+
},
47+
"path": {
48+
"type": "string",
49+
"description": "Ingress path",
50+
"default": "/"
51+
},
52+
"annotations": {
53+
"type": "object",
54+
"additionalProperties": {
55+
"type": "string"
56+
},
57+
"description": "Custom annotations for this ingress"
58+
}
59+
},
60+
"required": ["enabled"]
61+
}
62+
},
63+
"required": ["name", "port"]
64+
}
65+
}
66+
},
67+
"required": ["name", "ports"]
68+
},
69+
"ingress": {
70+
"type": "object",
71+
"description": "Global ingress settings",
72+
"properties": {
73+
"className": {
74+
"type": "string",
75+
"description": "Ingress class to use (e.g., nginx, traefik)"
76+
},
77+
"annotations": {
78+
"type": "object",
79+
"description": "Global ingress annotations",
80+
"additionalProperties": {
81+
"type": "string"
82+
}
83+
},
84+
"tls": {
85+
"type": "array",
86+
"description": "TLS configuration for ingress",
87+
"items": {
88+
"type": "object",
89+
"properties": {
90+
"secretName": {
91+
"type": "string",
92+
"description": "Name of the TLS secret"
93+
},
94+
"hosts": {
95+
"type": "array",
96+
"items": {
97+
"type": "string"
98+
},
99+
"description": "List of hostnames for the TLS cert"
100+
}
101+
},
102+
"required": ["secretName", "hosts"]
103+
}
104+
}
105+
}
106+
}
107+
},
108+
"required": ["namespace", "endpoint"]
109+
}

0 commit comments

Comments
 (0)