Skip to content

Commit 23baa77

Browse files
authored
Merge pull request #138 from sdcio/addsdctoolssection
Add cli-tools section
2 parents b94e66e + ddb548c commit 23baa77

9 files changed

Lines changed: 182 additions & 8 deletions

File tree

‎docs/cli-tools/index.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# CLI Tools
2+
3+
SDC ships two official command-line tools that complement the Kubernetes-based control plane.
4+
5+
| | [sdc-lite](sdc-lite.md) | [kubectl-sdc](kubectl-sdc.md) |
6+
|---|---|---|
7+
| **What it is** | Standalone CLI for YANG-based config work | `kubectl` plugin for SDC on Kubernetes |
8+
| **Requires Kubernetes** | No | Yes |
9+
| **Requires a live device** | No | No (reads from data-server) |
10+
| **Primary audience** | Network engineers, CI pipelines, offline workflows | Operators managing live SDC-managed targets |
11+
| **Key capabilities** | Schema loading, config validation, format conversion, diffing, blame | Running config retrieval, blame, deviation inspection and revert |
12+
13+
## When to use which
14+
15+
Use **`sdc-lite`** when you want to work with YANG schemas and device configurations without a running Kubernetes cluster — for example, to validate a config file in CI, convert between formats (JSON, XML, JSON-IETF), or explore what a set of intents produces before pushing them.
16+
17+
Use **`kubectl-sdc`** when you have a live cluster with SDC installed and want to inspect the state of managed targets — for example, to trace which intent owns a given config leaf, retrieve the running config from a device, or detect and revert deviations.

