Kuberig

Kuberig

  • Docs
  • Blog
  • Help

›All Blog Posts

All Blog Posts

  • CRD support a challenge!
  • CircleCI setup
  • Learnk8s Featured
  • ConfigMaps
  • Elastic Kubernetes Service (Amazon EKS)
  • The initEnvironment Task
  • Google Kubernetes Engine (GKE)
  • Digital Ocean Kubernetes (DOKS)
  • Resource Coding
  • Microk8s

ConfigMaps

July 11, 2019

Tom Eyckmans

Tom Eyckmans

Dealing with Kubernetes ConfigMaps in plain yaml files can be a hassle.

Especially when you need to include files. You loose all your file type specific editor support and are left back in the stone age.

KubeRig makes it easy to include environment specific files and values.

Prerequisites

You have a working local development environment.

If KubeRig is new for you, you may also want to read KubeRig Resource Coding.

Example

Lets jump right in with an example.

@EnvResource
fun basicConfigMap(): ConfigMapDsl {
    return configMap {
        metadata {
            name("app-config")
        }
        data("env.url", environmentConfig("env.url"))
        data("cert.pem", environmentFile("certs/app-cert.pem"))
    }
} 

What makes defining ConfigMaps with KubeRig so easy is mainly because of the environment support.

Via the ResourceGeneratorContext you have access to:

  • The current environment via environment().
  • Environment specific configuration values via environmentConfig(configName) read from the environments/{environment-name}/{environment-name}-config.properties file.
  • Environment specific files via environmentFileText(filePath) and environmentFileBytes(filePath); filePath is used within the environment directory environments/{environment-name}.

Via """...""".trimIndent() available in Kotlin. You have a simple way of creating a template for files that contain a lot of configuration values.

What is next?

Now that you know how to access environment specific files and values we can show you how to work with sensitive information and generate Secrets in a next post.

Stay tuned and happy resource coding!

Recent Posts
Kuberig
Docs
HomeQuick StartDSL Intro
Community
Stack OverflowDiscordTwitter
More
BlogGitHubStar
Follow @kuberigio
Copyright © 2021 Rigeldev BV