Skip to content

Instantly share code, notes, and snippets.

@suhas316380
Last active March 25, 2021 20:17
Show Gist options
  • Select an option

  • Save suhas316380/c4dd4f7f9cc76eb8a1a29d67c32bb7b1 to your computer and use it in GitHub Desktop.

Select an option

Save suhas316380/c4dd4f7f9cc76eb8a1a29d67c32bb7b1 to your computer and use it in GitHub Desktop.
Read kubernetes secrets from node
  1. Create a pod and mount a secret:
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: httpd
  name: httpd
spec:
  nodeName: <change_to_desired_nodeName>
  containers:
  - image: httpd
    name: httpd
    envFrom:
    - secretRef:
        name: httpd-secret
  dnsPolicy: ClusterFirst
  restartPolicy: Always
---
apiVersion: v1
data:
  creditcard: MTExMTIyMjIzMzMzNDQ0NA==
kind: Secret
metadata:
  name: httpd-secret
  namespace: default
type: Opaque
  1. SSH to the worker node, sudo to root and run pstree -p (or on the node, grep for the container command and grab the PID)
  2. Look for the root pid for "httpd" under containerd-shim
  3. run cat /proc/<pid>/environ to see the cleartext secret along with all the environment values that are loaded into the httpd pod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment