Skip to content

Commit a50e873

Browse files
committed
kubernetes with https ingress
1 parent 551db27 commit a50e873

22 files changed

+207
-98
lines changed

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ build/bindata/bindata.go: hashed-artifacts
2222
go-bindata -modtime 1 -pkg bindata -prefix build/by-hash/ -o $@ build/by-hash/*
2323

2424

25+
# build the cms
26+
content: FORCE
27+
@cd content && npm install && npm run build
28+
2529
# build the website
2630
www: FORCE
2731
@cd www && npm install && npm run build
@@ -36,7 +40,7 @@ GO = GOPATH=$(CURDIR)/.gopath GOBIN=$(CURDIR)/build go
3640
GO_BUILDFLAGS =
3741
GO_LDFLAGS = -s -w
3842

39-
$(CMD): generate www
43+
$(CMD): deps generate www
4044
$(GO) build $(GO_BUILDFLAGS) -ldflags '$(GO_LDFLAGS)' '$(PKG)'
4145

4246

@@ -56,3 +60,7 @@ vendor: FORCE
5660
generate: FORCE
5761
@./generate.sh
5862
.PHONY: FORCE
63+
64+
deps: FORCE
65+
@go install github.com/pacedotdev/oto
66+
.PHONY: FORCE

content/config/ca-certificate.crt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIEQTCCAqmgAwIBAgIUHPelrk5WEIQnPwobbCJv0g3OxyAwDQYJKoZIhvcNAQEM
3+
BQAwOjE4MDYGA1UEAwwvZDFhNzgyNDgtMTY4Zi00YTBkLWFkNzUtZGEwZWU4NTgz
4+
ZWFiIFByb2plY3QgQ0EwHhcNMjAxMTIwMDE1OTM5WhcNMzAxMTE4MDE1OTM5WjA6
5+
MTgwNgYDVQQDDC9kMWE3ODI0OC0xNjhmLTRhMGQtYWQ3NS1kYTBlZTg1ODNlYWIg
6+
UHJvamVjdCBDQTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAOwjCZFB
7+
eWrzvFBL8nf5zn+Fd2hlTXWYv87ra9tdpE9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espvP2vvOwjSTXk6Ijc/wq5f
24+
QQg7TgIELHjtpCNUI609vEdar9d3zisY7/wG9iFjlC9sI1g1cg==
25+
-----END CERTIFICATE-----

content/config/database.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const fs = require('fs');
12
module.exports = ({ env }) => ({
23
defaultConnection: 'default',
34
connections: {
@@ -10,7 +11,9 @@ module.exports = ({ env }) => ({
1011
database: env('DATABASE_NAME', 'strapi'),
1112
username: env('DATABASE_USERNAME', 'strapi'),
1213
password: env('DATABASE_PASSWORD', 'magical_password'),
13-
ssl: env.bool('DATABASE_SSL', false),
14+
ssl: {
15+
ca: fs.readFileSync(`${__dirname}/ca-certificate.crt`).toString(),
16+
}
1417
},
1518
options: {}
1619
},

content/package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

content/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"build": "strapi build",
1010
"strapi": "strapi"
1111
},
12-
"devDependencies": {},
12+
"devDependencies": {
13+
"fs": "0.0.1-security"
14+
},
1315
"dependencies": {
1416
"strapi": "3.3.3",
1517
"strapi-admin": "3.3.3",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v0.16.1/cert-manager.yaml
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: Certificate
3+
metadata:
4+
name: contentgc-prod
5+
namespace: default
6+
spec:
7+
secretName: contentgc-tls
8+
issuerRef:
9+
name: letsencrypt
10+
commonName: content.gophercon.com
11+
dnsNames:
12+
- content.gophercon.com
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
annotations:
5+
service.beta.kubernetes.io/do-loadbalancer-enable-proxy-protocol: 'true'
6+
service.beta.kubernetes.io/do-loadbalancer-hostname: "lb.gophercon.com"
7+
labels:
8+
helm.sh/chart: ingress-nginx-2.11.1
9+
app.kubernetes.io/name: ingress-nginx
10+
app.kubernetes.io/instance: ingress-nginx
11+
app.kubernetes.io/version: 0.34.1
12+
app.kubernetes.io/managed-by: Helm
13+
app.kubernetes.io/component: controller
14+
name: ingress-nginx-controller
15+
namespace: ingress-nginx
16+
spec:
17+
type: LoadBalancer
18+
externalTrafficPolicy: Local
19+
ports:
20+
- name: http
21+
port: 80
22+
protocol: TCP
23+
targetPort: http
24+
- name: https
25+
port: 443
26+
protocol: TCP
27+
targetPort: https
28+
selector:
29+
app.kubernetes.io/name: ingress-nginx
30+
app.kubernetes.io/instance: ingress-nginx
31+
app.kubernetes.io/component: controller
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: cert-manager.io/v1alpha2
2+
kind: ClusterIssuer
3+
metadata:
4+
name: letsencrypt-prod
5+
namespace: cert-manager
6+
spec:
7+
acme:
8+
# The ACME server URL
9+
server: https://acme-v02.api.letsencrypt.org/directory
10+
# Email address used for ACME registration
11+
12+
# Name of a secret used to store the ACME account private key
13+
privateKeySecretRef:
14+
name: letsencrypt-prod
15+
# Enable the HTTP-01 challenge provider
16+
solvers:
17+
- http01:
18+
ingress:
19+
class: nginx
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: ClusterIssuer
3+
metadata:
4+
name: letsencrypt-staging
5+
spec:
6+
acme:
7+
# You must replace this email address with your own.
8+
# Let's Encrypt will use this to contact you about expiring
9+
# certificates, and issues related to your account.
10+
11+
server: https://acme-staging-v02.api.letsencrypt.org/directory
12+
privateKeySecretRef:
13+
# Secret resource that will be used to store the account's private key.
14+
name: example-issuer-account-key
15+
# Add a single challenge solver, HTTP01 using nginx
16+
solvers:
17+
- http01:
18+
ingress:
19+
class: nginx
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kubectl get pods --namespace cert-manager

contrib/kubernetes/ingress.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

contrib/kubernetes/manager-service.yaml

Lines changed: 0 additions & 13 deletions
This file was deleted.

contrib/kubernetes/manager.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

contrib/kubernetes/strapi/ingress.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ kind: Ingress
33
metadata:
44
name: strapi-ingress
55
annotations:
6-
kubernetes.io/ingress.class: addon-http-application-routing
6+
kubernetes.io/ingress.class: "nginx"
7+
cert-manager.io/cluster-issuer: "letsencrypt-prod"
78
spec:
9+
tls:
10+
- hosts:
11+
- content.gophercon.com
12+
secretName: contentgc-tls
813
rules:
9-
- host: content.44ec396da6024f08b75a.eastus2.aksapp.io
14+
- host: content.gophercon.com
1015
http:
1116
paths:
1217
- backend:
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: networking.k8s.io/v1beta1
2+
kind: Ingress
3+
metadata:
4+
name: strapi-temp-ingress
5+
spec:
6+
rules:
7+
- host: content.gophercon.com
8+
http:
9+
paths:
10+
- backend:
11+
serviceName: strapi
12+
servicePort: strapi-port

contrib/kubernetes/strapi/strapi.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,23 @@ spec:
1616
spec:
1717
containers:
1818
- name: strapi
19-
image: bketelsen/strapi:0
19+
image: bketelsen/content:10
2020
imagePullPolicy: Always
2121
env:
2222
- name: DATABASE_NAME
2323
value: "strapi"
2424
- name: DATABASE_HOST
25-
value: "gcpostgres-postgresql"
25+
value: "private-gophercon-do-user-167863-0.b.db.ondigitalocean.com"
2626
- name: DATABASE_PORT
27-
value: "5432"
27+
value: "25060"
2828
- name: DATABASE_USERNAME
29-
value: "postgres"
29+
value: "strapi"
3030
- name: DATABASE_PASSWORD
31-
value: "nope"
31+
valueFrom:
32+
secretKeyRef:
33+
name: strapi-db-secret
34+
key: password
3235
ports:
3336
- name: strapi-port
3437
containerPort: 1337
35-
protocol: TCP
38+
protocol: TCP

contrib/kubernetes/test-resources.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
github.com/opentracing-contrib/go-grpc v0.0.0-20200813121455-4a6760c71486
1212
github.com/opentracing-contrib/go-stdlib v0.0.0-20190519235532-cf7a6c988dc9
1313
github.com/opentracing/opentracing-go v1.2.0
14+
github.com/pacedotdev/oto v0.10.8 // indirect
1415
github.com/pacedotdev/oto/otohttp v0.8.0
1516
github.com/pkg/errors v0.9.1
1617
github.com/prometheus/client_golang v1.5.1

0 commit comments

Comments
 (0)