Created
October 19, 2023 21:07
-
-
Save chadmcrowell/133746150c0b85a658ef47ab890ae64f to your computer and use it in GitHub Desktop.
Dallas Kubernetes Workshop - Logging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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