Skip to content

Commit

Permalink
Add Kubernetes configuration for the frontend.Aadd Kubernetes configu…
Browse files Browse the repository at this point in the history
…ration for the frontend.
  • Loading branch information
hangy committed Sep 26, 2018
1 parent cecfbf4 commit a771793
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docker/kubernetes/data-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: po-data
labels:
app: po
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
67 changes: 67 additions & 0 deletions docker/kubernetes/frontend-conf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: po-frontend-config
labels:
app: po
component: frontend
data:
nginx.conf: |
server {
listen 80;
listen [::]:80;
# Product Opener needs a root domain + a wildcard for all subdomains
server_name po.992d6328c7ec48169146.westeurope.aksapp.io *.po.992d6328c7ec48169146.westeurope.aksapp.io;
root /opt/product-opener/html/;
gzip on;
gzip_min_length 1000;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
location ~* \.(eot|ttf|woff|woff2)$ {
add_header Access-Control-Allow-Origin *;
}
location ~ ^/images/products/ {
add_header Link "<https://creativecommons.org/licenses/by-sa/3.0/>; rel='license'; title='CC-BY-SA 3.0'";
}
location ~ ^/(favicon.ico) {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# Static files are served directly by NGINX
location ~ ^/(.well-known|images|js|css|rss|data|files|resources|foundation|bower_components)/ {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location = /robots.txt {
try_files $uri $uri/ =404;
}
# Dynamically generated files and CGI scripts are passed
# to the Apache + mod_perl server running on the backend container
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://example.org/cgi/display.pl?;
}
location /cgi/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://example.org;
}
}
42 changes: 42 additions & 0 deletions docker/kubernetes/frontend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: po-frontend
labels:
app: po
component: frontend
spec:
replicas: 1
template:
metadata:
labels:
app: po
component: frontend
spec:
containers:
- name: po-frontend
image: openfoodfacts/productopener-frontend
lifecycle:
postStart:
exec:
command:
- '/bin/sh'
- '-c'
- >
cp -Lrf /tmp/nginx.conf /etc/nginx/conf.d/default.conf;
nginx -s reload; touch /var/log/nginx/conf.done
ports:
- containerPort: 80
volumeMounts:
- name: frontend-config
mountPath: "/tmp/nginx.conf"
subPath: nginx.conf
- name: product-images
mountPath: "/opt/product-opener/html/images/products/"
volumes:
- name: frontend-config
configMap:
name: po-frontend-config
- name: product-images
persistentVolumeClaim:
claimName: po-images
16 changes: 16 additions & 0 deletions docker/kubernetes/frontend-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: po-frontend
labels:
app: po
component: frontend
spec:
type: LoadBalancer
ports:
- port: 80
protocol: TCP
name: http
selector:
app: po
component: frontend
12 changes: 12 additions & 0 deletions docker/kubernetes/images-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: po-images
labels:
app: po
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
18 changes: 18 additions & 0 deletions docker/kubernetes/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: po
labels:
app: po
spec:
backend:
serviceName: po-frontend
servicePort: 80
rules:
- host: "*.po.992d6328c7ec48169146.westeurope.aksapp.io"
http:
paths:
- path: /
backend:
serviceName: po-frontend
servicePort: 80

0 comments on commit a771793

Please sign in to comment.