Skip to content

Commit a5532f0

Browse files
authored
refactor: remove sidecar sshd runtime (#18)
* refactor(ssh): remove sidecar sshd runtime * fix(ssh): start dev sessions in workspace * docs(site): refine docs styling
1 parent 6365d93 commit a5532f0

44 files changed

Lines changed: 454 additions & 6928 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
.okdev.yaml
77
.stfolder
88
.worktrees/
9+
site/

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This file is the canonical repository guidance for coding agents working in `okd
2222

2323
- Interactive transient status output must clear cleanly and must not pollute table or machine-readable output.
2424
- `okdev ssh-proxy` must stay silent by default; diagnostics should only appear behind explicit debug or verbose behavior.
25-
- `okdev ssh` and tmux-backed sessions must land in the dev container, not the sidecar.
25+
- `okdev ssh` and tmux-backed sessions run inside the dev container via `okdev-sshd`.
2626
- Tmux behavior should preserve the normal shell experience and avoid exposing wrapper implementation details unless intentionally designed.
2727

2828
## Build And Release Rules
@@ -45,6 +45,6 @@ This file is the canonical repository guidance for coding agents working in `okd
4545

4646
## Repo-Specific Expectations
4747

48-
- Keep sidecar, SSH, tmux, and Syncthing behavior aligned; changes in one often require checking the others.
48+
- Keep sidecar (syncthing), SSH (`okdev-sshd`), tmux, and Syncthing behavior aligned; changes in one often require checking the others.
4949
- Be careful with config-loading output paths because many commands share the same helper logic.
5050
- When changing pod or sidecar behavior, consider both local installs and sidecar image rebuild/publish steps.

cmd/okdev-sshd/main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,23 @@ func buildInteractiveLoginScript(sessionEnv map[string]string, shell, workspace,
137137
var parts []string
138138

139139
if workspace != "" {
140+
parts = append(parts, fmt.Sprintf("if [ -d %s ]; then cd %s; fi", shellQuote(workspace), shellQuote(workspace)))
140141
postAttach := shellQuote(strings.TrimRight(workspace, "/") + "/.okdev/post-attach.sh")
141142
parts = append(parts, fmt.Sprintf("if [ -x %s ]; then %s 2>&1 || echo 'warning: postAttach script failed' >&2; fi", postAttach, postAttach))
142143
}
143144

144145
if tmuxFlag == "1" && sessionEnv["OKDEV_NO_TMUX"] != "1" {
145-
parts = append(parts, embeddedTmuxBootstrapScript())
146+
parts = append(parts, devTmuxBootstrapScript())
146147
}
147148

148149
parts = append(parts, "exec "+shellQuote(shell)+" -l")
149150
return strings.Join(parts, "; ")
150151
}
151152

152-
func embeddedTmuxBootstrapScript() string {
153+
func devTmuxBootstrapScript() string {
153154
return strings.Join([]string{
154155
`if [ "${TERM:-}" = "xterm-ghostty" ]; then export TERM=xterm-256color; fi`,
155-
`if command -v tmux >/dev/null 2>&1; then if [ -f /var/okdev/embedded.tmux.conf ]; then exec tmux -f /var/okdev/embedded.tmux.conf new-session -A -s okdev; fi; exec tmux new-session -A -s okdev; fi`,
156+
`if command -v tmux >/dev/null 2>&1; then if [ -f /var/okdev/dev.tmux.conf ]; then exec tmux -f /var/okdev/dev.tmux.conf new-session -A -s okdev; fi; exec tmux new-session -A -s okdev; fi`,
156157
`echo 'warning: tmux not available in dev container; continuing without tmux' >&2`,
157158
}, "; ")
158159
}

cmd/okdev-sshd/main_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import (
55
"testing"
66
)
77

8-
func TestBuildInteractiveLoginScriptIncludesEmbeddedTmuxBootstrap(t *testing.T) {
8+
func TestBuildInteractiveLoginScriptIncludesDevTmuxBootstrap(t *testing.T) {
99
script := buildInteractiveLoginScript(map[string]string{}, "/bin/bash", "/workspace", "1")
1010

1111
for _, want := range []string{
12+
"cd '/workspace'",
1213
"/workspace/.okdev/post-attach.sh",
13-
"/var/okdev/embedded.tmux.conf",
14+
"/var/okdev/dev.tmux.conf",
1415
"exec tmux new-session -A -s okdev",
1516
} {
1617
if !strings.Contains(script, want) {

docs/command-reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
- `okdev up [--wait-timeout 3m] [--dry-run]`
2020
- Reconciles Pod/PVC resources, updates SSH config, initializes managed forwarding/sync, then exits.
2121
- tmux-backed persistent interactive shells are enabled by default.
22-
- `--tmux`: explicitly enable tmux mode on the sidecar.
22+
- `--tmux`: explicitly enable tmux mode in the dev container.
2323
- `--no-tmux`: disable tmux mode for this pod.
2424
- When `sync.engine=syncthing`, `okdev up` starts background sync in bidirectional mode by default.
2525
- `spec.ports` is materialized as SSH `LocalForward`.
@@ -29,7 +29,7 @@
2929
- `okdev use <session>`
3030
- `okdev connect [--shell /bin/bash] [--cmd "..."] [--no-tty]`
3131
- `okdev ssh [--setup-key] [--user root] [--cmd "..."] [--no-tmux]`
32-
- Targets merged `okdev-sidecar` (`sshd` + Syncthing).
32+
- Targets `okdev-sshd` in the `dev` container.
3333
- Maintains managed host alias in `~/.ssh/config` as `okdev-<session>`.
3434
- `--no-tmux`: bypass tmux for this SSH session when tmux mode is enabled.
3535
- `okdev ports`

docs/config-manifest.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,13 @@ Validation:
9999
## `spec.ssh`
100100

101101
- `user` (`string`, default: `root`)
102-
- `remotePort` (`int`, default: `22`)
103102
- `privateKeyPath` (`string`, optional)
104103
- `autoDetectPorts` (`bool`, default: `true`)
105104
- `persistentSession` (`bool`, default: `true`) enables tmux-backed interactive session mode
106105
- `keepAliveIntervalSeconds` (`int`, default: `10`)
107106
- `keepAliveTimeoutSeconds` (`int`, default: `10`)
108107

109108
Validation:
110-
- `remotePort` must be `1..65535`
111109
- `keepAliveIntervalSeconds > 0`
112110
- `keepAliveTimeoutSeconds > 0`
113111
- `keepAliveTimeoutSeconds >= keepAliveIntervalSeconds`
@@ -178,7 +176,6 @@ spec:
178176
remote: 6006
179177
ssh:
180178
user: root
181-
remotePort: 22
182179
persistentSession: true
183180
keepAliveIntervalSeconds: 30
184181
keepAliveTimeoutSeconds: 90

docs/index.md

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,60 @@
11
# okdev
22

3-
`okdev` is a CRD-less CLI for Kubernetes development sessions.
4-
It provisions and operates dev environments from `.okdev.yaml` using standard Pod/PVC resources.
3+
**CRD-less Kubernetes dev environments from a single manifest.**
54

6-
## Core Capabilities
5+
okdev provisions and operates dev sessions using standard Pod/PVC resources -- no operators, no CRDs, no cluster-side components.
76

8-
- PodSpec-driven environment definition
9-
- Multi-session workflow per repo/branch/user
10-
- Session setup via `okdev up` (SSH config, managed forwards, sync bootstrap)
11-
- Syncthing-based workspace synchronization
12-
- Reattach from any machine with kube access
7+
---
8+
9+
## How it works
10+
11+
```
12+
.okdev.yaml --> okdev up --> Pod + PVC + SSH + Sync
13+
```
14+
15+
1. Define your environment in `.okdev.yaml` (image, volumes, ports, sync paths).
16+
2. Run `okdev up` to create the pod, configure SSH, and start file sync.
17+
3. Connect with `ssh okdev-<session>` or `okdev connect`.
18+
19+
---
20+
21+
## Key features
22+
23+
| | |
24+
|---|---|
25+
| **One-command setup** | `okdev up` handles pod creation, SSH config, port forwarding, and sync |
26+
| **Persistent sessions** | tmux-backed shells survive disconnects by default |
27+
| **File sync** | Bidirectional Syncthing sync with exclude patterns |
28+
| **Port forwarding** | Declare ports in config, get automatic SSH `LocalForward` entries |
29+
| **Multi-session** | Run multiple environments per repo with named sessions |
30+
| **No cluster deps** | Works with any Kubernetes cluster -- RBAC for Pods and PVCs is all you need |
31+
32+
---
33+
34+
## Quick start
35+
36+
```bash
37+
# Install
38+
curl -fsSL https://raw.githubusercontent.com/acmore/okdev/main/scripts/install.sh | sh
39+
40+
# Initialize config
41+
okdev init
42+
43+
# Start session
44+
okdev up
45+
46+
# Connect
47+
ssh okdev-<session>
48+
```
49+
50+
See the [Quickstart guide](quickstart.md) for details.
51+
52+
---
1353

1454
## Documentation
1555

16-
- [Quickstart](quickstart.md)
17-
- [Config Manifest](config-manifest.md)
18-
- [Command Reference](command-reference.md)
19-
- [Troubleshooting](troubleshooting.md)
20-
- [Release & Versioning](release.md)
21-
- [Repository](https://github.com/acmore/okdev)
56+
- [Quickstart](quickstart.md) -- install, configure, and launch your first session
57+
- [Config Manifest](config-manifest.md) -- full `.okdev.yaml` field reference
58+
- [Command Reference](command-reference.md) -- every CLI command and flag
59+
- [Troubleshooting](troubleshooting.md) -- common issues and fixes
60+
- [Release & Versioning](release.md) -- release process and image tags

0 commit comments

Comments
 (0)