skip to content
Alvin Lucillo

YAML for k8 via stdin and post-mortem

/ 1 min read

💻 Tech

While studying for CKAD, I learned about this command:

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx 
EOF

The command creates a pod without having to create a file. Specifically, the YAML content is passed to the kubectl apply command via stdin. cat <<EOF ...EOF, called a here document, means that the lines in between are the input to the cat command. The pipe | means that the output of the cat command is passed to the kubectl command as input. Finally, the - means that kubectl will expect the input from stdin instead of a file.

💪 Productivity

If there’s a post-mortem after an undertaking, there must also be a pre-mortem. A pre-mortem may help us achieve our goals by identifying potential roadblocks and challenges so that we can plan and set our goals for success.