Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for the Cloud output #86

Merged
merged 15 commits into from
May 13, 2022
Merged

Support for the Cloud output #86

merged 15 commits into from
May 13, 2022

Conversation

yorugac
Copy link
Collaborator

@yorugac yorugac commented Dec 7, 2021

This PR adds basic support for the Cloud output. If token is set and arguments contain --out cloud, the test will generate a new test run on the Cloud and send metrics to the Cloud. In other aspects, operator should behave as before.

Things of note:

  • in case of the Cloud output there is some initialization and finishing tasks to do so new stages were added as well as initializing job which starts one pod with the same image as runner
  • token is currently passed in as a k8s secret
  • some refactoring was done here too, mostly to avoid code duplication, esp. around how script / configmap is handled
  • the default labels for runner jobs now include "runner": "true" to be able to distinguish between them and initializing pod
  • this implementation depends on this PR to k6 so it'll work only with k6 v0.36+

Current issues / things to improve:

  • thresholds are absent (a blocker on the cloud side) was resolved

It'd be best to see to #83 before merging this PR.

Fixes #9

@yorugac yorugac force-pushed the feature/cloud-output branch 2 times, most recently from 9de10ba to 7fb851a Compare December 8, 2021 11:56
@yorugac yorugac force-pushed the feature/cloud-output branch 2 times, most recently from 6dd7a4f to 29f772a Compare December 22, 2021 16:10
@yorugac yorugac marked this pull request as ready for review December 22, 2021 16:19
@yorugac yorugac changed the title WIP Support for the Cloud output Support for the Cloud output Dec 22, 2021
@yorugac yorugac force-pushed the feature/cloud-output branch 2 times, most recently from 184d838 to 4ed219b Compare February 16, 2022 09:49
@yorugac yorugac mentioned this pull request Feb 18, 2022
@yorugac yorugac force-pushed the feature/cloud-output branch from fdc0e54 to 0cdcc9d Compare February 18, 2022 16:26
Comment on lines +44 to +71
var (
secrets corev1.SecretList
secretOpts = &client.ListOptions{
// TODO: find out a better way to get namespace here
Namespace: "k6-operator-system",
LabelSelector: labels.SelectorFromSet(map[string]string{
"k6cloud": "token",
}),
}
)
if err := r.List(ctx, &secrets, secretOpts); err != nil {
log.Error(err, "Failed to load k6 Cloud token")
return res, err
}

if len(secrets.Items) < 1 {
err := fmt.Errorf("There are no secrets to hold k6 Cloud token")
log.Error(err, err.Error())
return res, err
}

if t, ok := secrets.Items[0].Data["token"]; !ok {
err := fmt.Errorf("The secret doesn't have a field token for k6 Cloud")
log.Error(err, err.Error())
return res, err
} else {
token = string(t)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we consider trying to load the token from other sources as well? For instance we typically don't use k8s secrets, instead we use Vault with a side car to mount a secrets volume for the container. In our case, with Vault, we were hoping to use the file configuration (https://k6.io/docs/cloud/integrations/token/#authentication-with-a-config-file). Is it possible to look for the other methods of providing a token as documented at the link above, then also look for k8s secret? While the env var approach is certainly not as secure, it does come in handy for testing...however, at the very least file config support would be appreciated. :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @brian-groux-hs! Sorry for such a delay in response.
Yes, I definitely would like to have alternative options to load secrets here. I wasn't sure what people might use so you just gave me an answer to that, thank you 😄 I'm not sure at the moment if operator should try to load everything one by one as you describe or be a separate configuration option though...
Either way, I won't be able to add it right now but noted in TODO. I'll probably create a separate issue for this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related issue: #103

@yorugac yorugac force-pushed the feature/cloud-output branch from d4ab53e to aec7aed Compare April 1, 2022 12:08
@yorugac yorugac force-pushed the feature/cloud-output branch 5 times, most recently from 8f29aa0 to 5061106 Compare May 4, 2022 11:45
No matter the status of the pods, FinishJobs must be able to a) finalize the cloud
output test and b) proceed to the next stage of controller.
@yorugac yorugac force-pushed the feature/cloud-output branch from 5061106 to f08da61 Compare May 4, 2022 12:20
@yorugac yorugac merged commit 9db5af6 into main May 13, 2022
@yorugac yorugac deleted the feature/cloud-output branch May 13, 2022 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support to ship results to k6 cloud
2 participants