Skip to content

4.7. Secrets

Overview

The Secrets page manages every Secret held on the MCM control plane in one place. A Secret is the Kubernetes resource that stores sensitive data -- passwords, OAuth tokens, SSH keys, TLS certificates and the like.

What it is for:

  • Managing multi-cluster Secrets together
  • Storing and distributing sensitive data safely
  • Managing Secrets by type (Opaque, TLS, Docker Registry and so on)
  • Distributing Secrets through a PropagationPolicy

Where Secrets are used:

  • Storing database passwords
  • Managing API keys and tokens
  • Storing TLS/SSL certificates
  • Docker registry credentials
  • Managing SSH keys
  • Service account tokens

How the Screen Is Laid Out

The Secrets page shows the Secret list as a table.

The Secrets main screen

The Elements at the Top of the Page

ElementDescription
Namespace filterShows only the Secrets of a particular namespace
Include system namespacesToggles showing the Secrets of system namespaces (kube-system and so on)
Refresh buttonRefreshes the Secret list
Create buttonOpens the dialog for creating a new Secret
Search boxSearches by Secret name

Table Columns

ColumnDescriptionSortable
NameThe Secret name
NamespaceThe namespace the Secret belongs to
TypeThe Secret type (Opaque, kubernetes.io/tls and so on)
KeysThe list of data keys stored
AgeThe time since the Secret was created
ActionsThe edit and delete buttons-

Secret Types

TypeDescription
OpaqueOrdinary secret data (the default)
kubernetes.io/tlsA TLS certificate and key
kubernetes.io/dockerconfigjsonDocker registry credentials
kubernetes.io/basic-authBasic authentication credentials (username/password)
kubernetes.io/ssh-authSSH credentials
kubernetes.io/service-account-tokenA service account token

Secret Detail

Clicking a Secret row opens the detail panel.

Secret detail

The Detail Panel Header

ElementDescription
Secret nameThe name of the chosen Secret
NamespaceThe namespace the Secret belongs to
TypeThe Secret type (Opaque, for example)

The Action Buttons

ButtonWhat it does
RefreshRefreshes the Secret information
EditOpens the YAML edit mode
DeleteDeletes the Secret

The Tabs

The Overview Tab

Shows the Secret's basic information, its type, and its data.

Basic information:

ItemDescription
NameThe Secret name
NamespaceThe namespace the Secret belongs to
TypeThe Secret type
KeysThe number of data keys stored
AgeThe time since creation
CreatedWhen the Secret was created

Secret Type Information:

Shows a description of the chosen Secret's type:

  • Opaque: ordinary secret data
  • kubernetes.io/tls: a TLS certificate and private key
  • kubernetes.io/dockerconfigjson: Docker registry credentials

Data:

Each data key is shown as an accordion:

The data expanded
ElementDescription
Key nameThe data key name (password, for example)
Data sizeThe number of characters in the value (8 chars, for example)
Expand/collapseClick to show or hide the data
MaskingThe data is masked by default (••••••••)
Show buttonClick to reveal the actual value
Copy buttonCopies the data to the clipboard

Security note: Secret data is masked by default. The "Show" button has to be pressed to see the actual value.

The Multi-Cluster Policies Tab

Shows the multi-cluster policies that apply to the Secret.

The multi-cluster policies tab

PropagationPolicy:

ColumnDescription
NameThe PropagationPolicy name
NamespaceThe namespace the policy belongs to
ScopeNamespace-scoped policies / cluster-scoped policies
Target ClustersThe list of target clusters

OverridePolicy:

Shown where there are per-cluster custom settings.

The Labels Tab

Shows the list of Kubernetes labels applied to the Secret.

The Annotations Tab

Shows the list of annotations applied to the Secret.

The Events Tab

Shows the Kubernetes events related to the Secret.

Creating a Secret

Creates a new Secret on the MCM control plane.

Fields

FieldRequiredDescription
NameThe Secret name
NamespaceThe namespace to deploy into
TypeChoose the Secret type
DataThe key-value pair data

Creating by Secret Type

Opaque (an ordinary secret):

apiVersion: v1
kind: Secret
metadata:
name: my-secret
namespace: default
type: Opaque
data:
username: YWRtaW4= # the Base64-encoded value
password: cGFzc3dvcmQ=

A TLS certificate:

apiVersion: v1
kind: Secret
metadata:
name: tls-secret
namespace: default
type: kubernetes.io/tls
data:
tls.crt: <base64-encoded-cert>
tls.key: <base64-encoded-key>

A Docker registry:

apiVersion: v1
kind: Secret
metadata:
name: docker-registry-secret
namespace: default
type: kubernetes.io/dockerconfigjson
data:
.dockerconfigjson: <base64-encoded-docker-config>

