Skip to content

Commit 3b111dc

Browse files
author
Néstor Salceda
committed
Make invoication shorter just with kubectl capture
1 parent f22da6d commit 3b111dc

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ duration of time and is download locally in order to use it with
1010

1111
## Installing
1212

13-
In order to use this plugin, just copy the `kubectl-sysdig_capture` to your
13+
In order to use this plugin, just copy the `kubectl-capture` to your
1414
PATH, and ensure it has execution permissions.
1515

1616
You can verify its installation using `kubectl`:
@@ -19,7 +19,7 @@ You can verify its installation using `kubectl`:
1919
$ kubectl plugin list
2020
The following kubectl-compatible plugins are available:
2121

22-
/usr/local/bin/kubectl-sysdig_capture
22+
/usr/local/bin/kubectl-capture
2323
```
2424

2525
In this case is installed into /usr/local/bin, but will work with another
@@ -30,14 +30,14 @@ location listed in PATH.
3030
Once you have the `kubectl` plugin installed, you can start taking captures:
3131

3232
```bash
33-
$ kubectl sysdig-capture nginx-78f5d695bd-bcbd8
33+
$ kubectl capture nginx-78f5d695bd-bcbd8
3434
Sysdig is starting to capture system calls. See details below:
3535

3636
Node: gke-sysdig-work-default-pool-c2d817f5-ggwv
3737
Pod: nginx-78f5d695bd-bcbd8
3838
Duration: 120 seconds
3939

40-
Your capture is now available at sysdig-capture-1550080529-nginx-78f5d695bd-bcbd8.scap.gz
40+
Your capture is now available at capture-1550080529-nginx-78f5d695bd-bcbd8.scap.gz
4141
```
4242

4343
And then, you can start troubleshooting with [Sysdig Inspect](https://sysdig.com/opensource/inspect/).
@@ -64,5 +64,5 @@ You can uninstall this plugin from `kubectl` by simply removing it from your
6464
PATH:
6565

6666
```bash
67-
$ rm /usr/local/bin/kubectl-sysdig_capture
67+
$ rm /usr/local/bin/kubectl-capture
6868
```

kubectl-sysdig_capture renamed to kubectl-capture

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ duration="120"
1010

1111
function main() {
1212
parse_arguments "$@"
13-
create_job_for_sysdig_capture
13+
start_capture
1414
}
1515

1616
function parse_arguments() {
@@ -50,24 +50,24 @@ function parse_arguments() {
5050

5151
function usage_and_die() {
5252
cat << 'EOF'
53-
Usage: kubectl sysdig-capture pod_name
53+
Usage: kubectl capture pod_name
5454
Options:
5555
-d | --duration Capture system calls for this duration (default: 120 seconds)
5656
-n | --namespace The namespace where the target pod lives (default: default)
5757
EOF
5858
exit $1
5959
}
6060

61-
function create_job_for_sysdig_capture() {
61+
function start_capture() {
6262
local now=$(date +%s)
63-
local capture_pod="sysdig-capture-${now}-${pod}"
63+
local capture_pod="capture-${now}-${pod}"
6464

6565
node=$(kubectl -n ${namespace} get pod ${pod} -o jsonpath='{.spec.nodeName}' 2>/dev/null)
6666
if [[ $? -ne 0 ]];then
6767
exit 1
6868
fi
6969

70-
cat << EOF > sysdig-capture-pod.yaml
70+
cat << EOF > capture-pod.yaml
7171
apiVersion: v1
7272
kind: Pod
7373
metadata:
@@ -134,8 +134,8 @@ spec:
134134
nodeName: ${node}
135135
EOF
136136

137-
kubectl apply -f sysdig-capture-pod.yaml > /dev/null 2>&1
138-
rm sysdig-capture-pod.yaml
137+
kubectl apply -f capture-pod.yaml > /dev/null 2>&1
138+
rm capture-pod.yaml
139139

140140
echo "Sysdig is starting to capture system calls. See details below:"
141141
echo ""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bats
22

33
@test "when the command is run without specifing a pod it returns an error" {
4-
run ./kubectl-sysdig_capture
4+
run ./kubectl-capture
55

66
[ "$status" -eq 1 ]
77
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
#!/usr/bin/env bats
22

3-
@test "it does a sysdig capture" {
3+
@test "it does a capture" {
44
kubectl create deployment nginx --image=nginx
55
POD=$(kubectl get pod | grep nginx | cut -f1 -d" ")
66

7-
run ./kubectl-sysdig_capture $POD -d 5
7+
run ./kubectl-capture $POD -d 5
88

99
kubectl delete deployment nginx
1010

1111
[ "$status" -eq 0 ]
1212
}
1313

14-
@test "when pod is inside a namespace it does a sysdig capture" {
14+
@test "when pod is inside a namespace it does a capture" {
1515
kubectl create namespace scope
1616
kubectl -n scope create deployment nginx --image=nginx
1717
POD=$(kubectl -n scope get pod | grep nginx | cut -f1 -d" ")
1818

19-
run ./kubectl-sysdig_capture $POD -d 5 -n scope
19+
run ./kubectl-capture $POD -d 5 -n scope
2020

2121
kubectl delete namespace scope
2222

2323
[ "$status" -eq 0 ]
2424
}
2525

2626
@test "when a pod doesn't exist it returns an error" {
27-
run ./kubectl-sysdig_capture nonexistentpod
27+
run ./kubectl-capture nonexistentpod
2828

2929
[ "$status" -eq 1 ]
3030
}

0 commit comments

Comments
 (0)