Serve HTTP with TLS from the LabKit configuration
### Problem
This service serves plain HTTP. It calls `httpserver.NewWithConfig` at
`internal/server/server.go:133`, and that configuration has no field for a
certificate. The service therefore cannot serve TLS, and TLS terminates at a
proxy in front of it.
The service cannot write its own HTTP server instead, because it uses the
LabKit middleware for correlation, tracing, access logs, and panic recovery.
### Change
1. Take the TLS fields that gitlab-org/labkit#143 adds to `httpserver.Config`.
2. Connect the existing `TLSConfig` message of the protocol definition to those
fields. The docstring of that message already includes the server
certificate.
3. Add a mode field for client certificate verification. The current
`TLSConfig` message holds `ca_cert`, `cert`, `key`, and `server_name` only.
Use the vocabulary of `ssl_verify_client`: `off`, `optional_no_ca`,
`optional`, and `on`.
A certificate authority with no mode gives `optional`. Mutual TLS is therefore
possible, and it is never obligatory. `gitlab-org/ops/artifact-registry#1016`
(item A6) does not block this issue.
The probes need no change. They already use port 9090.
### Acceptance criteria
- The service serves HTTPS from a `kubernetes.io/tls` secret that
`secretVolumes` mounts.
- An operator can select each of the four verification modes.
- New certificate files change the served certificate. The service does not
restart.
- `curl -v --http2` negotiates `h2`.
- A slow TLS handshake does not fail a valid request. The handshake consumes
the `ReadTimeout` of the application server, and that default is 5 seconds
(`v2/httpserver/server.go:23`, applied at `:181`). A large certificate chain
makes this measurable. Give the timeout a value, or record that the default
is sufficient.
### Two client-visible changes
1. **The probe listener is untouched.** TLS goes on the application server
only. LabKit builds the probe listener as a separate `http.Server` with its
own mux and no middleware (`v2/httpserver/server.go:186-192`), and serves
the two listeners with two separate calls (`:264`, `:272`). The insertion
point for TLS is `s.srv.Serve(ln)` at `:264`, which becomes `ServeTLS` or a
`tls.NewListener` wrap.
2. **HTTP/2 arrives with TLS.** There is no `http2`, `h2c`, `TLSNextProto`, or
ALPN handling anywhere in LabKit v2 today. The acceptance criterion
"`curl -v --http2` negotiates `h2`" on gitlab-org/labkit#143 implies ALPN, and ALPN
happens only under TLS. This issue therefore moves Artifact Registry from
HTTP/1.1 to HTTP/2 by default. Confirm that each client tolerates it.
### Ship this with `gitlab-com/gl-infra/platform/runway/fairway#66` (item C1b)
`internal/chartsrc/templates/service.yaml:15-20` writes `appProtocol` as a
constant: `kubernetes.io/h2c` for a gRPC service, `"http"` for every other
protocol. Once this issue lands, this service speaks `h2` while the chart
advertises `"http"`. A load balancer or a mesh can read that value and select
the wrong behaviour for the port.
Item **C1b** of Epic P3 makes the value settable. **Neither issue blocks the
other from merging** — this one is a service change, that one is a template
change, and they share no code. What matters is the window between them, in
which the chart is wrong. Treat them as a co-requirement: land C1b first or
land them together, and if this one must ship alone, record the incorrect
`appProtocol` as a known defect with C1b named as the fix.
### Relationship to #98
An earlier version of this tree called these two items a conflict. That was
overstated. The conflict is **textual, not a disagreement about design.** The
two changes touch different fields, use different LabKit keys, and share no
semantics:
| | #98 | this issue |
| :-- | :-- | :-- |
| Proto | `ServerConfig.probe_address` | `TLSConfig`, and a verify-mode field |
| LabKit key | `httpserver.Config.ProbeAddr` | a TLS field that does not exist yet |
| Removes | `deriveProbeAddr`, `ErrProbePortCollision` | — |
Either order works. Expect a merge conflict in `server_config.proto` and in
`server.New`.
**Sequence #98 first, for one reason beyond merge mechanics.** Issue #98 moves
collision detection to configuration-load time, with a protovalidate rule that
refuses `probe_address == address`. Today a collision is an annoyance at
start-up. After this issue, the two listeners differ in whether they carry
TLS, so their distinctness becomes a trust boundary. A rule that refuses the
collision at configuration load is therefore a precondition that this issue
benefits from.
Note also that #98 is the consequence of LabKit `!402`, not its resolution.
Issue #98 says so: the S01 specification was written against an early LabKit
v2 that served the probe paths on the application listener, and `!402`
(LabKit v2.6.1) introduced the dedicated probe listener that the pinned
v2.8.0 inherits. Issue #98 is Artifact Registry catching up to that split.
### Reference
Item A4 of the plan in gitlab-org/gitlab#619690.
Depends on gitlab-org/labkit#143, which holds the LabKit design.
The workplan on this issue holds the design of this half.
### Related
- #326 — closed. It introduced the `TLSConfig`
message, for outbound clients to virtual-repository upstreams.
- #304 — closed. It confirms that the current
deployment terminates TLS at a proxy.
---
Drafted with Claude :claude:
issue
GitLab AI Context
Project: gitlab-org/ops/artifact-registry
Instance: https://gitlab.com
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://gitlab.com/gitlab-org/ops/artifact-registry/-/raw/main/CONTRIBUTING.md — contribution guidelines
- https://gitlab.com/gitlab-org/ops/artifact-registry/-/raw/main/README.md — project overview and setup
- https://gitlab.com/gitlab-org/ops/artifact-registry/-/raw/main/AGENTS.md — AI agent instructions
- https://gitlab.com/gitlab-org/ops/artifact-registry/-/raw/main/CLAUDE.md — Claude Code instructions
Repository: https://gitlab.com/gitlab-org/ops/artifact-registry
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD