10. Command line

The program kudurru is the server and the command line client in one file. This chapter shows how to connect the client to a server and lists the commands that you use most.

Before you start:

  • You have the kudurru program. It is in the container image and in the Linux packages. You can also download it from a release.
  • You have a token (Chapter 9) or the password of an account.

Two kinds of command

KindWhere it runsExamples
Client commandsOn any computer. They use the API of a server.get, apply, lists, logs, query, settings
Host commandsOn the host of the node. They read the local files or the local socket.serve, doctor, health, admin

In Docker, run a host command with docker exec:

docker exec kudurru kudurru health --ready

Connect to a server

A context holds the address of a server and a token. Use login to make one.

  1. Sign in with a password:

    kudurru login --server https://dns.example.net:8080 --username admin
    

    Enter the password when the command asks for it. The command makes a token for the command line and stores it.

  2. Or use a token that you made in the dashboard:

    kudurru login --server https://dns.example.net:8080 --token-stdin < token.txt
    
  3. Test the connection:

    kudurru nodes
    

The command stores the token in the keyring of your system. If there is no keyring, it stores the token in a file that only you can read. To skip the keyring, set KUDURRU_KEYRING=file.

If your local account has an authenticator, add --totp:

kudurru login --server https://dns.example.net:8080 --username admin --totp

Enter the password and current six-digit code at the hidden prompts. For piped input, use --password-stdin --totp-stdin and provide the password line followed by the code line. Leading zeros matter. The code is never saved; there is no flag that takes its value or environment variable for it.

Login and token creation do not follow redirects and do not try again. Use the final address of the server. If you do not get an answer, look at your sessions and tokens in the dashboard first. It is possible that the server completed the request. Then start a new attempt.

Sign in with single sign-on

The command can use an identity provider instead of a password or a token.

You need these items:

  • A node with SQLite storage and a license key for single sign-on.
  • A public client for the command line at the provider. The entry of the provider in auth.identityProviders has its client ID in cliClientID.
  • HTTPS for the API and for the provider, with certificates that your computer trusts.
  1. Start the sign-in. Replace corp with the identifier of the provider:

    kudurru login --server https://dns.example.net:8080 --provider corp
    
  2. Sign in to the provider in the browser that opens.

  3. Go back to the terminal. The command stores the context.

If only one provider has a client for the command line, you can omit --provider.

On a computer without a browser, add --device:

kudurru login --server https://dns.example.net:8080 --provider corp --device

The command shows an address and a code. Open the address on a different device and enter the code there.

CAUTION: Approve only a request that you started. Compare the provider, the client and the code with the text in the terminal.

The command stores the ID token of the provider. It does not make a kudurru token or a browser session. When the ID token expires, sign in again. Command-line sign-in has the details of the setup at the provider.

NOTE: The default certificate of kudurru is self-signed. Use --ca-file with the certificate to trust it. For a test only, use --insecure-skip-tls-verify. Do not use this option in production.

Use more than one server

TaskCommand
List the contextskudurru config get-contexts
Show the current contextkudurru config current-context
Change the contextkudurru config use-context <name>
Use a context for one commandkudurru --context <name> nodes
Delete a contextkudurru config delete-context <name>

Use a Kubernetes context directly

--context continues to select a saved Kudurru HTTP context by default. Add --transport kubernetes to select that name from kubeconfig for generic CRD commands:

kudurru --transport kubernetes --kubeconfig /path/to/config --context lab get zones
kudurru --transport kubernetes --context lab -n dns apply -f objects.yaml

Only get, apply, delete and describe use this mode. Credentials, optional impersonation, TLS trust and the default namespace come from kubeconfig; Kubernetes RBAC applies. Existing object ownership is enforced without force. Do not combine API server/token overrides with this mode. The CLI start guide describes bounds and supported kinds.

Output formats

Use -o to select the format: table (default), wide, json, yaml or name. Use -n <namespace> to select a namespace. The default namespace comes from the selected context, otherwise default.

Common tasks

