-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpod-gcloud.yaml
More file actions
45 lines (44 loc) · 1.38 KB
/
pod-gcloud.yaml
File metadata and controls
45 lines (44 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Copyright 2025 Matheus Pimenta.
# SPDX-License-Identifier: AGPL-3.0
apiVersion: v1
kind: Pod
metadata:
name: test-gcloud
namespace: default
spec:
serviceAccountName: <SERVICE_ACCOUNT>
hostAliases:
- hostnames: [metadata.google.internal]
ip: 169.254.169.254
restartPolicy: Never
containers:
- name: gcs
image: google/cloud-sdk:561.0.0-slim
command:
- sh
- -c
- |
# loop trying to create a new object in gs://gke-metadata-server-test with a random key and
# content until it succeeds, then read the object back. delete the object, and finally,
# if the content is different from the original, exit with an error code.
while true; do
key=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
content=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
echo $content > /tmp/$key
if gcloud storage cp /tmp/$key gs://gke-metadata-server-test/$key; then
break
fi
done
gcloud storage cat gs://gke-metadata-server-test/$key > /tmp/${key}.2
gcloud storage rm gs://gke-metadata-server-test/$key
cat <<EOF
Original content: $(cat /tmp/$key)
Downloaded content: $(cat /tmp/${key}.2)
EOF
if diff /tmp/$key /tmp/${key}.2; then
echo "Content match"
exit 0
fi
echo "Content mismatch"
exit 1
<NODE_SELECTOR>