Skip to content

Commit

Permalink
plz: image as part of spec and registration
Browse files Browse the repository at this point in the history
  • Loading branch information
yorugac committed Jul 19, 2024
1 parent 535c529 commit 3174bce
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions api/v1alpha1/privateloadzone_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type PrivateLoadZoneSpec struct {
Resources corev1.ResourceRequirements `json:"resources"`
ServiceAccountName string `json:"serviceAccountName,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Image string `json:"image,omitempty"`
}

// PrivateLoadZoneStatus defines the observed state of PrivateLoadZone
Expand Down Expand Up @@ -81,6 +82,9 @@ func (plz *PrivateLoadZone) Register(ctx context.Context, logger logr.Logger, cl
CPU: plz.Spec.Resources.Limits.Cpu().String(),
Memory: plz.Spec.Resources.Limits.Memory().String(),
},
LZConfig: cloud.LZConfig{
RunnerImage: plz.Spec.Image,
},
UID: uid,
}

Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/k6.io_privateloadzones.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ spec:
type: object
spec:
properties:
image:
type: string
nodeSelector:
additionalProperties:
type: string
Expand Down
4 changes: 4 additions & 0 deletions pkg/cloud/plz.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const (
func RegisterPLZ(client *cloudapi.Client, data PLZRegistrationData) error {
url := fmt.Sprintf("%s/cloud-resources/v1/load-zones", strings.TrimSuffix(client.BaseURL(), "/v1"))

data.LZConfig = LZConfig{
RunnerImage: data.RunnerImage,
}

req, err := client.NewRequest("POST", url, data)
if err != nil {
return err
Expand Down
11 changes: 7 additions & 4 deletions pkg/cloud/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ type TestRunData struct {
}

type LZConfig struct {
RunnerImage string `json:"load_runner_image"`
InstanceCount int `json:"instance_count"`
ArchiveURL string `json:"k6_archive_temp_public_url"`
Environment map[string]string `json:"environment"`
RunnerImage string `json:"load_runner_image,omitempty"`
InstanceCount int `json:"instance_count,omitempty"`
ArchiveURL string `json:"k6_archive_temp_public_url,omitempty"`
Environment map[string]string `json:"environment,omitempty"`
}

func (trd *TestRunData) TestRunID() string {
Expand Down Expand Up @@ -104,6 +104,9 @@ type PLZRegistrationData struct {
// defined by user as `name`
LoadZoneID string `json:"k6_load_zone_id"`
Resources PLZResources `json:"pod_tiers"`

LZConfig `json:"config"`

// Unique identifier of PLZ, generated by k6-operator
// during PLZ registration. It's purpose is to distinguish
// between PLZs with accidentally duplicate names.
Expand Down

0 comments on commit 3174bce

Please sign in to comment.