Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic resource cleanup #140

Merged
merged 23 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
coverage:
status:
project:
default:
target: 70% # the required coverage value
threshold: 1% # the leniency in hitting the target
patch:
default:
target: 70%
threshold: 1%

comment:
layout: "reach, diff, flags, files"
behavior: default
require_changes: false

ignore:
- "**/*_test.go"
- "**/vendor/**"
- "**/cmd/**"
53 changes: 53 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Tests

on:
pull_request:
branches: [ master ]
push:
branches: [ master ]

jobs:
test:
name: Run Tests and Analysis
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
check-latest: true
cache: true

- name: Install dependencies
run: |
go mod download
go install golang.org/x/tools/cmd/cover@latest
go install github.com/securego/gosec/v2/cmd/gosec@latest

- name: Run tests with coverage
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
fail_ci_if_error: false

- name: Run security scan
run: |
gosec -exclude-dir=.git -exclude-dir=vendor ./...
if [ $? -ne 0 ]; then
echo "Security scan found issues"
exit 1
fi

- name: Check code formatting
run: |
if [ -n "$(gofmt -l .)" ]; then
echo "The following files are not formatted correctly:"
gofmt -l .
exit 1
fi
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ build:

docs: build
@GEN_DOC=true ./ktunnel version
proto:
@buf generate
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,17 @@ ktunnel expose myapp 80:8000 -r #deployment & service will be reused if exists o
This will currently only work for deployments with 1 replica - it will expose a listening port on the pod through a tunnel to your local machine
```bash
ktunnel inject deployment mydeployment 3306
```
```

### Resource Cleanup
ktunnel now automatically tracks and cleans up resources (deployments and services) when the process exits. This ensures no orphaned resources are left in your cluster, even after unexpected shutdowns.

- Resources are automatically cleaned up when you press Ctrl+C
- A 30-second timeout ensures cleanup doesn't hang indefinitely
- Use the `-v` flag for verbose logging to see cleanup operations
```bash
ktunnel expose myapp 80:8000 -v
```

### Star History

Expand Down
26 changes: 26 additions & 0 deletions api/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: v1
name: buf.build/omrikiei/ktunnel
lint:
deps:
- buf.build/envoyproxy/protoc-gen-validate
- buf.build/grpc-ecosystem/grpc-gateway
- buf.build/googleapis/googleapis
use:
- COMMENTS
- DEFAULT
except:
- PACKAGE_DIRECTORY_MATCH
ignore_only:
ENUM_ZERO_VALUE_SUFFIX:
- observables/v1/observables.proto
- timeline/v1/timeline.proto
- sla-timers/v1/sla_timers.proto
- notes/v1/notes.proto
allow_comment_ignores: true
breaking:
use:
- PACKAGE
ignore:
- protodep
ignore_unstable_packages: true

Loading
Loading