Editing the YAML

The "Edit YAML" tab lets you write the Secret definition directly.

Note: Secret data has to be Base64-encoded.

Secret Operations

Editing a Secret

  1. Choose the Secret
  2. Press the "Edit" button in the detail panel
  3. Change the Secret definition in the YAML editor
  4. Press the "Save" button

Caution: changing a Secret does not reach pods that are already running straight away. The pods have to be restarted for the change to take effect.

Deleting a Secret

⚠️ Caution: deleting a Secret can cause errors in the pods that reference it. Check what references it before deleting.

  1. Choose the Secret to delete
  2. Press the "Delete" button in the detail panel
  3. Type the Secret name in the confirmation dialog
  4. Press the "Delete" button

Worked Examples

Scenario 1: Creating a Database Credentials Secret

  1. Press the "Create" button
  2. Enter the Secret details:
    • Name: db-credentials
    • Namespace: production
    • Type: Opaque
    • Data:
      • username: admin (Base64: YWRtaW4=)
      • password: secret123 (Base64: c2VjcmV0MTIz)
  3. Press the "Create" button
  4. Name the target clusters with a PropagationPolicy

Scenario 2: Creating a TLS Certificate Secret

  1. Press the "Create" button and choose the Edit YAML tab
  2. Write this YAML:
    apiVersion: v1
    kind: Secret
    metadata:
    name: tls-cert
    namespace: web
    type: kubernetes.io/tls
    data:
    tls.crt: <base64-encoded-certificate>
    tls.key: <base64-encoded-private-key>
  3. Press the "Create" button
  4. Reference the TLS Secret from the Ingress

Scenario 3: Checking Secret Data

  1. Click the Secret you want to check in the list
  2. Look at the Data section on the Overview tab
  3. Click the key you want to expand it
  4. Press the "Show" button to unmask it
  5. Read the actual data value
  6. Copy it to the clipboard with the "Copy" button if needed

Scenario 4: Creating a Docker Registry Secret

  1. Create the Secret from the command line:
    kubectl create secret docker-registry my-registry \
    --docker-server=registry.example.com \
    --docker-username=user \
    --docker-password=password \
    --docker-email=user@example.com \
    -n production
  2. Check the Secret in OPENMARU MCM
  3. Apply a PropagationPolicy to deploy it across clusters

Scenario 5: Deploying a Secret Across Clusters

  1. Create the Secret
  2. Create a PropagationPolicy:
    • Resource selector: name the Secret
    • Target clusters: choose the clusters to deploy to
  3. Check the "Multi-Cluster Policies" tab in the detail panel
  4. Confirm the Secret has been deployed to the target clusters

Secret against ConfigMap

TraitSecretConfigMap
PurposeSensitive dataOrdinary configuration data
How it is storedBase64-encodedStored as plain text
SecurityRestricted access, RBAC appliedOrdinary access
In memoryMounted on tmpfs (never written to disk)The ordinary file system
Size limit1MB1MB
ExamplesPasswords, tokens, certificatesConfiguration files, environment variables

How to Use a Secret

1. Injected as an environment variable:

env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: db-credentials
key: password

2. The whole Secret as environment variables:

envFrom:
- secretRef:
name: db-credentials

3. Mounted as a volume:

volumes:
- name: secret-volume
secret:
secretName: db-credentials
volumeMounts:
- name: secret-volume
mountPath: /etc/secrets
readOnly: true

Base64 Encoding

Secret data has to be Base64-encoded:

# encode
echo -n 'mypassword' | base64
# output: bXlwYXNzd29yZA==

# decode
echo 'bXlwYXNzd29yZA==' | base64 -d
# output: mypassword

Note: Base64 is not encryption. It is only an encoding, for data integrity in transit.

Good Practice for Secret Security

  1. Apply RBAC: keep access to Secrets to a minimum
  2. Enable encryption: protect them at rest with etcd encryption
  3. Use an external secret manager: HashiCorp Vault, AWS Secrets Manager and the like
  4. Rotate regularly: change passwords and keys periodically
  5. Audit logging: monitor the record of Secret access

Managing Secrets Across Clusters

When deploying a Secret to several clusters through MCM:

PropagationPolicy:

  • Copies the same Secret to several clusters
  • Chooses the clusters and sets the deployment strategy

OverridePolicy:

  • Applies a different Secret value per cluster
  • For example, a different database password per cluster

Security considerations:

  • The Secret is spread across several clusters
  • Each cluster's security policy has to be checked
  • Confirm the transfer over the network is encrypted

Next Steps