Skip to content

Commit 27aedbf

Browse files
feat(internal-gateway): refactor int-gw (Ilia's improvements) (#47)
1 parent 2b24782 commit 27aedbf

File tree

14 files changed

+602
-217
lines changed

14 files changed

+602
-217
lines changed

charts/internal-gateway/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
appVersion: v0.0.0
33
description: A Helm chart for Codefresh Internal Gateway
44
name: internal-gateway
5-
version: 0.1.1
5+
version: 0.2.1
66
home: https://github.com/codefresh-io/helm-charts
77
keywords:
88
- codefresh
@@ -13,4 +13,4 @@ maintainers:
1313
dependencies:
1414
- name: cf-common
1515
repository: https://chartmuseum.codefresh.io/cf-common
16-
version: "0.6.0"
16+
version: "0.9.3"

charts/internal-gateway/README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# internal-gateway
22

3-
![Version: 0.1.1](https://img.shields.io/badge/Version-0.1.1-informational?style=flat-square) ![AppVersion: v0.0.0](https://img.shields.io/badge/AppVersion-v0.0.0-informational?style=flat-square)
3+
![Version: 0.2.1](https://img.shields.io/badge/Version-0.2.1-informational?style=flat-square) ![AppVersion: v0.0.0](https://img.shields.io/badge/AppVersion-v0.0.0-informational?style=flat-square)
44

55
A Helm chart for Codefresh Internal Gateway
66

@@ -16,14 +16,13 @@ A Helm chart for Codefresh Internal Gateway
1616

1717
| Repository | Name | Version |
1818
|------------|------|---------|
19-
| https://chartmuseum.codefresh.io/cf-common | cf-common | 0.6.0 |
19+
| https://chartmuseum.codefresh.io/cf-common | cf-common | 0.9.3 |
2020

2121
## Values
2222

2323
| Key | Type | Default | Description |
2424
|-----|------|---------|-------------|
25-
| codefresh | object | See below | Codefresh platform settings |
26-
| configMaps | object | See below | Configmap parameters |
25+
| codefresh | object | See below | Codefresh platform settings List of services endpoints and port |
2726
| container | object | See below | Main container parameters |
2827
| containerSecurityContext | object | See below | Container security context parameters |
2928
| controller | object | See below | Controller parameters |
@@ -33,16 +32,23 @@ A Helm chart for Codefresh Internal Gateway
3332
| global.dnsService | string | `"kube-dns"` | configures DNS service name |
3433
| hpa | object | See below | HPA parameters |
3534
| ingress | object | See below | Ingress parameters |
36-
| libraryMode | bool | `false` | |
35+
| libraryMode | bool | `true` | |
3736
| nginx.config.accessLogEnabled | bool | `true` | Enables NGINX access logs |
3837
| nginx.config.errorLogLevel | string | `"error"` | Sets the log level of the NGINX error log. One of `debug`, `info`, `notice`, `warn`, `error`, `crit`, `alert`, or `emerg` |
39-
| nginx.config.file | string | See below | Config file contents for Nginx. Passed through the `tpl` function to allow templating. |
40-
| nginx.config.httpSnippet | string | `""` | Allows appending custom configuration to the http block |
41-
| nginx.config.logFormat | string | `"main '$remote_addr - $remote_user [$time_local] $status '\n '\"$request\" $body_bytes_sent \"$http_referer\" '\n '\"$http_user_agent\" \"$http_x_forwarded_for\"';"` | NGINX log format |
42-
| nginx.config.proxyConf | object | `{"client_body_buffer_size":"16k","client_max_body_size":"5M","proxy_buffer_size":"64k","proxy_buffers":"4 64k","proxy_connect_timeout":"5s","proxy_read_timeout":"60s","proxy_send_timeout":"60s"}` | Set proxy parameters Ref: https://nginx.org/en/docs/http/ngx_http_proxy_module.html |
38+
| nginx.config.file | string | See below | Config file contents for Nginx. Passed through the `tpl` function to allow templating. !! Moved into separate template at `templates/nginx/configmap.yaml` |
39+
| nginx.config.httpDirectives | object | `{}` | Allows appending custom directives to the http block (map) |
40+
| nginx.config.httpSnippet | string | `""` | Allows appending custom configuration to the http block (string) |
41+
| nginx.config.locationDirectives | object | `{}` | Allows appending custom directives to the location blocks (map) |
42+
| nginx.config.locationSnippet | string | `""` | Allows appending custom configuration to the location blocks (string) |
43+
| nginx.config.locations | object | `{}` | Allow add custom locations |
44+
| nginx.config.logFormat | string | `"main escape=json '{ \"time\": \"$time_iso8601\", \"remote_addr\": \"$proxy_protocol_addr\", \"x-forward-for\": \"$proxy_add_x_forwarded_for\", \"remote_user\": \"$remote_user\", \"bytes_sent\": $bytes_sent, \"request_time\": $request_time, \"status\": $status, \"vhost\": \"$host\", \"request_proto\": \"$server_protocol\", \"path\": \"$uri\", \"request_query\": \"$args\", \"request_length\": $request_length, \"duration\": $request_time, \"method\": \"$request_method\", \"http_referrer\": \"$http_referer\", \"http_user_agent\": \"$http_user_agent\", \"http_x_github_delivery\": \"$http_x_github_delivery\", \"http_x_hook_uuid\": \"$http_x_hook_uuid\", \"metadata\": { \"correlationId\": \"$request_id\", \"service\": \"ingress\", \"time\": \"$time_iso8601\" } }';"` | NGINX log format |
4345
| nginx.config.resolver | string | `nil` | Allows to set a custom resolver |
44-
| nginx.config.serverSnippet | string | `""` | Allows appending custom configuration to the server block |
45-
| nginx.config.verboseLogging | bool | `true` | Enable logging of 2xx and 3xx HTTP requests |
46+
| nginx.config.serverDirectives | object | `{}` | Allows appending custom directives to the server block (map) |
47+
| nginx.config.serverSnippet | string | `""` | Allows appending custom configuration to the server block (string) |
48+
| nginx.config.verboseLogging | bool | `false` | Enable logging of 2xx and 3xx HTTP requests |
49+
| nginx.config.workerConnections | string | `"16384"` | Sets the maximum number of simultaneous connections that can be opened by a worker process. |
50+
| nginx.config.workerProcesses | string | `"8"` | Defines the number of worker processes. |
51+
| nginx.config.workerRlimitNofile | string | `"1047552"` | Changes the limit on the largest size of a core file (RLIMIT_CORE) for worker processes. Used to increase the limit without restarting the main process. |
4652
| pdb | object | See below | PDB parameters |
4753
| podAnnotations | object | See below | Pod annotations |
4854
| podSecurityContext | object | See below | Pod Security Context parameters |
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
{{- define "internal-gateway.configmap" -}}
2+
3+
{{- $vals := include "internal-gateway.default-values" . | fromYaml }}
4+
{{- $mergedValues := mergeOverwrite $vals .Values }}
5+
{{- $_ := set . "Values" $mergedValues }}
6+
7+
{{- $nginxConfig := index (include "internal-gateway.nginx-config" . | fromYaml) "nginx" "config" }}
8+
---
9+
kind: ConfigMap
10+
apiVersion: v1
11+
metadata:
12+
name: {{ include "internal-gateway.fullname" . }}-config
13+
labels:
14+
{{- include "internal-gateway.labels" . | nindent 4 }}
15+
data:
16+
nginx.conf: |
17+
worker_processes {{ $nginxConfig.workerProcesses }};
18+
error_log /dev/stderr {{ $nginxConfig.errorLogLevel }};
19+
pid /tmp/nginx.pid;
20+
worker_rlimit_nofile {{ $nginxConfig.workerRlimitNofile }};
21+
22+
events {
23+
worker_connections {{ $nginxConfig.workerConnections }};
24+
}
25+
26+
http {
27+
client_body_temp_path /tmp/client_temp;
28+
proxy_temp_path /tmp/proxy_temp_path;
29+
fastcgi_temp_path /tmp/fastcgi_temp;
30+
uwsgi_temp_path /tmp/uwsgi_temp;
31+
scgi_temp_path /tmp/scgi_temp;
32+
33+
variables_hash_max_size 2048;
34+
variables_hash_bucket_size 64;
35+
36+
default_type application/octet-stream;
37+
log_format {{ $nginxConfig.logFormat }}
38+
39+
{{- if $nginxConfig.verboseLogging }}
40+
access_log /dev/stderr main;
41+
{{- else }}
42+
43+
map $status $loggable {
44+
~^[23] 0;
45+
default 1;
46+
}
47+
access_log {{ $nginxConfig.accessLogEnabled | ternary "/dev/stderr main if=$loggable;" "off;" }}
48+
{{- end }}
49+
sendfile on;
50+
tcp_nopush on;
51+
52+
map $http_upgrade $connection_upgrade {
53+
default upgrade;
54+
'' close;
55+
}
56+
57+
{{- if $nginxConfig.resolver }}
58+
resolver {{ $nginxConfig.resolver }};
59+
{{- else }}
60+
resolver {{ .Values.global.dnsService }}.{{ .Values.global.dnsNamespace }}.svc.{{ .Values.global.clusterDomain }};
61+
{{- end }}
62+
63+
{{- with $nginxConfig.httpSnippet }}
64+
{{ . | nindent 6 }}
65+
{{- end }}
66+
67+
{{- range $key, $val := $nginxConfig.httpDirectives }}
68+
{{ printf "%s %s;" $key $val }}
69+
{{- end }}
70+
71+
server {
72+
listen 8080;
73+
74+
{{- range $key, $val := $nginxConfig.locations }}
75+
{{- if $val.enabled }}
76+
location {{ $key }} {
77+
78+
{{- $location_host := printf "location_host%s" (trimSuffix "/" $key | replace "/" "_" | replace "." "_" | replace "-" "_" | lower ) }}
79+
{{- $location_port := printf "location_port%s" (trimSuffix "/" $key | replace "/" "_" | replace "." "_" | replace "-" "_" | lower ) }}
80+
set ${{ $location_host }} {{ $val.proxy.host }};
81+
set ${{ $location_port }} {{ $val.proxy.port }};
82+
83+
proxy_pass http://${{ $location_host }}:${{ $location_port }};
84+
85+
{{- if hasKey $val.proxy "proxyPassSnippet" }}
86+
{{- print $val.proxy.proxyPassSnippet | nindent 10 }}
87+
{{- end }}
88+
89+
{{- $locationSnippet := "" }}
90+
{{- if hasKey $val "locationSnippet" }}
91+
{{- $locationSnippet = $val.locationSnippet }}
92+
{{- else if hasKey $nginxConfig "locationSnippet"}}
93+
{{- $locationSnippet = $nginxConfig.locationSnippet }}
94+
{{- end }}
95+
96+
{{- if $locationSnippet }}
97+
{{ print $val.locationSnippet | nindent 10 }}
98+
{{- end }}
99+
100+
{{- $locationDirectives := dict }}
101+
{{- if hasKey $val "locationDirectives" }}
102+
{{- $locationDirectives = $val.locationDirectives }}
103+
{{- else if hasKey $nginxConfig "locationDirectives"}}
104+
{{- $locationDirectives = $nginxConfig.locationDirectives }}
105+
{{- end }}
106+
107+
{{- range $key, $val := $locationDirectives }}
108+
{{ printf "%s %s;" $key $val }}
109+
{{- end }}
110+
111+
}
112+
{{- end }}
113+
{{- end }}
114+
}
115+
}
116+
{{- end }}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{{- define "internal-gateway.default-values" }}
2+
codefresh:
3+
serviceEndpoints:
4+
cfapi-endpoints:
5+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "cfapi-endpoints-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
6+
port: {{ index .Values.codefresh "cfapi-endpoints-port" }}
7+
cfapi-environments:
8+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "cfapi-environments-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
9+
port: {{ index .Values.codefresh "cfapi-environments-port" }}
10+
cfapi-downloadlogmanager:
11+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "cfapi-downloadlogmanager-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
12+
port: {{ index .Values.codefresh "cfapi-downloadlogmanager-port" }}
13+
cfapi-gitops-resource-receiver:
14+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "cfapi-gitops-resource-receiver-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
15+
port: {{ index .Values.codefresh "cfapi-gitops-resource-receiver-port" }}
16+
cfapi-test-reporting:
17+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "cfapi-test-reporting-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
18+
port: {{ index .Values.codefresh "cfapi-test-reporting-port" }}
19+
cfapi-kubernetesresourcemonitor:
20+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "cfapi-kubernetesresourcemonitor-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
21+
port: {{ index .Values.codefresh "cfapi-kubernetesresourcemonitor-port" }}
22+
cfapi-kubernetes-endpoints:
23+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "cfapi-kubernetes-endpoints-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
24+
port: {{ index .Values.codefresh "cfapi-kubernetes-endpoints-port" }}
25+
cfapi-admin:
26+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "cfapi-admin-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
27+
port: {{ index .Values.codefresh "cfapi-admin-port" }}
28+
cfapi-teams:
29+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "cfapi-teams-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
30+
port: {{ index .Values.codefresh "cfapi-teams-port" }}
31+
cfapi-ws:
32+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "cfapi-ws-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
33+
port: {{ index .Values.codefresh "cfapi-ws-port" }}
34+
cfui:
35+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "cfui-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
36+
port: {{ index .Values.codefresh "cfui-port" }}
37+
argo-platform-api-graphql:
38+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "argo-platform-api-graphql-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
39+
port: {{ index .Values.codefresh "argo-platform-api-graphql-port" }}
40+
argo-platform-api-events:
41+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "argo-platform-api-events-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
42+
port: {{ index .Values.codefresh "argo-platform-api-events-port" }}
43+
argo-platform-ui:
44+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "argo-platform-ui-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
45+
port: {{ index .Values.codefresh "argo-platform-ui-port" }}
46+
argo-hub:
47+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "argo-hub-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
48+
port: {{ index .Values.codefresh "argo-hub-port" }}
49+
nomios:
50+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "nomios-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
51+
port: {{ index .Values.codefresh "nomios-port" }}
52+
jira-addon:
53+
svc: '{{ .Release.Name }}-{{ index .Values.codefresh "jira-addon-svc" }}.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}'
54+
port: {{ index .Values.codefresh "jira-addon-port" }}
55+
{{- end }}

0 commit comments

Comments
 (0)