>_ IzzyLab

Hands-on task

This task is step 3 of the course “Kubernetes: manifests from Namespace to RBAC”

Secret with data

easy~5 min

Prepare in /root/secret.yaml a Secret db-cred (type Opaque) with the key password=s3cret. It's easiest to generate it with a kubectl command using --dry-run=client -o yaml. Note: kubectl will base64-encode the value itself — that's how secrets are stored in the cluster. Open the resulting file in the Editor tab and find the encoded value.

What you'll practise:
  • kubernetes
  • secret
  • kubectl
  • base64
  • dry-run

Topic breakdown

A Secret in Kubernetes stores sensitive data and differs from a ConfigMap in that the values in the data field are held in base64 — this is not encryption, but an encoding for storing binary data in etcd. The kubectl create secret generator takes the value from the literal and encodes it itself, so in the finished manifest the original string will be replaced by its base64 representation. The --dry-run=client -o yaml flags print the manifest to the screen instead of creating the object — all that's left is to redirect the output to a file.

What's checked

  1. Manifest is valid against the schema
  2. kind is Secret
  3. password is base64-encoded
  4. Secret db-cred of type Opaque

What it looks like