liveBook · Manning

Configmap

As explained in Machine Learning Platform Engineering

A Kubernetes ConfigMap is an API object that stores non-sensitive configuration data as key-value pairs for consumption by workloads.

A ConfigMap is a Kubernetes API object for storing non-sensitive configuration as key-value pairs. Workloads can consume values without embedding environment-specific settings in their definitions. section 3.3.5

Define configuration

Create a ConfigMap with apiVersion v1, kind ConfigMap, a metadata.name, and a data map. A practical example stores database-url and environment values in test-configmap. Apply it with kubectl create -f, then inspect it using kubectl get configmaps or kubectl describe configmap test-configmap. section 3.3.5

Listing 3.10 config-map.yaml: creating a ConfigMap
apiVersion: v1    #1
kind: ConfigMap    #2
metadata:
  name: test-configmap     #3
data:    #4
  database-url: "cloudsql-proxy.prod.company.data"
  environment: sandbox 

Shows the complete minimal manifest structure for creating a ConfigMap with two configuration entries. section 3.3.5

Expose individual entries to a container through env.valueFrom.configMapKeyRef. The reference names the ConfigMap and the required key, allowing a pod to receive DATABASE_URL from database-url. section 3.3.5

apiVersion: v1
kind: Pod
metadata:
  name: pod-using-configmap
spec:
  containers:
    - name: container-using-configmap
      image: ubuntu
      env:
        - name: DATABASE_URL
          valueFrom:
            configMapKeyRef:
              name: test-configmap
              key: database-url
        - name: API_KEY
          valueFrom:
            configMapKeyRef:
              name: test-configmap
              key: api-key                   

Shows a pod consuming ConfigMap keys as environment variables and illustrates the name-and-key reference pattern. section 3.3.5

Keep credentials in a Secret rather than a ConfigMap. Secrets are represented separately, with opaque data and base64-encoded values, while ConfigMaps hold ordinary settings such as URLs and environment names. section 3.3.5

Configure Kubeflow notebook options

Kubeflow uses a ConfigMap, usually named with jupyter-web-app-config in the kubeflow namespace, to control notebook menu options. Its embedded configuration can set default images, list selectable images, and mark options read-only. Similar configuration exposes node-affinity choices for notebook placement. section 7.1.4

Listing 7.2 Jupyter web app ConfigMap
apiVersion: v1
data:
  spawner_ui_config.yaml: >
    spawnerFormDefaults:
      image:
        value: kubeflownotebookswg/jupyter-scipy:v1.6.1
        options:
            - asia.gcr.io/kubeflow-notebook-servers/jupyter-tensorflow:2.6.0
            - asia.gcr.io/kubeflow-notebook-servers/jupyter-pytorch:1.9.0
      imageGroupOne:
        - kubeflownotebookswg/codeserver-python:v1.6.1
      imageGroupTwo:
        - kubeflownotebookswg/rstudio-tidyverse:v1.6.1

Displays a Jupyter web app ConfigMap whose embedded YAML configures default notebook images and selectable alternatives. section 7.1.4

How Machine Learning Platform Engineering covers it

How deep it goes
Defines manifests, inspection commands, pod references, and Kubeflow configuration, but does not explain ConfigMap storage internals.
Examples
Uses database settings, pod environment variables, notebook image menus, and node-affinity options as concrete configurations.
What it assumes
Assumes basic Kubernetes resource and pod familiarity while distinguishing ConfigMaps from Secrets through concrete manifests.
What you can do after
Operate/configure ConfigMaps with kubectl and inject selected keys into pods or Kubeflow notebook workflows.
How it connects
Connects ConfigMaps to Kubernetes Pods, Deployments, Secrets, namespaces, Kubeflow notebooks, and node affinity.

Also explained in

Compare how 8 books explain configmap →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Platform Engineering. The section links point to the parts of the book it draws on.