-
Notifications
You must be signed in to change notification settings - Fork 3
Add support to enable transport encryption TLS #31
Conversation
b8553e6
to
69b25e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking really good!
leaving some comments to improve the parameter docs
operator/params.yaml
Outdated
default: "false" | ||
|
||
- name: TRANSPORT_ENCRYPTION_REQUIRE_CLIENT_AUTH | ||
description: "TODO" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets add some description here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, and the following ones as well.
@shubhanilBag could you please merge in the latest master? |
646e3dd
to
8932a7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @shubhanilBag, thanks for the great progress so far!
A few comments from my side.
operator/operator.yaml
Outdated
@@ -1,6 +1,6 @@ | |||
apiVersion: kudo.dev/v1beta1 | |||
name: "cassandra" | |||
operatorVersion: "0.1.2" | |||
operatorVersion: "0.2.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's revert the operator version bump. Version bumps should happen in the stable branches.
operator/params.yaml
Outdated
default: "false" | ||
|
||
- name: TRANSPORT_ENCRYPTION_REQUIRE_CLIENT_AUTH | ||
description: "TODO" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, and the following ones as well.
name: {{ .Name }}-generate-cqlshrc-sh | ||
namespace: {{ .Namespace }} | ||
data: | ||
generate-cqlshrc.sh: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be a configmap of cqlshrc
itself instead of a bash script that generates it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is what I was going to do initially, but I made a script so that in future if additional configuration is needed for cqlsh, it can be in one script; like adding custom config containing additional config for cqlsh ref: https://docs.datastax.com/en/cql-oss/3.3/cql/cql_reference/cqlshUsingCqlshrc.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference regarding supporting future additional configuration between:
A) a templated bash script that outputs a file
B) a templated file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like here what we do for kafka custom properties taken from a user provided CM https://github.com/kudobuilder/operators/blob/ebaf9e6dba463aa4ff8ec7b4e537c7fdc8c3f629/repository/kafka/operator/templates/bootstrap.yaml#L175
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is not required for cqlshrc file then I can revert back to the usual way for mounting a CM and cp it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mpereira as discussed we are keeping the script based approach as POD_NAME env variable is used in the script to create the hostname
@@ -148,6 +154,17 @@ spec: | |||
- name: node-readiness-probe-sh | |||
mountPath: /etc/cassandra/node-readiness-probe.sh | |||
subPath: node-readiness-probe.sh | |||
- name: cassandra-home | |||
mountPath: /home/cassandra/.cassandra/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should cassandra-home
be just /home/cassandra/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both cqlsh and nodetool creates files in .cassandra
, /home/cassandra is not used directly
so directly mounted it in .cassandra, otherwise it would need another mkdir.
cassandra@cassandra-node-0:~ $ ls -lah
total 0
drwxr-xr-x. 3 root root 24 Jan 29 14:46 .
drwxr-xr-x. 1 root root 23 Jan 29 14:46 ..
drwxrwsrwx. 2 root cassandra 66 Jan 29 14:49 .cassandra
cassandra@cassandra-node-0:~$ ls -lah .cassandra/
total 12K
drwxrwsrwx. 2 root cassandra 66 Jan 29 14:49 .
drwxr-xr-x. 3 root root 24 Jan 29 14:46 ..
-rw-------. 1 cassandra cassandra 5 Jan 29 14:49 cqlsh_history
-rw-r--r--. 1 cassandra cassandra 264 Jan 29 14:46 cqlshrc
-rw-r--r--. 1 cassandra cassandra 1.7K Jan 29 14:50 nodetool.history
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's name it something other than "cassandra-home" then, since it implies /home/cassandra
. Maybe something like cassandra-configuration-directory
or dot-cassandra
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dot-cassandra
SGTM 👍
tests/utils/k8s/k8s.go
Outdated
@@ -128,3 +128,25 @@ func ExecInPodContainer( | |||
|
|||
return stdout, nil | |||
} | |||
|
|||
func FetchLogsOfPod(namespaceName, podName, containerName string) (*bytes.Buffer, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would PodContainerLogs
be a more representative name for this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go with FetchContainerLogs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is that function different than the already existing k8s.GetPodContainerLogs
by the way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not, I made a duplicate by mistake 🤔! Thanks for pointing it out, will fix that
tests/utils/cassandra/cassandra.go
Outdated
@@ -120,3 +122,19 @@ func getConfigurationFromNodeLogs( | |||
|
|||
return configuration, nil | |||
} | |||
|
|||
// CQLSH TODO function comment. | |||
func CQLSH( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func CQLSH( | |
func cqlsh( |
Expect(err).To(BeNil()) | ||
assertNumberOfCassandraNodes(NodeCount) | ||
}) | ||
It("Check container logs", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to follow the active voice for the test names, so that it reads like:
It "checks for the container logs"
like the above
It "installs the operator from a directory"
On the other tests as well.
@@ -0,0 +1,214 @@ | |||
package cassandra_tls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put this test file in tests/suites/tls_test.go
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed kudo-kafka-operator's way of having tests in different packages with it's own folder. If we have the tls_test.go
and sanity_test.go
under same package sanity they will share the global vars and functions. We won't get full isolation. like https://github.com/mesosphere/kudo-cassandra-operator/blob/d6f6784bb48ae6b0473a4ed70fc97af783fad2e2/tests/suites/sanity_test.go#L23
and
https://github.com/mesosphere/kudo-cassandra-operator/blob/8932a7e5f58b52495466ca16265aace4b8b3ca97/tests/suites/cassandra_tls/tls_test.go#L19 will conflict if tls_test was in same folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. In that case, let's move
tests/suites/sanity_test.go
totests/suites/sanity/sanity_test.go
tests/suites/cassandra_tls/tls_test.go
totests/suites/tls/tls_test.go
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure 👍
@@ -411,7 +411,7 @@ func UpgradeOperator( | |||
func UninstallOperator( | |||
operatorName string, namespaceName string, instanceName string, | |||
) error { | |||
uninstallScript := "../../scripts/uninstall_operator.sh" | |||
uninstallScript := "../../../scripts/uninstall_operator.sh" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required because the suites moved one directory deeper?
Maybe we should pass in the scripts directory as an absolute path at some point and not rely on relative paths. Seems to be ok for now though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be ok for now for me too. Is there a way to make this relative to the actual kudo.go
file instead, though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ANeumann82 right, later we can do something like this: https://github.com/mesosphere/kudo-kafka-operator/pull/6/files#diff-dc3495b5db55989eec09ceab2776f370R29
Set a REPO_ROOT
env var and create abs paths using that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already available to be passed as an environment variable fwiw: https://github.com/mesosphere/kudo-cassandra-operator/blob/7a143804c906b3f8c5fda40f359ab297506c35ff/run-tests.sh#L7
"NODE_CPU_MC=200", | ||
"NODE_MEM_MIB=800", | ||
"PROMETHEUS_EXPORTER_CPU_MC=100", | ||
"PROMETHEUS_EXPORTER_MEM_MIB=200", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are probably development settings for local testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right! I will remove these ☑️ from here and tls test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it's a good practice to have tests that consume as less resource as possible, I added these as the default ones where too large to run in konovy cluster with default config.
It can help in starting up running tests in small clusters faster, plus if we have extra pods in tests like KDC or like a client pod for testing out application features then those can fail to run due to resource starvation on the k8s nodes WDYT @ANeumann82 ?
fyi same practice is followed by kudo-kafka ref:https://github.com/mesosphere/kudo-kafka-operator/blob/b692a7f003afe31a3b35002820542afe62178cbd/tests/utils/client.go#L241
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm fine with that. I didn't know Cassandra enough yet to tune the settings down, but as long as we don't make anything flaky because Cassandra doesn't have enough CPU or Mem, i'm fine with having lower values for the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These settings are too low, and can likely cause resource throttling issues. I've seen it happen during MWTs. Unless we're specifically testing CPU/MEM parameters, let's use the default parameter values.
Signed-off-by: Shubhanil Bag <[email protected]>
* wip * add todo Co-authored-by: Murilo Pereira <[email protected]>
Signed-off-by: Shubhanil Bag <[email protected]>
Signed-off-by: Shubhanil Bag <[email protected]>
Signed-off-by: Shubhanil Bag <[email protected]>
Signed-off-by: Shubhanil Bag <[email protected]>
Signed-off-by: Shubhanil Bag <[email protected]>
Signed-off-by: Shubhanil Bag <[email protected]>
Signed-off-by: Shubhanil Bag <[email protected]>
Signed-off-by: Shubhanil Bag <[email protected]>
8932a7e
to
fd0ff10
Compare
@zmalik @mpereira @ANeumann82 thanks for the thorough review 👍 added changes as requested in fd0ff10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @shubhanilBag. Just a few comments from my side regarding documentation, but nothing blocking. Thanks!
README.md
Outdated
@@ -48,6 +48,7 @@ kubectl kudo install cassandra | |||
- [Managing](/docs/managing.md) | |||
- [Upgrading](/docs/upgrading.md) | |||
- [Monitoring](/docs/monitoring.md) | |||
- [Security](./docs/secuity.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [Security](./docs/secuity.md) | |
- [Security](./docs/security.md) |
docs/security.md
Outdated
@@ -0,0 +1,68 @@ | |||
# Securing KUDO Cassandra Operator instances | |||
|
|||
The KUDO Cassandra service supports Cassandra’s native transport **encryption** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rephrase all instances of "service" with "operator" to maintain consistency.
The KUDO Cassandra service supports Cassandra’s native transport **encryption** | |
The KUDO Cassandra operator supports Cassandra’s native transport **encryption** |
docs/security.md
Outdated
|
||
The KUDO Cassandra service supports Cassandra’s native transport **encryption** | ||
mechanism. The service provides automation and orchestration to simplify the use | ||
of these important features. For more information on Cassandra’s security, read |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also rephrase "Cassadra" instances to "Apache Cassandra" for the same reason.
of these important features. For more information on Cassandra’s security, read | |
of these important features. For more information on Apache Cassandra’s security, read |
docs/security.md
Outdated
|
||
``` | ||
kubectl kudo install cassandra \ | ||
--instance=cassandra --namespace=kudo-cassandra \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's maintain consistency of either all parameters in one line, or one parameter per-line when there's lots of them.
--instance=cassandra --namespace=kudo-cassandra \ | |
--instance=cassandra \ | |
--namespace=kudo-cassandra \ |
I pushed two small commits fixing a documentation thing. @shubhanilBag would you be able to add an "unreleased" changelog entry as well? |
Signed-off-by: Shubhanil Bag <[email protected]>
@mpereira Added the doc fixes and added changelog entry in b3bf8f8 |
🚢 |
Looks like there are two test failures:
@shubhanilBag could you take a look when you get a chance? |
Signed-off-by: Shubhanil Bag <[email protected]>
The sanity test suite was running the tests in this order:
As the result the 3 param update tests were running with 4 nodes in the c* instance, so the SS took more time to update itself than the estimated 5mins of timeout, and failing the tests |
tests/utils/cassandra/cassandra.go
Outdated
@@ -120,3 +122,19 @@ func getConfigurationFromNodeLogs( | |||
|
|||
return configuration, nil | |||
} | |||
|
|||
// Cqlsh TODO function comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in a2162f4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🎉
Signed-off-by: Shubhanil Bag <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
This PR:
1.1 Node-to-Node transport encryption
1.2 Client-to-Node encryption
1.3 Node-to-Node along with Client-to-Node encryption
1.4 Data read and write using cqlsh
6. Bumps operator version to0.2.0