### Install decK on Windows by downloading binary Source: https://github.com/kong/deck/blob/main/README.md Download the latest decK binary for Windows from the GitHub releases page. This example downloads a .tar.gz archive and extracts it. ```shell curl -sL https://github.com/kong/deck/releases/download/v1.63.0/deck_1.63.0_windows_amd64.tar.gz -o deck.tar.gz tar -xzvf deck.tar.gz ``` -------------------------------- ### Install decK on Linux by downloading binary Source: https://github.com/kong/deck/blob/main/README.md Download the latest decK binary for Linux from the GitHub releases page. This example downloads version 1.63.0 for amd64 architecture and installs it to /usr/local/bin. ```shell curl -sL https://github.com/kong/deck/releases/download/v1.63.0/deck_1.63.0_linux_amd64.tar.gz -o deck.tar.gz tar -xf deck.tar.gz -C /tmp sudo cp /tmp/deck /usr/local/bin/ ``` -------------------------------- ### Example Configuration File Source: https://github.com/kong/deck/blob/main/_autodocs/configuration.md A sample YAML configuration file for decK, showing settings for Kong connection, TLS, authentication, Konnect, and output preferences. ```yaml # Kong connection kong-addr: https://kong.example.com:8443 timeout: 30 # TLS configuration tls-skip-verify: false ca-cert-file: /etc/ssl/certs/ca.crt tls-client-cert-file: /etc/ssl/certs/client.crt tls-client-key-file: /etc/ssl/private/client.key # Authentication headers: - Kong-Admin-Token: my-secret-token - X-Custom-Auth: value # Konnect configuration (if using Konnect) konnect-token: kpat_xxxxx control-plane-name: production # Output preferences no-color: false analytics: true verbose: 0 ``` -------------------------------- ### File-Based Configuration Example Source: https://github.com/kong/deck/blob/main/_autodocs/INDEX.md Store command options in a YAML file for persistent configuration. ```yaml kong-addr: https://kong.example.com:8001 headers: - Kong-Admin-Token: secret-key tls-skip-verify: false analytics: false ``` -------------------------------- ### Function Reference Format Example Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Shows the structure for documenting functions, including signature, parameters, return values, and a code example. ```Markdown ### functionName Function signature in code block | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | param | type | Yes | Description | **Returns:** Return type and description **Example:** ```go code example ``` ``` -------------------------------- ### Get decK help Source: https://github.com/kong/deck/blob/main/README.md Use the --help flag with the decK command to display available commands and options directly in the terminal. This is useful for quick reference after installation. ```shell deck --help ``` -------------------------------- ### Builder Pattern Example (Go) Source: https://github.com/kong/deck/blob/main/_autodocs/architecture.md Demonstrates the Builder pattern for flexible object construction, as used in kong2kic. It involves obtaining a concrete builder, initializing a director, building manifests, and marshalling the content. ```go builder := getBuilder(builderType) // Get concrete builder director := newDirector(builder) // Create director kicContent := director.buildManifests(content) // Build manifests := kicContent.marshalKICContentToFormat(format) // Marshal ``` -------------------------------- ### Kong Deck Configuration File Source: https://github.com/kong/deck/blob/main/_autodocs/cli-reference.md Store configuration settings in the `~/.deck.yaml` file. This example shows common settings like Kong address, custom headers, TLS verification, and analytics. ```yaml kong-addr: http://localhost:8001 headers: - X-Custom-Header: value tls-skip-verify: false analytics: true ``` -------------------------------- ### Install decK on macOS using Homebrew Source: https://github.com/kong/deck/blob/main/README.md Use this command to install decK on macOS if you have Homebrew installed. It taps the kong/deck repository and then installs the deck package. ```shell brew tap kong/deck brew install kong/deck/deck ``` -------------------------------- ### Type Reference Format Example Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Illustrates the standard format for defining types within the documentation, including fields, types, requirements, defaults, and descriptions. ```Markdown ### TypeName Type definition from source code | Field | Type | Required | Default | Description | |-------|------|----------|---------|-------------| | name | string | Yes | — | Field description | ``` -------------------------------- ### Running Goreleaser for Release Automation Source: https://github.com/kong/deck/blob/main/RELEASE.md Execute Goreleaser to automate the creation of GitHub releases and upload build artifacts. Ensure your Go version is up-to-date and Goreleaser is installed. ```bash goreleaser release --rm-dist ``` -------------------------------- ### decK Package Dependencies Source: https://github.com/kong/deck/blob/main/_autodocs/architecture.md Visualizes the package dependencies starting from the main entry point, showing how different modules interact and external libraries are utilized. ```tree main.go └─ cmd.Execute() ├─ cmd/root.go (Cobra command setup) ├─ convert/ (Format conversion) ├─ validate/ (Validation) ├─ lint/ (Linting) ├─ sanitize/ (Data sanitization) ├─ kong2kic/ (KIC conversion) └─ kong2tf/ (Terraform conversion) └─ go-kong (External: Kong client) └─ go-database-reconciler (External: State management) ``` -------------------------------- ### Kong Configuration Schema Example Source: https://github.com/kong/deck/blob/main/_autodocs/architecture.md This YAML defines the structure for Kong configuration, including metadata and various entity collections such as services, routes, plugins, upstreams, consumers, certificates, and CA certificates. Ensure all required fields for each entity are correctly populated. ```yaml # Metadata _format_version: "1.1" _info: select_tags: [] _konnect: control_plane_name: production # Entity collections services: - name: api host: api.example.com routes: - name: api-route service: api paths: [/api] plugins: - name: rate-limiting config: minute: 100 upstreams: - name: backend targets: - target: backend1.example.com:8080 consumers: - username: user1 custom_id: cust-123 certificates: [] ca_certificates: [] ``` -------------------------------- ### Example Rule Set Structure Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/lint.md Defines a custom rule set using YAML, extending a default rule set and specifying a custom rule with a JSONPath expression and severity. ```yaml extends: spectral:oas rules: my-custom-rule: given: "$.info" severity: error message: "Custom validation rule" then: function: pattern functionOptions: match: "^v\d+" ``` -------------------------------- ### Perform Sanitization of Kong Configuration Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/sanitize.md This snippet demonstrates how to load a Kong configuration, initialize the sanitizer with necessary options including a Kong client and salt, perform the sanitization, and save the output. Ensure the kongClient is properly initialized and context is managed. ```go // Load configuration content, _ := file.GetContentFromFilesWithEnvVars([]string{"kong.yaml"}, envVarsMode) // Create sanitizer sanitizer := sanitize.NewSanitizer(&sanitize.SanitizerOptions{ Ctx: context.Background(), Client: kongClient, Content: content, Salt: "production-salt-value", IsKonnect: true, }) // Perform sanitization sanitized, _ := sanitizer.Sanitize() // Save sanitized output sanitize.WriteContentToFile(sanitized, "output.yaml", file.FormatYAML, "yaml") ``` -------------------------------- ### Apply decK Configuration (Execute) Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Apply changes from a state file to your Kong gateway configuration. Use `--assume-yes` to bypass confirmation prompts. ```bash # Apply configuration (execute) deck gateway sync --state-file kong.yaml --assume-yes ``` -------------------------------- ### Apply decK Configuration (Dry Run) Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Preview changes to your Kong gateway configuration without applying them. Useful for verifying the `sync` operation. ```bash # Apply configuration (preview) deck gateway sync --state-file kong.yaml --dry-run ``` -------------------------------- ### Apply Kong Configuration with Confirmation Source: https://github.com/kong/deck/blob/main/_autodocs/INDEX.md Synchronize a local Kong configuration file with a running Kong Gateway. The `--assume-yes` flag automatically confirms any prompts, applying changes immediately. ```bash deck gateway sync --state-file kong.yaml --assume-yes ``` -------------------------------- ### Pull decK Docker image Source: https://github.com/kong/deck/blob/main/README.md Fetch the latest decK Docker image from Docker Hub. This image can be used to run decK commands without local installation. ```shell docker pull kong/deck ``` -------------------------------- ### Apply Configuration Changes Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Synchronize your configuration file with the running Kong instance. Use --dry-run to preview changes or --assume-yes to apply them directly. ```bash deck gateway sync --state-file kong.yaml --dry-run ``` ```bash deck gateway sync --state-file kong.yaml --assume-yes ``` -------------------------------- ### List All Tags in Configuration Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/cmd.md Lists all unique tags present in a configuration file. ```bash deck file listtags --state-file kong.yaml ``` -------------------------------- ### Configure decK via File Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Define decK settings in a configuration file, typically located at `~/.deck.yaml`. This allows for persistent configuration. ```yaml kong-addr: http://localhost:8001 headers: - Kong-Admin-Token: secret-key timeout: 30 tls-skip-verify: false analytics: true ``` -------------------------------- ### Show decK Configuration Differences Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Compares a state file with the running Kong gateway configuration to show differences. ```bash # Show differences deck gateway diff --state-file kong.yaml ``` -------------------------------- ### List All Documentation Files Source: https://github.com/kong/deck/blob/main/_autodocs/COMPLETION_REPORT.md Lists all markdown files within the documentation directory in sorted order. ```bash # List all files find /workspace/home/output -type f -name "*.md" | sort ``` -------------------------------- ### Convert Configuration Formats Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Transform configuration files between different formats, such as from Kong Gateway to Konnect. ```bash deck file convert --from kong-gateway --to konnect --state-file kong.yaml ``` -------------------------------- ### Create New Validator Instance Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/validate.md Instantiate a new Validator with specific configuration options. Ensure `ctx`, `kongState`, and `kongClient` are properly initialized before use. The `Parallelism` option controls the concurrency of validation operations. ```go validator := validate.NewValidator(validate.ValidatorOpts{ Ctx: ctx, State: kongState, Client: kongClient, Parallelism: 10, }) ``` -------------------------------- ### Convert decK to Kubernetes Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Convert your Kong gateway configuration into Kubernetes manifests using the `kong2kic` utility. ```bash # Convert to Kubernetes deck file kong2kic --state-file kong.yaml --output-file manifests.yaml ``` -------------------------------- ### Linting with Custom Rule Set Source: https://github.com/kong/deck/blob/main/_autodocs/architecture.md Demonstrates how to use a custom rule set file with the `deck file lint` command. Ensure the custom rule set YAML file is correctly formatted and accessible. ```bash deck file lint --ruleset custom.yaml ``` -------------------------------- ### Combine Multiple Configuration Files Source: https://github.com/kong/deck/blob/main/_autodocs/INDEX.md Use multiple state files to combine configurations during a sync operation. ```bash deck gateway sync --state-file base.yaml --state-file overrides.yaml ``` -------------------------------- ### Convert Configuration Formats Source: https://github.com/kong/deck/blob/main/_autodocs/cli-reference.md Converts configuration files between different formats, such as Kong Gateway to Konnect. Specify source and target formats with `--from` and `--to`, and input/output files with `--state-file` and `--output-file`. ```bash deck file convert --from --to --state-file ``` ```bash deck file convert --from kong-gateway --to konnect --state-file kong.yaml --output-file konnect.yaml ``` -------------------------------- ### Execute Root Command Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/cmd.md Main entry point for the CLI. Sets up the Cobra command hierarchy and executes the user-specified command. Handles graceful termination on SIGINT and SIGTERM signals. ```go func Execute(ctx context.Context) ``` -------------------------------- ### Diff Configuration with Konnect Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/cmd.md Shows differences between a local configuration file and the current configuration in Konnect. ```bash deck konnect diff --state-file konnect.yaml ``` -------------------------------- ### Add Plugins to Kong Configuration Source: https://github.com/kong/deck/blob/main/_autodocs/cli-reference.md Use this command to insert plugins into your Kong configuration file. You need to specify both the state file containing your Kong configuration and the file containing the plugin definitions. ```bash deck file addplugins --state-file --plugins-file ``` -------------------------------- ### List Tags in Configuration Source: https://github.com/kong/deck/blob/main/_autodocs/cli-reference.md Lists all unique tags present in a given configuration file. Use `--state-file` to specify the file. ```bash deck file listtags --state-file ``` -------------------------------- ### Builder Architecture Flow Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/kong2kic.md Illustrates the builder pattern used in the conversion process, showing the flow from Kong Configuration to KIC Content and finally to YAML/JSON. ```text Kong Configuration ↓ Director ↓ Builder (selectable) ├── KICv2GatewayAPIBuilder ├── KICv2IngressAPIBuilder ├── KICv3GatewayAPIBuilder └── KICv3IngressAPIBuilder ↓ KICContent (manifests) ↓ Marshal to YAML/JSON ``` -------------------------------- ### Create a new Sanitizer instance Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/sanitize.md Use NewSanitizer to create a Sanitizer. Provide SanitizerOptions, including context, Kong client, configuration content, and an optional salt for consistent hashing. If no salt is provided, a random one is generated. ```go sanitizer := sanitize.NewSanitizer(&sanitize.SanitizerOptions{ Ctx: ctx, Client: kongClient, Content: kongConfig, Salt: "my-consistent-salt", IsKonnect: false, }) ``` -------------------------------- ### Convert decK File Formats Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Convert configuration files between different Kong formats, such as Kong Gateway to Konnect. ```bash # Convert formats deck file convert --from kong-gateway --to konnect \ --state-file kong.yaml --output-file konnect.yaml ``` -------------------------------- ### Building and Pushing Docker Image for Release Source: https://github.com/kong/deck/blob/main/RELEASE.md Build a Docker image for the current release tag and push it to a container registry. This process uses build arguments for the tag and commit hash. ```bash export TAG=$(git describe --abbrev=0 --tags) export COMMIT=$(git rev-parse --short $TAG) docker build --build-arg TAG=$TAG --build-arg COMMIT=$COMMIT -t kong/deck:$TAG . docker push kong/deck:$TAG ``` -------------------------------- ### Format Configuration File Source: https://github.com/kong/deck/blob/main/_autodocs/cli-reference.md Formats a configuration file to a specified output format (yaml or json). Use `--state-file` for input and `--output-file` for output. `--sort-keys` can be used to sort keys alphabetically. ```bash deck file format --state-file --output-file --format ``` -------------------------------- ### Convert Kong Configuration to Kubernetes Manifests Source: https://github.com/kong/deck/blob/main/_autodocs/INDEX.md Transform a Kong configuration file into Kubernetes manifests suitable for deployment using tools like `kubectl` or Helm. ```bash deck file kong2kic --state-file kong.yaml --output-file manifests.yaml ``` -------------------------------- ### Apply Kong Configuration with Dry Run Source: https://github.com/kong/deck/blob/main/_autodocs/INDEX.md Synchronize a local Kong configuration file with a running Kong Gateway. The `--dry-run` flag allows you to preview the changes without applying them. ```bash deck gateway sync --state-file kong.yaml --dry-run ``` -------------------------------- ### decK Project Organization Source: https://github.com/kong/deck/blob/main/_autodocs/architecture.md Illustrates the directory structure of the decK project, highlighting the main entry point, CLI command implementations, and specialized modules for data handling and conversion. ```tree /workspace/home/deck/ ├── main.go # Entry point ├── cmd/ # CLI command implementations (Cobra) ├── convert/ # Format conversion and migrations ├── validate/ # Schema validation ├── lint/ # Rule-based linting ├── sanitize/ # Data sanitization ├── kong2kic/ # Kong to KIC conversion ├── kong2tf/ # Kong to Terraform conversion ├── utils/ # Utility constants ├── tests/ # Integration tests └── examples/ # Example configurations ``` -------------------------------- ### Execute Root Command Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/cmd.md The main entry point for the `deck` CLI. It sets up the command hierarchy and executes user-specified commands. It also handles signal handling for graceful termination. ```APIDOC ## Execute ### Description Main entry point called from `main.go`. Sets up Cobra command hierarchy and executes user-specified command. ### Method `Execute` ### Parameters #### Path Parameters - **ctx** (context.Context) - Required - Context for managing lifecycle and cancellation ### Signal Handling - `SIGINT` (Ctrl+C) cancels context and terminates gracefully - `SIGTERM` receives same treatment - Output message: "received signal, terminating..." ``` -------------------------------- ### WithContent Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/lint.md Lints Kong configuration from byte content against a rule set. This function works with in-memory content rather than files. ```APIDOC ## WithContent ### Description Lints Kong configuration from byte content against a rule set. This function works with in-memory content rather than files. ### Function Signature ```go func WithContent( stateFileBytes []byte, rulesetContent []byte, cmdLintFailSeverity string, cmdLintOnlyFailures bool, ) (map[string]interface{}, error) ``` ### Parameters #### Path Parameters - **stateFileBytes** ([]byte) - Yes - YAML or JSON encoded Kong configuration - **rulesetContent** ([]byte) - Yes - YAML or JSON encoded rule set definition #### Query Parameters - **cmdLintFailSeverity** (string) - Yes - Minimum severity level to treat as failure - **cmdLintOnlyFailures** (bool) - Yes - Report only failures at or above severity threshold ### Returns - `(map[string]interface{}, error)` — Linting results map with keys: "total_count", "fail_count", "results" ### Returns Special Case - If the state file is empty or contains only comments, returns an empty results set with a warning message rather than an error ### Request Example ```go configBytes, _ := ioutil.ReadFile("kong.yaml") rulesetBytes, _ := ioutil.ReadFile("ruleset.yaml") results, err := lint.WithContent( configBytes, rulesetBytes, "error", true, ) ``` ``` -------------------------------- ### Format Configuration File Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/cmd.md Formats a configuration file, including converting between YAML/JSON, sorting keys, and pretty-printing output. ```bash deck file format --state-file kong.yaml --output-file output.yaml ``` -------------------------------- ### Convert Package API Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Documentation for the Convert package, which handles format conversion and version migration for Kong configurations. ```APIDOC ## Convert Package API ### Description Provides functions for parsing format strings and converting configurations between different formats, including Kong, Konnect, and others. It also defines the `Format` type for enumerating supported configurations. ### Functions - `ParseFormat(format string) (Format, error)`: Parses format strings into a `Format` type. - `Convert(sourceConfig interface{}, sourceFormat Format, targetFormat Format) (interface{}, error)`: Converts configuration data from a source format to a target format. ### Types - `Format`: Enumeration of supported configuration formats. ### Supported Conversions Details on supported conversion paths and version migrations are available. ``` -------------------------------- ### Export Kong Configuration Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Use this command to extract the current configuration from a running Kong instance to a file. ```bash deck gateway dump --output-file kong.yaml ``` -------------------------------- ### Sync Configuration to Konnect Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/cmd.md Use this command to synchronize your local configuration file with the Konnect platform. It requires Konnect authentication and operates on service packages. ```bash deck konnect sync --state-file konnect.yaml --control-plane-name prod ``` -------------------------------- ### Sync Kong Gateway Configuration Source: https://github.com/kong/deck/blob/main/_autodocs/cli-reference.md Applies configuration from a state file to Kong Gateway. Use --dry-run to preview changes or --assume-yes to skip confirmation. Supports multiple state files and tag selection. ```bash deck gateway sync [flags] ``` ```bash deck gateway sync --state-file kong.yaml --dry-run ``` ```bash deck gateway sync --state-file kong.yaml --assume-yes ``` -------------------------------- ### Validate decK Configuration Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Validate your Kong configuration file against the gateway. Use `--online` for real-time validation against a running Kong instance. ```bash # Validate configuration deck gateway validate --state-file kong.yaml --online ``` -------------------------------- ### Export decK Configuration Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Use this command to export your Kong gateway configuration to a YAML file. ```bash # Export configuration deck gateway dump --output-file kong.yaml ``` -------------------------------- ### Convert Kong Configuration Format Source: https://github.com/kong/deck/blob/main/_autodocs/INDEX.md Convert Kong configuration files between different versions or platforms. Specify the source and target formats using `--from` and `--to` flags. ```bash # Kong 2.x → 3.x deck file convert --from kong-gateway-2.x --to 3.4 \ --state-file old.yaml --output-file new.yaml ``` ```bash # Kong → Konnect deck file convert --from kong-gateway --to konnect \ --state-file kong.yaml --output-file konnect.yaml ``` -------------------------------- ### Diff Kong Gateway Configuration Source: https://github.com/kong/deck/blob/main/_autodocs/cli-reference.md Displays differences between a configuration file and the live Kong Gateway state. Can specify a workspace and select entities by tag. ```bash deck gateway diff [flags] ``` ```bash deck gateway diff --state-file kong.yaml ``` ```bash deck gateway diff --state-file prod.yaml --workspace production ``` -------------------------------- ### Convert Kong Config to KIC Manifests Source: https://github.com/kong/deck/blob/main/_autodocs/cli-reference.md Use this command to convert your Kong configuration file into Kubernetes Ingress Controller (KIC) manifests. Specify the input state file and the desired output file path. The KIC API version can be adjusted using the `--kic-version-api` flag. ```bash deck file kong2kic --state-file --output-file ``` -------------------------------- ### Detect Configuration Drift Source: https://github.com/kong/deck/blob/main/_autodocs/INDEX.md Compare a local Kong configuration file with the actual configuration in a running Kong Gateway to detect any discrepancies or drifts. ```bash deck gateway diff --state-file kong.yaml ``` -------------------------------- ### Preview Changes with Dry Run Source: https://github.com/kong/deck/blob/main/_autodocs/configuration.md Use the `--dry-run` flag to preview changes that would be applied to your Kong gateway without actually making them. This is useful for verifying the impact of your configuration. ```bash # Preview changes deck gateway diff --state-file kong.yaml ``` ```bash # Dry run sync deck gateway sync --state-file kong.yaml --dry-run ``` -------------------------------- ### Define SanitizerOptions Type Source: https://github.com/kong/deck/blob/main/_autodocs/types.md Defines the configuration options for creating a Sanitizer. Ctx, Client, and Content are required, while Salt and IsKonnect are optional. ```go type SanitizerOptions struct { Ctx context.Context // Required context Client *kong.Client // Required Kong client Content *file.Content // Required configuration Salt string // Optional: generated if empty IsKonnect bool // Optional: default false } ``` -------------------------------- ### Convert decK to Terraform Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Convert your Kong gateway configuration into Terraform HCL using the `kong2tf` utility. ```bash # Convert to Terraform deck file kong2tf --state-file kong.yaml --output-file main.tf ``` -------------------------------- ### Lint Kong Configuration from Content Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/lint.md Lints Kong configuration directly from byte content against a rule set. Use this function for in-memory data, avoiding file I/O. ```go func WithContent( stateFileBytes []byte, rulesetContent []byte, cmdLintFailSeverity string, cmdLintOnlyFailures bool, ) (map[string]interface{}, error) ``` ```go configBytes, _ := ioutil.ReadFile("kong.yaml") rulesetBytes, _ := ioutil.ReadFile("ruleset.yaml") results, err := lint.WithContent( configBytes, rulesetBytes, "error", true, ) ``` -------------------------------- ### Kong2KIC Package API Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Documentation for the Kong2KIC package, which converts Kong configuration to Kubernetes Ingress Controller manifests. ```APIDOC ## Kong2KIC Package API ### Description Facilitates the conversion of Kong configuration into Kubernetes Ingress Controller (KIC) manifests. It supports various KIC versions and maps Kong resources to their KIC equivalents. ### Functions - `MarshalKongToKIC(kongConfig interface{}, kicVersion string) (KICContent, error)`: Generates KIC manifests from Kong configuration. ### Types - `KICContent`: Represents the generated Kubernetes manifest content. ### Supported KIC Versions Supports KIC v2/v3, and Gateway API/Ingress resource types. ``` -------------------------------- ### Insert or Update Plugins in Configuration Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/cmd.md Inserts or updates plugins in a configuration file using a specified plugins file. ```bash deck file addplugins --state-file kong.yaml --plugins-file plugins.yaml ``` -------------------------------- ### Verify Markdown Syntax Source: https://github.com/kong/deck/blob/main/_autodocs/COMPLETION_REPORT.md Iterates through all markdown files and checks their syntax. ```bash # Verify markdown syntax for f in $(find /workspace/home/output -name "*.md"); do echo "Checking: $f" done ``` -------------------------------- ### Convert OpenAPI Specification to Kong Configuration Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/cmd.md Converts an OpenAPI specification file to a Kong configuration file. ```bash deck file openapi2kong --spec openapi.yaml --output-file kong.yaml ``` -------------------------------- ### Format Type Definition Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/convert.md Defines the supported configuration formats for Kong Gateway and Konnect. Includes constants for specific versions and a slice of all supported formats. ```go type Format string const ( FormatDistributed Format = "distributed" FormatKongGateway Format = "kong-gateway" FormatKonnect Format = "konnect" FormatKongGateway2x Format = "kong-gateway-2.x" FormatKongGateway3x Format = "kong-gateway-3.x" FormatKongGatewayVersion28x Format = "2.8" FormatKongGatewayVersion34x Format = "3.4" FormatKongGatewayVersion310x Format = "3.10" FormatKongGatewayVersion314x Format = "3.14" ) var AllFormats = []Format{FormatKongGateway, FormatKonnect} ``` -------------------------------- ### Convert Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/convert.md Converts Kong configuration from a list of input files to a specified output file and format. It supports various conversions between Kong Gateway versions and Konnect, with options for environment variable rendering and diagnostic handling. ```APIDOC ## Convert ### Description Converts Kong configuration from one format to another. Supports conversions between Kong Gateway versions and Konnect format, with support for distributed configuration files and environment variable rendering. ### Signature ```go func Convert( inputFilenames []string, outputFilename string, outputFormat file.Format, from Format, to Format, envVarsMode file.RenderEnvVarsMode, diagnosticPolicy utils.DiagnosticPolicy, ) error ``` ### Parameters #### Path Parameters - **inputFilenames** ([]string) - Required - List of input configuration file paths to convert - **outputFilename** (string) - Required - Output file path for the converted configuration - **outputFormat** (file.Format) - Required - Output format (YAML or JSON) - **from** (Format) - Required - Source format to convert from - **to** (Format) - Required - Target format to convert to - **envVarsMode** (file.RenderEnvVarsMode) - Required - Environment variable rendering mode - **diagnosticPolicy** (utils.DiagnosticPolicy) - Required - Policy for handling diagnostics during conversion ### Returns - `error` — An error if conversion fails ### Example ```go err := convert.Convert( []string{"kong.yaml"}, "output.yaml", file.FormatYAML, convert.FormatKongGateway, convert.FormatKonnect, file.RenderEnvVarsDefault, utils.DiagnosticPolicyWarn, ) ``` ``` -------------------------------- ### Merge Multiple Configuration Files Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/cmd.md Merges multiple configuration files into a single output file. ```bash deck file merge --output-file merged.yaml base.yaml overrides.yaml ``` -------------------------------- ### Merge Configuration Files Source: https://github.com/kong/deck/blob/main/_autodocs/cli-reference.md Merges multiple Kong configuration files into a single output file. The output file is specified with `--output-file`, followed by the input files. ```bash deck file merge --output-file ... ``` -------------------------------- ### Dump Kong Gateway Configuration Source: https://github.com/kong/deck/blob/main/_autodocs/INDEX.md Use this command to export the current configuration of your Kong Gateway. The output is typically saved to a YAML file for backup or migration purposes. ```bash deck gateway dump --output-file kong-backup.yaml ``` -------------------------------- ### Lint Kong Configuration File Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/lint.md Lints a Kong configuration file against a specified rule set. Reads both configuration and rule set from disk. Use when working with files on the filesystem. ```go func Lint( cmdLintInputFilename string, ruleSetFileName string, cmdLintFailSeverity string, cmdLintOnlyFailures bool, ) (map[string]interface{}, error) ``` ```go results, err := lint.Lint( "kong.yaml", "ruleset.yaml", "warn", false, ) if err != nil { log.Fatal(err) } totalCount := results["total_count"].(int) failCount := results["fail_count"].(int) lintResults := results["results"].([]lint.Result) fmt.Printf("Found %d issues (%d failures)\\n", totalCount, failCount) ``` -------------------------------- ### Sync Konnect Configuration Source: https://github.com/kong/deck/blob/main/_autodocs/cli-reference.md Syncs configuration to Konnect. Use `--state-file` to specify configuration files and `--control-plane-name` for the target control plane. `--assume-yes` can skip confirmation prompts. ```bash deck konnect sync [flags] ``` ```bash deck konnect sync --state-file konnect.yaml --control-plane-name prod ``` -------------------------------- ### Validate Configuration File Source: https://github.com/kong/deck/blob/main/_autodocs/cli-reference.md Validates the syntax and schema of a Kong configuration file. Use the `--state-file` flag to specify the file to validate. ```bash deck file validate --state-file ``` -------------------------------- ### Command Package API Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Documentation for the Command package, which implements the command-line interface for decK. ```APIDOC ## Command Package API ### Description This package contains the implementation of the decK command-line interface (CLI). It exposes functions for executing commands, managing gateway and Konnect configurations, and performing file manipulations. ### Functions - `Execute() error`: The main entry point for the decK CLI, responsible for parsing arguments and executing the appropriate commands. ### Command Groups - Gateway commands (dump, sync, diff, validate, reset, ping) - Konnect commands (sync, diff, dump, ping) - File manipulation commands (validate, lint, format, convert, merge, addtags, removetags, kong2kic, kong2tf, etc.) ### Utilities Includes common utility functions and management of global configuration state. ``` -------------------------------- ### Configure Mutual TLS (mTLS) Authentication Source: https://github.com/kong/deck/blob/main/_autodocs/configuration.md Set up client certificates for mutual TLS authentication with Kong. Provide client certificate and key using file paths or raw PEM strings. ```bash deck gateway dump \ --tls-client-cert-file client.crt \ --tls-client-key-file client.key ``` -------------------------------- ### ValidatorOpts Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/validate.md ValidatorOpts provides configuration options for creating a new Validator instance, including context, Kong state, API client, concurrency settings, and filtering options. ```APIDOC ## ValidatorOpts ### Description Options for creating a new Validator instance. ### Fields - **Ctx** (context.Context) - Required - Context for request lifecycle - **State** (*state.KongState) - Required - Kong state containing entities to validate - **Client** (*kong.Client) - Required - Configured Kong API client - **Parallelism** (int) - Required - Number of concurrent validation goroutines - **RBACResourcesOnly** (bool) - Optional - Limit validation to RBAC resources only - **OnlineEntitiesFilter** ([]string) - Optional - Entity types to validate (empty = all) ``` -------------------------------- ### Lint Package API Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Documentation for the Lint package, offering rule-based configuration linting using Spectral. ```APIDOC ## Lint Package API ### Description Provides functionality to lint configuration files based on predefined or custom rules using Spectral. It allows linting of byte content and formatting of lint results. ### Functions - `Lint(filePath string, ruleSet interface{}) ([]Result, error)`: Lints a configuration file against a given rule set. - `WithContent(content []byte, ruleSet interface{}) ([]Result, error)`: Lints configuration content directly. - `GetLintOutput(results []Result) string`: Formats lint results into a human-readable string. ### Types - `Result`: Represents an individual lint violation, including details like path, message, and severity. ``` -------------------------------- ### Dump Konnect Configuration to File Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/cmd.md Exports the current Konnect configuration to a specified YAML file. ```bash deck konnect dump --output-file konnect.yaml ``` -------------------------------- ### Convert Kong Config to Terraform Source: https://github.com/kong/deck/blob/main/_autodocs/cli-reference.md This command converts your Kong configuration into Terraform HCL. It takes an input state file and generates a Terraform output file. Use the `--with-imports` flag to generate an import file, and `--ignore-credentials` to mark credentials for ignoring changes. ```bash deck file kong2tf --state-file --output-file ``` -------------------------------- ### Lint Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/lint.md Lints a Kong configuration file against a rule set. Reads both the configuration file and rule set from disk. ```APIDOC ## Lint ### Description Lints a Kong configuration file against a rule set. Reads both the configuration file and rule set from disk. ### Function Signature ```go func Lint( cmdLintInputFilename string, ruleSetFileName string, cmdLintFailSeverity string, cmdLintOnlyFailures bool, ) (map[string]interface{}, error) ``` ### Parameters #### Path Parameters - **cmdLintInputFilename** (string) - Yes - Path to the Kong configuration file to lint - **ruleSetFileName** (string) - Yes - Path to the rule set file (YAML) #### Query Parameters - **cmdLintFailSeverity** (string) - Yes - Minimum severity level to report as failure (hint, info, warn, error) - **cmdLintOnlyFailures** (bool) - Yes - If true, only report violations at or above fail severity ### Returns - `(map[string]interface{}, error)` — Linting results with keys: "total_count", "fail_count", "results" ([]Result) ### Request Example ```go results, err := lint.Lint( "kong.yaml", "ruleset.yaml", "warn", false, ) if err != nil { log.Fatal(err) } totalCount := results["total_count"].(int) failCount := results["fail_count"].(int) lintResults := results["results"].([]lint.Result) fmt.Printf("Found %d issues (%d failures)\\n", totalCount, failCount) ``` ``` -------------------------------- ### Lint Configuration File Source: https://github.com/kong/deck/blob/main/_autodocs/cli-reference.md Lints a configuration file against a specified rule set. Requires `--state-file` for the configuration and `--ruleset` for the rules. `--fail-severity` can be used to set the minimum severity level for failures. ```bash deck file lint --state-file --ruleset ``` ```bash deck file lint --state-file kong.yaml --ruleset ruleset.yaml --fail-severity error ``` -------------------------------- ### Use Cookie Jar for Session Authentication Source: https://github.com/kong/deck/blob/main/_autodocs/configuration.md Configure decK to use a Netscape-format cookie jar for instances using session-based authentication with cookies. The cookie jar can be created using tools like curl. ```bash # Create cookie jar with curl curl -c cookies.txt -b cookies.txt \ -X POST http://localhost:8001/auth/login \ -d "username=admin&password=password" # Use with decK deck gateway dump --kong-cookie-jar-path cookies.txt ``` -------------------------------- ### Lint decK Configuration Source: https://github.com/kong/deck/blob/main/_autodocs/README.md Lint your Kong configuration file against a specified ruleset to check for potential issues or enforce standards. ```bash # Lint configuration deck file lint --state-file kong.yaml --ruleset ruleset.yaml ``` -------------------------------- ### Docker Release Commands Source: https://github.com/kong/deck/blob/main/docs/development/release.md Commands to build and push Docker images for a specific tag and the 'latest' tag. Ensure you are on the correct tag commit before running. ```bash export TAG=$(git describe --abbrev=0 --tags) export COMMIT=$(git rev-parse --short $TAG) docker build --build-arg TAG=$TAG --build-arg COMMIT=$COMMIT -t kong/deck:$TAG . docker push kong/deck:$TAG docker tag kong/deck:$TAG kong/deck:$TAG docker push kong/deck:$TAG # if also the latest release (not for a back-ported patch release): docker tag kong/deck:$TAG kong/deck:latest docker push kong/deck:latest docker tag kong/deck:latest kong/deck:latest docker push kong/deck:latest ``` -------------------------------- ### Validate Configuration File Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/cmd.md Validates the syntax and schema of a configuration file. ```bash deck file validate --state-file kong.yaml ``` -------------------------------- ### Kong Client Configuration (Go) Source: https://github.com/kong/deck/blob/main/_autodocs/architecture.md Defines the configuration for the Kong API client, used for reading schemas, validating entities, and making admin API calls. Supports Konnect mode. ```go KongClientConfig { Address string // Admin API URL Timeout int // Request timeout Headers []string // Custom headers TLSConfig // TLS settings CookieJarPath string // Session auth } ``` -------------------------------- ### Tagging Docker Image as Latest Source: https://github.com/kong/deck/blob/main/RELEASE.md If the current release is the latest stable release, tag the Docker image as 'latest' and push it to the registry. This is typically done for non-back-ported patch releases. ```bash docker tag kong/deck:$TAG kong/deck:latest docker push kong/deck:latest ``` -------------------------------- ### Configure TLS/HTTPS Verification Source: https://github.com/kong/deck/blob/main/_autodocs/configuration.md Manage TLS/HTTPS verification for the Kong Admin API connection. Options include skipping verification, specifying a server name, or providing custom CA certificates via raw string or file path. Skipping verification is not recommended for production. ```bash # Using environment variable with raw certificate export DECK_CA_CERT=$(cat ca.crt) deck gateway dump ``` ```bash # Or using file path deck gateway dump --ca-cert-file /path/to/ca.crt ``` ```bash # Or skip verification (not recommended for production) deck gateway dump --tls-skip-verify ``` -------------------------------- ### Default Kong Address Constant Source: https://github.com/kong/deck/blob/main/_autodocs/architecture.md Defines the hardcoded default URL for the Kong instance. This is the lowest precedence configuration and is used only if no other method is specified. ```go const defaultKongURL = "http://localhost:8001" ``` -------------------------------- ### gateway diff Source: https://github.com/kong/deck/blob/main/_autodocs/api-reference/cmd.md Shows differences between a configuration file and the current Kong cluster state. Exits with 0 if no differences, 2 if differences are detected. ```APIDOC ## gateway diff ### Description Shows differences between configuration file and Kong cluster. ### Method `gateway diff` ### Endpoint `deck gateway diff` ### Parameters #### Query Parameters - **--state-file** (string) - Required - Path to the configuration file (e.g., `kong.yaml`) ### Exit Codes - 0 — No differences - 2 — Differences detected ```