Skip to content

Commit 41ef6f1

Browse files
authored
feat(docs): update docs for "import from knative service" (#49)
1 parent abe6f1b commit 41ef6f1

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ Kuba provides several commands to help you manage your configuration:
209209
- `completion`: Generates shell completion scripts for Kuba
210210
- `config`: Manages global Kuba configuration options such as:
211211
- `cache`: Enable or disable local caching of secrets
212-
- `convert`: Converts existing **dotenv** (`.env*`) files to `kuba.yaml` format
212+
- `convert`: Converts existing configuration sources (e.g. **dotenv** (`.env*`), **Knative Service** manifests) to `kuba.yaml` format
213213
- `help`: Displays help information for Kuba and its commands
214214
- `init`: Initializes a new `kuba.yaml` configuration file in the current directory
215215
- `run`: Runs an application with environment variables fetched from secrets
@@ -567,6 +567,30 @@ kuba convert --infile .env
567567
kuba convert --infile .env.staging --outfile my-kuba.yaml --env staging
568568
```
569569

570+
### Converting Knative Service (`ksvc`) manifests
571+
572+
If you already have a Knative Service (for example a Cloud Run service) with all
573+
your environment variables defined, you can generate a `kuba.yaml` from that
574+
manifest:
575+
576+
```sh
577+
# Convert a Knative Service manifest to kuba.yaml for the production environment
578+
kuba convert --from ksvc --infile service.yaml --env production
579+
```
580+
581+
Kuba will:
582+
583+
- Read the container `env` section of the Service template.
584+
- Convert hard-coded `value` entries into `value` mappings in `kuba.yaml`.
585+
- Convert `valueFrom.secretKeyRef` entries into `secret-key` mappings, using the
586+
Kubernetes Secret name as the secret identifier.
587+
588+
For Knative Services running on GCP (Cloud Run), the generated environment will
589+
default to:
590+
591+
- `provider: gcp`
592+
- `project`: the Service `metadata.namespace` (typically the GCP project number)
593+
570594
### Show effective environment variables
571595

572596
You can use the `show` subcommand to display the

web/src/routes/configuration/+page.svelte

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,33 @@
9191
</p>
9292
</div>
9393
</div>
94+
95+
<div class="divider">OR</div>
96+
97+
<div class="card bg-base-200 mb-6">
98+
<div class="card-body">
99+
<h3 class="card-title">
100+
Import from Knative Service (<code>ksvc</code>)
101+
</h3>
102+
<p class="mb-4">
103+
If you're running on Cloud Run / Knative, you can generate a <code>kuba.yaml</code>
104+
from an existing Knative Service manifest. Kuba will read the container
105+
<code>env</code> entries, convert hard-coded values to <code>value</code> mappings and
106+
<code>valueFrom.secretKeyRef</code> entries to <code>secret-key</code> mappings.
107+
</p>
108+
<pre><code
109+
class="language-bash"
110+
data-toolbar-order="copy-to-clipboard"
111+
data-prismjs-copy="📋"
112+
>kuba convert --from ksvc --infile service.yaml --env production</code
113+
></pre>
114+
<p class="mt-4">
115+
For Knative Services running on GCP, the environment will default to provider
116+
<code>gcp</code> and use the Service's <code>metadata.namespace</code> as the
117+
<code>project</code> (which is typically the GCP project number for Cloud Run).
118+
</p>
119+
</div>
120+
</div>
94121
</section>
95122

96123
<section>

0 commit comments

Comments
 (0)