Skip to content

Commit 49ad081

Browse files
committed
exec credential provider: add InteractiveMode API
Signed-off-by: Andrew Keesler <[email protected]>
1 parent ca3bad7 commit 49ad081

File tree

1 file changed

+61
-0
lines changed
  • keps/sig-auth/541-external-credential-providers

1 file changed

+61
-0
lines changed

keps/sig-auth/541-external-credential-providers/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ users:
161161
# very large CA data, to this exec plugin as a part of the KUBERNETES_EXEC_INFO
162162
# environment variable. Optional. Defaults to false.
163163
provideClusterInfo: true
164+
165+
# The contract between the exec plugin and the standard input I/O stream. If the
166+
# contract cannot be satisfied, this plugin will not be run and an error will be
167+
# returned. Valid values are "Never" (this exec plugin never uses standard input),
168+
# "IfAvailable" (this exec plugin wants to use standard input if it is available),
169+
# or "Always" (this exec plugin requires standard input to function).
170+
#
171+
# In v1alpha1 and v1beta1, this is optional and defaults to IfAvailable. It is
172+
# required otherwise.
173+
interactiveMode: IfAvailable
164174
clusters:
165175
- name: my-cluster
166176
cluster:
@@ -213,7 +223,39 @@ type ExecConfig struct {
213223
// to false. Package k8s.io/client-go/tools/auth/exec provides helper methods for
214224
// reading this environment variable.
215225
ProvideClusterInfo bool `json:"provideClusterInfo"`
226+
227+
// InteractiveMode determines this plugin's relationship with standard input. Valid
228+
// values are "Never" (this exec plugin never uses standard input), "IfAvailable" (this
229+
// exec plugin wants to use standard input if it is available), or "Always" (this exec
230+
// plugin requires standard input to function). See ExecInteractiveMode values for more
231+
// details.
232+
//
233+
// If APIVersion is client.authentication.k8s.io/v1alpha1 or
234+
// client.authentication.k8s.io/v1beta1, then this field is optional and defaults
235+
// to "IfAvailable" when unset. Otherwise, this field is required.
236+
// +optional
237+
InteractiveMode ExecInteractiveMode `json:"interactiveMode,omitempty"`
216238
}
239+
240+
// ExecInteractiveMode is a string that describes an exec plugin's relationship with standard input.
241+
type ExecInteractiveMode string
242+
243+
const (
244+
// NeverExecInteractiveMode declares that this exec plugin never needs to use standard
245+
// input, and therefore the exec plugin will be run regardless of whether standard input is
246+
// available for user input.
247+
NeverExecInteractiveMode ExecInteractiveMode = "Never"
248+
// IfAvailableExecInteractiveMode declares that this exec plugin would like to use standard input
249+
// if it is available, but can still operate if standard input is not available. Therefore, the
250+
// exec plugin will be run regardless of whether stdin is available for user input. If standard
251+
// input is available for user input, then it will be provided to this exec plugin.
252+
IfAvailableExecInteractiveMode ExecInteractiveMode = "IfAvailable"
253+
// AlwaysExecInteractiveMode declares that this exec plugin requires standard input in order to
254+
// run, and therefore the exec plugin will only be run if standard input is available for user
255+
// input. If standard input is not available for user input, then the exec plugin will not be run
256+
// and an error will be returned by the exec plugin runner.
257+
AlwaysExecInteractiveMode ExecInteractiveMode = "Always"
258+
)
217259
```
218260

219261
`apiVersion` specifies the expected version of this API that the plugin
@@ -234,6 +276,14 @@ is missing.
234276
potentially contain very large CA data, to this exec plugin as a part
235277
of the `KUBERNETES_EXEC_INFO` environment variable.
236278

279+
`interactiveMode` specifies the contract between the exec plugin and the
280+
standard input I/O stream. If the contract cannot be satisfied, this plugin will
281+
not be run and an error will be returned. Valid values are "Never" (this exec
282+
plugin never uses standard input), "IfAvailable" (this exec plugin wants to use
283+
standard input if it is available), or "Always" (this exec plugin requires
284+
standard input to function). In v1alpha1 and v1beta1, this is optional and
285+
defaults to IfAvailable. It is required otherwise.
286+
237287
### Provider input format
238288

239289
In JSON:
@@ -243,6 +293,7 @@ In JSON:
243293
"apiVersion": "client.authentication.k8s.io/v1beta1",
244294
"kind": "ExecCredential",
245295
"spec": {
296+
"interactive": true,
246297
"cluster": {
247298
"server": "https://1.2.3.4:8080",
248299
"tls-server-name": "bar",
@@ -281,6 +332,9 @@ type ExecCredentialSpec struct {
281332
// ExecConfig.ProvideClusterInfo).
282333
// +optional
283334
Cluster *Cluster `json:"cluster,omitempty"`
335+
336+
// Interactive declares whether stdin has been passed to this exec plugin.
337+
Interactive bool `json:"interactive"`
284338
}
285339

286340
// Cluster contains information to allow an exec plugin to communicate with the
@@ -437,6 +491,11 @@ func LoadExecCredentialFromEnv() (runtime.Object, *rest.Config, error)
437491
func LoadExecCredential(data []byte) (runtime.Object, *rest.Config, error)
438492
```
439493

494+
The `interactive` field is used to communicate to the exec plugin whether
495+
standard input is available for use. This is helpful for plugins that can
496+
operate with and without standard input so that they can easily distinguish
497+
between the two cases.
498+
440499
### Provider output format
441500

442501
In JSON:
@@ -647,6 +706,8 @@ Integration (or e2e CLI) tests to confirm:
647706
+ Cert based auth
648707
- Interactive login flows work
649708
+ TTY forwarding between client and executable works
709+
+ `kubectl` commands and exec credential plugins do not fight for standard input
710+
+ All `InteractiveMode` values are supported
650711
- Metrics are reported as they should
651712

652713
### Graduation Criteria

0 commit comments

Comments
 (0)