‎docs/cli-tools/kubectl-sdc.md‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# kubectl-sdc
2+
3+
[`kubectl-sdc`](https://github.com/sdcio/kubectl-sdc) is a `kubectl` plugin that extends the Kubernetes CLI with SDC-specific commands. It provides visibility into the state of SDC-managed targets directly from the command line, without needing to query raw Kubernetes resources.
4+
5+
## Use cases
6+
7+
- **Inspect running config** — retrieve the actual configuration present on a managed device, in a human-readable format.
8+
- **Trace intent ownership** — use `blame` to see which Config CR (or the device itself) is the source of each configuration leaf, and detect where higher-priority intents are overriding others.
9+
- **Detect and revert deviations** — list configuration paths where the device has drifted from its intended state, and selectively revert them.
10+
11+
## Installation
12+
13+
```bash
14+
curl -fsSL https://raw.githubusercontent.com/sdcio/kubectl-sdc/main/install.sh | sh
15+
```
16+
17+
Alternatively, if you have Go installed:
18+
19+
```bash
20+
go install github.com/sdcio/kubectl-sdc/cmd/kubectl-sdc@main
21+
```
22+
23+
Once installed, `kubectl sdc` is available as a `kubectl` plugin. The install script also installs `kubectl_complete-sdc` for tab-completion support.
24+
25+
## Key commands
26+
27+
| Command | Description |
28+
|---|---|
29+
| `kubectl sdc blame --target <name>` | Tree view of the running config showing which intent owns each leaf |
30+
| `kubectl sdc runningconfig --target <name>` | Retrieve the running config from the data-server |
31+
| `kubectl sdc deviation --target <name>` | List deviations (drifts between intended and actual config) for a target |
32+
| `kubectl sdc apply -f <file>` | Apply a `TargetClearDeviation` manifest to revert selected deviations |
33+
34+
Both `blame` and `deviation` support `--filter-*` flags for narrowing output by path, leaf name, or owner, and an `--interactive` mode backed by a fuzzy finder.
35+
36+
## Workflow example
37+
38+
The following walkthrough inspects a live SDC-managed target, finds a deviation, and reverts it.
39+
40+
```bash
41+
# 1. See the running config for a target in xpath format
42+
kubectl sdc runningconfig --target srl1 --format xpath
43+
44+
# 2. Check which intent owns each config leaf — filter to just the interface subtree
45+
kubectl sdc blame --target srl1 --filter-path /interface
46+
47+
# 3. List all deviations on the target
48+
kubectl sdc deviation --target srl1
49+
50+
# 4. Narrow down to deviations under /interface only
51+
kubectl sdc deviation --target srl1 --filter-path /interface
52+
53+
# 5. Render the selected deviations as a TargetClearDeviation manifest
54+
kubectl sdc deviation --target srl1 --filter-path /interface --format resource-yaml
55+
56+
# 6. Apply the manifest to revert the deviations
57+
kubectl sdc deviation --target srl1 --filter-path /interface --format resource-yaml \
58+
| kubectl sdc apply -f -
59+
```
60+
61+
!!! note
62+
All commands use the current `kubectl` context and namespace.
63+
64+
## Further reference
65+
66+
Full command reference, filtering options, and interactive mode documentation are available in the [kubectl-sdc GitHub repository](https://github.com/sdcio/kubectl-sdc).

‎docs/cli-tools/sdc-lite.md‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# sdc-lite
2+
3+
[`sdc-lite`](https://github.com/sdcio/sdc-lite) is a standalone CLI tool for working with network operating system (NOS) configurations based on YANG schemas. It runs entirely on your local machine — no Kubernetes cluster or live device connection required.
4+
5+
## Use cases
6+
7+
- **Validate configs offline** — check a configuration file against a YANG schema before pushing it to a device or submitting it to a CI pipeline.
8+
- **Convert between formats** — load a config in one format (e.g. `json_ietf`) and output it in another (e.g. `xml` or `json`).
9+
- **Inspect and diff intents** — load multiple config intents at different priorities and see the merged result, or diff it against a baseline running config.
10+
- **Trace intent ownership** — use `blame` to see which intent is the source of each config leaf in the merged result.
11+
12+
## Installation
13+
14+
```bash
15+
curl -fsSL https://raw.githubusercontent.com/sdcio/sdc-lite/main/install.sh | bash
16+
```
17+
18+
Alternatively, if you have Go installed:
19+
20+
```bash
21+
go install github.com/sdcio/sdc-lite@latest
22+
```
23+
24+
Shell completions (bash, zsh, fish) are installed automatically by the install script.
25+
26+
## Key commands
27+
28+
| Command | Description |
29+
|---|---|
30+
| `sdc-lite schema load -t <target> -f <schema.yaml>` | Load a YANG schema and associate it with a target |
31+
| `sdc-lite schema list` | List all loaded schemas |
32+
| `sdc-lite config load -t <target> --file <path> --file-format <fmt> --intent-name <name>` | Load a config file as a named intent |
33+
| `sdc-lite config validate -t <target>` | Validate the merged config against the schema |
34+
| `sdc-lite config diff -t <target>` | Show a diff between the intent config and the running baseline |
35+
| `sdc-lite config show -t <target> -o json -a` | Show the full merged configuration |
36+
| `sdc-lite config blame -t <target>` | Show which intent owns each config leaf |
37+
| `sdc-lite target show -t <target>` | Show target details (schema, intents) |
38+
| `sdc-lite target remove -t <target>` | Remove a target and its associated state |
39+
40+
## Workflow example
41+
42+
The following walkthrough loads a Nokia SR Linux schema, applies a running config as a baseline, overlays a config intent, and inspects the result.
43+
44+
```bash
45+
# 1. Load the YANG schema for SR Linux 24.10.1 and associate it with "router1"
46+
sdc-lite schema load -t router1 \
47+
-f https://raw.githubusercontent.com/sdcio/config-server/refs/heads/main/example/schemas/schema-nokia-srl-24.10.1.yaml
48+
49+
# 2. Load the device's running config as the lowest-priority baseline intent
50+
sdc-lite config load -t router1 \
51+
--file https://raw.githubusercontent.com/sdcio/sdc-lite/refs/tags/v0.1.0/data/config/running/running_srl_01.json \
52+
--file-format json \
53+
--intent-name running
54+
55+
# 3. Load a config intent at higher priority (ethernet-1/1 VLAN config)
56+
sdc-lite config load -t router1 \
57+
--file https://raw.githubusercontent.com/sdcio/sdc-lite/refs/tags/v0.1.0/data/config/additions/srl_01.json \
58+
--file-format json \
59+
--intent-name config1 \
60+
--priority 50
61+
62+
# 4. Validate the merged config against the schema
63+
sdc-lite config validate -t router1
64+
65+
# 5. Diff the intent additions against the running baseline
66+
sdc-lite config diff -t router1 --type patch
67+
68+
# 6. Blame — see which intent owns each config leaf under /interface
69+
sdc-lite config blame -t router1 -p /interface
70+
71+
# 7. Clean up
72+
sdc-lite target remove -t router1
73+
```
74+
75+
## Further reference
76+
77+
Full command reference and additional examples are available in the [sdc-lite GitHub repository](https://github.com/sdcio/sdc-lite).

‎docs/examples/1_k8s_srl.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,7 @@ EOF
269269

270270
[containerlab]: (https://containerlab.dev/install/)
271271
[kind]: (https://kind.sigs.k8s.io/)
272+
273+
## Next steps
274+
275+
Once your targets are configured, use [`kubectl-sdc`](../cli-tools/kubectl-sdc.md) to inspect the running config, trace intent ownership with `blame`, and detect or revert deviations.

‎docs/examples/2_k8s_sros.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ SDC will need to interact with a device that talks `YANG`. You can use physical,
1010

1111
[containerlab]: (https://containerlab.dev/install/)
1212

13+
!!!tip
14+
Once your targets are up and running, use [`kubectl-sdc`](../cli-tools/kubectl-sdc.md) to inspect running config, trace intent ownership with `blame`, and detect or revert deviations.
15+
1316
## SDC on Kubernetes
1417
Install the [k8s-collocated](../install/3_k8s_installation.md) environment using a [kind][kind] cluster
1518

‎docs/getting-started/basic-usage.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
The following examples demonstrate the basic usage of SDC in a scenario where a Nokia SR Linux node is being configured via SDC installed in a Kind based Kubernetes cluster.
33

44
## Prerequisites
5-
Please ensure that [Docker](https://docs.docker.com) is installed and running on your system. An installation guide can be found in the [Install Docker Engine](https://docs.docker.com/engine/install/) page. Also ensure [post-installation steps](https://docs.docker.com/engine/install/linux-postinstall/) are followed, so that the current user can run docker commands without sudo.
5+
Please ensure that [Docker](https://docs.docker.com) is installed and running on your system. An installation guide can be found in the [Install Docker Engine](https://docs.docker.com/engine/install/) page.
6+
7+
!!!tip
8+
If you want to explore and validate SDC configurations without a running Kubernetes cluster, check out [sdc-lite](../cli-tools/sdc-lite.md) — a standalone CLI tool for offline config validation, diffing, and format conversion.
69

710
Furthermore, the following tools are required to be installed on your system:
811
- [jq](https://stedolan.github.io/jq/) - a lightweight and flexible command-line JSON processor.
912

10-
1113
## Kind
1214
[kind](https://kind.sigs.k8s.io/) is a tool for running local Kubernetes clusters using Docker container “nodes”. `kind` was primarily designed for testing Kubernetes itself, but may be used for local development or CI.
1315

‎docs/user-guide/deviation.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ SDC will automatically reapply the Config CR when a NOT-APPLIED deviation is det
3232

3333
SDC will treat the deviation as part of the active configuration.
3434

35-
To clear a deviation we can select the deviations using the clear deviation logic in kubectl-sdc
35+
To clear a deviation we can select the deviations using the clear deviation logic in `kubectl-sdc`. See the [kubectl-sdc CLI tool](../cli-tools/kubectl-sdc.md) for installation and usage details.
3636

3737
[kubectl-sdc deviation](https://github.com/sdcio/kubectl-sdc/blob/main/README.md#deviation)
3838

‎docs/user-guide/troubleshooting.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ v1alpha1.inv.sdcio.dev Local True
1818
```
1919

2020
### Deployment
21-
SDC is deployed in the `sdc-system` namespace. If successful, you should see 3 running containers similar to this:
21+
The sdc components are deployed in the `sdc-system` namespace.
22+
Check if they are running.
2223

2324
```bash
2425
kubectl get pods -n sdc-system
2526
```
26-
There should be a config-server in the Ready state.
27+
There should be a 3 pods in Running state
2728
```
2829
NAME READY STATUS RESTARTS AGE
2930
api-server-6d7db47894-xj8wg 1/1 Running 0 38h
@@ -32,13 +33,13 @@ data-server-controller-0 2/2 Running 0 38h
3233
```
3334

3435
### Service
35-
For the APIServer a Service is referenced, this reference must resolve to the config-server.
36+
For the APIServer a Service is referenced, this reference must resolve to the api-server .
3637
Via the Endpoints the association to the pod can be verified.
3738
```bash
38-
kubectl get -n sdc-system endpoints api-server -o yaml
39+
kubectl get -n sdc-system endpoints api-server -o yaml
3940
```
4041

41-
The Subsets addresses must list the api-server pod.
42+
The Subsets addresses must list the config-server pod.
4243
```yaml
4344
apiVersion: v1
4445
kind: Endpoints

‎mkdocs.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ nav:
3333
- Deviation: user-guide/deviation.md
3434
- Disable Validation: user-guide/disablevalidation.md
3535
- Troubeshooting: user-guide/troubleshooting.md
36+
- CLI Tools:
37+
- Overview: cli-tools/index.md
38+
- sdc-lite: cli-tools/sdc-lite.md
39+
- kubectl-sdc: cli-tools/kubectl-sdc.md
3640
- System architecture:
3741
- Design: system-architecture/architecture.md
3842
- Components:

0 commit comments

Comments
 (0)