Skip to content

Commit

Permalink
Add docs of node service
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Mar 31, 2023
1 parent 3d4a058 commit 5c375f0
Show file tree
Hide file tree
Showing 12 changed files with 317 additions and 1 deletion.
17 changes: 17 additions & 0 deletions demo/exec.demo
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Let's getting started with kwokctl!
kwokctl create cluster -c ./test/kwokctl/exec.yaml

# Create a node.
kubectl apply -f ./test/kwok/fake-node.yaml

# Apply a deployment.
kubectl apply -f ./test/kwok/fake-deployment.yaml

# Exec into the pod.
kubectl exec deployment/fake-pod -- ls -lh

# Delete the cluster.
kwokctl delete cluster

# That's all, enjoy it!
clear
1 change: 1 addition & 0 deletions demo/exec.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions demo/port-forward.demo
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Let's getting started with kwokctl!
kwokctl create cluster -c ./test/kwokctl/port-forward.yaml

# Create a node.
kubectl apply -f ./test/kwok/fake-node.yaml

# Apply a deployment.
kubectl apply -f ./test/kwok/fake-deployment.yaml

# Port forward to the deployment.
kubectl port-forward deployment/fake-pod 8080:10247 &

# Check the port forward.
curl http://localhost:8080/healthz

# Delete the cluster.
kwokctl delete cluster

# That's all, enjoy it!
clear
1 change: 1 addition & 0 deletions demo/port-forward.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions site/content/en/docs/user/attach-configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Attach Configuration

{{< hint "info" >}}

This document walks you through how to configure the Attach feature.

{{< /hint >}}

## What is a Attach?

The Attach API is a [`kwok` Configuration]({{< relref "/docs/user/configuration" >}}) that allows users to define and simulate attach to an Pod(s).

A Attach resource has the following fields:

``` yaml
kind: Attach
apiVersion: kwok.x-k8s.io/v1alpha1
metadata:
name: <string>
namespace: <string>
spec:
attaches:
- containers:
- <string>
logsFile: <string>
```
To attach a container, you can set the `attaches` field in the spec section of a Logs resource.
The `containers` field is used to match an item in the `attaches` field. If the `containers` field is not set, the `attaches` item will default to all containers.
The `logsFile` field specifies the file path of the logs. If the `logsFile` field is not set, this item will be ignored.

### ClusterAttach

The ClusterAttach API is a special Attach API which is cluster-side.

A ClusterAttach resource has the following fields:

``` yaml
kind: ClusterAttach
apiVersion: kwok.x-k8s.io/v1alpha1
metadata:
name: <string>
spec:
selector:
matchNamespaces:
- <string>
matchNames:
- <string>
attaches:
- containers:
- <string>
logsFile: <string>
```

The `selector` field specifies the Pods to be attached.
The `matchNamespaces` field specifies the namespaces to be matched. If the `matchNamespaces` field is not set, the `matchNamespaces` field will default to all namespaces.
The `matchNames` field specifies the names to be matched. If the `matchNames` field is not set, the `matchNames` field will default to all names.
72 changes: 72 additions & 0 deletions site/content/en/docs/user/exec-configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Exec Configuration

{{< hint "info" >}}

This document walks you through how to configure the Exec feature.

{{< /hint >}}

## What is a Exec?

The Exec API is a [`kwok` Configuration]({{< relref "/docs/user/configuration" >}}) that allows users to define and simulate exec to an Pod(s).

A Exec resource has the following fields:

``` yaml
kind: Exec
apiVersion: kwok.x-k8s.io/v1alpha1
metadata:
name: <string>
namespace: <string>
spec:
execs:
- containers:
- <string>
local:
workDir: <string>
envs:
- name: <string>
value: <string>
```
To exec a container, you can set the `execs` field in the spec section of a Exec resource.
The `containers` field is used to match an item in the `execs` field. If the `containers` field is not set, the `execs` item will default to all containers.
The `local` field specifies the local environment to be executed.
The `workDir` field specifies the working directory of the local environment. If the `workDir` field is not set, the working directory will be the root directory.
The `envs` field specifies the environment variables of the local environment.

### ClusterExec

The ClusterExec API is a special Exec API which is cluster-side.

A ClusterExec resource has the following fields:

``` yaml
kind: ClusterExec
apiVersion: kwok.x-k8s.io/v1alpha1
metadata:
name: <string>
spec:
selector:
matchNamespaces:
- <string>
matchNames:
- <string>
execs:
- containers:
- <string>
local:
workDir: <string>
envs:
- name: <string>
value: <string>
```

The `selector` field specifies the Pods to be executed.
The `matchNamespaces` field specifies the namespaces to be matched. If the `matchNamespaces` field is not set, the `ClusterExec` will match all namespaces.
The `matchNames` field specifies the names to be matched. If the `matchNames` field is not set, the `ClusterExec` will match all names.

## Examples

<img width="700px" src="/img/demo/exec.svg">
61 changes: 61 additions & 0 deletions site/content/en/docs/user/logs-configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Logs Configuration

{{< hint "info" >}}

This document walks you through how to configure the Logs feature.

{{< /hint >}}

## What is a Logs?

The Logs API is a [`kwok` Configuration]({{< relref "/docs/user/configuration" >}}) that allows users to define and simulate logs to an Pod(s).

