Marcin Jahn | Dev Notebook
  • Home
  • Programming
  • Technologies
  • Projects
  • About
  • Home
  • Programming
  • Technologies
  • Projects
  • About
  • An icon of the Networking section Networking
    • HTTP Protocol
    • OSI Model
    • TCP Procol
    • UDP Protocol
    • WebSocket
    • HSTS
    • DNS
    • Server Name Indication
    • gRPC
  • An icon of the Security section Security
    • OAuth2
      • Sender Constraint
    • Cryptography
      • Cryptography Basics
    • TPM
      • Overiew
      • TPM Entities
      • TPM Operations
  • An icon of the Linux section Linux
    • Gist of Linux Tooling
    • Unknown
    • SELinux
    • Containers
    • Bash Scripting
    • Linux From Scratch
    • Networking
  • An icon of the Kubernetes section Kubernetes
    • Meaning and Purpose
    • Cluster
    • Dev Environment
    • Kubernetes API
    • Objects
    • Pods
    • Scaling
    • Events
    • Storage
    • Configuration
    • Organizing Objects
    • Services
    • Ingress
    • Helm
  • An icon of the Observability section Observability
    • Tracing
  • An icon of the Databases section Databases
    • ACID
    • Glossary
    • Index
    • B-Tree and B+Tree
    • Partitioning and Sharding
    • Concurrency
    • Database Tips
  • An icon of the SQL Server section SQL Server
    • Overview
    • T-SQL
  • An icon of the MongoDB section MongoDB
    • NoSQL Overview
    • MongoDB Overview
    • CRUD
    • Free Text Search
  • An icon of the Elasticsearch section Elasticsearch
    • Overview
  • An icon of the Git section Git
    • Git
  • An icon of the Ansible section Ansible
    • Ansible
  • An icon of the Azure section Azure
    • Table Storage
    • Microsoft Identity
  • An icon of the Google Cloud section Google Cloud
    • Overview
  • An icon of the Blockchain section Blockchain
    • Overview
    • Smart Contracts
    • Solidity
    • Dapps
  • Home Assistant
    • Home Assistant Tips
  • An icon of the Networking section Networking
    • HTTP Protocol
    • OSI Model
    • TCP Procol
    • UDP Protocol
    • WebSocket
    • HSTS
    • DNS
    • Server Name Indication
    • gRPC
  • An icon of the Security section Security
    • OAuth2
      • Sender Constraint
    • Cryptography
      • Cryptography Basics
    • TPM
      • Overiew
      • TPM Entities
      • TPM Operations
  • An icon of the Linux section Linux
    • Gist of Linux Tooling
    • Unknown
    • SELinux
    • Containers
    • Bash Scripting
    • Linux From Scratch
    • Networking
  • An icon of the Kubernetes section Kubernetes
    • Meaning and Purpose
    • Cluster
    • Dev Environment
    • Kubernetes API
    • Objects
    • Pods
    • Scaling
    • Events
    • Storage
    • Configuration
    • Organizing Objects
    • Services
    • Ingress
    • Helm
  • An icon of the Observability section Observability
    • Tracing
  • An icon of the Databases section Databases
    • ACID
    • Glossary
    • Index
    • B-Tree and B+Tree
    • Partitioning and Sharding
    • Concurrency
    • Database Tips
  • An icon of the SQL Server section SQL Server
    • Overview
    • T-SQL
  • An icon of the MongoDB section MongoDB
    • NoSQL Overview
    • MongoDB Overview
    • CRUD
    • Free Text Search
  • An icon of the Elasticsearch section Elasticsearch
    • Overview
  • An icon of the Git section Git
    • Git
  • An icon of the Ansible section Ansible
    • Ansible
  • An icon of the Azure section Azure
    • Table Storage
    • Microsoft Identity
  • An icon of the Google Cloud section Google Cloud
    • Overview
  • An icon of the Blockchain section Blockchain
    • Overview
    • Smart Contracts
    • Solidity
    • Dapps
  • Home Assistant
    • Home Assistant Tips

Configuration

Applications in pods might be configured in a few ways.

ConfigMaps

Mounting as volumes

When mounting a ConfigMap/Secret as a volume, the files in the container are actually symbolic links. Next to them is a directory with the actual files. This was done so that when configMap changes, and Kubernetes updates the files, the symbolic links will be switched to point to new files only after all of them get updated properly. This solves a potential issue of container seeing only half of the files being updated, which could lead to improper configuration of the app.

When using subPath while mounting configMap, the files do not get updated together with configMap updates.

Secrets

Secrets are very similar to configMaps. Some differences:

  • Secrets are only distrubuted to the Nodes that run the Pods taht need the given Secret.
  • Secrets in the Nodes are always only in memory, never written to the disk.

By default Secrets have type set to Opaque. There are various types of secrets used by various K8s components. Examples of secret types:

  • kubernetes.io/basic-auth - must container username and password
  • kubernetes.io/tls - must contain tls.crt and tls.key

Secrets objects store secrets under the data key in base64 encoded format. In order to crete a secret, you can either provide the base64-encoded values under data or provide raw values under the stringData key. They will be transformed to base64 and put under data by K8s. stringData is only writable, not readable.

Downward API

It allows to expose pod and container metadata (metadata, spec or status fields and resource constraints, like CPU, RAM) via environment variables or files (like ConfigMaps).

Supported metadata fields:

FieldDescriptionAllowed in envAllowed in volume
metadata.nameThe pod’s name.YesYes
metadata.namespaceThe pod’s namespace.YesYes
metadata.uidThe pod’s UID.YesYes
metadata.labelsAll the pod’s labels, one label per line, formatted as key=“value”NoYes
metadata.labels[‘key’]The value of the specified label.YesYes
metadata.annotationsAll the pod’s annotations, one per line, formatted as key=“value”.NoYes
metadata.annotations[‘key’]The value of the specified annotation.YesYes
spec.nodeNameThe name of the worker node the pod runs on.YesNo
spec.serviceAccountNameThe name of the pod’s service account.YesNo
status.podIpThe pod’s IP address.YesNo
status.hostIPThe worker node’s IP address.YesNo

Supported resource cnstraints injection:

Resource fieldDescriptionAllowed in envAllowed in vol
requests.cpuThe container’s CPU request.YesYes
requests.memoryThe container’s memory request.YesYes
requests.ephemeral-storageThe container’s ephemeral storage request.YesYes
limits.cpuThe container’s CPU limit.YesYes
limits.memoryThe container’s memory limit.YesYes
limits.ephemeral-storageThe container’s ephemeral storage limit.YesYes

Projected Volumes

When mounting Secrets, ConfigMaps, Downward API as volumes, they cannot be mounted in the same directory (unless using subPath). Projected Volumes allow to do that.

←  Storage
Organizing Objects  →
© 2023 Marcin Jahn | Dev Notebook | All Rights Reserved. | Built with Astro.