> ## Documentation Index
> Fetch the complete documentation index at: https://orphelix.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ConfigMaps & Secrets

> Manage Kubernetes configuration and secrets - view, edit, and track usage across deployments

## Overview

ConfigMaps and Secrets store configuration data and sensitive information used by your applications. Orphelix provides both table and grid views for easy management and tracks which resources use each ConfigMap or Secret.

![ConfigMaps and Secrets](https://mintlify.s3.us-west-1.amazonaws.com/orphelix/images/configmaps-secrets.png)

## ConfigMaps

### What are ConfigMaps?

ConfigMaps store non-confidential configuration data in key-value pairs. They decouple configuration from container images, making applications more portable.

**Common Use Cases:**

* Application configuration files
* Environment variables
* Command-line arguments
* Configuration properties
* Feature flags

### List View

> [card] Table View
>
> Traditional table format with sorting and filtering

> [card] Grid View
>
> Card-based layout for better visualization

**Table Columns:**

* **Name**: ConfigMap name (clickable)
* **Data Keys**: Number of key-value pairs
* **Age**: Time since creation
* **Usage**: Number of resources using this ConfigMap
* **Actions**: View, Edit, Delete

### Detail View

Click any ConfigMap name to view details:

**1. Metadata**

* **Name**: ConfigMap identifier
* **Namespace**: Current namespace
* **Labels**: Key-value labels
* **Annotations**: Metadata annotations
* **Created**: Creation timestamp

**2. Data**

All key-value pairs stored in the ConfigMap:

![ConfigMap Data](https://mintlify.s3.us-west-1.amazonaws.com/orphelix/images/configmap-data.png)

* **Key**: Configuration key name
* **Value**: Configuration value (can be multi-line)
* **Size**: Value size in bytes

> [!TIP]
>
> Values are displayed with syntax highlighting for YAML, JSON, XML, and properties files

**3. Usage Tracking**

Shows which resources reference this ConfigMap:

* **Deployments**: As volumes or environment variables
* **StatefulSets**: Configuration mounts
* **DaemonSets**: Node-specific config
* **Pods**: Direct references

> [!NOTE]
>
> Click resource names to navigate to their detail pages

**4. Events**

Recent events related to this ConfigMap:

* Created
* Updated
* Mounted by pod
* Mount failures

### Creating ConfigMaps

ConfigMaps can be created from:

> [tab] Literal Values
>
> Create from command-line literals:
>
> ```bash theme={null}
> kubectl create configmap app-config \
>   --from-literal=database.host=postgres \
>   --from-literal=database.port=5432 \
>   --from-literal=log.level=info
> ```
>
> Result:
>
> ```yaml theme={null}
> data:
>   database.host: postgres
>   database.port: "5432"
>   log.level: info
> ```

> [tab] Files
>
> Create from configuration files:
>
> ```bash theme={null}
> kubectl create configmap app-config \
>   --from-file=application.yaml \
>   --from-file=logging.properties
> ```
>
> Result:
>
> ```yaml theme={null}
> data:
>   application.yaml: |
>     server:
>       port: 8080
>   logging.properties: |
>     log.level=DEBUG
> ```

> [tab] Directory
>
> Create from all files in a directory:
>
> ```bash theme={null}
> kubectl create configmap app-config \
>   --from-file=./config/
> ```
>
> Creates one key per file in directory

> [tab] YAML Manifest
>
> Create from YAML file:
>
> ```yaml theme={null}
> apiVersion: v1
> kind: ConfigMap
> metadata:
>   name: app-config
> data:
>   database.host: postgres
>   database.port: "5432"
>   application.yaml: |
>     server:
>       port: 8080
>       timeout: 30
> ```

### Using ConfigMaps

ConfigMaps can be consumed by pods in several ways:

#### As Environment Variables

> [tab] All Keys
>
> Import all ConfigMap keys as environment variables:
>
> ```yaml theme={null}
> envFrom:
> - configMapRef:
>     name: app-config
> ```
>
> Creates one env var per key

> [tab] Specific Keys
>
> Import specific keys:
>
> ```yaml theme={null}
> env:
> - name: DATABASE_HOST
>   valueFrom:
>     configMapKeyRef:
>       name: app-config
>       key: database.host
> - name: DATABASE_PORT
>   valueFrom:
>     configMapKeyRef:
>       name: app-config
>       key: database.port
> ```

#### As Volume Mounts

Mount ConfigMap as files in pod:

```yaml theme={null}
volumes:
- name: config
  configMap:
    name: app-config
    items:  # Optional: select specific keys
    - key: application.yaml
      path: app-config.yaml

containers:
- name: app
  volumeMounts:
  - name: config
    mountPath: /etc/config
    readOnly: true
```

Files appear at:

* `/etc/config/application.yaml`
* `/etc/config/database.host`
* `/etc/config/database.port`

> [!WARNING]
>
> ConfigMap updates propagate to mounted volumes after a delay (kubelet sync period). Pods don't automatically restart - you must restart them to use new values.

### Grid View

Alternative card-based layout for ConfigMaps:

![ConfigMap Grid View](https://mintlify.s3.us-west-1.amazonaws.com/orphelix/images/configmap-grid.png)

**Card Contents:**

* ConfigMap name
* Number of data keys
* Age
* Used by X resources (badge)
* Quick actions menu

**Benefits:**

* Better for browsing many ConfigMaps
* Visual grouping by namespace
* Quick access to most-used ConfigMaps

## Secrets

### What are Secrets?

Secrets store sensitive information like passwords, tokens, and keys. They're similar to ConfigMaps but designed for confidential data.

> [!WARNING]
>
> Secrets are only base64-encoded, not encrypted. Use encryption at rest and RBAC to secure them properly.

**Common Use Cases:**

* Database credentials
* API keys and tokens
* TLS certificates
* SSH keys
* Docker registry credentials
* OAuth tokens

### Secret Types

> [accordion] Opaque
>
> Generic secret for arbitrary data (default type)
>
> ```yaml theme={null}
> apiVersion: v1
> kind: Secret
> metadata:
>   name: db-secret
> type: Opaque
> data:
>   username: YWRtaW4=  # base64 encoded
>   password: cGFzc3dvcmQ=
> ```

> [accordion] kubernetes.io/tls
>
> TLS certificate and private key
>
> ```yaml theme={null}
> apiVersion: v1
> kind: Secret
> metadata:
>   name: tls-secret
> type: kubernetes.io/tls
> data:
>   tls.crt: <base64-encoded-cert>
>   tls.key: <base64-encoded-key>
> ```
>
> Used by Ingress for HTTPS

> [accordion] kubernetes.io/dockerconfigjson
>
> Docker registry credentials
>
> ```yaml theme={null}
> apiVersion: v1
> kind: Secret
> metadata:
>   name: regcred
> type: kubernetes.io/dockerconfigjson
> data:
>   .dockerconfigjson: <base64-encoded-config>
> ```
>
> Used in imagePullSecrets

> [accordion] kubernetes.io/basic-auth
>
> Basic authentication credentials
>
> ```yaml theme={null}
> apiVersion: v1
> kind: Secret
> metadata:
>   name: basic-auth
> type: kubernetes.io/basic-auth
> data:
>   username: <base64-username>
>   password: <base64-password>
> ```

> [accordion] kubernetes.io/ssh-auth
>
> SSH private key
>
> ```yaml theme={null}
> apiVersion: v1
> kind: Secret
> metadata:
>   name: ssh-key
> type: kubernetes.io/ssh-auth
> data:
>   ssh-privatekey: <base64-key>
> ```

> [accordion] kubernetes.io/service-account-token
>
> ServiceAccount token (auto-created)
>
> Automatically created for each ServiceAccount

### List View

Same table and grid views as ConfigMaps:

**Table Columns:**

* **Name**: Secret name
* **Type**: Secret type (Opaque, TLS, etc.)
* **Data Keys**: Number of keys
* **Age**: Time since creation
* **Usage**: Resources using this Secret

> [!NOTE]
>
> Secret values are never displayed in the list view for security

### Detail View

**1. Metadata**

* **Name**: Secret identifier
* **Type**: Secret type
* **Namespace**: Current namespace
* **Labels & Annotations**: Metadata
* **Created**: Creation timestamp

**2. Data**

Keys are displayed, but values are **masked** for security:

![Secret Data (Masked)](https://mintlify.s3.us-west-1.amazonaws.com/orphelix/images/secret-data.png)

* **Key**: Data key name
* **Value**: `••••••••` (masked)
* **Size**: Value size in bytes

> [!WARNING]
>
> Secret values are intentionally hidden in Orphelix UI. Use kubectl to view them if needed.

**3. Usage Tracking**

Shows which resources reference this Secret (same as ConfigMaps)

**4. Events**

Secret-related events (creation, mounting, errors)

### Creating Secrets

> [tab] From Literal
>
> Create from command-line:
>
> ```bash theme={null}
> kubectl create secret generic db-secret \
>   --from-literal=username=admin \
>   --from-literal=password='S3cr3t!'
> ```

> [tab] From File
>
> Create from files:
>
> ```bash theme={null}
> kubectl create secret generic tls-secret \
>   --from-file=tls.crt=./cert.pem \
>   --from-file=tls.key=./key.pem
> ```

> [tab] TLS Secret
>
> Create TLS secret:
>
> ```bash theme={null}
> kubectl create secret tls tls-secret \
>   --cert=path/to/cert.pem \
>   --key=path/to/key.pem
> ```

> [tab] Docker Registry
>
> Create registry secret:
>
> ```bash theme={null}
> kubectl create secret docker-registry regcred \
>   --docker-server=registry.example.com \
>   --docker-username=user \
>   --docker-password=pass \
>   --docker-email=user@example.com
> ```

### Using Secrets

#### As Environment Variables

```yaml theme={null}
env:
- name: DB_USERNAME
  valueFrom:
    secretKeyRef:
      name: db-secret
      key: username
- name: DB_PASSWORD
  valueFrom:
    secretKeyRef:
      name: db-secret
      key: password
```

> [!WARNING]
>
> Environment variables are visible in pod spec. Use volume mounts for highly sensitive data.

#### As Volume Mounts

```yaml theme={null}
volumes:
- name: secrets
  secret:
    secretName: db-secret
    items:
    - key: username
      path: db-username
    - key: password
      path: db-password

containers:
- name: app
  volumeMounts:
  - name: secrets
    mountPath: /etc/secrets
    readOnly: true
```

Files appear at:

* `/etc/secrets/db-username`
* `/etc/secrets/db-password`

#### As ImagePullSecrets

For private container registries:

```yaml theme={null}
spec:
  imagePullSecrets:
  - name: regcred
  containers:
  - name: app
    image: registry.example.com/app:latest
```

## Usage Tracking

Orphelix tracks which resources use each ConfigMap or Secret:

![Config Usage Tracking](https://mintlify.s3.us-west-1.amazonaws.com/orphelix/images/config-usage.png)

**Tracking Information:**

* **Resource Type**: Deployment, StatefulSet, Pod, etc.
* **Resource Name**: Specific resource using config
* **Mount Type**: Environment variable or volume
* **Keys Used**: Which keys are referenced
* **Path**: Mount path (for volumes)

**Benefits:**

* Identify unused ConfigMaps/Secrets
* Find dependencies before deletion
* Audit configuration usage
* Plan configuration updates

> [!TIP]
>
> Before deleting a ConfigMap/Secret, check the usage section to ensure no resources depend on it

## Best Practices

> [accordion] Use Secrets for Sensitive Data
>
> Never store credentials in ConfigMaps - always use Secrets

> [accordion] Enable Encryption at Rest
>
> Configure Kubernetes to encrypt Secrets in etcd:
>
> ```yaml theme={null}
> # EncryptionConfiguration
> apiVersion: apiserver.config.k8s.io/v1
> kind: EncryptionConfiguration
> resources:
> - resources:
>   - secrets
>   providers:
>   - aescbc:
>       keys:
>       - name: key1
>         secret: <base64-key>
> ```

> [accordion] Use RBAC
>
> Limit who can read Secrets:
>
> ```yaml theme={null}
> apiVersion: rbac.authorization.k8s.io/v1
> kind: Role
> metadata:
>   name: secret-reader
> rules:
> - apiGroups: [""]
>   resources: ["secrets"]
>   verbs: ["get", "list"]
> ```

> [accordion] Rotate Secrets Regularly
>
> Update secrets periodically and restart pods to use new values

> [accordion] Use External Secret Managers
>
> Consider tools like:
>
> * AWS Secrets Manager
> * HashiCorp Vault
> * Azure Key Vault
> * Google Secret Manager
>
> With operators like External Secrets Operator

> [accordion] Namespace Secrets Appropriately
>
> Create secrets in the same namespace as pods using them

> [accordion] Document Secret Keys
>
> Use labels/annotations to document secret purpose and key meanings

## Troubleshooting

### Pod Can't Mount ConfigMap/Secret

**Symptom:** Pod stuck in ContainerCreating

**Check Events:**

```
MountVolume.SetUp failed: configmap "app-config" not found
```

**Solutions:**

1. Verify ConfigMap/Secret exists: `kubectl get configmap app-config`
2. Check namespace - must be same as pod
3. Verify name spelling in pod spec
4. Check RBAC permissions

### Application Not Using Updated Config

**Symptom:** Config changes don't take effect

**Reasons:**

1. **Environment Variables**: Don't update automatically - must restart pod
2. **Volume Mounts**: Update after sync period (up to 1 minute + cache TTL)
3. **Application Cache**: App may cache config internally

**Solutions:**

* Restart deployment: `kubectl rollout restart deployment/app`
* Use ConfigMap/Secret update strategy with versioned names
* Implement file watch in application

### Secret Values Not Working

**Symptom:** Application authentication fails

**Check:**

1. **Base64 Encoding**: Ensure values are properly encoded
   ```bash theme={null}
   echo -n 'mypassword' | base64
   # Result: bXlwYXNzd29yZA==
   ```

2. **No Trailing Newlines**: Use `echo -n` to avoid newlines

3. **Special Characters**: Quote complex passwords in manifests

4. **Key Names**: Verify key names match application expectations

## Next Steps

> [card] [Deployments](https://orphelix.mintlify.site/user/deployments.md)
>
> See how to use ConfigMaps in deployments

> [card] [Pods](https://orphelix.mintlify.site/user/pods.md)
>
> View which pods use configurations

> [card] [Topology](https://orphelix.mintlify.site/user/topology.md)
>
> Visualize configuration relationships

> [card] [GitHub Integration](https://orphelix.mintlify.site/user/github/overview.md)
>
> Edit configs with GitOps workflow


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.