Skip to content

Commit cadeff4

Browse files
committed
Add service account example with API lookup
Add service account example with API lookup
1 parent 355ce0f commit cadeff4

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
sleep 5
2828
type kubectl
2929
kubectl version || true | tee apply.txt
30+
ls ~/.*
3031
kubectl create sa default 2>/dev/null || true
3132
kubectl get sa -A
3233
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: Role
4+
metadata:
5+
name: role-pod-read
6+
namespace: default
7+
rules:
8+
- apiGroups: [""]
9+
resources: ["pods"]
10+
verbs: ["get", "watch", "list"]
11+
---
12+
apiVersion: rbac.authorization.k8s.io/v1
13+
kind: RoleBinding
14+
metadata:
15+
name: service-account-rolebinding
16+
namespace: default
17+
subjects:
18+
- kind: ServiceAccount
19+
name: service-account-pod-read
20+
roleRef:
21+
kind: Role
22+
name: role-pod-read
23+
apiGroup: rbac.authorization.k8s.io
24+
---
25+
apiVersion: v1
26+
kind: ServiceAccount
27+
metadata:
28+
name: service-account-pod-read
29+
namespace: default
30+
---
31+
apiVersion: v1
32+
kind: Pod
33+
metadata:
34+
name: service-account-pod
35+
namespace: default
36+
spec:
37+
containers:
38+
- command: ["/bin/bash","-c","apt update -y -qq && apt install -qq -y curl && curl -s https://kubernetes:443/api/v1/namespaces/default/pods --header \"Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)\" --insecure && sleep 3600"]
39+
image: ubuntu
40+
name: pods-simple-container
41+
serviceAccount: service-account-pod-read

0 commit comments

Comments
 (0)