Skip to content

Commit

Permalink
Merge pull request #14 from europeana/EA-2825_setup_k8s
Browse files Browse the repository at this point in the history
EA-2825: Setup K8s deployment
  • Loading branch information
Luthien-in-edhil authored Mar 22, 2022
2 parents 0f17ae7 + d92c71c commit 178b5da
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 6 deletions.
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/manifest.yml
/.env.docker
api-gateway.iml
.env
.env.*
!.env.example

#IntelliJ project files
.idea
*.iml

# Kubernetes config properties
*.properties.yaml
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# NB: ensure the version matches that in buildpack.yml
FROM nginx:mainline

MAINTAINER Europeana Foundation <development@europeana.eu>
LABEL Author="Europeana Foundation <development@europeana.eu>"

# TODO: add a self-signed SSL certificate

COPY docker/env-nginx docker/rewrite-nginx-conf /usr/sbin/

COPY public /usr/share/nginx/html
COPY mime.types nginx.conf.d /etc/nginx/
COPY mime.types /etc/nginx/
COPY nginx.conf.d/ /etc/nginx/nginx.conf.d/

COPY nginx.conf /etc/nginx/nginx.template.conf

RUN rewrite-nginx-conf
Expand Down
7 changes: 6 additions & 1 deletion docker/env-nginx
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ vars='$ANNOTATION_API_HOST

envsubst "${vars}" < /etc/nginx/nginx.template.conf > /etc/nginx/nginx.conf

nginx
if [ -z "$1" ]; then
echo "No container params. Running default nginx command"
nginx
else
exec "$@"
fi
11 changes: 11 additions & 0 deletions k8s/cluster-ip-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: api-gateway-cluster-ip-service
spec:
type: ClusterIP
selector:
app: api-gateway
ports:
- port: 80
targetPort: 80
20 changes: 20 additions & 0 deletions k8s/config.properties.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To configure deployment,
# - copy this file to "config-map.properties.yaml"
# - add config vars
apiVersion: v1
kind: ConfigMap
metadata:
name: api-gateway-config
data:
ANNOTATION_API_HOST:
ENTITY_API_HOST:
ENTITY_MANAGEMENT_HOST:
FULLTEXT_API_HOST:
MANIFEST_API_HOST:
OAI_RECORD_HOST:
RECOMMENDATION_API_HOST:
RESOLVER_ADDRESS:
ROOT_REDIRECT_URL:
SEARCH_API_HOST:
SET_API_HOST:
THUMBNAIL_API_HOST:
22 changes: 22 additions & 0 deletions k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-gateway-deployment
spec:
replicas: 1
selector:
matchLabels:
app: api-gateway
template:
metadata:
labels:
app: api-gateway
spec:
containers:
- name: api-gateway
image: europeana/api-gateway
ports:
- containerPort: 80
envFrom:
- configMapRef:
name: api-gateway-config
27 changes: 27 additions & 0 deletions k8s/ingress.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Ingress for routing traffic on IBM cloud.
# To configure,
# - copy this file to "ingress.properties.yaml"
# - replace HOSTNAME and SECRET_NAME placeholders with correct values
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: api-gateway-ingress
annotations:
cert-manager.io/issuer: letsencrypt-production
spec:
ingressClassName: public-iks-k8s-nginx
tls:
- hosts:
- HOSTNAME
secretName: SECRET_NAME
rules:
- host: HOSTNAME
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: api-gateway-cluster-ip-service
port:
number: 80
15 changes: 15 additions & 0 deletions k8s/node-port.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# NodePort service for accessing API locally. Use ingress for IBM cloud deployments
# API can be accessed on http://<cluster-ip>:31000
# For Docker Desktop, cluster-ip is "localhost";
# if using Minikube, run "minikube ip" to get IP address of your cluster
apiVersion: v1
kind: Service
metadata:
name: api-gateway-node-port
spec:
type: NodePort
ports:
- port: 80
nodePort: 31000
selector:
app: api-gateway
4 changes: 3 additions & 1 deletion nginx.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Based on: https://raw.githubusercontent.com/cloudfoundry/nginx-buildpack/v1.0.1/fixtures/mainline/nginx.conf

worker_processes auto;
daemon on;

# see https://github.com/cloudfoundry/nginx-buildpack/blob/master/fixtures/mainline/nginx.conf#L2
daemon off;

error_log stderr warn;

Expand Down

0 comments on commit 178b5da

Please sign in to comment.