Skip to content

Commit ac55187

Browse files
author
Ruben L. Mendoza
authored
Merge pull request #234 from developmentseed/ingress-ssl
Ingress ssl
2 parents 4a425b3 + 384d3ab commit ac55187

20 files changed

+404
-203
lines changed

osm-seed/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,40 @@ You need to install `helm` onto your cluster, and make sure it has adequate perm
2929

3030
With `minikube` as your cluster backend, this can be accomplished with `helm init`. Depending on your Kubernetes cluster backend, you may need some extra steps to ensure `helm` has adequate permissions on your cluster. See https://github.com/kubernetes/helm/blob/master/docs/rbac.md
3131

32+
### Install dependencies on your cluster
33+
34+
To handle domain routing and SSL, osm-seed needs the nginx ingress controller setup on the cluster as well as Lets Encrypt to handle SSL certificate generation.
35+
36+
You can do this with:
37+
38+
```sh
39+
helm upgrade --install ingress-nginx ingress-nginx \
40+
--repo https://kubernetes.github.io/ingress-nginx \
41+
--namespace ingress-nginx --create-namespace
42+
```
43+
44+
or install using `kubectl`
45+
46+
```sh
47+
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.1/deploy/static/provider/cloud/deploy.yaml
48+
```
49+
50+
For more options and cloud-specific instructions, see: https://kubernetes.github.io/ingress-nginx/deploy/
51+
52+
To install the Lets Encrypt `cert-manager` helm chart:
53+
54+
```sh
55+
helm repo add jetstack https://charts.jetstack.io
56+
helm repo update
57+
helm install \
58+
cert-manager jetstack/cert-manager \
59+
--namespace cert-manager \
60+
--create-namespace \
61+
--version v1.7.1 \
62+
--set installCRDs=true
63+
```
64+
For further information: https://cert-manager.io/docs/installation/helm/
65+
3266
### Install osm-seed onto your cluster
3367

3468
Look at the [`values.yaml`](osm-seed/values.yaml) file in the `osm-seed` sub-folder to see the various configuration options and values that you need to configure for your installation. Then create a `myvalues.yaml` file, where you can over-ride any of the values defined in `values.yaml`.

osm-seed/templates/NOTES.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
1. Get the application URL by running these commands:
2-
{{- if .Values.ingress.enabled }}
3-
{{- range .Values.ingress.hosts }}
4-
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
5-
{{- end }}
6-
{{- else if contains "minikube" .Values.cloudProvider }}
2+
{{- if contains "minikube" .Values.cloudProvider }}
73
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "osm-seed.fullname" . }}-web)
84
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
95
echo http://$NODE_IP:$NODE_PORT
@@ -17,4 +13,4 @@
1713
You can watch the status of by running 'kubectl get svc -w {{ template "osm-seed.fullname" . }}'
1814
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "osm-seed.fullname" . }}-web -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
1915
echo http://$SERVICE_IP
20-
{{- end }}
16+
{{- end }}

osm-seed/templates/ingress.yaml

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{- if eq .Values.serviceType "ClusterIP" }}
2+
apiVersion: cert-manager.io/v1
3+
kind: ClusterIssuer
4+
metadata:
5+
name: letsencrypt-prod-issuer
6+
spec:
7+
acme:
8+
# You must replace this email address with your own.
9+
# Let's Encrypt will use this to contact you about expiring
10+
# certificates, and issues related to your account.
11+
email: {{ .Values.adminEmail }}
12+
# ACME server URL for Let’s Encrypt’s staging environment.
13+
# Specify custom server here (https://acme-staging-v02.api.letsencrypt.org/directory)
14+
# to hit staging LE
15+
server: https://acme-v02.api.letsencrypt.org/directory
16+
privateKeySecretRef:
17+
# Secret resource used to store the account's private key.
18+
name: letsencrypt-issuer-key
19+
# Enable the HTTP-01 challenge provider
20+
# you prove ownership of a domain by ensuring that a particular
21+
# file is present at the domain
22+
solvers:
23+
- http01:
24+
ingress:
25+
class: nginx
26+
{{- end }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{- if and .Values.nominatimApi.enabled (eq .Values.serviceType "ClusterIP") }}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ template "osm-seed.fullname" . }}-ingress-nominatim-api
6+
annotations:
7+
kubernetes.io/ingress.class: nginx
8+
cert-manager.io/cluster-issuer: letsencrypt-prod-issuer
9+
spec:
10+
tls:
11+
- hosts:
12+
- nominatim.{{ .Values.domain }}
13+
secretName: {{ template "osm-seed.fullname" . }}-secret-nominatim
14+
15+
rules:
16+
- host: nominatim.{{ .Values.domain }}
17+
http:
18+
paths:
19+
- path: /
20+
pathType: Prefix
21+
backend:
22+
service:
23+
name: {{ template "osm-seed.fullname" . }}-nominatim-api
24+
port:
25+
number: 80
26+
{{- end }}

