Skip to content

Pod Attach API support for Agent

Proposal

The Javascript Client should support websocket access to the Pod attach API to allow for two-way communication between the shell environment deployed by gitlab-org/gitlab#418264 and GitLab.com

Technical Proposal

Create a websocket factory that handles all 5 kubernetes stream:

  1. Stream 0 - stdin, sending
  2. Stream 1 - stdout, receiving
  3. Stream 2 - stderr, receiving
  4. Stream 3 - status, receiving
  5. Stream 4 - resize, sending

The websocket wrapper object should have roughly the following interface:

interface WebSocketWrapper {
  // on... functions return functions that remove the callback
  onStdout: ((string) => any) => () => any
  onStderr: ((string) => any) => () => any
  onStatus: ((string) => any) => () => any


  sendStdin: (string) => any
  sendResize: (string) => any

The attach essential options are:

interface AttachOptions {
  stdin: boolean,
  stdout: boolean,
  stderr: boolean,
  tty: boolean,
  namespace: string,
  pod: string
}

The url pattern is /api/v1/namespaces/{namespace}/pods/{podName}/attach?{...opts}

Edited by Andrew Fontaine