forked from Azure/ARO-RP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathssh-k8s.sh
More file actions
executable file
·111 lines (103 loc) · 1.96 KB
/
Copy pathssh-k8s.sh
File metadata and controls
executable file
·111 lines (103 loc) · 1.96 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash -e
set -o pipefail
while [[ $1 == -* ]]; do
if [[ $1 == -- ]]; then
shift
break
fi
shift
done
if [[ "$#" -gt 0 ]]; then
NODENAME=$1
shift
fi
COMMAND='bash --login'
TTY=true
TTYOPT=-t
if [[ "$#" -gt 0 ]]; then
COMMAND="bash -c $(printf ' %q' "$@" | sed -e "s/'/''/g")"
TTY=false
TTYOPT=
fi
cleanup() {
[[ -n "$POD" ]] && oc delete pod -n default "$POD" >/dev/null
}
trap cleanup EXIT
POD=$(oc create -o json -f - <<EOF | jq -r .metadata.name
kind: Pod
apiVersion: v1
metadata:
generateName: debug
labels:
openshift.io/run-level: "0"
namespace: default
spec:
containers:
- command:
- /sbin/chroot
- /host
- /bin/bash
- -c
- 'cd && exec $COMMAND'
image: ubi9/ubi-minimal
name: debug
securityContext:
capabilities:
add:
- CHOWN
- DAC_OVERRIDE
- DAC_READ_SEARCH
- FOWNER
- FSETID
- KILL
- SETGID
- SETUID
- SETPCAP
- LINUX_IMMUTABLE
- NET_BIND_SERVICE
- NET_BROADCAST
- NET_ADMIN
- NET_RAW
- IPC_LOCK
- IPC_OWNER
- SYS_MODULE
- SYS_RAWIO
- SYS_CHROOT
- SYS_PTRACE
- SYS_PACCT
- SYS_ADMIN
- SYS_BOOT
- SYS_NICE
- SYS_RESOURCE
- SYS_TIME
- SYS_TTY_CONFIG
- MKNOD
- LEASE
- AUDIT_WRITE
- AUDIT_CONTROL
- SETFCAP
- MAC_OVERRIDE
- MAC_ADMIN
- SYSLOG
- WAKE_ALARM
- BLOCK_SUSPEND
- AUDIT_READ
stdin: true
tty: $TTY
volumeMounts:
- mountPath: /host
name: host
hostIPC: true
hostNetwork: true
hostPID: true
nodeName: "$NODENAME"
restartPolicy: Never
terminationGracePeriodSeconds: 0
volumes:
- hostPath:
path: /
name: host
EOF
)
oc wait --timeout=300s --for=condition=Ready -n default "pod/$POD" >/dev/null
oc attach -i $TTYOPT -n default -c debug "pod/$POD"