Skip to content

iscsi: Attempt to pull SSL crt and key's from mon config-key store - #173

Merged
mikechristie merged 1 commit into
ceph:masterfrom
matthewoliver:ssl_from_config_key
Apr 29, 2020
Merged

mikechristie merged 1 commit into
ceph:masterfrom
matthewoliver:ssl_from_config_key

Conversation

@matthewoliver

@matthewoliver matthewoliver commented Feb 20, 2020 •

Copy link
Copy Markdown
Contributor

I'm looking at attempting to add iscsi to cephadm, but frankly having
to place the crt and key inside the container makes things a little
harder. While working on adding RGW SSL support to cephadm sage et al,
suggested we should use the mon config-key store the certs[0][1].

So thought why not fo the same here. This will mean when setting up
service in cephadm, an op can either place the certs:

ceph config-key put 'iscsi//iscsi-gateway.crt -i
ceph config-key put 'iscsi//iscsi-gateway.key -i

Or if given the files via cephadm we can place them on their behalf.

[0]- ceph/ceph#32951
[1]- ceph/ceph#33287

Signed-off-by: Matthew Oliver [email protected]

@matthewoliver

Copy link
Copy Markdown
Contributor Author

This is still a WIP, just wanted to post it somewhere. Still needs debugging, testing, docs and well tests :P

But thought better it was done from the beginning in the open, so here it is :)

If someone could add the DNM tag then that'll be great.

@dillaman dillaman changed the title iscsi: Attempt to pull SSL crt and key's from mon config-key store [DNM] iscsi: Attempt to pull SSL crt and key's from mon config-key store Feb 20, 2020
Comment thread rbd-target-api.py
if not ret:
return temp_files

