Skip to content

Commit 96d158c

Browse files
committed
Add pigeon chart
1 parent 1e42419 commit 96d158c

File tree

15 files changed

+681
-0
lines changed

15 files changed

+681
-0
lines changed

osf-pigeon/Chart.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
description: A Helm chart for Kubernetes
3+
name: osf-pigeon
4+
version: 0.0.1
5+
sources:
6+
- https://github.com/CenterForOpenScience/osf-pigeon/
7+
maintainers:
8+
- name: Matt Frazier
9+
email: matt@cos.io
10+
url: https://github.com/mfraezz
11+
- name: Matt Clark
12+
email: mattclark@cos.io
13+
url: https://github.com/mattclark
14+
engine: gotpl
15+
tillerVersion: '>=2.7.0'

osf-pigeon/files/robots.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-agent: *
2+
Disallow: /

osf-pigeon/templates/NOTES.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.hostname }}
3+
http://{{- .Values.ingress.hostname }}
4+
{{- else if contains "NodePort" .Values.service.type }}
5+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "osf-pigeon.fullname" . }})
6+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
7+
echo http://$NODE_IP:$NODE_PORT
8+
{{- else if contains "LoadBalancer" .Values.service.type }}
9+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
10+
You can watch the status of by running 'kubectl get svc -w {{ template "osf-pigeon.fullname" . }}'
11+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "osf-pigeon.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
12+
echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
13+
{{- else if contains "ClusterIP" .Values.service.type }}
14+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "osf-pigeon.fullname" . }}" -o jsonpath="{.items[0].metadata.name}")
15+
echo "Visit http://127.0.0.1:8080 to use your application"
16+
kubectl port-forward $POD_NAME 8080:{{ .Values.service.externalPort }}
17+
{{- end }}

