forked from calfonso/rusternetes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-server-config.html
More file actions
386 lines (356 loc) · 13.9 KB
/
Copy pathapi-server-config.html
File metadata and controls
386 lines (356 loc) · 13.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Server Configuration - Rūsternetes</title>
<link rel="icon" type="image/svg+xml" href="../favicon.svg">
<link rel="stylesheet" href="../style.css">
</head>
<body>
<nav class="nav">
<div class="nav-inner">
<a href="../index.html" class="nav-logo">
<img src="../favicon-colored.svg" width="22" height="22" alt="" style="vertical-align: middle;"> rūsternetes
</a>
<div class="nav-links">
<a href="index.html" style="color: var(--walle-yellow);">Docs</a>
<a href="https://github.com/calfonso/rusternetes" class="nav-gh">GitHub</a>
</div>
</div>
</nav>
<div class="doc-layout">
<aside class="doc-sidebar">
<div class="doc-search">
<input type="text" class="doc-search-input" placeholder="Search docs... ( / )">
</div>
<div class="doc-search-results"></div>
<div class="sidebar-section">
<div class="sidebar-heading">Getting Started</div>
<ul class="sidebar-links">
<li><a href="quickstart.html">Quick Start</a></li>
<li><a href="installation.html">Installation</a></li>
</ul>
</div>
<div class="sidebar-section">
<div class="sidebar-heading">Deployment</div>
<ul class="sidebar-links">
<li><a href="deployment.html">Overview</a></li>
<li><a href="all-in-one.html">All-in-One Binary</a></li>
<li><a href="docker-cluster.html">Compose + etcd</a></li>
<li><a href="sqlite-cluster.html">Compose + SQLite</a></li>
<li><a href="redis-cluster.html">Compose + Redis</a></li>
<li><a href="high-availability.html">High Availability</a></li>
</ul>
</div>
<div class="sidebar-section">
<div class="sidebar-heading">Cluster Setup</div>
<ul class="sidebar-links">
<li><a href="bootstrap.html">Bootstrap</a></li>
</ul>
</div>
<div class="sidebar-section">
<div class="sidebar-heading">Configuration</div>
<ul class="sidebar-links">
<li><a href="api-server-config.html" class="active">API Server</a></li>
<li><a href="kubelet-config.html">Kubelet</a></li>
<li><a href="scheduler-config.html">Scheduler</a></li>
<li><a href="controller-manager-config.html">Controller Manager</a></li>
<li><a href="kube-proxy-config.html">Kube-Proxy</a></li>
<li><a href="storage-config.html">Storage Backends</a></li>
</ul>
</div>
<div class="sidebar-section">
<div class="sidebar-heading">Features</div>
<ul class="sidebar-links">
<li><a href="workloads.html">Workloads</a></li>
<li><a href="networking.html">Networking</a></li>
<li><a href="storage-volumes.html">Storage & Volumes</a></li>
<li><a href="security.html">Security</a></li>
<li><a href="crds.html">Custom Resources</a></li>
<li><a href="scheduling.html">Scheduling</a></li>
<li><a href="containers.html">Container Runtime</a></li>
<li><a href="kubectl.html">kubectl</a></li>
</ul>
</div>
<div class="sidebar-section">
<div class="sidebar-heading">Operations</div>
<ul class="sidebar-links">
<li><a href="authentication.html">Authentication</a></li>
<li><a href="monitoring.html">Monitoring</a></li>
<li><a href="troubleshooting.html">Troubleshooting</a></li>
<li><a href="cloud-providers.html">Cloud Providers</a></li>
</ul>
</div>
<div class="sidebar-section">
<div class="sidebar-heading">Reference</div>
<ul class="sidebar-links">
<li><a href="api-reference.html">API Reference</a></li>
<li><a href="conformance.html">Conformance</a></li>
</ul>
</div>
</aside>
<div class="doc-overlay"></div>
<main class="doc-content">
<p class="breadcrumb">Configuration › API Server</p>
<h1>API Server Configuration</h1>
<p class="lead">
The API server is the central hub of the Rūsternetes cluster. It exposes the Kubernetes
REST API over HTTPS using Axum with 76 handlers and a 2500-line router.
</p>
<h2>CLI Flags</h2>
<table>
<thead>
<tr>
<th>Flag</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>--bind-address</code></td>
<td>String</td>
<td><code>0.0.0.0:6443</code></td>
<td>Address and port the API server listens on</td>
</tr>
<tr>
<td><code>--etcd-servers</code></td>
<td>String</td>
<td><code>http://localhost:2379</code></td>
<td>Comma-separated list of etcd endpoints</td>
</tr>
<tr>
<td><code>--log-level</code></td>
<td>String</td>
<td><code>info</code></td>
<td>Log level: <code>trace</code>, <code>debug</code>, <code>info</code>, <code>warn</code>, <code>error</code></td>
</tr>
<tr>
<td><code>--jwt-secret</code></td>
<td>String</td>
<td><code>rusternetes-secret-change-in-production</code></td>
<td>HMAC fallback secret for SA tokens (RS256 preferred when SA keys exist)</td>
</tr>
<tr>
<td><code>--tls</code></td>
<td>bool</td>
<td><code>false</code></td>
<td>Enable TLS/HTTPS</td>
</tr>
<tr>
<td><code>--tls-cert-file</code></td>
<td>String</td>
<td>—</td>
<td>Path to TLS certificate file (PEM format)</td>
</tr>
<tr>
<td><code>--tls-key-file</code></td>
<td>String</td>
<td>—</td>
<td>Path to TLS private key file (PEM format)</td>
</tr>
<tr>
<td><code>--tls-self-signed</code></td>
<td>bool</td>
<td><code>false</code></td>
<td>Generate a self-signed certificate if no TLS files are provided</td>
</tr>
<tr>
<td><code>--tls-san</code></td>
<td>String</td>
<td><code>localhost,127.0.0.1</code></td>
<td>Comma-separated Subject Alternative Names for self-signed cert</td>
</tr>
<tr>
<td><code>--skip-auth</code></td>
<td>bool</td>
<td><code>false</code></td>
<td>Disable authentication and authorization (insecure, dev only). Enabled by default in all-in-one mode.</td>
</tr>
<tr>
<td><code>--storage-backend</code></td>
<td>String</td>
<td><code>etcd</code></td>
<td>Storage backend: <code>etcd</code>, <code>sqlite</code>, or <code>redis</code></td>
</tr>
<tr>
<td><code>--data-dir</code></td>
<td>String</td>
<td><code>./data/rusternetes.db</code></td>
<td>SQLite database path (only used with <code>--storage-backend=sqlite</code>)</td>
</tr>
<tr>
<td><code>--redis-url</code></td>
<td>String</td>
<td><code>redis://localhost:6379</code></td>
<td>Redis server URL (only used with <code>--storage-backend=redis</code>)</td>
</tr>
<tr>
<td><code>--prometheus-url</code></td>
<td>String</td>
<td>—</td>
<td>Prometheus server URL for custom metrics queries (HPA, etc.)</td>
</tr>
</tbody>
</table>
<h2>Usage Examples</h2>
<pre>
<div class="code-header">
<span class="code-dot red"></span>
<span class="code-dot yellow"></span>
<span class="code-dot green"></span>
<span class="code-title">terminal</span>
</div>
<code><span class="comment"># Production with etcd and TLS certificates</span>
rusternetes-api-server \
<span class="flag">--tls</span> \
<span class="flag">--tls-cert-file</span> <span class="value">/etc/rusternetes/certs/api-server.crt</span> \
<span class="flag">--tls-key-file</span> <span class="value">/etc/rusternetes/certs/api-server.key</span> \
<span class="flag">--etcd-servers</span> <span class="value">http://etcd:2379</span>
<span class="comment"># Development with self-signed cert</span>
rusternetes-api-server \
<span class="flag">--tls</span> \
<span class="flag">--tls-self-signed</span> \
<span class="flag">--skip-auth</span>
<span class="comment"># SQLite backend (no external dependencies)</span>
rusternetes-api-server \
<span class="flag">--storage-backend</span> <span class="value">sqlite</span> \
<span class="flag">--data-dir</span> <span class="value">./data/rusternetes.db</span> \
<span class="flag">--tls</span> <span class="flag">--tls-self-signed</span>
<span class="comment"># Redis backend (via rhino gRPC)</span>
rusternetes-api-server \
<span class="flag">--storage-backend</span> <span class="value">redis</span> \
<span class="flag">--redis-url</span> <span class="value">redis://localhost:6379</span> \
<span class="flag">--tls</span> <span class="flag">--tls-self-signed</span></code>
</pre>
<h2>HTTP/2 Settings</h2>
<p>
The API server configures HTTP/2 parameters to match Kubernetes behavior and support
many concurrent watch streams without flow control stalls:
</p>
<table>
<thead>
<tr>
<th>Setting</th>
<th>Value</th>
<th>Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td>Initial stream window size</td>
<td>256 KB</td>
<td>Per-stream flow control window (K8s: 256 KB)</td>
</tr>
<tr>
<td>Initial connection window size</td>
<td>25 MB</td>
<td>Total connection flow control (256 KB × 100 streams)</td>
</tr>
<tr>
<td>Max concurrent streams</td>
<td>250</td>
<td>Maximum HTTP/2 streams per connection</td>
</tr>
<tr>
<td>ALPN protocols</td>
<td><code>h2</code>, <code>http/1.1</code></td>
<td>Required for Go client-go compatibility</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<div class="admonition-title">HTTP/2 ALPN</div>
<p>
The TLS configuration must set ALPN protocols to <code>["h2", "http/1.1"]</code>.
Without this, Go's client-go library cannot negotiate HTTP/2, causing watch streams
to fail with "context canceled" errors.
</p>
</div>
<h2>TLS Configuration</h2>
<h3>Self-Signed Certificate</h3>
<p>
When <code>--tls-self-signed</code> is used, the API server generates an in-memory
certificate with these properties:
</p>
<table>
<thead>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Validity</td>
<td>10 years</td>
</tr>
<tr>
<td>Organization</td>
<td>Rūsternetes</td>
</tr>
<tr>
<td>Country</td>
<td>US</td>
</tr>
<tr>
<td>CA</td>
<td>TRUE</td>
</tr>
<tr>
<td>SANs</td>
<td>From <code>--tls-san</code> flag (default: <code>localhost,127.0.0.1</code>)</td>
</tr>
</tbody>
</table>
<h3>PEM Certificate Loading</h3>
<p>
For production, provide PEM-encoded certificate and key files. The API server
supports mTLS — the loaded certificate is also used to verify client certificates
when presented.
</p>
<h2>Authentication</h2>
<p>
The API server uses RS256 JWT tokens for ServiceAccount authentication. It automatically
detects RSA keys at <code>.rusternetes/certs/sa.key</code> and <code>sa.pub</code>. If
RSA keys are not found, it falls back to HMAC HS256 using the <code>--jwt-secret</code> value.
</p>
<div class="admonition warning">
<div class="admonition-title">CHANGE THE DEFAULT SECRET</div>
<p>
The default <code>--jwt-secret</code> value is insecure. In production, always use
RS256 with proper SA signing keys, or at minimum change the HMAC secret.
</p>
</div>
<h2>Startup Behavior</h2>
<p>On startup, the API server:</p>
<ul>
<li>Connects to the storage backend (etcd, SQLite, or Redis)</li>
<li>Initializes the TokenManager with RS256 keys or HMAC fallback</li>
<li>Sets up RBAC authorization (or AlwaysAllow if <code>--skip-auth</code>)</li>
<li>Bootstraps the <code>kubernetes</code> Service Endpoints with the server's IP</li>
<li>Creates the default ServiceCIDR (<code>10.96.0.0/12</code>)</li>
<li>Pre-allocates ClusterIPs from existing services to prevent collisions</li>
<li>Starts the HTTP/2 server with TLS (or plain HTTP if TLS disabled)</li>
</ul>
<div class="doc-pager">
<a href="bootstrap.html" class="prev">
<span class="pager-label">Previous</span>
← Bootstrap
</a>
<a href="kubelet-config.html" class="next">
<span class="pager-label">Next</span>
Kubelet Config →
</a>
</div>
</main>
</div>
<footer class="doc-footer">
<p><a href="../index.html">Rūsternetes</a> — Kubernetes reimplemented in Rust. Apache-2.0 License.</p>
</footer>
<button class="sidebar-toggle" aria-label="Toggle navigation">☰</button>
<script src="search.js"></script>
</body>
</html>