diff --git a/16-sidecar-containers/00-fluentd-configmap.yml b/16-sidecar-containers/00-fluentd-configmap.yml
deleted file mode 100644
index 6c068af..0000000
--- a/16-sidecar-containers/00-fluentd-configmap.yml
+++ /dev/null
@@ -1,20 +0,0 @@
----
-apiVersion: v1
-kind: ConfigMap
-metadata:
- name: fluentd
-data:
- fluent.conf: |
-
-
-
- @type stdout
-
diff --git a/16-sidecar-containers/01-sidecar.yml b/16-sidecar-containers/01-sidecar.yml
index af2656b..97f8281 100644
--- a/16-sidecar-containers/01-sidecar.yml
+++ b/16-sidecar-containers/01-sidecar.yml
@@ -3,6 +3,8 @@ apiVersion: v1
kind: Pod
metadata:
name: two-containers
+ labels:
+ app: sidecar-container
spec:
volumes:
- name: shared-logs
@@ -13,6 +15,8 @@ spec:
containers:
- name: nginx
image: nginx
+ ports:
+ - containerPort: 80
volumeMounts:
- name: shared-logs
mountPath: /var/log/nginx
@@ -23,3 +27,34 @@ spec:
mountPath: /logs
- name: fluentd-config
mountPath: /fluentd/etc
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: fluentd
+data:
+ fluent.conf: |
+
+
+
+ @type stdout
+
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: nginx
+spec:
+ ports:
+ - port: 80
+ targetPort: 80
+ selector:
+ app: sidecar-container
diff --git a/16-sidecar-containers/README.md b/16-sidecar-containers/README.md
index df63880..c9e00f4 100644
--- a/16-sidecar-containers/README.md
+++ b/16-sidecar-containers/README.md
@@ -14,7 +14,7 @@ spec:
- name: container1
image: nginx
- name: container2
- image: busybox
+ image: fluentd
```
Here we have 2 containers: `container1` and `container2`.
@@ -33,14 +33,20 @@ Istio, the service mesh tool, installs a sidecar container to do its job: https:
## Exercices
-Review and apply the file [01-sidecar.yml](01-sidecar.yml). Connect to the `nginx` container and look at the file system in `/usr/share/nginx/html`.
+Review and apply the file [01-sidecar.yml](01-sidecar.yml).
+
+Connect to the `nginx` container (`kubectl exec -it two-containers -c nginx`) and look at the file system in `/var/log/nginx`.
+
+Do the same for the `fluentd` container and this time look in `/logs`. What do you see?
+
+Tail the logs from the fluentd pod (`kubectl logs -f two-containers -c fluentd`) and in another terminal window, send requests to the nginx service with a curl from a separate pod. What do you see? How do you explain it?
This exercice is taken from the [official Kubernetes documentation](https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/#creating-a-pod-that-runs-two-containers).
## Clean up
```sh
-kubectl delete service,deployment,pod --all
+kubectl delete service,deployment,pod,configmap --all
```
## Links