Skip to content

Commit db1dfd7

Browse files
committed
docs: add descriptions to all main fields in the CRDs
1 parent 8709b97 commit db1dfd7

File tree

5 files changed

+140
-72
lines changed

5 files changed

+140
-72
lines changed

api/v1alpha1/privateloadzone_types.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,22 @@ type PrivateLoadZoneSpec struct {
3636
// +kubebuilder:validation:Type=string
3737
Token string `json:"token"`
3838

39-
Resources corev1.ResourceRequirements `json:"resources"`
40-
ServiceAccountName string `json:"serviceAccountName,omitempty"`
41-
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
39+
Resources corev1.ResourceRequirements `json:"resources"`
40+
41+
// Service account name which should be associated with all created Pods.
42+
ServiceAccountName string `json:"serviceAccountName,omitempty"`
43+
44+
// Node selector which should be applied to all created Pods.
45+
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
46+
47+
// The Docker image of the k6 runners.
4248
// +kubebuilder:default="grafana/k6:latest"
43-
Image string `json:"image,omitempty"`
49+
Image string `json:"image,omitempty"`
50+
51+
// The imagePullSecrets which should be configured for all created Pods.
4452
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
4553

54+
// Configuration of the test runs specific for this `PrivateLoadZone`.
4655
Config PrivateLoadZoneConfig `json:"config,omitempty"`
4756
}
4857

@@ -76,12 +85,12 @@ type PrivateLoadZoneList struct {
7685
}
7786

7887
type PrivateLoadZoneConfig struct {
88+
// Secrets contains a list of definitions copied from `corev1.EnvFromSource`.
89+
// They are re-packed into `EnvFromSource` struct during TestRun creation.
7990
Secrets []PLZSecretsConfig `json:"secrets,omitempty"`
8091
}
8192

8293
type PLZSecretsConfig struct {
83-
// these definitions are copies from corev1.EnvFromSource - to be
84-
// re-packed into that struct during TestRun creation
8594
ConfigMapRef *corev1.ConfigMapEnvSource `json:"configMapRef,omitempty"`
8695
SecretRef *corev1.SecretEnvSource `json:"secretRef,omitempty"`
8796
}