osm-seed/templates/nominatim-api/nominatim-api-service.yaml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,29 @@ metadata:
88
component: nominatim-api-service
99
environment: {{ .Values.environment }}
1010
release: {{ .Release.Name }}
11-
{{- if eq .Values.cloudProvider "aws" }}
1211
annotations:
13-
service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: "300"
14-
{{- if .Values.AWS_SSL_ARN }}
12+
{{- if and (eq .Values.serviceType "LoadBalancer") .Values.AWS_SSL_ARN }}
1513
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: {{ .Values.AWS_SSL_ARN }}
1614
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
17-
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https
15+
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https
16+
{{- end }}
17+
{{- if eq .Values.serviceType "ClusterIP" }}
18+
kubernetes.io/ingress.class: nginx
19+
cert-manager.io/cluster-issuer: letsencrypt-prod-issuer
20+
{{- else }}
21+
fake.annotation: fake
22+
{{- end }}
23+
{{- with .Values.nominatimApi.serviceAnnotations }}
24+
{{- toYaml . | nindent 4 }}
1825
{{- end }}
19-
{{- end }}
2026
spec:
21-
# In case cloudProvider=aws
22-
{{- if eq .Values.cloudProvider "aws" }}
23-
type: LoadBalancer
24-
{{- end }}
25-
# In case cloudProvider=gcp
26-
{{- if eq .Values.cloudProvider "gcp" }}
27-
type: LoadBalancer
28-
{{- end }}
29-
# In case cloudProvider=minikube
30-
{{- if eq .Values.cloudProvider "minikube" }}
31-
type: NodePort
32-
{{- end }}
27+
type: {{ .Values.serviceType }}
3328
ports:
34-
- port: 8080
29+
- port: 80
3530
targetPort: http
3631
protocol: TCP
3732
name: http
38-
{{- if .Values.AWS_SSL_ARN }} #FIXME: make generic
33+
{{- if and (eq .Values.serviceType "LoadBalancer") .Values.AWS_SSL_ARN }}
3934
- port: 443
4035
targetPort: http
4136
protocol: TCP
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{- if and .Values.overpassApi.enabled (eq .Values.serviceType "ClusterIP") }}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ template "osm-seed.fullname" . }}-ingress-overpass-api
6+
annotations:
7+
kubernetes.io/ingress.class: nginx
8+
cert-manager.io/cluster-issuer: letsencrypt-prod-issuer
9+
spec:
10+
tls:
11+
- hosts:
12+
- overpass.{{ .Values.domain }}
13+
secretName: {{ template "osm-seed.fullname" . }}-secret-overpass
14+
15+
rules:
16+
- host: overpass.{{ .Values.domain }}
17+
http:
18+
paths:
19+
- path: /
20+
pathType: Prefix
21+
backend:
22+
service:
23+
name: {{ template "osm-seed.fullname" . }}-overpass-api
24+
port:
25+
number: 80
26+
{{- end }}

