Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ is at [docs.gen0sec.com](https://docs.gen0sec.com).
- [Header rules](./use-cases/header-rules/): add and remove request and
response headers, with a script that checks every rule against the running
example.
- [cert-manager on Kubernetes](./use-cases/kubernetes-cert-manager/): a
`SynapseProxy` of the Synapse operator serves an Ingress with a certificate
from cert-manager, and picks up a renewal without a restart. Needs Synapse
operator 0.2.0 (not released yet) and Synapse 0.8.8 or later.

### Being updated

Expand Down
1 change: 1 addition & 0 deletions use-cases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ closest to what you want and copy it. Every set uses placeholder values
| [`tcp-mss`](./tcp-mss/) | proxy | no | none: the demo listens on port 8080 | Cap the MSS of the connections a listener accepts; needs Synapse 0.8.9 or later |
| [`edge-headers`](./edge-headers/) | proxy | no | none: the demo listens on ports 8080 and 8443 | `X-Forwarded-For`, `X-Forwarded-Proto`, `Via`, a request ID and HSTS; needs Synapse 0.8.9 or later |
| [`header-rules`](./header-rules/) | proxy | no | none: the demo listens on port 8080 | Add and remove request and response headers, with a script that checks every rule |
| [`kubernetes-cert-manager`](./kubernetes-cert-manager/) | proxy | no | a privileged proxy pod, Kubernetes cluster | A `SynapseProxy` of the Synapse operator serving an Ingress with a certificate from cert-manager, and the proxy picking up a renewed certificate without a restart; needs Synapse operator 0.2.0 (not released yet) and Synapse 0.8.8 or later |

"Privileges" lists what the set's own config needs; the installation guide
lists what the container image needs on top. Installation is covered in the
Expand Down
14 changes: 14 additions & 0 deletions use-cases/kubernetes-cert-manager/00-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# The proxy pod is privileged and runs as root, so its namespace must allow
# that, and nothing else should live in it. The back-end, the Ingress and the
# client go in a second namespace that keeps the default Pod Security.
apiVersion: v1
kind: Namespace
metadata:
name: synapse-demo
labels:
pod-security.kubernetes.io/enforce: privileged
---
apiVersion: v1
kind: Namespace
metadata:
name: synapse-demo-apps
37 changes: 37 additions & 0 deletions use-cases/kubernetes-cert-manager/10-cert-manager-issuers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# The standard cert-manager "CA issuer" recipe: a self-signed issuer signs a
# CA certificate, and a second issuer signs with that CA. The demo has no public
# ingress, so no real ACME server can reach it. See issuer-acme-http01.yaml for
# the issuer a public cluster uses instead.
#
# A ClusterIssuer keeps its CA in the "cluster resource namespace", which is
# cert-manager by default.
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: demo-selfsigned
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: demo-ca
namespace: cert-manager
spec:
isCA: true
commonName: demo-ca
secretName: demo-ca
privateKey:
algorithm: ECDSA
size: 256
issuerRef:
name: demo-selfsigned
kind: ClusterIssuer
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: demo-ca
spec:
ca:
secretName: demo-ca
35 changes: 35 additions & 0 deletions use-cases/kubernetes-cert-manager/20-synapseproxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# One resource makes the proxy: the operator renders its configuration and
# creates its Deployment, Service and ServiceAccount. Needs the operator to run
# with --proxy-controller, and Synapse 0.8.8 or later in the image.
apiVersion: synapse.gen0sec.com/v1alpha1
kind: SynapseProxy
metadata:
name: edge
namespace: synapse-demo
spec:
image: ghcr.io/gen0sec/synapse:0.8.8
replicas: 1
service:
# ClusterIP for the demo. A cluster with a load balancer uses LoadBalancer.
type: ClusterIP
listeners:
- name: http
port: 80
protocol: HTTP
- name: https
port: 443
protocol: TLS
---
# An Ingress with ingressClassName: edge is served by the proxy above.
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: edge
spec:
controller: gen0sec.com/synapse
parameters:
apiGroup: synapse.gen0sec.com
kind: SynapseProxy
scope: Namespace
namespace: synapse-demo
name: edge
33 changes: 33 additions & 0 deletions use-cases/kubernetes-cert-manager/30-whoami.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# The back-end: it answers with its own host name and the request it got.
apiVersion: apps/v1
kind: Deployment
metadata:
name: whoami
namespace: synapse-demo-apps
spec:
replicas: 1
selector:
matchLabels:
app: whoami
template:
metadata:
labels:
app: whoami
spec:
containers:
- name: whoami
image: traefik/whoami:v1.10.3
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: whoami
namespace: synapse-demo-apps
spec:
selector:
app: whoami
ports:
- port: 80
targetPort: 80
35 changes: 35 additions & 0 deletions use-cases/kubernetes-cert-manager/40-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# cert-manager watches this Ingress, asks the issuer named in the annotation for
# a certificate for every host in spec.tls, and stores it in the Secret that
# spec.tls names. The operator copies that Secret to the proxy as
# app.example.com.crt and app.example.com.key.
#
# The duration and renew-before annotations make the certificate live one hour
# and renew five minutes after it is issued, so the demo shows a rotation. A
# real certificate uses the issuer's default (Let's Encrypt: 90 days, renewed
# at 60), so leave both annotations out.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: whoami
namespace: synapse-demo-apps
annotations:
cert-manager.io/cluster-issuer: demo-ca
cert-manager.io/duration: 1h
cert-manager.io/renew-before: 55m
spec:
ingressClassName: edge
tls:
- hosts:
- app.example.com
secretName: app-example-com-tls
rules:
- host: app.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: whoami
port:
number: 80
Loading