A Logs resource has the following fields:

``` yaml
kind: Logs
apiVersion: kwok.x-k8s.io/v1alpha1
metadata:
name: <string>
namespace: <string>
spec:
logs:
- containers:
- <string>
logsFile: <string>
follow: <bool>
```
To log a container, you can set the `logs` field in the spec section of a Logs resource.
The `containers` field is used to match an item in the `logs` field. If the `containers` field is not set, the `logs` item will default to all containers.
The `logsFile` field specifies the file path of the logs. If the `logsFile` field is not set, this item will be ignored.
The `follow` field specifies whether to follow the logs. If the `follow` field is not set, the `follow` field will default to false.

### ClusterLogs

The ClusterLogs API is a special Logs API which is cluster-side.

A ClusterLogs resource has the following fields:

``` yaml
kind: ClusterLogs
apiVersion: kwok.x-k8s.io/v1alpha1
metadata:
name: <string>
spec:
selector:
matchNamespaces:
- <string>
matchNames:
- <string>
logs:
- containers:
- <string>
logsFile: <string>
follow: <bool>
```

The `selector` field specifies the Pods to be logged.
The `matchNamespaces` field specifies the namespaces to be matched. If the `matchNamespaces` field is not set, the `matchNamespaces` field will default to all namespaces.
The `matchNames` field specifies the names to be matched. If the `matchNames` field is not set, the `matchNames` field will default to all names.
80 changes: 80 additions & 0 deletions site/content/en/docs/user/port-forward-configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# PortForward Configuration

{{< hint "info" >}}

This document walks you through how to configure the PortForward feature.

{{< /hint >}}

## What is a PortForward?

The PortForward API is a [`kwok` Configuration]({{< relref "/docs/user/configuration" >}}) that allows users to define and simulate port forwarding to an Pod(s).

A PortForward resource has the following fields:

``` yaml
kind: PortForward
apiVersion: kwok.x-k8s.io/v1alpha1
metadata:
name: <string>
namespace: <string>
spec:
forwards:
- ports:
- <int>
target:
port: <int>
address: <string>

- ports:
- <int>
command:
- <string>
- <string>
```
To forward a port, you can set the `forwards` field in the spec section of a PortForward resource.
The `ports` field is used to match an item in the `forwards` field. If the `ports` field is not set, the `forwards` item will default to all ports.
The `target` field specifies the target address to be forwarded to. If the `command` field is set, the `target` field will be ignored.
The `command` field allows users to define the command to be executed to forward the port. The `command` is executed in the container of kwok.
The `command` should be a string array, where the first element is the command and the rest are the arguments. Also, the command should be in the container’s PATH.

### ClusterPortForward

The ClusterPortForward API is a special PortForward API which is cluster-side.

A ClusterPortForward resource has the following fields:

``` yaml
kind: ClusterPortForward
apiVersion: kwok.x-k8s.io/v1alpha1
metadata:
name: <string>
spec:
selector:
matchNamespaces:
- <string>
matchNames:
- <string>
forwards:
- ports:
- <int>
target:
port: <int>
address: <string>
- ports:
- <int>
command:
- <string>
- <string>
```

The `selector` field is used to select the Pods to be port forwarded.
The `matchNamespaces` field is used to match the namespace of the Pods. If the `matchNamespaces` field is not set, the ClusterPortForward will match all namespaces.
The `matchNames` field is used to match the name of the Pods. If the `matchNames` field is not set, the ClusterPortForward will match all Pods.

## Examples

<img width="700px" src="/img/demo/port-forward.svg">
2 changes: 1 addition & 1 deletion site/content/en/docs/user/stages-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This document walks you through how to configure the Stages of Lifecycle.

## What is a Stage?

The Stage API is a [`kwok` Configuration](./configuration) that allows users to define and simulate different stages in the lifecycle of Kubernetes resources, such as nodes and pods.
The Stage API is a [`kwok` Configuration]({{< relref "/docs/user/configuration" >}}) that allows users to define and simulate different stages in the lifecycle of Kubernetes resources, such as nodes and pods.
Each Stage resource specifies a resourceRef field that identifies the type of resource that the stage applies to, and a selector field that determines when the stage should be executed.

A Stage resource has the following fields:
Expand Down
4 changes: 4 additions & 0 deletions site/content/en/menu/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ headless: true
- **Configuration**
- [Options]({{< relref "/docs/user/configuration" >}})
- [Stages]({{< relref "/docs/user/stages-configuration" >}})
- [PortForward]({{< relref "/docs/user/port-forward-configuration" >}})
- [Exec]({{< relref "/docs/user/exec-configuration" >}})
- [Logs]({{< relref "/docs/user/logs-configuration" >}})
- [Attach]({{< relref "/docs/user/attach-configuration" >}})
- **Tools**
- [`kwok`]({{< relref "/docs/generated/kwok" >}})
- [`kwokctl`]({{< relref "/docs/generated/kwokctl" >}})
Expand Down
1 change: 1 addition & 0 deletions site/static/img/demo/exec.svg
1 change: 1 addition & 0 deletions site/static/img/demo/port-forward.svg

0 comments on commit 5c375f0

Please sign in to comment.