Attach Configuration #
This document walks you through how to configure the Attach feature.
What is an Attach? #
The
Attach is a
kwok Configuration that allows users to define and simulate attaching to a single pod.
The YAML below shows all the fields of an Attach resource:
kind: Attach
apiVersion: kwok.x-k8s.io/v1alpha1
metadata:
name: <string>
namespace: <string>
spec:
attaches:
- containers:
- <string>
logsFile: <string>
To associate an Attach with a certain pod to be simulated, users must ensure metadata.name and metadata.namespace
are inconsistent with the name and namespace of the target pod.
The attaching simulation setting of a pod are specified via attaches field.
The attaches field is organized by groups, with each corresponding to a collection of containers that shares a same attaching simulation setting.
Each group consists of a list of container names (containers) and the shared attaching simulation setting (logsFile).
Ifcontainersis not given in a group, thelogsFilein that group will be applied to all containers of the target pod.
The logsFile field specifies the file path of the logs. If the logsFile field is not set, this item will be ignored.
ClusterAttach #
In addition to simulating a single pod, users can also simulate the attaching for multiple pods via ClusterAttach.
The YAML below shows all the fields of a ClusterAttach resource:
kind: ClusterAttach
apiVersion: kwok.x-k8s.io/v1alpha1
metadata:
name: <string>
spec:
selector:
matchNamespaces:
- <string>
matchNames:
- <string>
attaches:
- containers:
- <string>
logsFile: <string>
Compared to Attach, whose metadata.name and metadata.namespace are required to match the associated pod,
ClusterAttach has an additional selector field for specifying the target pods to be simulated.
matchNamespaces and matchNames are both represented as list,which are designed to take pod collections by different levels:
- If
matchNamespacesis empty, ClusterAttach will be applied to all pods that are managed bykwokand whose names listed inmatchNames. - If
matchNamesis empty, ClusterAttach will be applied to all pods managed bykwokand under namespaces listed inmatchNamespaces. - If
matchNamesandmatchNamespacesare both unset, ClusterAttach will be applied to all pods thatkwokmanages.
The attaches field of ClusterAttach has the same semantic with the one in Attach.