osm-seed/templates/overpass-api/overpass-api-service.yaml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.tilerServer.enabled -}}
1+
{{- if .Values.overpassApi.enabled -}}
22
apiVersion: v1
33
kind: Service
44
metadata:
@@ -8,37 +8,33 @@ metadata:
88
component: overpass-api-service
99
environment: {{ .Values.environment }}
1010
release: {{ .Release.Name }}
11-
{{- if eq .Values.cloudProvider "aws" }}
1211
annotations:
13-
service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: "300"
14-
{{- if .Values.AWS_SSL_ARN }}
12+
{{- if and (eq .Values.serviceType "LoadBalancer") .Values.AWS_SSL_ARN }}
1513
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: {{ .Values.AWS_SSL_ARN }}
1614
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
15+
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https
16+
{{- end }}
17+
{{- if eq .Values.serviceType "ClusterIP" }}
18+
kubernetes.io/ingress.class: nginx
19+
cert-manager.io/cluster-issuer: letsencrypt-prod-issuer
20+
{{- else }}
21+
fake.annotation: fake
22+
{{- end }}
23+
{{- with .Values.overpassApi.serviceAnnotations }}
24+
{{- toYaml . | nindent 4 }}
1725
{{- end }}
18-
{{- end }}
1926
spec:
20-
# In case cloudProvider=aws
21-
{{- if eq .Values.cloudProvider "aws" }}
22-
type: LoadBalancer
23-
{{- end }}
24-
# In case cloudProvider=gcp
25-
{{- if eq .Values.cloudProvider "gcp" }}
26-
type: LoadBalancer
27-
{{- end }}
28-
# In case cloudProvider=minikube
29-
{{- if eq .Values.cloudProvider "minikube" }}
30-
type: NodePort
31-
{{- end }}
27+
type: {{ .Values.serviceType }}
3228
ports:
3329
- port: 80
34-
targetPort: 80
30+
targetPort: http
3531
protocol: TCP
3632
name: http
37-
{{- if .Values.AWS_SSL_ARN }}
33+
{{- if and (eq .Values.serviceType "LoadBalancer") .Values.AWS_SSL_ARN }}
3834
- port: 443
3935
targetPort: http
4036
protocol: TCP
41-
name: https
37+
name: https
4238
{{- end }}
4339

4440
selector:
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{- if and .Values.taginfo.enabled (eq .Values.serviceType "ClusterIP") }}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ template "osm-seed.fullname" . }}-ingress-taginfo-api
6+
annotations:
7+
kubernetes.io/ingress.class: nginx
8+
cert-manager.io/cluster-issuer: letsencrypt-prod-issuer
9+
spec:
10+
tls:
11+
- hosts:
12+
- taginfo.{{ .Values.domain }}
13+
secretName: {{ template "osm-seed.fullname" . }}-secret-taginfo
14+
15+
rules:
16+
- host: taginfo.{{ .Values.domain }}
17+
http:
18+
paths:
19+
- path: /
20+
pathType: Prefix
21+
backend:
22+
service:
23+
name: {{ template "osm-seed.fullname" . }}-taginfo
24+
port:
25+
number: 80
26+
{{- end }}

osm-seed/templates/taginfo/taginfo-service.yaml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,29 @@ metadata:
88
component: taginfo-service
99
environment: {{ .Values.environment }}
1010
release: {{ .Release.Name }}
11-
{{- if eq .Values.cloudProvider "aws" }}
1211
annotations:
13-
service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: "300"
14-
{{- if .Values.AWS_SSL_ARN }}
12+
{{- if and (eq .Values.serviceType "LoadBalancer") .Values.AWS_SSL_ARN }}
1513
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: {{ .Values.AWS_SSL_ARN }}
1614
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
17-
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https
15+
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https
16+
{{- end }}
17+
{{- if eq .Values.serviceType "ClusterIP" }}
18+
kubernetes.io/ingress.class: nginx
19+
cert-manager.io/cluster-issuer: letsencrypt-prod-issuer
20+
{{- else }}
21+
fake.annotation: fake
22+
{{- end }}
23+
{{- with .Values.taginfo.serviceAnnotations }}
24+
{{- toYaml . | nindent 4 }}
1825
{{- end }}
19-
{{- end }}
2026
spec:
21-
# In case cloudProvider=aws
22-
{{- if eq .Values.cloudProvider "aws" }}
23-
type: LoadBalancer
24-
{{- end }}
25-
# In case cloudProvider=gcp
26-
{{- if eq .Values.cloudProvider "gcp" }}
27-
type: LoadBalancer
28-
{{- end }}
29-
# In case cloudProvider=minikube
30-
{{- if eq .Values.cloudProvider "minikube" }}
31-
type: NodePort
32-
{{- end }}
27+
type: {{ .Values.serviceType }}
3328
ports:
3429
- port: 80
3530
targetPort: http
3631
protocol: TCP
3732
name: http
38-
{{- if .Values.AWS_SSL_ARN }} #FIXME: make generic
33+
{{- if and (eq .Values.serviceType "LoadBalancer") .Values.AWS_SSL_ARN }}
3934
- port: 443
4035
targetPort: http
4136
protocol: TCP

0 commit comments

Comments
 (0)