osf-pigeon/templates/_helpers.tpl

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "osf-pigeon.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
*/}}
13+
{{- define "osf-pigeon.fullname" -}}
14+
{{- $name := default .Chart.Name .Values.nameOverride -}}
15+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
16+
{{- end -}}
17+
18+
{{/*
19+
Create a default fully qualified certificate name.
20+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
21+
*/}}
22+
{{- define "osf-pigeon.certificate.fullname" -}}
23+
{{- $name := default .Chart.Name .Values.nameOverride -}}
24+
{{- printf "%s-%s-%s" .Release.Name $name .Values.certificate.name | trunc 63 | trimSuffix "-" -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Overridable deployment annotations
29+
*/}}
30+
{{- define "osf-pigeon.deploymentAnnotations" -}}
31+
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
32+
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
33+
{{- end -}}
34+
35+
{{- define "osf-pigeon.environment" -}}
36+
{{- $fullname := include "osf-pigeon.fullname" . -}}
37+
{{- range $key, $value := .Values.configEnvs }}
38+
- name: {{ $key }}
39+
valueFrom:
40+
configMapKeyRef:
41+
name: {{ $fullname }}
42+
key: {{ $key }}
43+
{{- end }}
44+
{{- range $key, $value := .Values.secretEnvs }}
45+
- name: {{ $key }}
46+
valueFrom:
47+
secretKeyRef:
48+
name: {{ $fullname }}
49+
key: {{ $key }}
50+
{{- end }}
51+
{{- end -}}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{- if (and .Values.networkPolicy.enabled .Values.certificate.enabled) }}
2+
apiVersion: networking.k8s.io/v1
3+
kind: NetworkPolicy
4+
metadata:
5+
name: "{{ template "osf-pigeon.certificate.fullname" . }}"
6+
labels:
7+
app: {{ template "osf-pigeon.name" . }}
8+
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
9+
component: "{{ .Values.certificate.name }}"
10+
heritage: {{ .Release.Service }}
11+
release: {{ .Release.Name }}
12+
spec:
13+
policyTypes:
14+
- Ingress
15+
podSelector:
16+
matchExpressions:
17+
- {key: certmanager.k8s.io/acme-http-domain, operator: Exists}
18+
- {key: certmanager.k8s.io/acme-http-token, operator: Exists}
19+
ingress:
20+
- from: []
21+
{{- end }}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{{- if .Values.certificate.enabled -}}
2+
apiVersion: certmanager.k8s.io/v1alpha1
3+
kind: Certificate
4+
metadata:
5+
name: "{{ template "osf-pigeon.certificate.fullname" . }}"
6+
labels:
7+
app: {{ template "osf-pigeon.name" . }}
8+
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
9+
component: "{{ .Values.certificate.name }}"
10+
heritage: {{ .Release.Service }}
11+
release: {{ .Release.Name }}
12+
spec:
13+
secretName: "{{ template "osf-pigeon.certificate.fullname" . }}"
14+
issuerRef:
15+
name: {{ .Values.certificate.issuerRef.name }}
16+
kind: {{ .Values.certificate.issuerRef.kind }}
17+
commonName: {{ .Values.certificate.commonName }}
18+
dnsNames:
19+
{{- range .Values.certificate.dnsNames }}
20+
- {{ . }}
21+
{{- end }}
22+
acme:
23+
config:
24+
- http01:
25+
{{- if hasKey .Values.certificate.acmeConfig.http01 "ingress" }}
26+
ingress: {{ .Values.certificate.acmeConfig.http01.ingress }}
27+
{{- else }}
28+
ingress: {{ template "osf-pigeon.fullname" . }}
29+
{{- end }}
30+
domains:
31+
{{- range .Values.certificate.acmeConfig.domains }}
32+
- {{ . }}
33+
{{- end }}
34+
{{- end -}}
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ template "osf-pigeon.fullname" . }}
5+
labels:
6+
app: {{ template "osf-pigeon.name" . }}
7+
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
8+
heritage: {{ .Release.Service }}
9+
release: {{ .Release.Name }}
10+
data:
11+
{{- define "osf-pigeon.inlineconfigs" }}
12+
nginx.conf: |-
13+
user nginx;
14+
worker_processes {{ .Values.nginx.workerCount }};
15+
16+
load_module /usr/lib/nginx/modules/ngx_http_brotli_filter_module.so;
17+
{{- if .Values.nginx.vts.enabled }}
18+
load_module /usr/lib/nginx/modules/ngx_http_geoip_module.so;
19+
load_module /usr/lib/nginx/modules/ngx_http_vhost_traffic_status_module.so;
20+
{{- end }}
21+
22+
error_log /var/log/nginx/error.log warn;
23+
pid /var/run/nginx.pid;
24+
25+
events {
26+
worker_connections 1024;
27+
}
28+
29+
http {
30+
include /etc/nginx/mime.types;
31+
default_type application/octet-stream;
32+
33+
log_format main '$remote_addr - $upstream_cache_status $remote_user [$time_local] '
34+
'"$request" $status $body_bytes_sent '
35+
'"$http_referer" "$http_user_agent" "$http_x_forwarded_for" '
36+
'rt=$request_time uct="$upstream_connect_time" uht="$upstream_header_time" urt="$upstream_response_time"';
37+
access_log /var/log/nginx/access.log main;
38+
39+
real_ip_header {{ .Values.nginx.realIpHeader }};
40+
real_ip_recursive {{ .Values.nginx.realIpRecursive }};
41+
{{- range .Values.nginx.proxySourceRanges }}
42+
set_real_ip_from {{ . }};
43+
{{- end }}
44+
45+
{{- if .Values.nginx.vts.enabled }}
46+
geoip_country /etc/nginx/GeoIP.dat;
47+
geoip_city /etc/nginx/GeoLiteCity.dat;
48+
geoip_proxy_recursive on;
49+
{{- range .Values.nginx.proxySourceRanges }}
50+
geoip_proxy {{ . }};
51+
{{- end }}
52+
53+
vhost_traffic_status_zone shared:vhost_traffic_status:{{ .Values.nginx.vts.statusZoneSize }};
54+
vhost_traffic_status_filter_by_set_key {{ .Values.nginx.vts.defaultFilterKey }};
55+
{{- end }}
56+
57+
sendfile on;
58+
tcp_nopush on;
59+
tcp_nodelay on;
60+
keepalive_timeout 620s;
61+
keepalive_requests 10000;
62+
types_hash_max_size 2048;
63+
server_tokens off;
64+
65+
gzip on;
66+
gzip_proxied any;
67+
gzip_disable "msie6";
68+
gzip_min_length 1400;
69+
gzip_vary on;
70+
gzip_buffers 4 32k;
71+
gzip_types text/plain text/css image/svg+xml application/javascript application/x-javascript text/xml text/javascript application/json application/vnd.api+json;
72+
73+
brotli on;
74+
brotli_types text/plain text/css image/svg+xml application/javascript application/x-javascript text/xml text/javascript application/json application/vnd.api+json;
75+
76+
{{- if .Values.nginx.vts.enabled }}
77+
server {
78+
listen {{ .Values.nginx.vts.internalPort }};
79+
server_name _;
80+
81+
location /healthz {
82+
access_log off;
83+
return 200;
84+
}
85+
86+
location /nginx_status {
87+
vhost_traffic_status_display;
88+
vhost_traffic_status_display_format html;
89+
}
90+
}
91+
{{- end }}
92+
93+
server {
94+
listen {{ .Values.service.internalPort }};
95+
keepalive_timeout 620s;
96+
client_max_body_size 25M;
97+
server_name _;
98+
99+
if ($http_x_forwarded_proto = "http") {
100+
return 301 https://$host$request_uri;
101+
}
102+
103+
location = /healthz {
104+
access_log off;
105+
return 200;
106+
}
107+
108+
location = /robots.txt {
109+
alias /usr/share/nginx/html/robots.txt;
110+
}
111+
112+
location / {
113+
# Disable caching of application requests
114+
add_header Cache-Control "no-cache, no-store, max-age=0, must-revalidate";
115+
add_header Expires "Mon, 01 Jan 1990 00:00:00 GMT";
116+
add_header Pragma "no-cache";
117+
118+
# Mitigate HTTPoxy Vulnerability
119+
# https://www.nginx.com/blog/mitigating-the-httpoxy-vulnerability-with-nginx/
120+
proxy_set_header Proxy "";
121+
122+
proxy_buffering off;
123+
proxy_request_buffering off;
124+
proxy_set_header Host $host;
125+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
126+
proxy_pass http://127.0.0.1:{{ .Values.service.externalPort }};
127+
}
128+
}
129+
}
130+
{{- end -}}
131+
{{- range $key, $value := .Values.configEnvs }}
132+
{{ $key }}: {{ $value | quote }}
133+
{{- end }}
134+
{{- range $key, $value := merge .Values.configFiles (include "osf-pigeon.inlineconfigs" . | fromYaml) ((.Files.Glob "files/*").AsConfig | fromYaml) }}
135+
{{ $key }}: |-
136+
{{- $value | nindent 4 }}
137+
{{- end }}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "osf-pigeon.fullname" . }}
5+
labels:
6+
app: {{ template "osf-pigeon.name" . }}
7+
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
8+
heritage: {{ .Release.Service }}
9+
release: {{ .Release.Name }}
10+
spec:
11+
selector:
12+
matchLabels:
13+
app: {{ template "osf-pigeon.name" . }}
14+
release: {{ .Release.Name }}
15+
replicas: {{ .Values.replicaCount }}
16+
{{- if .Values.strategy }}
17+
strategy:
18+
{{- toYaml .Values.strategy | nindent 4 }}
19+
{{- end }}
20+
template:
21+
metadata:
22+
labels:
23+
app: {{ template "osf-pigeon.name" . }}
24+
release: {{ .Release.Name }}
25+
annotations:
26+
{{- include "osf-pigeon.deploymentAnnotations" . | nindent 8 }}
27+
spec:
28+
affinity:
29+
{{- if .Values.additionalAffinities }}
30+
{{- toYaml .Values.additionalAffinities | nindent 8 }}
31+
{{- end }}
32+
{{- if eq .Values.antiAffinity "hard" }}
33+
podAntiAffinity:
34+
requiredDuringSchedulingIgnoredDuringExecution:
35+
- topologyKey: kubernetes.io/hostname
36+
labelSelector:
37+
matchLabels:
38+
app: {{ template "osf-pigeon.name" . }}
39+
release: {{ .Release.Name }}
40+
{{- else if eq .Values.antiAffinity "soft" }}
41+
podAntiAffinity:
42+
preferredDuringSchedulingIgnoredDuringExecution:
43+
- weight: 1
44+
podAffinityTerm:
45+
topologyKey: kubernetes.io/hostname
46+
labelSelector:
47+
matchLabels:
48+
app: {{ template "osf-pigeon.name" . }}
49+
release: {{ .Release.Name }}
50+
{{- end }}
51+
containers:
52+
- name: nginx
53+
image: "{{ .Values.nginx.image.repository }}:{{ .Values.nginx.image.tag }}"
54+
imagePullPolicy: {{ .Values.nginx.image.pullPolicy }}
55+
command:
56+
- nginx
57+
- -c
58+
- /etc/nginx/nginx.conf
59+
- -g
60+
- daemon off;
61+
ports:
62+
- name: http-internal
63+
containerPort: {{ .Values.service.internalPort }}
64+
readinessProbe:
65+
httpGet:
66+
path: /healthz
67+
port: {{ .Values.service.internalPort }}
68+
initialDelaySeconds: 10
69+
volumeMounts:
70+
- name: config
71+
subPath: nginx.conf
72+
mountPath: /etc/nginx/nginx.conf
73+
readOnly: true
74+
- name: config
75+
subPath: robots.txt
76+
mountPath: /usr/share/nginx/html/robots.txt
77+
readOnly: true
78+
resources:
79+
{{- toYaml .Values.nginx.resources | nindent 12 }}
80+
- name: sanic
81+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
82+
imagePullPolicy: {{ .Values.image.pullPolicy }}
83+
command:
84+
- /bin/sh
85+
- -c
86+
- python3 -m osf_pigeon
87+
env:
88+
{{- include "osf-pigeon.environment" . | nindent 12 }}
89+
ports:
90+
- name: http-external
91+
containerPort: {{ .Values.service.externalPort }}
92+
readinessProbe:
93+
httpGet:
94+
path: /
95+
port: {{ .Values.service.externalPort }}
96+
volumeMounts:
97+
- name: localcache
98+
mountPath: /tmp/pigeonlocalcache
99+
resources:
100+
{{- toYaml .Values.sanic.resources | nindent 12 }}
101+
volumes:
102+
- name: localcache
103+
emptyDir: {}
104+
- name: config
105+
configMap:
106+
name: {{ template "osf-pigeon.fullname" . }}
107+
- name: secret
108+
secret:
109+
secretName: {{ template "osf-pigeon.fullname" . }}
110+
{{- if .Values.nodeSelector }}
111+
nodeSelector:
112+
{{- toYaml .Values.nodeSelector | nindent 8 }}
113+
{{- end }}

0 commit comments

Comments
 (0)