|
| 1 | +# DNS & TLS Certificates |
| 2 | + |
| 3 | +<!-- toc --> |
| 4 | + |
| 5 | +## Introduction |
| 6 | +### What is the Domain Name System (DNS)? |
| 7 | + |
| 8 | +The DNS is a system used across to internet to associate domains, such as `berkeleytime.com`, with IP addresses, such as `123.123.123.123`. Internet browsers use the DNS protocol to translate common domains to IP addresses to know where to route packets. |
| 9 | + |
| 10 | +UC Berkeley classes that cover how a DNS work include: |
| 11 | +- [CS 168 (Internet Architecture)](https://www2.eecs.berkeley.edu/Courses/CS168/) |
| 12 | +- [CS 161 (Computer Security)](https://www2.eecs.berkeley.edu/Courses/CS161/) |
| 13 | + |
| 14 | +Learn more about DNSs: |
| 15 | +- [CS 168 Textbook - DNS](https://textbook.cs168.io/applications/dns.html) |
| 16 | +- [What is DNS? | How DNS works](https://www.cloudflare.com/learning/dns/what-is-dns/) |
| 17 | + |
| 18 | +### What are TLS Certificates? |
| 19 | + |
| 20 | +A TLS Certificate secures connections between internet browsers and web servers by authenticating web servers, exchanging keys to encrypt data packets, and providing integrity guarantees over the connection. Connections to websites secured with TLS certificates typically use HTTPS instead of HTTP. |
| 21 | + |
| 22 | +UC Berkeley classes that cover how TLS Certificates work include: |
| 23 | +- [CS 161 (Computer Security)](https://www2.eecs.berkeley.edu/Courses/CS161/) |
| 24 | +- [CS 168 (Internet Architecture)](https://www2.eecs.berkeley.edu/Courses/CS168/) |
| 25 | + |
| 26 | +Learn more about SSL/TLS (SSL is the predecessor to TLS): |
| 27 | +- [What is an SSL Certificate?](https://www.cloudflare.com/learning/ssl/what-is-an-ssl-certificate/) |
| 28 | +- [What is SSL? | SSL definition](https://www.cloudflare.com/learning/ssl/what-is-ssl/) |
| 29 | + |
| 30 | +## Our Cloudflare DNS Setup |
| 31 | + |
| 32 | +For the most relevant setup documentation, refer to [Cloudflare's DNS Setup Docs](https://developers.cloudflare.com/dns/). |
| 33 | + |
| 34 | +We pay for the domains `berkeleytime.com` and `stanfurdtime.com`, both registered with [Cloudflare Registrar](https://www.cloudflare.com/products/registrar/). In addition, our authoritative DNS is also Cloudlfare, and its configuration (what domains map to what IPs) can be changed on [the Cloudflare Developer Dashboard](https://dash.cloudflare.com/). |
| 35 | + |
| 36 | +## Our Kubernetes Cluster Setup |
| 37 | + |
| 38 | +There are two relevant Kubernetes components when discussing DNS and Certificates: our reverse proxy `ingress-nginx` and `cert-manager`. |
| 39 | + |
| 40 | +### Ingress Nginx |
| 41 | + |
| 42 | +Recall from [An HTTP Request's Life](./onboarding.md#an-http-requests-life), `ingress-nginx` is our reverse proxy responsible for routing between our application services. Its input is effectively a mapping from a path to a service. This is down through the [Ingress Resource](https://kubernetes.io/docs/concepts/services-networking/ingress/): |
| 43 | + |
| 44 | +```yaml |
| 45 | +apiVersion: networking.k8s.io/v1 |
| 46 | +kind: Ingress |
| 47 | +metadata: |
| 48 | + # ... |
| 49 | +spec: |
| 50 | + ingressClassName: nginx |
| 51 | + tls: |
| 52 | + # ... |
| 53 | + rules: |
| 54 | + - host: berkeleytime.com |
| 55 | + http: |
| 56 | + paths: |
| 57 | + - path: / |
| 58 | + backend: |
| 59 | + service: |
| 60 | + name: bt-frontend-svc |
| 61 | + - path: /api |
| 62 | + backend: |
| 63 | + service: |
| 64 | + name: bt-backend-svc |
| 65 | +``` |
| 66 | +
|
| 67 | +This example `Ingress` resource maps packets routed to `berkeleytime.com/` to the frontend service and maps packets routed to `berkeleytime.com/api` to the backend service. |
| 68 | + |
| 69 | +The `ingressClassName` instructs `ingress-nginx` to manage this `Ingress` resource as one of its reverse proxy destinations. |
| 70 | + |
| 71 | + |
| 72 | +### Certificate Manager |
| 73 | + |
| 74 | +`cert-manager` is a service that can automatically issue and renew certificates. We only use it to renew certificates. We hardcode a certificate with all domains needed instead of automatic issuing. |
| 75 | + |
| 76 | +```yaml |
| 77 | +apiVersion: cert-manager.io/v1 |
| 78 | +kind: Certificate |
| 79 | +metadata: |
| 80 | + name: bt-cert |
| 81 | +spec: |
| 82 | + secretName: bt-cert |
| 83 | + dnsNames: |
| 84 | + - berkeleytime.com |
| 85 | + - "*.berkeleytime.com" |
| 86 | + - "*.dev.berkeleytime.com" |
| 87 | + - stanfurdtime.com |
| 88 | + - "*.stanfurdtime.com" |
| 89 | + - "*.dev.stanfurdtime.com" |
| 90 | +``` |
| 91 | + |
| 92 | +Here is a snippet of the hardcoded certificate deployed as of August 2025. This is linked in the `Ingress` resource earlier under `spec.tls`. |
0 commit comments