Skip to content

Instantly share code, notes, and snippets.

@chadmcrowell
Created October 19, 2023 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadmcrowell/133746150c0b85a658ef47ab890ae64f to your computer and use it in GitHub Desktop.
Save chadmcrowell/133746150c0b85a658ef47ab890ae64f to your computer and use it in GitHub Desktop.
Dallas Kubernetes Workshop - Logging
# perform the commands from this lab environment:
# https://studyk8s.club/cka-logging
# create a pod that will output logs to stdout
cat << EOF > pod-logging.yaml
apiVersion: v1
kind: Pod
metadata:
name: pod-logging
spec:
containers:
- name: main
image: busybox
args: [/bin/sh, -c, 'while true; do echo $(date); sleep 1; done']
EOF
# create a pod with a sidecar
cat << EOF > pod-logging-sidecar.yaml
apiVersion: v1
kind: Pod
metadata:
name: pod-logging-sidecar
spec:
containers:
- image: busybox
name: main
args: [ 'sh', '-c', 'while true; do echo "$(date)\n" >> /var/log/main-container.log; sleep 5; done' ]
volumeMounts:
- name: varlog
mountPath: /var/log
- name: sidecar
image: busybox
args: [ /bin/sh, -c, 'tail -f /var/log/main-container.log' ]
volumeMounts:
- name: varlog
mountPath: /var/log
volumes:
- name: varlog
emptyDir: {}
EOF
# create a mysql deployment
k create deploy mysql --image mysql:8
# fix the mysql deployment
# add the following to the deployment YAML
# env:
# - name: MYSQL_PASSWORD
# value: password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment