Skip to content

A Kubectl plugin that enhances Kustomize with support for environment variables

Notifications You must be signed in to change notification settings

felixgborrego/kubectl-envkustomize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kubectl Plugin for Environment Variable Support in Kustomize

A kubectl plugin that enables the use of environment variables in Kustomize overlays. image

Why This Plugin?

I've used Kustomize extensively over the years, and I've always missed the ability to evaluate environment variables in overlays. The recommended approach, using patches and overlays, is just too much work when managing a large fleet of clusters. It can be a pain, even for basic tasks like patching an image name!

This plugin is largely a response to the frustrations described here:

How Does It Work?

The plugin is a lightweight wrapper around the official Kustomize API (krusty) Kustomizer. It replaces the original filesystem loader with a custom one that evaluates environment variables before loading the file.

How to Use It?

# You need to run it in a valid Kustomize overlay folder like this:
cd /examples/overlay/env-dev
kubectl envkustomize render
# Check the rendered.yaml file generated in the same folder

Installation

  • Homebrew
brew tap felixgborrego/kubectl-envkustomize https://github.com/felixgborrego/kubectl-envkustomize
brew install kubectl-envkustomize
  • Manually (Linux) / CI/CD
      - name: Install kubectl-envkustomize
        run: |
          curl -L "https://github.com/felixgborrego/kubectl-envkustomize/releases/download/v0.0.1/kubectl-envkustomize_Linux_i386.tar.gz" -o kubectl-envkustomize.tar.gz
          tar -xzf kubectl-envkustomize.tar.gz
          sudo mv kubectl-envkustomize /usr/local/bin/

Evaluations Supported

  • Basic environment variables replacement: ${{{ VAR }}}
  • Load of environment variables from .env files or from the environment itself (using a prefix to avoid loading all environment variables and to avoid conflicts)
  • Load secrets from GCP Secret Manager (Welcome PRs to add AWS Secrets Manager and Azure Key Vault support)
  • Expand environment with ${{{env-expand://ENV_}}} to inject automatically all environment variables starting with ENV_
  • Support for environment variables substitution even inside helm charts (or other external resources as long as they are referenced in the kustomize overlay)

About

A Kubectl plugin that enhances Kustomize with support for environment variables

Resources

Stars

Watchers

Forks

Packages

No packages published