Skip to content

Commit dd7e496

Browse files
committed
0.0.1 release
1 parent f304036 commit dd7e496

File tree

3 files changed

+82
-1
lines changed

3 files changed

+82
-1
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,25 @@ kubectl debug POD_NAME
3030
kubectl debug -h
3131
```
3232

33+
# Build from source
34+
35+
Clone this repo and:
36+
```bash
37+
# build plugin
38+
go build -o kubectl-debug ./cmd/plugin
39+
# install plugin
40+
mv kubectl-debug /usr/local/bin
41+
42+
# build agent
43+
go build -o debug-agent ./cmd/agent
44+
# build agent image
45+
docker build . -t debug-agent
46+
```
47+
48+
# Demo
49+
50+
[![asciicast](https://asciinema.org/a/yswc937xUwvnIMRpvJSNJLJj7.png)](https://asciinema.org/a/yswc937xUwvnIMRpvJSNJLJj7)
51+
3352
# Default image and entrypoint
3453

3554
`kubectl-debug` use [nicolaka/netshoot](https://github.com/nicolaka/netshoot) as the default image to run debug container, and use `bash` as default entrypoint.

pkg/util/resizeevents_windows.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
Copyright 2016 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package term
18+
19+
import (
20+
"time"
21+
22+
"k8s.io/apimachinery/pkg/util/runtime"
23+
"k8s.io/client-go/tools/remotecommand"
24+
)
25+
26+
// monitorResizeEvents spawns a goroutine that periodically gets the terminal size and tries to send
27+
// it to the resizeEvents channel if the size has changed. The goroutine stops when the stop channel
28+
// is closed.
29+
func monitorResizeEvents(fd uintptr, resizeEvents chan<- remotecommand.TerminalSize, stop chan struct{}) {
30+
go func() {
31+
defer runtime.HandleCrash()
32+
33+
size := GetSize(fd)
34+
if size == nil {
35+
return
36+
}
37+
lastSize := *size
38+
39+
for {
40+
// see if we need to stop running
41+
select {
42+
case <-stop:
43+
return
44+
default:
45+
}
46+
47+
size := GetSize(fd)
48+
if size == nil {
49+
return
50+
}
51+
52+
if size.Height != lastSize.Height || size.Width != lastSize.Width {
53+
lastSize.Height = size.Height
54+
lastSize.Width = size.Width
55+
resizeEvents <- *size
56+
}
57+
58+
// sleep to avoid hot looping
59+
time.Sleep(250 * time.Millisecond)
60+
}
61+
}()
62+
}

scripts/agent_daemonset.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ spec:
1414
app: debug-agent
1515
spec:
1616
containers:
17-
- image: registry.qunhequnhe.com/monitor/debug-agent:0.0.5
17+
- image: aylei/debug-agent:0.0.1
1818
imagePullPolicy: IfNotPresent
1919
livenessProbe:
2020
failureThreshold: 3

0 commit comments

Comments
 (0)