cmd["key"] = "iscsi/{}/iscsi-gateway.key".format(client_name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would need to double-check from the cephadm-side, but for security reasons, is the private key locked down so only the iSCSI user can read them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's limited to the iscsi user unfortunately. Though you would need a keyring with I guess mon read caps.. I haven't tested this. So you'd at least need to be authenticated.

But a very interesting point

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

using mon caps you could limit access to this prefix for just the iscsi user though. We use similar things for the mgr, for instance, although we achieve that in particular by hardcoding those caps via the mgr profile.

In https://docs.ceph.com/docs/master/rados/operations/user-management/#authorization-capabilities you will find a few examples of this, but I would imagine you'd want to limit access to that key via

mon 'allow command "config-key get" with key prefix iscsi/$client_name/iscsi-gateway.key,allow command "config-key set" with key prefix iscsi/$client_name/iscsi-gateway.key"

If you want to see a lot more examples of how this could be achieved, you can take a look at qa/workunits/mon/test_config_key_caps.sh.

Comment thread rbd-target-api.py Resolved
matthewoliver pushed a commit to matthewoliver/ceph that referenced this pull request Apr 2, 2020
This if the first draft of the ceph-iscsi in cephadm.
There are a few gotchas when running `rbd-target-api` in a container:

 1. We need both the ceph.conf and iscsi-gateway.cfg, so needed to
ability to pass extra config. This latter is based off the spec, so now
the daemon config func api allows you to return a dict of configs:

  { 'config': '<str>' # will be appended to the ceph.conf
    '<conf name>': 'str', # Will be dumped in datadir/<conf name>
    ...
  }

It will be up to cephadm to know to bind mount it to the right location.
The first 'config' isn't used by this patch, but makes it possible for
specs or config funcs to append anything? maybe it's overkill.

 2. We need the kernel's configfs in the container so we can configure
LIO. There is a chicken and egg problem, configfs isn't mounted on the
host to bind mount when the container starts. So now a check is added to
the `unit.run` and cleanup in the `unit.poststop` scripts for
daemon_type iscsi.

 3. rbd-target-api is python and hardcodes a few things, like logging
through `/dev/log` which happens to be a domain socket. So `/dev/log`
also needed to be bind mounted into the continer.

 4. The daemon expects the keyring to be in `/etc/ceph` so this needed to
be specifically bind mounted to the correct location too.

As this currently stands this is deploying and starting the api on port
5000, so seems to be "working", also gateway.conf does exist in the
pool. I have yet to set up an iscsi device, but will test that next.

The `rbd-target-api` daemon expects the ssl key and cert to be named a
certain name in the contianer. So SSL isn't working yet. However, I do
hav a PR in ceph-iscsi to look in the mon config-key store for them[0].

[0] - ceph/ceph-iscsi#173

Signed-off-by: Matthew Oliver <[email protected]>
@sebastian-philipp

Copy link
Copy Markdown

ping @ricardoasmarques + @matthewoliver anything I can do to unstuck this?

jschmid1 pushed a commit to ceph/ceph-ci that referenced this pull request Apr 14, 2020
This if the first draft of the ceph-iscsi in cephadm.
There are a few gotchas when running `rbd-target-api` in a container:

 1. We need both the ceph.conf and iscsi-gateway.cfg, so needed to
ability to pass extra config. This latter is based off the spec, so now
the daemon config func api allows you to return a dict of configs:

  { 'config': '<str>' # will be appended to the ceph.conf
    '<conf name>': 'str', # Will be dumped in datadir/<conf name>
    ...
  }

It will be up to cephadm to know to bind mount it to the right location.
The first 'config' isn't used by this patch, but makes it possible for
specs or config funcs to append anything? maybe it's overkill.

 2. We need the kernel's configfs in the container so we can configure
LIO. There is a chicken and egg problem, configfs isn't mounted on the
host to bind mount when the container starts. So now a check is added to
the `unit.run` and cleanup in the `unit.poststop` scripts for
daemon_type iscsi.

 3. rbd-target-api is python and hardcodes a few things, like logging
through `/dev/log` which happens to be a domain socket. So `/dev/log`
also needed to be bind mounted into the continer.

 4. The daemon expects the keyring to be in `/etc/ceph` so this needed to
be specifically bind mounted to the correct location too.

As this currently stands this is deploying and starting the api on port
5000, so seems to be "working", also gateway.conf does exist in the
pool. I have yet to set up an iscsi device, but will test that next.

The `rbd-target-api` daemon expects the ssl key and cert to be named a
certain name in the contianer. So SSL isn't working yet. However, I do
hav a PR in ceph-iscsi to look in the mon config-key store for them[0].

[0] - ceph/ceph-iscsi#173

Signed-off-by: Matthew Oliver <[email protected]>
sebastian-philipp pushed a commit to sebastian-philipp/ceph that referenced this pull request Apr 14, 2020
This if the first draft of the ceph-iscsi in cephadm.
There are a few gotchas when running `rbd-target-api` in a container:

 1. We need both the ceph.conf and iscsi-gateway.cfg, so needed to
ability to pass extra config. This latter is based off the spec, so now
the daemon config func api allows you to return a dict of configs:

  { 'config': '<str>' # will be appended to the ceph.conf
    '<conf name>': 'str', # Will be dumped in datadir/<conf name>
    ...
  }

It will be up to cephadm to know to bind mount it to the right location.
The first 'config' isn't used by this patch, but makes it possible for
specs or config funcs to append anything? maybe it's overkill.

 2. We need the kernel's configfs in the container so we can configure
LIO. There is a chicken and egg problem, configfs isn't mounted on the
host to bind mount when the container starts. So now a check is added to
the `unit.run` and cleanup in the `unit.poststop` scripts for
daemon_type iscsi.

 3. rbd-target-api is python and hardcodes a few things, like logging
through `/dev/log` which happens to be a domain socket. So `/dev/log`
also needed to be bind mounted into the continer.

 4. The daemon expects the keyring to be in `/etc/ceph` so this needed to
be specifically bind mounted to the correct location too.

As this currently stands this is deploying and starting the api on port
5000, so seems to be "working", also gateway.conf does exist in the
pool. I have yet to set up an iscsi device, but will test that next.

The `rbd-target-api` daemon expects the ssl key and cert to be named a
certain name in the contianer. So SSL isn't working yet. However, I do
hav a PR in ceph-iscsi to look in the mon config-key store for them[0].

[0] - ceph/ceph-iscsi#173

Signed-off-by: Matthew Oliver <[email protected]>
(cherry picked from commit 4179b96)
jschmid1 pushed a commit to ceph/ceph-ci that referenced this pull request Apr 15, 2020
This if the first draft of the ceph-iscsi in cephadm.
There are a few gotchas when running `rbd-target-api` in a container:

 1. We need both the ceph.conf and iscsi-gateway.cfg, so needed to
ability to pass extra config. This latter is based off the spec, so now
the daemon config func api allows you to return a dict of configs:

  { 'config': '<str>' # will be appended to the ceph.conf
    '<conf name>': 'str', # Will be dumped in datadir/<conf name>
    ...
  }

It will be up to cephadm to know to bind mount it to the right location.
The first 'config' isn't used by this patch, but makes it possible for
specs or config funcs to append anything? maybe it's overkill.

 2. We need the kernel's configfs in the container so we can configure
LIO. There is a chicken and egg problem, configfs isn't mounted on the
host to bind mount when the container starts. So now a check is added to
the `unit.run` and cleanup in the `unit.poststop` scripts for
daemon_type iscsi.

 3. rbd-target-api is python and hardcodes a few things, like logging
through `/dev/log` which happens to be a domain socket. So `/dev/log`
also needed to be bind mounted into the continer.

 4. The daemon expects the keyring to be in `/etc/ceph` so this needed to
be specifically bind mounted to the correct location too.

As this currently stands this is deploying and starting the api on port
5000, so seems to be "working", also gateway.conf does exist in the
pool. I have yet to set up an iscsi device, but will test that next.

The `rbd-target-api` daemon expects the ssl key and cert to be named a
certain name in the contianer. So SSL isn't working yet. However, I do
hav a PR in ceph-iscsi to look in the mon config-key store for them[0].

[0] - ceph/ceph-iscsi#173

Signed-off-by: Matthew Oliver <[email protected]>
I'm looking at attempting to add iscsi to cephadm, but frankly having
to place the crt and key inside the container makes things a little
harder. While working on adding RGW SSL support to cephadm sage et al,
suggested we should use the mon config-key store the certs[0][1].

So thought why not fo the same here. This will mean when setting up
service in cephadm, an op can either place the certs:

  ceph config-key put 'iscsi/<client-name>/iscsi-gateway.crt -i <file>
  ceph config-key put 'iscsi/<client-name>/iscsi-gateway.key -i <file>

Or if given the files via cephadm we can place them on their behalf.

[0]- ceph/ceph#32951
[1]- ceph/ceph#33287

Signed-off-by: Matthew Oliver <[email protected]>
@matthewoliver matthewoliver changed the title [DNM] iscsi: Attempt to pull SSL crt and key's from mon config-key store iscsi: Attempt to pull SSL crt and key's from mon config-key store Apr 20, 2020
@matthewoliver

Copy link
Copy Markdown
Contributor Author

I've finally had a chance to test, and with the latest force push it is now getting the SSL and key out of the config-key store.

So @jschmid1 you might need to update what your testing in ci. had a few bool checks the wrong way. And the mon_command slightly wrong.

So from that point of view the code is working. I mean with the security questions aside.

@dillaman dillaman left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

lgtm -- thx!

@dillaman

Copy link
Copy Markdown

(I left a comment for addressing the config-key get caps in the other PRs)

@sebastian-philipp

sebastian-philipp commented Apr 29, 2020 •

Copy link
Copy Markdown

anything we can do to get this in?

@mikechristie
mikechristie merged commit 0fded1d into ceph:master Apr 29, 2020
pritha-srivastava pushed a commit to ceph/ceph-ci that referenced this pull request May 7, 2020
This if the first draft of the ceph-iscsi in cephadm.
There are a few gotchas when running `rbd-target-api` in a container:

 1. We need both the ceph.conf and iscsi-gateway.cfg, so needed to
ability to pass extra config. This latter is based off the spec, so now
the daemon config func api allows you to return a dict of configs:

  { 'config': '<str>' # will be appended to the ceph.conf
    '<conf name>': 'str', # Will be dumped in datadir/<conf name>
    ...
  }

It will be up to cephadm to know to bind mount it to the right location.
The first 'config' isn't used by this patch, but makes it possible for
specs or config funcs to append anything? maybe it's overkill.

 2. We need the kernel's configfs in the container so we can configure
LIO. There is a chicken and egg problem, configfs isn't mounted on the
host to bind mount when the container starts. So now a check is added to
the `unit.run` and cleanup in the `unit.poststop` scripts for
daemon_type iscsi.

 3. rbd-target-api is python and hardcodes a few things, like logging
through `/dev/log` which happens to be a domain socket. So `/dev/log`
also needed to be bind mounted into the continer.

 4. The daemon expects the keyring to be in `/etc/ceph` so this needed to
be specifically bind mounted to the correct location too.

As this currently stands this is deploying and starting the api on port
5000, so seems to be "working", also gateway.conf does exist in the
pool. I have yet to set up an iscsi device, but will test that next.

The `rbd-target-api` daemon expects the ssl key and cert to be named a
certain name in the contianer. So SSL isn't working yet. However, I do
hav a PR in ceph-iscsi to look in the mon config-key store for them[0].

[0] - ceph/ceph-iscsi#173

Signed-off-by: Matthew Oliver <[email protected]>
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.

5 participants