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

Kafka kerberos authentication support for collector/ingester #1589

Merged
merged 1 commit into from
Jun 27, 2019

Conversation

rubenvp8510
Copy link
Contributor

@rubenvp8510 rubenvp8510 commented Jun 5, 2019

Signed-off-by: Ruben Vargas ruben.vp8510@gmail.com

Which problem is this PR solving?

Short description of the changes

  • Now that sarama library has support for Kerberos authentication, this PR add support for it on the jaeger side using flags.

@rubenvp8510 rubenvp8510 force-pushed the kafka-kerbero-support branch 4 times, most recently from 3610065 to 53e2731 Compare June 6, 2019 02:15
@rubenvp8510 rubenvp8510 changed the title WIP - Add kafka kerberos authentication support for collector/ingester Kafka kerberos authentication support for collector/ingester Jun 6, 2019
@codecov
Copy link

codecov bot commented Jun 6, 2019

Codecov Report

Merging #1589 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1589      +/-   ##
==========================================
+ Coverage   98.72%   98.74%   +0.02%     
==========================================
  Files         191      191              
  Lines        9182     9190       +8     
==========================================
+ Hits         9065     9075      +10     
+ Misses         91       89       -2     
  Partials       26       26
Impacted Files Coverage Δ
cmd/ingester/app/flags.go 100% <100%> (ø) ⬆️
plugin/storage/kafka/options.go 100% <100%> (ø) ⬆️
...lugin/sampling/strategystore/adaptive/processor.go 100% <0%> (+0.78%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b52726...fa0e5ad. Read the comment docs.

@rubenvp8510 rubenvp8510 changed the title Kafka kerberos authentication support for collector/ingester WIP - Kafka kerberos authentication support for collector/ingester Jun 6, 2019
@rubenvp8510
Copy link
Contributor Author

I just need to test this.

Copy link
Contributor

@objectiser objectiser left a comment

Choose a reason for hiding this comment

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

Just left some initial comments, as will be on PTO next week.

// KerberosPrefix for Kerberos configuration options
KerberosPrefix = ".kerberos"
// SuffixKerberosServiceName is the suffix for Kerberos service name
SuffixKerberosServiceName = ".serviceName"
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of camel case, I think most flags use hyphens (e.g. service-name). Same applies to useKeyTab and kerberosConfig.

// SuffixKerberosPassword is Kerberos password
SuffixKerberosPassword = ".password"
// SuffixKerberosConfig is path to the kerberos configuration file.
SuffixKerberosConfig = ".kerberosConfig"
Copy link
Contributor

Choose a reason for hiding this comment

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

This option will already have a .kerberos prefix - so the option itself could just be named .config

UseKeyTab bool
Username string
Password string
KerberosConfigPath string
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This could be just ConfigPath

suffixAuthentication = ".authentication"
// Kerberos configuration options
kerberosPrefix = ".kerberos"
suffixKerberosServiceName = ".serviceName"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comments as for the ingester, related to the option names.

@@ -150,7 +150,7 @@ required = [

[[constraint]]
name = "github.com/Shopify/sarama"
version = "1.20.1"
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to depend on a version?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hopefully a new release should be coming soon: IBM/sarama#1366 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just temporal, waiting for a new release of sarama.

Copy link
Contributor

Choose a reason for hiding this comment

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

@pavolloffay if we don't get a sarama release soon, are we ok to release with the SHA?

suffixBrokers = ".brokers"
suffixTopic = ".topic"
suffixEncoding = ".encoding"
suffixAuthentication = ".authentication"
Copy link
Member

Choose a reason for hiding this comment

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

Are there more authentication mechanisms? Is so maybe we should rather have .kerberos=true

Copy link
Contributor

Choose a reason for hiding this comment

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

Or .authentication=kerberos

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for now, there is only one authentication mechanism which is in this case Kerberos, but Kafka (and Sarama) support others, I would say that @objectiser suggestion is the way to go, just in case that in the future we wanted more mechanisms.

@rubenvp8510 rubenvp8510 force-pushed the kafka-kerbero-support branch 12 times, most recently from 4ac2890 to b68c652 Compare June 7, 2019 13:38
@rubenvp8510 rubenvp8510 force-pushed the kafka-kerbero-support branch 2 times, most recently from 4424d7e to be8726a Compare June 7, 2019 17:53
@rubenvp8510 rubenvp8510 changed the title WIP - Kafka kerberos authentication support for collector/ingester Kafka kerberos authentication support for collector/ingester Jun 7, 2019
@rubenvp8510
Copy link
Contributor Author

I've already tested this with a kafka cluster configured with Kerberos. this PR is still using a commit hash, waiting for a new release of Sarama.

@objectiser objectiser mentioned this pull request Jun 7, 2019
@@ -150,7 +150,7 @@ required = [

[[constraint]]
name = "github.com/Shopify/sarama"
version = "1.20.1"
Copy link
Contributor

Choose a reason for hiding this comment

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

@pavolloffay if we don't get a sarama release soon, are we ok to release with the SHA?

flagSet.String(
KafkaConsumerConfigPrefix+SuffixAuthentication,
DefaultAuthentication,
"Authentication type used to authenticate with kafka cluster")
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you include the valid values (e.g. none, kerberos) and which is default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this to indicate valid values, the default value is displayed by the library that generates the help output.

This is the printed message:

--kafka.consumer.authentication string Authentication type used to authenticate with kafka cluster. e.g. none, kerberos (default "none")

@rubenvp8510 rubenvp8510 force-pushed the kafka-kerbero-support branch 2 times, most recently from 519f845 to 772e6a1 Compare June 19, 2019 17:40
Copy link
Member

@pavolloffay pavolloffay left a comment

Choose a reason for hiding this comment

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

It looks good. Just some massaging comments.

The flags names should be changed for consistency and the kerberos flags could be defined in one place.

// SuffixKerberosPassword is Kerberos password
SuffixKerberosPassword = ".password"
// SuffixKerberosConfig is path to the kerberos configuration file.
SuffixKerberosConfig = ".config-path"
Copy link
Member

Choose a reason for hiding this comment

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

For the consistency with other flags this should be changed .config-file.

PAN_STORAGE_TYPE=elasticsearch go run -tags ui ./cmd/all-in-one/main.go -h | grep file                                                                          11:30 
2019/06/26 11:31:02 maxprocs: Leaving GOMAXPROCS=8: CPU quota undefined
      --collector.grpc.tls.cert string                            Path to TLS certificate file
      --collector.grpc.tls.key string                             Path to TLS key file
      --config-file string                                        Configuration file in JSON, TOML, YAML, HCL, or Java properties formats (default none). See spf13/viper for precedence.
      --es-archive.tags-as-fields.all                             (experimental) Store all span and process tags as object fields. If true .tags-as-fields.config-file is ignored. Binary tags are always stored as nested objects.
      --es-archive.tags-as-fields.config-file string              (experimental) Optional path to a file containing tag keys which will be stored as object fields. Each key should be on a separate line.
      --es-archive.tls.ca string                                  Path to TLS CA file
      --es-archive.tls.cert string                                Path to TLS certificate file
      --es-archive.tls.key string                                 Path to TLS key file
      --es-archive.token-file string                              Path to a file containing bearer token. This flag also loads CA if it is specified.
      --es.tags-as-fields.all                                     (experimental) Store all span and process tags as object fields. If true .tags-as-fields.config-file is ignored. Binary tags are always stored as nested objects.
      --es.tags-as-fields.config-file string                      (experimental) Optional path to a file containing tag keys which will be stored as object fields. Each key should be on a separate line.
      --es.tls.ca string                                          Path to TLS CA file
      --es.tls.cert string                                        Path to TLS certificate file
      --es.tls.key string                                         Path to TLS key file
      --es.token-file string                                      Path to a file containing bearer token. This flag also loads CA if it is specified.
      --query.static-files string                                 The directory path override for the static assets for the UI
      --query.ui-config string                                    The path to the UI configuration file in JSON format
      --reporter.grpc.tls.ca string                               Path to a TLS CA file. (default use the systems truststore)
      --sampling.strategies-file string                           The path for the sampling strategies file in JSON format. See sampling documentation to see format of the file

// SuffixKerberosConfig is path to the kerberos configuration file.
SuffixKerberosConfig = ".config-path"
// SuffixKerberosKeyTab is path keytab file used instead of password when SuffixKerberosUseKeyTab = true
SuffixKerberosKeyTab = ".keytab-path"
Copy link
Member

Choose a reason for hiding this comment

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

See the previous comment - change to keytab-file

flagSet.String(
KafkaConsumerConfigPrefix+KerberosPrefix+SuffixKerberosConfig,
DefaultKerberosConfig,
"Path to Kerberos configuration. i.e /etc/krb5.conf")
Copy link
Member

Choose a reason for hiding this comment

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

use the DefaultKerberosConfig

flagSet.String(
KafkaConsumerConfigPrefix+KerberosPrefix+SuffixKerberosKeyTab,
DefaultKerberosKeyTab,
"Path to keytab file. i.e /etc/security/kafka.keytab")
Copy link
Member

Choose a reason for hiding this comment

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

use DefaultKerberosKeyTab

defaultTopic = "jaeger-spans"
defaultEncoding = EncodingProto
defaultAuthentication = "none"
defaultKerberosConfig = "/etc/krb5.conf"
Copy link
Member

Choose a reason for hiding this comment

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

nit: reuse constant DefaultKerberosConfig?

defaultKerberosRealm = ""
defaultKerberosPassword = ""
defaultKerberosUsername = ""
defaultKerberosKeyTab = "/etc/security/kafka.keytab"
Copy link
Member

Choose a reason for hiding this comment

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

nit: reuse constant DefaultKerberosKeyTab?

@@ -69,12 +87,57 @@ func (opt *Options) AddFlags(flagSet *flag.FlagSet) {
defaultEncoding,
fmt.Sprintf(`(experimental) Encoding of spans ("%s" or "%s") sent to kafka.`, EncodingJSON, EncodingProto),
)
flagSet.String(
Copy link
Member

Choose a reason for hiding this comment

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

Instead of repeating this over, could we define it only in one place e.g. pkg/kafka/auth?

@rubenvp8510 rubenvp8510 force-pushed the kafka-kerbero-support branch 3 times, most recently from 2f5f210 to dc68b14 Compare June 26, 2019 15:08
Copy link
Member

@pavolloffay pavolloffay left a comment

Choose a reason for hiding this comment

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

LGTM just two nits

)

const none = "none"
const kerberos = "kerberos"
Copy link
Member

Choose a reason for hiding this comment

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

nit: I would define this as array and pass to flag description:

  • to avoid duplication in constants
  • this way we don't forget to update help message if new auth is added

suffixKerberosConfig = ".config-file"
suffixKerberosKeyTab = ".keytab-file"

defaultAuthentication = "none"
Copy link
Member

Choose a reason for hiding this comment

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

nit: related to my previous comment, remove this and just pass authTypes[0] to flag definition

@rubenvp8510 rubenvp8510 force-pushed the kafka-kerbero-support branch 2 times, most recently from 95738f8 to 6eac579 Compare June 26, 2019 19:16
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
@pavolloffay pavolloffay merged commit 5b58ebc into jaegertracing:master Jun 27, 2019
@gauravgill95
Copy link

Hi I am getting error saying Failed to init storage factory. Kafka client has run out of available brokers to talk to(Is your cluster reachable) ?
I error comes in SASL PlAINTEXT. My producer works fine in Plaintext.
Any help would be great

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.

Using a kerberos secured Kafka as buffer between Jaeger and Elasticsearch
4 participants