@dmgnr/kuber 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -0
- package/dist/index.js +114 -114
- package/package.json +14 -11
- package/schema/docker.d.ts +2595 -0
- package/types.d.ts +72 -0
package/README.md
CHANGED
|
@@ -37,6 +37,10 @@ Not required locally:
|
|
|
37
37
|
|
|
38
38
|
Docker is not required because builds happen on the remote builder after `kuber` syncs your repo state there. `kubectl` is not required because cluster access is handled through the bundled Kubernetes client.
|
|
39
39
|
|
|
40
|
+
## Next.js Example
|
|
41
|
+
|
|
42
|
+
[`example/`](example/) contains a documented deployment template for adding kuber to an existing Bun-powered Next.js project without initializing or bundling an application in this repository. It includes a standalone-output Dockerfile, `.dockerignore`, `compose.yml`, and the required Next.js configuration.
|
|
43
|
+
|
|
40
44
|
## Running
|
|
41
45
|
|
|
42
46
|
During development:
|
|
@@ -63,6 +67,17 @@ bun run index.ts start
|
|
|
63
67
|
bun run index.ts stop
|
|
64
68
|
bun run index.ts restart
|
|
65
69
|
bun run index.ts db ls
|
|
70
|
+
bun run index.ts s3 ls
|
|
71
|
+
bun run index.ts s3 creds app
|
|
72
|
+
bun run index.ts s3 ui app
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
All commands accept `--config` to use a configuration file other than
|
|
76
|
+
`.kuberrc.ts`:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
kuber --config deploy/production.kuberrc.ts up
|
|
80
|
+
kuber up --config deploy/production.kuberrc.ts
|
|
66
81
|
```
|
|
67
82
|
|
|
68
83
|
### Shell Completion
|
|
@@ -90,6 +105,64 @@ For a permanent setup, write the generated script to a file and source it from y
|
|
|
90
105
|
- `exec <deployment> <command...>`: execute a command inside a running deployment pod
|
|
91
106
|
- `db ls`: list managed Postgres claims declared in the current Compose file
|
|
92
107
|
- `db creds <service>`: print the generated connection details for a managed Postgres claim
|
|
108
|
+
- `s3 ls`: list managed S3 claims declared in the current Compose file
|
|
109
|
+
- `s3 creds <service>`: print all generated S3 environment variables for a service
|
|
110
|
+
- `s3 ui <service>`: print the Garage UI object-browser URL for a service bucket
|
|
111
|
+
|
|
112
|
+
## Configuration
|
|
113
|
+
|
|
114
|
+
Kuber optionally loads `.kuberrc.ts` from the working directory. The file must
|
|
115
|
+
default export an object satisfying the published `KuberConfig` type:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import type { KuberConfig } from "@dmgnr/kuber";
|
|
119
|
+
|
|
120
|
+
export default {
|
|
121
|
+
project: "my-app",
|
|
122
|
+
composeFile: "compose.production.yml",
|
|
123
|
+
registry: "registry.example.com",
|
|
124
|
+
builders: {
|
|
125
|
+
amd64: "kuber@amd-builder",
|
|
126
|
+
arm64: "kuber@arm-builder",
|
|
127
|
+
remoteRoot: "kuber-build",
|
|
128
|
+
},
|
|
129
|
+
rolloutTimeoutMs: 10 * 60_000,
|
|
130
|
+
|
|
131
|
+
async compose(compose) {
|
|
132
|
+
const app = compose.services?.app;
|
|
133
|
+
if (app && !Array.isArray(app.environment)) {
|
|
134
|
+
app.environment ??= {};
|
|
135
|
+
app.environment.NEXT_PUBLIC_BUILD_ID =
|
|
136
|
+
await Bun.$`git rev-parse --short HEAD`
|
|
137
|
+
.text()
|
|
138
|
+
.then((value) => value.trim());
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
} satisfies KuberConfig;
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Operational defaults:
|
|
145
|
+
|
|
146
|
+
- `project`: current working directory name
|
|
147
|
+
- `composeFile`: the first recognized Compose filename in the working directory
|
|
148
|
+
- `registry`: `registry.neko-piranha.ts.net`
|
|
149
|
+
- `builders.amd64`: `kuber@astral-th`
|
|
150
|
+
- `builders.arm64`: `kuber@astral`
|
|
151
|
+
- `builders.remoteRoot`: `kuber-build`
|
|
152
|
+
- `rolloutTimeoutMs`: `300000`
|
|
153
|
+
|
|
154
|
+
Configuration hooks can be synchronous or asynchronous and receive mutable
|
|
155
|
+
values:
|
|
156
|
+
|
|
157
|
+
- `compose(compose, context)`: once after parsing and validation; affects every command that reads Compose
|
|
158
|
+
- `preBuild(compose, context)`: before build eligibility is evaluated when builds are enabled
|
|
159
|
+
- `postBuild(result, context)`: after images are built; `result` contains `built` and `changed` service names
|
|
160
|
+
- `postRender(resources, context)`: after rendering and before reconciliation planning; also runs for `export`
|
|
161
|
+
- `postApply(resources, context)`: after desired resources are successfully applied
|
|
162
|
+
|
|
163
|
+
Hook context contains the resolved `cwd`, `project`, `composeFile`, and optional
|
|
164
|
+
`configFile`. A hook error aborts the command and is reported by the normal CLI
|
|
165
|
+
error handler.
|
|
93
166
|
|
|
94
167
|
## Compose Conventions
|
|
95
168
|
|
|
@@ -188,6 +261,18 @@ The Garage operator generates the credentials. `kuber` reads its generated Secre
|
|
|
188
261
|
|
|
189
262
|
One service can declare both `postgresql:...` and `s3:...`; all generated values are merged into the same service Secret. Managed Garage buckets and keys are retained by normal `down` and deleted by `down -f`.
|
|
190
263
|
|
|
264
|
+
Inspect a claim, print its generated credentials, or get its Garage UI URL:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
kuber s3 ls
|
|
268
|
+
kuber s3 creds app
|
|
269
|
+
kuber s3 ui app
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
`s3 creds` prints `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`,
|
|
273
|
+
`AWS_ENDPOINT_URL_S3`, `AWS_REGION`, and `S3_BUCKET` as shell-style environment
|
|
274
|
+
assignments. `s3 ui` only prints the URL; it does not open a browser.
|
|
275
|
+
|
|
191
276
|
### Environment Files
|
|
192
277
|
|
|
193
278
|
`env_file` entries are read locally and turned into a Kubernetes `Secret` named `<service>-env`. Deployments then consume that secret through `envFrom`.
|