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 user configs, user secrets and separate environments for cassandra and sidecar #218

Merged

Conversation

alourie
Copy link
Contributor

@alourie alourie commented Aug 2, 2019

Fixes #213

alourie added 3 commits July 27, 2019 00:48
Fixes instaclustr#213
Fixes instaclustr#208

* Fixed some comments from PR review
* Added Env to CRD to allow specifying environment for containers
(exists in java version)
* Added userConfigMap handling (instaclustr#213)
* Restored PrivelegedSupported handling (instaclustr#208)
* Backup secret volume allows providing GOOGLE_APPLICATION_CREDENTIALS
in a secret
* Cloud providers creds can be set using Env field in CRD

Signed-off-by: Alex Lourie <[email protected]>
@alourie alourie requested review from zegelin and benbromhead August 2, 2019 06:10
examples/go/example-datacenter.yaml Outdated Show resolved Hide resolved
path: creds.json
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: "/etc/google/creds.json"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the "default"? If so, do we need to set it as an environment variable?

Copy link
Collaborator

Choose a reason for hiding this comment

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

There does not seem to be any default https://cloud.google.com/docs/authentication/getting-started

Copy link
Collaborator

Choose a reason for hiding this comment

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

i checked the source code, there is not any default location

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, no defaults for that one. This is just an example of where to place that file, I literally look it up in the env and if it's there - we use it. If not defined, we'll use /etc/gcp, but I might change that to something more generic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the default process is this: https://cloud.google.com/docs/authentication/production#finding_credentials_automatically

So yes, we need a way to define the environment variable, but that's probably also going to be the more uncommon approach, as on GKE the credentials will be automatically discovered.

C* clusters running on GKE would most likely backup to Google Cloud Storage. Same on Amazon EKS -- S3 is the most likely destination. But we don't want to prevent clusters running on other K8s environments from accessing cloud storage, so having the option is always nice. Could also be useful for GKE -> EKS migrations for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, it's a convenient option, and it's optional. Also, might be that even on GKE they might want to use some different account for backups, and that's when it would be handy.

examples/go/example-datacenter.yaml Outdated Show resolved Hide resolved
pkg/controller/cassandradatacenter/statefulset.go Outdated Show resolved Hide resolved
pkg/apis/cassandraoperator/v1alpha1/cassandradatacenter.go Outdated Show resolved Hide resolved
pkg/controller/cassandradatacenter/statefulset.go Outdated Show resolved Hide resolved
alourie added 2 commits August 6, 2019 01:16
Signed-off-by: Alex Lourie <[email protected]>
Signed-off-by: Alex Lourie <[email protected]>
@alourie alourie marked this pull request as ready for review August 5, 2019 15:57
@@ -24,21 +23,9 @@ const (
OperatorConfigVolumeMountPath = "/tmp/operator-config"
UserConfigVolumeMountPath = "/tmp/user-config"
UserSecretVolumeMountPath = "/tmp/user-secret-config"
BackupSecretVolumeMountPath = "/tmp/backup-secret"
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference between BackupSecret and UserSecret?

Copy link
Contributor Author

@alourie alourie Aug 6, 2019

Choose a reason for hiding this comment

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

The difference is in fact that BackupSecret would hold the credentials for the backup functionality (i.e. GCP and maybe AWS/Azure should they choose to) and will be mounted in the sidecar container, while UserSecret is for C* encryption/auth credentials and to be mounted in the Cassandra container. Having backup stuff mounted in the cassandra container or cassandra credentials in the sidecar container, while not horrible, feels pretty hacky and dirty. That's why the split.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe change to sidecarSecret/cassandraSecret? So it relates to the pod name

I don't mind the C* and sidecar containers sharing secrets to be honest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I can rename it, but I think it's better called a "backup" secret as it hints the usage for backups only.

Actually, the only other "secrets" usage would be for secure communications as far as I can tell, and we're going to resolve it differently anyway. So I'd just keep it as "backup" for now, and if ever we combine "user" and "backup" secrets, we can change the naming convention.

@@ -24,21 +23,9 @@ const (
OperatorConfigVolumeMountPath = "/tmp/operator-config"
UserConfigVolumeMountPath = "/tmp/user-config"
UserSecretVolumeMountPath = "/tmp/user-secret-config"
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably should just be /tmp/user-secret for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@@ -12,4 +12,12 @@ do
done
)

# Copy over cqlshrc to a default location if defined as ENV
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can make this nicer. It IMO shouldn't be a requirement that users have to define an environment variable and add a file to a config map to get cqlsh to function.

Instead I suggest that we write our own wrapper for cqlsh that detects if SSL is enabled, and fetches the CA cert (or just disables trust checking). This will also be necessary once we support authn/authz, since we need to implement shared-secret support.

As a side question, should cqlsh be installed the C* container at all? If people want to connect to the cluster, should they instead start a new pod/container that just contains cqlsh?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zegelin we currently use cqlsh now in cql-readiness-probe, and this is easily replaceable with either python script or, say, a statically compiled gocql simple program. So we don't have an inherent requirement to have it in the container at all.

Also, if people want to use cqlsh to connect to the cluster, they can either spin a new container with all the certificates and custom configs as they need to, or have it installed locally if they have the network access to the cluster. So, if you think that's a good path to follow, I can replace the readiness script with something else pretty quickly and stop the dependency on cqlsh.

Copy link
Contributor Author

@alourie alourie Aug 6, 2019

Choose a reason for hiding this comment

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

I did rush it a bit. Clearly, any "script" we use will have to know about SSL configuration to be able to connect to the node. So having a wrapper around cqlsh might be a useful and simpler solution.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In order to get the PR closed, I think we should create a new issue/PR for the wrapper script and solve that one separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea, I'm going to remove this part and deal with that in #241

Signed-off-by: Alex Lourie <[email protected]>
@zegelin
Copy link
Contributor

zegelin commented Aug 8, 2019

Is this ready to be merged?

@alourie
Copy link
Contributor Author

alourie commented Aug 9, 2019

@zegelin it can be merged, but the "secure" Cassandra needs more work. I'd prefer merging this, as it fixes a bunch of tickets/features/bugs, and continuing work on proper TLS support separately. If we do it, I'll rename the merge to "Support backups secrets, user secrets and user maps" to avoid misunderstanding.

@alourie alourie changed the title Support TLS certificates Support user configs, user secrets and separate environments for cassandra and sidecar Aug 16, 2019
Copy link
Collaborator

@benbromhead benbromhead left a comment

Choose a reason for hiding this comment

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

Overall lgtm - I think wrap up the rebase on existing changes and the above nits and lets get this merged

@@ -24,21 +23,9 @@ const (
OperatorConfigVolumeMountPath = "/tmp/operator-config"
UserConfigVolumeMountPath = "/tmp/user-config"
UserSecretVolumeMountPath = "/tmp/user-secret-config"
BackupSecretVolumeMountPath = "/tmp/backup-secret"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe change to sidecarSecret/cassandraSecret? So it relates to the pod name

I don't mind the C* and sidecar containers sharing secrets to be honest.

@@ -12,4 +12,12 @@ do
done
)

# Copy over cqlshrc to a default location if defined as ENV
Copy link
Collaborator

Choose a reason for hiding this comment

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

In order to get the PR closed, I think we should create a new issue/PR for the wrapper script and solve that one separately.

@smiklosovic
Copy link
Collaborator

looks good to me

Signed-off-by: Alex Lourie <[email protected]>
@alourie
Copy link
Contributor Author

alourie commented Aug 20, 2019

Now can be squashed and merged @benbromhead

@benbromhead benbromhead merged commit df5ef00 into instaclustr:superdupertopsecretrewrite Aug 21, 2019
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.

4 participants