Skip to content

Commit

Permalink
Merge pull request #26 from ElmCompany/feature/new-chart-service-proxy
Browse files Browse the repository at this point in the history
feat: NEW CHart- Service Proxy - Envoy
  • Loading branch information
abdennour authored Jul 14, 2023
2 parents 022a41e + 116cde9 commit 24fc6ce
Show file tree
Hide file tree
Showing 26 changed files with 1,043 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/service-proxy/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions charts/service-proxy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: service-proxy
description: A Helm chart for Deployed Envoy Proxy with Less Configuration effort

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v1.25-latest"
32 changes: 32 additions & 0 deletions charts/service-proxy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Overview
Envoy proxy for any service, easy to install & easy to configure.
Ability to proxy:
- https traffic & expose it as http traffic
- S3 endpoint (Cloud or on-prem like MinIO)


# Values

Check default Values of this chart [here](
https://github.com/ElmCompany/helm-charts/blob/master/charts/service-proxy/values.yaml)

# How to install the app

**Set Elm Repo**

```sh

helm repo add elm https://raw.githubusercontent.com/ElmCompany/helm-charts/gh-pages
helm repo update
```

**Use it** `helm install elm/service-proxy -f values.sample-http-https.yaml`

# Authors

This chart is maintained by:
- @abdennour

# License

LGPL v3
74 changes: 74 additions & 0 deletions charts/service-proxy/files/envoy-modes/envoy-http-https.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: {{ .Values.proxyPorts.webPort }}
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
codec_type: AUTO
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: app
domains:
- "*"
routes:
- match:
prefix: "/"
route:
cluster: {{ include "service-proxy.fullname" . }}
auto_host_rewrite: true
internal_redirect_policy:
max_internal_redirects: 10
redirect_response_codes:
- 301
- 302
predicates:
- name: envoy.internal_redirect_predicates.safe_cross_scheme
typed_config:
'@type': type.googleapis.com/envoy.extensions.internal_redirect.safe_cross_scheme.v3.SafeCrossSchemeConfig
allow_cross_scheme_redirect: false
http_filters:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

clusters:
- name: {{ include "service-proxy.fullname" . }}
type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: {{ include "service-proxy.fullname" . }}
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: {{ required "Backend Service ADDRESS is Required" .Values.backendService.address }}
port_value: {{ .Values.backendService.port }}
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
{{- if (include "service-proxy.backendServiceHasCaCert" .) }}
common_tls_context:
validation_context:
match_typed_subject_alt_names:
- san_type: DNS
matcher:
exact: {{ .Values.backendService.address }}
trusted_ca:
filename: /tmp/certs/backend-ca.crt
{{- end }}

admin:
access_log_path: "/dev/null"
address:
socket_address:
address: 0.0.0.0
port_value: {{ .Values.proxyPorts.adminPort }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: {{ .Values.proxyPorts.webPort }}
filter_chains:
- filters:
- name: envoy.filters.network.tcp_proxy
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy
cluster: {{ include "service-proxy.fullname" . }}
stat_prefix: https_passthrough

clusters:
- name: {{ include "service-proxy.fullname" . }}
type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: {{ include "service-proxy.fullname" . }}
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: {{ required "Backend Service ADDRESS is Required" .Values.backendService.address }}
port_value: {{ .Values.backendService.port }}
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
sni: {{ .Values.backendService.address }}
admin:
access_log_path: "/dev/null"
address:
socket_address:
address: 0.0.0.0
port_value: {{ .Values.proxyPorts.adminPort }}
37 changes: 37 additions & 0 deletions charts/service-proxy/files/envoy-modes/envoy-redis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
static_resources:
listeners:
- name: redis_listener
address:
socket_address:
address: 0.0.0.0
port_value: {{ .Values.proxyPorts.webPort }}
filter_chains:
- filters:
- name: envoy.filters.network.redis_proxy
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.redis_proxy.v3.RedisProxy
stat_prefix: egress_redis
settings:
op_timeout: 5s
prefix_routes:
catch_all_route:
cluster: {{ include "service-proxy.fullname" . }}
clusters:
- name: {{ include "service-proxy.fullname" . }}
type: STRICT_DNS # static
lb_policy: MAGLEV
load_assignment:
cluster_name: {{ include "service-proxy.fullname" . }}
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: {{ required "Redis Backend Service ADDRESS is Required" .Values.backendService.address }}
port_value: {{ .Values.backendService.port }}
admin:
access_log_path: "/dev/null"
address:
socket_address:
address: 0.0.0.0
port_value: {{ .Values.proxyPorts.adminPort }}
79 changes: 79 additions & 0 deletions charts/service-proxy/files/envoy-modes/envoy-s3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: {{ .Values.proxyPorts.webPort }}
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
codec_type: AUTO
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: app
domains:
- "*"
routes:
- match:
prefix: "/"
route:
cluster: {{ include "service-proxy.fullname" . }}
# auto_host_rewrite: true
# internal_redirect_policy:
# max_internal_redirects: 10
# redirect_response_codes:
# - 301
# - 302
# predicates:
# - name: envoy.internal_redirect_predicates.safe_cross_scheme
# typed_config:
# '@type': type.googleapis.com/envoy.extensions.internal_redirect.safe_cross_scheme.v3.SafeCrossSchemeConfig
# allow_cross_scheme_redirect: false
http_filters:
# docs: https://envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/aws_request_signing/v3/aws_request_signing.proto.html
- name: sigv4-signing
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.aws_request_signing.v3.AwsRequestSigning
service_name: s3
# host_rewrite: s3.amazonaws.com
host_rewrite: {{ required "S3 Endpoint (.backendService.address) is Required" .Values.backendService.address }}
region: us-east-1
use_unsigned_payload: true
match_excluded_headers:
- prefix: x-envoy
- prefix: x-forwarded
- exact: x-amzn-trace-id
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

clusters:
- name: {{ include "service-proxy.fullname" . }}
connect_timeout: 0.5s
type: LOGICAL_DNS
# type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: {{ include "service-proxy.fullname" . }}
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: {{ required "S3 Endpoint (.backendService.address) is Required" .Values.backendService.address }}
port_value: {{ .Values.backendService.port }}
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext

admin:
access_log_path: "/dev/null"
address:
socket_address:
address: 0.0.0.0
port_value: {{ .Values.proxyPorts.adminPort }}
22 changes: 22 additions & 0 deletions charts/service-proxy/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "service-proxy.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
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 "service-proxy.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "service-proxy.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "service-proxy.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}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
Loading

0 comments on commit 24fc6ce

Please sign in to comment.