You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/docker.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -192,7 +192,7 @@ Apart from the `container`, `host`, `network`, `platform` and `containerName` op
192
192
| `agentPath` | `string` | Contains the full path to the [ContainerSSH guest agent](https://github.com/containerssh/agent) inside the shell container. The agent must be installed in the guest image. |
193
193
| `disableAgent` | `bool` | Disable the ContainerSSH guest agent. This will disable several functions and is *not recommended*. |
194
194
| `subsystems` | `map[string]string` | Specifies a map of subsystem names to executables. It is recommended to set at least the `sftp` subsystem as many users will want to use it. |
195
-
| `imagePullPolicy` | `Never,IfNotPresent,Always` | Specifies when to pull the container image. Defaults to `IfNotPresent`, which pulls the image when it is not locally present *or* if the image has no tag/has the `latest` tag. It is recommended that you provide a custom, versioned image name to prevent pulling the image at every connection. |
195
+
| `imagePullPolicy` | `Never,IfNotPresent,Always` | Specifies when to pull the container image. Defaults to `IfNotPresent`, which pulls the image only when it is not locally present. It is recommended that you provide a custom, versioned image name to prevent pulling the image at every connection. |
Copy file name to clipboardExpand all lines: docs/reference/kubernetes.md
+50-3Lines changed: 50 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -199,9 +199,10 @@ Apart from the `metadata` and `spec` options ContainerSSH has the following opti
199
199
| Name | Type | Description |
200
200
|------|------|-------------|
201
201
| `consoleContainerNumber` | `uint` | Specifies the number of the container to attach to. Defaults to the first container. |
202
-
| `mode` | `string` | Specify `connection` to launch one pod per SSH connection or `session` to run one pod per SSH session (multiple pods per connection). In connection mode the container is started with the `idleCommand` as the first program and every session is launched similar to how `kubectl exec` runs programs. In session mode the command is launched directly. |
203
-
| `idleCommand` | `[]string` | Specifies the command to run as the first process in the container in `connection` mode. Parameters must be provided as separate items in the array. Has no effect in `session` mode. |
204
-
| `shellCommand` | `[]string` | Specifies the command to run as a shell in `connection` mode. Parameters must be provided as separate items in the array. Has no effect in `session` mode. |
202
+
| `mode` | `string` | Specify `connection` to launch one pod per SSH connection, `session` to run one pod per SSH session (multiple pods per connection), or `persistent` to exec into an already running pod. In connection mode the container is started with the `idleCommand` as the first program and every session is launched similar to how `kubectl exec` runs programs. In session mode the command is launched directly. In persistent mode the pod must already exist (or be auto-created with `createMissingPods`). |
203
+
| `createMissingPods` | `bool` | When set to `true` in `persistent` mode, ContainerSSH will automatically create a pod if no existing pod is found. Defaults to `false`. Only valid in `persistent` mode. |
204
+
| `idleCommand` | `[]string` | Specifies the command to run as the first process in the container in `connection` mode (also required in `persistent` mode when `createMissingPods` is enabled). Parameters must be provided as separate items in the array. Has no effect in `session` mode. |
205
+
| `shellCommand` | `[]string` | Specifies the command to run as a shell in `connection` mode (also required in `persistent` mode when `createMissingPods` is enabled). Parameters must be provided as separate items in the array. Has no effect in `session` mode. |
205
206
| `agentPath` | `string` | Contains the full path to the [ContainerSSH guest agent](https://github.com/containerssh/agent) inside the shell container. The agent must be installed in the guest image. |
206
207
| `disableAgent` | `bool` | Disable the ContainerSSH guest agent. This will disable several functions and is *not recommended*. |
207
208
| `subsystems` | `map[string]string` | Specifies a map of subsystem names to executables. It is recommended to set at least the `sftp` subsystem as many users will want to use it. |
@@ -210,6 +211,52 @@ Apart from the `metadata` and `spec` options ContainerSSH has the following opti
210
211
211
212
- In `connection` mode the `idleCommand` and `shellCommand` options are required.
212
213
- In `session` mode the restart policy must be empty or `Never`.
214
+
- In `persistent` mode with `createMissingPods` enabled, the `idleCommand`, `shellCommand`, and at least one container in the pod spec are required.
215
+
216
+
### Persistent mode
217
+
218
+
The `persistent` execution mode allows ContainerSSH to exec into an already running pod rather than creating a new one for each connection or session. This is useful when you have long-lived pods that should be reused across SSH sessions, for example pre-provisioned development environments.
219
+
220
+
```yaml
221
+
kubernetes:
222
+
pod:
223
+
mode: persistent
224
+
metadata:
225
+
name: my-existing-pod
226
+
namespace: default
227
+
spec:
228
+
containers:
229
+
- name: shell
230
+
image: containerssh/containerssh-guest-image
231
+
```
232
+
233
+
In persistent mode:
234
+
235
+
- ContainerSSH looks up the pod by `metadata.name` and `metadata.namespace` and creates an exec session inside it, similar to `kubectl exec`.
236
+
- The pod is **not removed** when the SSH session ends — it persists for future connections.
237
+
- Files from the authentication metadata (e.g. Kerberos credential caches) are automatically written into the container on connection.
238
+
239
+
If the target pod may not always exist, you can enable `createMissingPods` to have ContainerSSH create it automatically:
240
+
241
+
```yaml
242
+
kubernetes:
243
+
pod:
244
+
mode: persistent
245
+
createMissingPods: true
246
+
idleCommand:
247
+
- /bin/sh
248
+
shellCommand:
249
+
- /bin/bash
250
+
metadata:
251
+
name: my-pod
252
+
namespace: default
253
+
spec:
254
+
containers:
255
+
- name: shell
256
+
image: containerssh/containerssh-guest-image
257
+
```
258
+
259
+
When `createMissingPods` is enabled, the `idleCommand`, `shellCommand`, and at least one container in the pod spec must be configured.
0 commit comments