kubectl-sdc is the SDC specific kubectl plugin.
- Commands use the current kubectl config to access the cluster and namespace.
runningconfigconnects tosdc-system/data-servervia port-forward.
kubectl-sdc provides the following functionalities.
The blame command provides a tree based view on the actual running device configuration of the given SDC target.
It takes the --target parameter, that defines which targets is to be displayed.
The --format parameter supports tree (default) and xpath; with --format=xpath, the --interactive flag opens a fuzzyfinder with multi-select (Tab to select) and prints the selected XPath lines.
For every configured attribute you will see the highes preference value as well as the source of that value.
runningare attributes that come from the device itself, where no intent exist in sdc.defaultis all the default values that are present in the config, that are not overwritten by any specific config.<namespace>.<intentname>is the reference to the intent that defined the actual highes preference value for that config attribute.
kubectl sdc blame --target srl1 --filter-owner running --format tree --filter-path /interface[name=mgmt0]/subinterface --filter-path /system/snmp/access-group[name=SNMPv2-RO-Community] --filter-owner default --filter-leaf admin*
----- β π― default.srl1
----- β βββ π¦ interface
----- β β βββ π name=mgmt0
----- β β βββ π¦ subinterface
----- β β βββ π index=0
running β β βββ π admin-state -> enable
----- β β βββ π¦ ipv4
running β β β βββ π admin-state -> enable
----- β β βββ π¦ ipv6
running β β βββ π admin-state -> enable
----- β βββ π¦ system
----- β βββ π¦ snmp
----- β βββ π¦ access-group
----- β βββ π name=SNMPv2-RO-Community
default β βββ π admin-state -> enable
The blame command supports several filtering options to narrow down the results. All filters are cumulative (combined with "AND" logic), meaning only configuration elements that match ALL specified criteria will be displayed.
Available filters:
-
--filter-leaf <pattern>: Filter by leaf node name. Supports wildcards (*).- Example:
--filter-leaf "admin-state"shows only admin-state leaves - Example:
--filter-leaf "interface*"shows all leaves starting with "interface"
- Example:
-
--filter-owner <pattern>: Filter by configuration owner. Supports wildcards (*).- Example:
--filter-owner "running"shows only running configuration - Example:
--filter-owner "default.*"shows all default configurations - Example:
--filter-owner "production.intent-*"shows intents from production namespace
- Example:
-
--filter-path <pattern>: Filter by configuration path. Supports wildcards (*).- Example:
--filter-path "/config/service/*"shows only service-related configuration - Example:
--filter-path "*/interface/*"shows interface configuration at any level The whole path (including leaves) is involved in the pattern matching.
- Example:
-
--filter-deviation: Show only configuration elements that have deviations between intended and actual values.
# Show only admin-state configuration from running config
kubectl sdc blame --target sros --filter-leaf "admin-state" --filter-owner "running"
# Show all interface-related configuration with deviations
kubectl sdc blame --target sros --filter-path "*/interface/*" --filter-deviation
# Show configuration from specific intent with timeout-related leaves
kubectl sdc blame --target sros --filter-owner "production.intent-emergency" --filter-leaf "*timeout*"
# Combine multiple filters to find specific configuration
kubectl sdc blame --target sros --filter-path "/config/service/emergency/*" --filter-leaf "ambulance" --filter-owner "test-system.*"The runningconfig command retrieves the running configuration for a target from the data-server.
It takes the --target parameter, that defines which target is to be displayed.
The --format parameter controls the output format (json, json_ietf, xml, xpath, yaml). Default is xpath.
Hints:
- The command uses the current kubectl config to access the cluster and namespace.
- The command connects to the
sdc-system/data-serverservice (port-forward) to fetch the running config.
Example:
kubectl sdc runningconfig --target srl1 --format xpath
/system/snmp/access-group[name=SNMPv2-RO-Community]/name: SNMPv2-RO-Community
/system/snmp/access-group[name=SNMPv2-RO-Community]/security-level: no-auth-no-priv
/system/snmp/network-instance[name=mgmt]/admin-state: enable
/system/snmp/network-instance[name=mgmt]/name: mgmt
/system/ssh-server[name=mgmt-netconf]/admin-state: enable
/system/ssh-server[name=mgmt-netconf]/disable-shell: true
/system/ssh-server[name=mgmt-netconf]/name: mgmt-netconf
/system/ssh-server[name=mgmt-netconf]/network-instance: mgmt
/system/ssh-server[name=mgmt-netconf]/port: 830
/system/ssh-server[name=mgmt]/admin-state: enable
/system/ssh-server[name=mgmt]/name: mgmt
/system/ssh-server[name=mgmt]/network-instance: mgmt
/system/ssh-server[name=mgmt]/use-credentialz: true
/system/tls/server-profile[name=clab-profile]/authenticate-client: false
...
The deviation command lists and optionally reverts deviations.
By default, the command is non-interactive: it outputs all matching deviations directly.
Use --interactive to open the fuzzy finder selector.
It takes one of the following parameters:
--target: shows all deviations for the specified target and limits--deviationautocompletion to deviations from that target.--deviation: shows only the specified deviation resource.
At least one of --target or --deviation must be provided.
Flags:
--format: output format (text(default),resource-yaml,resource-json).--filter-path: filter deviation paths by prefix before selection/output. Can be repeated.--revert: clear the final selected/output deviations on the target.--interactive: enable interactive fuzzy finder mode.--preview: show preview panel in interactive mode.--query: initial fuzzy finder query in interactive mode.--select-path-prefix: mark matching path prefixes as selected in interactive mode. Can be repeated.--auto-accept-select-path-prefix: automatically confirm selected path prefixes in interactive mode.
--revert can be used with --target, --deviation, or both, and is compatible with --preview.
Mode behavior:
- Non-interactive (default): output all deviations after applying
--filter-path. - Interactive (
--interactive): choose deviations in fuzzy finder;--select-path-prefixand--queryapply here. --select-path-prefixand--auto-accept-select-path-prefixrequire--interactive.
Selection notes:
- The preview shows the actual and desired value for the currently selected path.
- When
--format=text, exiting the interactive window prints the current human-readable deviation output. - When
--format=resource-yamlor--format=resource-json, exiting the interactive window prints aTargetClearDeviationmanifest built from the selected entries. - When
--revertis set, the selected entries are cleared on the target.
Interactive quick keys:
Tabtoggle selectionEnterconfirm selectionEsc/Ctrl+CabortCtrl+Ttoggle previewCtrl+Stoggle selected-items view
Flag overview:
| Flag | Mode | Purpose |
|---|---|---|
--interactive |
Interactive | Open fuzzy finder selection UI |
--filter-path |
Both | Filter deviation paths by prefix before selection/output |
--select-path-prefix |
Interactive | Mark matching path prefixes as selected |
--auto-accept-select-path-prefix |
Interactive | Auto-confirm when --select-path-prefix matches |
--query |
Interactive | Seed fuzzy finder with an initial query |
--preview |
Interactive | Show details preview panel |
--revert |
Both | Clear final selected/output deviations on target |
Example (show all deviations for a target):
kubectl sdc deviation --target srl1Example (non-interactive with path filtering):
kubectl sdc deviation --target srl1 --filter-path /interface --filter-path /systemExample (start the interactive view with an initial query):
kubectl sdc deviation --target srl1 --interactive --query interfaceExample (interactive with selected path prefixes and auto-accept):
kubectl sdc deviation --target srl1 --interactive --select-path-prefix /interface --auto-accept-select-path-prefixExample (render selected deviations as a TargetClearDeviation manifest):
kubectl sdc deviation --target srl1 --format resource-yamlExample (interactive preview flow):
kubectl sdc deviation --deviation srl1 --interactive --previewThe apply command applies resources from YAML or JSON files, similar to kubectl apply.
Currently supported resource kinds:
TargetClearDeviation(config.sdcio.dev/v1alpha1)
Input options:
-f,--filename: one or more files to apply.- Positional arguments are also accepted as file paths.
- Use
-to read from stdin.
Behavior notes:
- Multi-document YAML files are supported.
- If a
TargetClearDeviationmanifest omitsmetadata.namespace, the current kubectl namespace is used. - The command sends the resource to the target
cleardeviationsubresource.
Examples:
Apply from a file:
kubectl sdc apply -f clear-dev.yamlApply from multiple files:
kubectl sdc apply -f clear-dev-1.yaml -f clear-dev-2.yamlApply using positional file arguments:
kubectl sdc apply clear-dev.yaml another-dev.yamlApply from stdin:
cat clear-dev.yaml | kubectl sdc apply -f -Example TargetClearDeviation manifest:
apiVersion: config.sdcio.dev/v1alpha1
kind: TargetClearDeviation
metadata:
name: srl1
spec:
config:
- name: intent-a
paths:
- /interface[name=ethernet-1/1]/admin-state
- /system/nameHave questions, ideas, bug reports or just want to chat? Come join our discord server.
Code is under the Apache License 2.0, documentation is CC BY 4.0.
The SDC project is following the CNCF Code of Conduct. More information and links about the CNCF Code of Conduct are here.
