rpk Profiles
Use rpk profiles to simplify your development experience using rpk with multiple Redpanda clusters by saving and reusing configurations for different clusters.
About rpk profiles
An rpk profile contains a reusable configuration for a Redpanda cluster. When running rpk, you can create a profile, configure it for a cluster you’re working with, and use it repeatably when running an rpk command for the cluster.
You can create different profiles for different Redpanda clusters. For example, your local cluster, development cluster, and production cluster can each have their own profile, with all of their information managed locally by rpk. You set a unique name for each profile.
A profile saves rpk-specific command properties. For details, see Specifying command properties.
All rpk commands can read configuration values from a profile. You pass a profile to an rpk command by setting the --profile flag. For example, the command rpk topic produce dev-topic --profile dev gets its configuration from the profile named dev.
Work with rpk profiles
The primary tasks for working with rpk profiles:
-
Create one or more profiles.
-
Choose the profile to use.
-
Edit or set default values across all profiles and values for a single profile.
-
Call an
rpkcommand with a profile. -
Delete unused profiles.
Create profile
To create a new profile, run rpk profile create:
rpk profile create <profile-name> [flags]
An rpk profile can be generated from different sources:
-
A
redpanda.yamlfile, using the--from-redpandaflag. -
A different rpk profile, using the
--from-profileflag. -
A Redpanda Cloud cluster, using the
--from-cloudflag.
You must provide a profile name when creating a profile that isn’t generated from a Redpanda Cloud cluster with the --from-cloud flag.
|
After the profile is created, rpk switches to the newly created profile.
You can specify the configuration during creation with the --set [key=value] flag. To simplify configuration, the --set flag supports autocompletion of valid keys, suggesting key names based on their -X format.
You should always use and set the --description flag to describe your profiles. The description is printed in the output of rpk profile list.
|
Created profiles are stored in an rpk.yaml file in a default local OS directory (for example, ~/.config/rpk/ for Linux and ~/Library/Application Support/rpk/ for MacOS). All profiles created by a developer are stored in the same rpk.yaml file.
Choose profile to use
With multiple created profiles, choose the profile to use with rpk profile use:
rpk profile use <name-of-profile-to-use>
Set or edit configuration values
You can configure settings that apply to all profiles. To set these globals:
-
Use
rpk profile set-globalsto setkey=valuepairs to write to the globals section ofrpk.yaml. -
Use
rpk profile edit-globalsto edit the globals section of therpk.yamlfile in your default editor.
You can customize settings for a single profile. To set a profile’s configuration:
-
Use
rpk profile setto setkey=valuepairs of configuration options to write to the profile’s section ofrpk.yaml. -
Use
rpk profile editto edit the profile’s section of therpk.yamlfile in your default editor.
Customize command prompt per profile
A configurable field of an rpk profile is the prompt field. It enables the customization of the command prompt for a profile, so information about the in-use profile can be displayed within your command prompt.
The format string is intended for a PS1 prompt. For details on the prompt format string, see the rpk profile prompt reference.
The rpk profile prompt command prints the ANSI-escaped text of the prompt field for the in-use profile. You can call rpk profile prompt in your shell’s (rc) configuration file to assign your PS1.
For example, to customize your bash prompt for a dev rpk profile , first call rpk profile edit dev to set its prompt field:
name: dev
prompt: hi-red, "[%n]"
-
hi-redsets the text to high-intensity red -
%nis a variable for the profile name
Then in .bashrc, set PS1 to include a call to rpk profile prompt:
export PS1='\u@\h\n$(rpk profile prompt)% '
When setting your PS1 variable, use single quotation marks and not double quotation marks, because double quotation marks aren’t reevaluated after every command.
|
The resulting prompt looks like this:
username@hostname[dev]%
Use profile with rpk command
An rpk command that can use a profile supports the --profile <profile-name> flag. When the --profile flag is set for an rpk command, the configuration for the cluster that rpk is interfacing with will be read from the named profile.
See the rpk commands reference for commands that support profiles.
Delete profile
To delete a profile, run rpk profile delete.
Related topics
For details about all commands for rpk profiles, see the rpk profile reference page and its sub-pages.