TaskCommand
Show if blocking is onkudurru blocking status
Turn blocking off for 5 minuteskudurru blocking disable 5m
Turn blocking onkudurru blocking enable
Show the queries of a clientkudurru logs --client 192.168.1.23 --limit 100
Show the blocked querieskudurru logs --status-class blocked
Follow new querieskudurru logs --follow
Test a namekudurru query example.com
Test a name for another clientkudurru query ads.example.net AAAA --client 192.168.1.23
Show the statistics of 24 hourskudurru stats summary
Show the top blocked nameskudurru stats top --dim domains --blocked
Remove the cachekudurru cache flush
Show the nodeskudurru nodes
Show the audit logkudurru audit --since 24h
Verify the retained audit trailkudurru audit verify
Show the settingskudurru settings get
Change a settingkudurru settings set cache.maxEntries=200000
Set a setting to its defaultkudurru settings set log.level-

You cannot change a setting with the label host only with settings set. Change it in kudurru.yaml.

Verify the audit trail

Run kudurru audit verify to check the server's complete retained audit chain and available batch seals. It requires audit.read and the audit license. The command prints whether verification passed and when it was checked, plus an explanation if an integrity check failed. The server shares scans and caches results for 30 seconds, so checkedAt can precede the command.

Use kudurru audit verify -o json for scripts. A completed integrity check prints a result in either format, including verified: false on failure. The exit status is nonzero when integrity fails, verification is unavailable, access is denied, or the request times out or is canceled. Request failures print an error to standard error without a verification result. The usual --context, --server and --request-timeout flags apply. This command checks the retained trail; it cannot prove that deleted history never existed.

Work with objects

Zones, record sets, block lists, client groups and policies are objects. The command line uses the same YAML as Kubernetes.

TaskCommand
List objects of a kindkudurru get policies
Show one object as YAMLkudurru get policy kids -o yaml
Show the state and the messages of an objectkudurru describe policy kids
Create or change objectskudurru apply -f policy.yaml
Create or change all files in a directorykudurru apply -f objects.d/ -R
Delete an objectkudurru delete policy kids
Print all objects as YAMLkudurru export

The kinds and their short names are:

KindShort names
dnszoneszone, zones
dnsrecordsetsrrset, rrsets
blocklistslist, lists, bl
clientgroupscg
policiespol, policy

Example

This file makes a client group and a policy for it:

apiVersion: kudurru.io/v1alpha1
kind: ClientGroup
metadata:
  name: kids
  namespace: default
spec:
  clients:
    - cidr: 10.0.20.0/24
      name: Kids VLAN
---
apiVersion: kudurru.io/v1alpha1
kind: Policy
metadata:
  name: kids
  namespace: default
spec:
  clientGroupRefs: [kids]
  blockListRefs: [starter]
  priority: 10

Apply it:

kudurru apply -f kids.yaml

The dashboard then shows the objects with the owner API. The folder deploy/kustomize/samples/ has more examples.

NOTE: kudurru apply refuses an object that a file or Kubernetes owns. The error says managed_by and names the owner.

NOTE: Without a license key, a node has one policy: the policy default. kudurru then makes the group kids but refuses the policy kids with the error license_required. See Chapter 13.

Back up and restore objects

TaskCommand
Save all objects to a filekudurru backup --out objects.yaml
Save without secrets in URLskudurru backup --out objects.yaml --safe
Load the objects againkudurru restore -f objects.yaml

Chapter 11 explains what a backup holds.

Other commands

CommandUse
kudurru doctorCheck the configuration, the ports and the API on the host
kudurru health --readyCheck that a node is ready (for example in a container health check)
kudurru config schemaList all settings with their scope and flags
kudurru config showShow the effective configuration
kudurru completion <shell>Print a script for shell completion
kudurru license statusShow the license that a node uses (state, plan, nodes, features)
kudurru license verify <key>Check a license key without a running node
kudurru versionShow the version

These command groups are for special tasks. Each has a page with the procedure.

CommandUseProcedure
kudurru clusterShow the cluster state. Make and change a cluster of SQLite nodes.Enrolled SQLite cluster
kudurru iam rolebindingsMake, change and delete role bindings on SQLiteReviewed RoleBinding commands
kudurru iam external-usersDisable, enable and sign out accounts from single sign-onExternal accounts
kudurru iam migrateMove the identity data of a Kubernetes installation to version 0.2Kubernetes IAM upgrade
kudurru integrationsShow, check and run integrationsBackground integrations
kudurru anchorsRead and recover the managed root trust anchors on a stopped nodeRunbooks
kudurru apiSend a request to an API path that has no commandStored TSIG keys

Use kudurru <command> --help for the options of each command. The command reference has all of them.

Source: docs/guide/admin/10-command-line.md