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

Adding output with kafka has SSL security #1619

Closed
wants to merge 6 commits into from

Conversation

ducmeit1
Copy link

@ducmeit1 ducmeit1 commented Sep 6, 2020

In century, K6 has supported sending the raw output format to Kafka Clusters. However, mostly Kafka usually secured by an authentication method. The Kafka Cluster usually protected by SSL. It requires the client must provide a certificate that was signed by Kafka Cluster to produce the data or consume.

This PR would like to improve the Kafka producer client with Sarama and supports SSL authentication.

Sample usage:

k6 run --out kafka="brokers={broker2,broker3:9092},topic=someTopic,format=json,tls_security=true,certificate=cert.pem,private_key=key.pem,certificate_authority=ca.pem,insecure_skip=true" scripts.js

Parameter requires:

  • tls_security: true
  • certificate: location of the certificate file (provide a relative or absolute path)
  • private_key: location of the private key file
  • certificate_authority: location of the CA (optional)
  • insecure_skip_verify: true (set false, if you want to validate the CA certificate)
  • topic: the topic name
  • brokers: the brokers list

@ducmeit1
Copy link
Author

ducmeit1 commented Sep 7, 2020

Hi @mostafa.
Long time no see.
Could you help me test this Pull Request?
I already tested and it's worked in my local and remote server.

Thanks

@na--
Copy link
Member

na-- commented Sep 8, 2020

Thanks for making this pull request! I skimmed it and didn't spot any obvious issues, but a detailed review will probably have to wait until next week, sorry. This week we're focused on wrapping up the planned changes for k6 v0.28.0, which is going to be released early next week, if there are no issues. We'll review the PR after the release, so it should become a part of k6 v0.29.0, scheduled for mid-November.

@na-- na-- added this to the v0.29.0 milestone Sep 8, 2020
@na-- na-- mentioned this pull request Sep 8, 2020
@mostafa
Copy link
Member

mostafa commented Sep 8, 2020

Hey @ducmeit1,

Good to see you back. Could you please address linting issues related to your code in here before my test/review:

https://app.circleci.com/pipelines/github/loadimpact/k6/719/workflows/cfe15faf-eb5b-4300-9cbf-b97529ac2990/jobs/12880

@ducmeit1
Copy link
Author

ducmeit1 commented Sep 8, 2020

Hey @ducmeit1,

Good to see you back. Could you please address linting issues related to your code in here before my test/review:

https://app.circleci.com/pipelines/github/loadimpact/k6/719/workflows/cfe15faf-eb5b-4300-9cbf-b97529ac2990/jobs/12880

Hi @mostafa , could you verify again!

@mostafa
Copy link
Member

mostafa commented Sep 8, 2020

Wow, you are fast!

Please test your code against Go 1.15.1: https://app.circleci.com/pipelines/github/loadimpact/k6/723/workflows/05569c46-67ba-4992-adc2-591a2423962e/jobs/12897

BTW, I'm not sure if this is related to your changes.

@imiric
Copy link
Contributor

imiric commented Sep 9, 2020

Hi guys, the TestExternallyControlledRun failure is a known flaky test, some of which were fixed in #1357, but there are still a few that pop up ocasionally, so I don't think this is related to Go 1.15.

Thanks for your contribution @ducmeit1!

@ducmeit1
Copy link
Author

ducmeit1 commented Sep 9, 2020

Hi guys, the TestExternallyControlledRun failure is a known flaky test, some of which were fixed in #1357, but there are still a few that pop up ocasionally, so I don't think this is related to Go 1.15.

Thanks for your contribution @ducmeit1!

You're welcome! Hope this repository will be passed and releasing asap.

@mostafa
Copy link
Member

mostafa commented Sep 9, 2020

Hey @imiric,

Thanks for the clarification, I suspected that doesn't have anything to do with this PR.

@ducmeit1 I'll test it then. 🙂

@mostafa
Copy link
Member

mostafa commented Sep 9, 2020

@ducmeit1,

I've used https://github.com/lensesio/fast-data-dev to setup a Kafka dev-env and used this guide to transform trust-store and client JKS files into PEM files. Yet, I still get an error while running this command:

$ k6 run --out kafka=brokers=127.0.0.1:9093,topic=k6-output,format=json,tls_security=true,certificate=client.cer.pem,private_key=client.key.pem,certificate_authority=server.cer.pem,insecure_skip=false test.js

The error:

ERRO[0001] kafka: client has run out of available brokers to talk to (Is your cluster reachable?)

Using kafkatool, I've confirmed that JKS files work as expected, so the 127.0.0.1:9093 is available using SSL/TLS keys. To double-check, I've also used the following command to confirm that the SSL/TLS is working:

$ openssl s_client -debug -connect localhost:9093 -tls1

Also, the unencrypted channel works well on 127.0.0.1:9092.

Can you elaborate more on your testing environment?

@ducmeit1
Copy link
Author

ducmeit1 commented Sep 9, 2020

k6 run --out kafka=brokers=127.0.0.1:9093,topic=k6-output,format=json,tls_security=true,certificate=client.cer.pem,private_key=client.key.pem,certificate_authority=server.cer.pem,insecure_skip=false test.js

Could you set insecure_skip=true and retry

@mostafa
Copy link
Member

mostafa commented Sep 9, 2020

Could you set insecure_skip=true and retry

Tried that, too. No luck!

@mstoykov mstoykov modified the milestones: v0.29.0, v0.30.0 Nov 4, 2020
@monwolf
Copy link

monwolf commented Nov 24, 2020

@ducmeit1 I would like to suggest not forcing to enable mTLS , in my case we are using Kafka with SSL only to cipher the communication not for authenticating the client, for this we are using ACLs.

@na-- na-- modified the milestones: v0.30.0, v0.31.0 Jan 13, 2021
@na-- na-- removed this from the v0.31.0 milestone Feb 24, 2021
@mstoykov
Copy link
Collaborator

mstoykov commented Apr 6, 2021

Thanks for all the work done here, but given that we are:

  1. depricateing kafka output
  2. have moved it out as an extension

I will close this PR and ask that if you want to add this functionality to do so in the extension repo.

@mstoykov mstoykov closed this Apr 6, 2021
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.

None yet

6 participants