api/v1alpha1/testrun_types.go

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -81,54 +81,92 @@ type K6Scuttle struct {
8181

8282
// TestRunSpec defines the desired state of TestRun
8383
type TestRunSpec struct {
84-
Script K6Script `json:"script"`
85-
Parallelism int32 `json:"parallelism"`
86-
Separate bool `json:"separate,omitempty"`
87-
Arguments string `json:"arguments,omitempty"`
88-
Ports []corev1.ContainerPort `json:"ports,omitempty"`
89-
Initializer *Pod `json:"initializer,omitempty"`
90-
Starter Pod `json:"starter,omitempty"`
91-
Runner Pod `json:"runner,omitempty"`
92-
Quiet string `json:"quiet,omitempty"`
93-
Paused string `json:"paused,omitempty"`
94-
Scuttle K6Scuttle `json:"scuttle,omitempty"`
95-
Cleanup Cleanup `json:"cleanup,omitempty"`
84+
// Script describes where the k6 script is located.
85+
Script K6Script `json:"script"`
9686

87+
// Parallelism shows the number of k6 runners.
88+
Parallelism int32 `json:"parallelism"`
89+
90+
// Separate is a quick way to run all k6 runners on different hostnames
91+
// using the podAntiAffinity rule.
92+
Separate bool `json:"separate,omitempty"`
93+
94+
// Arguments to pass to the k6 process.
95+
Arguments string `json:"arguments,omitempty"`
96+
97+
// Port to configure on all k6 containers.
98+
// Port 6565 is always configured for k6 processes.
99+
Ports []corev1.ContainerPort `json:"ports,omitempty"`
100+
101+
// Configuration for the initializer Pod. If omitted, the initializer
102+
// is configured with the same parameters as a runner Pod.
103+
Initializer *Pod `json:"initializer,omitempty"`
104+
105+
// Configuration for the starter Pod.
106+
Starter Pod `json:"starter,omitempty"`
107+
108+
// Configuration for a runner Pod.
109+
Runner Pod `json:"runner,omitempty"`
110+
111+
// Quiet is a boolean variable that allows to swtich off passing the `--quiet` to k6.
112+
// +kubebuilder:default="true"
113+
Quiet string `json:"quiet,omitempty"`
114+
115+
// Paused is a boolean variable that allows to switch off passing the `--paused` to k6.
116+
// Use with caution as it can skew the result of the test.
117+
// +kubebuilder:default="true"
118+
Paused string `json:"paused,omitempty"`
119+
120+
// Configuration for Envoy proxy.
121+
Scuttle K6Scuttle `json:"scuttle,omitempty"`
122+
123+
Cleanup Cleanup `json:"cleanup,omitempty"`
124+
125+
// TestRunID is reserved by Grafana Cloud k6. Do not set it manually.
97126
TestRunID string `json:"testRunId,omitempty"` // PLZ reserved field
98-
Token string `json:"token,omitempty"` // PLZ reserved field (for now)
127+
128+
// Token is reserved by Grafana Cloud k6. Do not set it manually.
129+
Token string `json:"token,omitempty"` // PLZ reserved field (for now)
99130
}
100131

101-
// K6Script describes where the script to execute the tests is found
132+
// K6Script describes where to find the k6 script.
102133
type K6Script struct {
103134
VolumeClaim K6VolumeClaim `json:"volumeClaim,omitempty"`
104135
ConfigMap K6Configmap `json:"configMap,omitempty"`
105-
LocalFile string `json:"localFile,omitempty"`
136+
// LocalFile describes the location of the script in the runner image.
137+
LocalFile string `json:"localFile,omitempty"`
106138
}
107139

108-
// K6VolumeClaim describes the volume claim script location
140+
// K6VolumeClaim describes the location of the script on the Volume.
109141
type K6VolumeClaim struct {
110-
Name string `json:"name"`
111-
File string `json:"file,omitempty"`
112-
ReadOnly bool `json:"readOnly,omitempty"`
142+
// Name of the persistent volumeClaim where the script is stored.
143+
// It is mounted as a `/test` folder to all k6 Pods.
144+
Name string `json:"name"`
145+
// Name of the file to execute (.js or .tar), stored on the Volume.
146+
File string `json:"file,omitempty"`
147+
// ReadOnly shows whether the volume should be mounted as `readOnly`.
148+
ReadOnly bool `json:"readOnly,omitempty"`
113149
}
114150

115-
// K6Configmap describes the config map script location
151+
// K6Configmap describes the location of the script in the ConfigMap.
116152
type K6Configmap struct {
153+
// Name of the ConfigMap. It is expected to be in the sanme namespace as the `TestRun`.
117154
Name string `json:"name"`
155+
// Name of the file to execute (.js or .tar), stored as a key in the ConfigMap.
118156
File string `json:"file,omitempty"`
119157
}
120158

121159
//TODO: cleanup pre-execution?
122160

123-
// Cleanup allows for automatic cleanup of resources post execution
161+
// Cleanup allows for automatic cleanup of resources post execution.
124162
// +kubebuilder:validation:Enum=post
125163
type Cleanup string
126164

127-
// Stage describes which stage of the test execution lifecycle our runners are in
165+
// Stage describes which stage of the test execution lifecycle k6 runners are in.
128166
// +kubebuilder:validation:Enum=initialization;initialized;created;started;stopped;finished;error
129167
type Stage string
130168

131-
// TestRunStatus defines the observed state of TestRun
169+
// TestRunStatus defines the observed state of TestRun.
132170
type TestRunStatus struct {
133171
Stage Stage `json:"stage,omitempty"`
134172
TestRunID string `json:"testRunId,omitempty"`
@@ -143,7 +181,7 @@ type TestRunStatus struct {
143181
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
144182
//+kubebuilder:printcolumn:name="TestRunID",type="string",JSONPath=".status.testRunId"
145183

146-
// TestRun is the Schema for the testruns API
184+
// TestRun is the Schema for the testruns API.
147185
type TestRun struct {
148186
metav1.TypeMeta `json:",inline"`
149187
metav1.ObjectMeta `json:"metadata,omitempty"`

charts/k6-operator/templates/crds/testrun.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,6 +1971,7 @@ spec:
19711971
format: int32
19721972
type: integer
19731973
paused:
1974+
default: "true"
19741975
type: string
19751976
ports:
19761977
items:
@@ -1993,6 +1994,7 @@ spec:
19931994
type: object
19941995
type: array
19951996
quiet:
1997+
default: "true"
19961998
type: string
19971999
runner:
19982000
properties:

config/crd/bases/k6.io_testruns.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,7 @@ spec:
19651965
format: int32
19661966
type: integer
19671967
paused:
1968+
default: "true"
19681969
type: string
19691970
ports:
19701971
items:
@@ -1987,6 +1988,7 @@ spec:
19871988
type: object
19881989
type: array
19891990
quiet:
1991+
default: "true"
19901992
type: string
19911993
runner:
19921994
properties:

0 commit comments

Comments
 (0)