Skip to content

Commit

Permalink
Gke ingress (#91)
Browse files Browse the repository at this point in the history
* gke-ingress

* revert nobl9 changes

* revert nobl9 changes

* revert nobl9 changes

* service
  • Loading branch information
aaronstutzer authored Feb 13, 2024
1 parent f123482 commit b6f1427
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The public Ricardo AG Helm Charts. The code is provided as-is with no warranties
* [metrics-exporter](https://github.com/ricardo-ch/helm-charts/tree/main/charts/metrics-exporter)
* [nobl9-agent](https://github.com/ricardo-ch/helm-charts/tree/main/charts/nobl9-agent)
* [promlens](https://github.com/ricardo-ch/helm-charts/tree/main/charts/promlens)
* [gke-ingress](https://github.com/ricardo-ch/helm-charts/tree/main/charts/gke-ingress)

## How To Use These Charts

Expand Down
15 changes: 15 additions & 0 deletions charts/gke-ingress/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v2
name: gke-ingress
version: 0.1.0
appVersion: 0.1.0
description: gke-ingress and related resources
sources:
- https://github.com/ricardo-ch/helm-charts/tree/main/charts/gke-ingress
maintainers:
- name: ricardo-ch
email: [email protected]
keywords:
- ingress
annotations:
artifacthub.io/changes: |
- Initial chart
22 changes: 22 additions & 0 deletions charts/gke-ingress/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# gke-ingress

![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square) ![Release Status](https://github.com/ricardo-ch/helm-charts/workflows/Release%20Charts/badge.svg) [![License](https://img.shields.io/github/license/ricardo-ch/helm-charts)](https://github.com/ricardo-ch/helm-charts/blob/main/LICENSE)

gke-ingress and related resources

## Helm Chart

Deploy backends, gateways, services and ingress needed to expose the mesh through GKE gateways. [From edge to mesh guide from google](https://cloud.google.com/architecture/exposing-service-mesh-apps-through-gke-ingress)

### How To Install

Simply add this Chart repository to Helm:

```sh
➜ helm repo add ricardo https://ricardo-ch.github.io/helm-charts/
"ricardo" has been added to your repositories
```

## Source Code

* <https://github.com/ricardo-ch/helm-charts/tree/main/charts/gke-ingress>
24 changes: 24 additions & 0 deletions charts/gke-ingress/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# {{ template "chart.name" . }}

{{ template "chart.deprecationWarning" . }}

{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}![Release Status](https://github.com/ricardo-ch/helm-charts/workflows/Release%20Charts/badge.svg) [![License](https://img.shields.io/github/license/ricardo-ch/helm-charts)](https://github.com/ricardo-ch/helm-charts/blob/main/LICENSE)

gke-ingress and related resources

## Helm Chart

Deploy backends, gateways, services and ingress needed to expose the mesh through GKE gateways. [From edge to mesh guide from google](https://cloud.google.com/architecture/exposing-service-mesh-apps-through-gke-ingress)

### How To Install

Simply add this Chart repository to Helm:

```sh
➜ helm repo add ricardo https://ricardo-ch.github.io/helm-charts/
"ricardo" has been added to your repositories
```

{{ template "chart.valuesSection" . }}

{{ template "chart.sourcesSection" . }}
58 changes: 58 additions & 0 deletions charts/gke-ingress/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{{- define "gke-ingress.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "gke-ingress.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "gke-ingress.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "gke-ingress.labels" -}}
helm.sh/chart: {{ include "gke-ingress.chart" . }}
{{ include "gke-ingress.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/name: {{ include "gke-ingress.name" . }}
{{- range $key, $val := .Values.service.labels }}
{{- if not (or (eq $key "app") (eq $key "istio")) }}
{{ $key | quote }}: {{ $val | quote }}
{{- end }}
{{- end }}
{{- end }}

{{- define "gke-ingress.selectorLabels" -}}
{{- if hasKey .Values.service.labels "app" }}
{{- with .Values.service.labels.app }}app: {{.|quote}}
{{- end}}
{{- else }}app: {{ include "gke-ingress.name" . }}
{{- end }}
{{- if hasKey .Values.service.labels "istio" }}
{{- with .Values.service.labels.istio }}
istio: {{.|quote}}
{{- end}}
{{- else }}
istio: {{ include "gke-ingress.name" . | trimPrefix "istio-" }}
{{- end }}
{{- end }}
21 changes: 21 additions & 0 deletions charts/gke-ingress/templates/backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{ range .Values.backends }}
apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
name: {{ .name }}
namespace: {{ default "istio-ingress" .namespace }}
spec:
healthCheck:
{{ toYaml .healthCheck | indent 4}}
{{- if .policyName}}
securityPolicy:
name: {{.policyName}}
{{- end}}
{{- if .iap}}
iap:
enabled: {{.iap.enabled}}
oauthclientCredentials:
secretName: {{.iap.secretName}}
{{- end}}
---
{{end}}
12 changes: 12 additions & 0 deletions charts/gke-ingress/templates/gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{with .Values.gateway}}
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: {{.name}}
namespace: {{ default "istio-ingress" .namespace }}
spec:
selector:
{{toYaml .selector | indent 4}}
servers:
{{toYaml .servers | indent 4}}
{{end}}
40 changes: 40 additions & 0 deletions charts/gke-ingress/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{range .Values.ingress}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{.name}}
namespace: {{ default "istio-ingress" .namespace}}
annotations:
{{toYaml .annotations | indent 4}}
{{- if .labels }}
labels:
{{toYaml .labels | indent 4}}
{{- end}}
spec:
{{- if .class}}
ingressClassName: {{.class}}
{{- end}}
defaultBackend:
service:
name: {{.defaultBackend.name}}
port:
number: {{.defaultBackend.port}}
{{- if .rules }}
{{- range .rules}}
rules:
- http:
paths:
- path: {{.path}}
pathType: {{.type}}
backend:
service:
name: {{.backend.name}}
port:
number: {{.backend.port}}
{{- if .host}}
host: {{.host}}
{{- end}}
{{end}}
{{end}}
---
{{end}}
18 changes: 18 additions & 0 deletions charts/gke-ingress/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{range .Values.service}}
apiVersion: v1
kind: Service
metadata:
name: {{ .name }}
namespace: {{ default "istio-ingress" .namespace}}
labels:
{{- include "gke-ingress.labels" . | nindent 4 }}
annotations:
{{- .annotations | toYaml | nindent 4 }}
spec:
type: {{ .type }}
ports:
{{ .ports | toYaml | indent 4 }}
selector:
{{- include "gke-ingress.selectorLabels" . | nindent 4 }}
---
{{ end }}
Empty file added charts/gke-ingress/values.yaml
Empty file.

0 comments on commit b6f1427

Please sign in to comment.