Skip to content
This repository was archived by the owner on Nov 1, 2022. It is now read-only.

Mount the sshdir into the helm-operator too #1166

Merged
merged 2 commits into from
Jun 28, 2018

Conversation

stephenmoloney
Copy link
Contributor

What is this MR for ?

  • Mounting the sshdir into the helm operator container

  • The known_hosts is only mounted in the flux container thus far.

I'm not 100% sure that the known_hosts are meant to be available in the helm-operator but
my guess is that they are. Perhaps someone can confirm?

@stephenmoloney
Copy link
Contributor Author

note to self: I should add this change to the helm-deploy folder too. Lets see if in principle this change will be accepted first, then I'll add it to the helm-deploy too.

@squaremo
Copy link
Member

Yes, this looks good and right.

I think we'll also need to change the helm-operator in line with #1154, so that mounting into /root/.ssh doesn't wipe out the config from the image.

@stephenmoloney
Copy link
Contributor Author

stephenmoloney commented Jun 25, 2018

I had an alternative thought on how to handle the known hosts.
Rather than bake the github.com, gitlab.com bitbucket.com hosts known_keys into the docker image, maybe a different approach might be to specify the hosts as a list in the yaml values in helm .
Then an init container will run and generate the known hosts at startup and save them into the /root/.ssh/known_keys file.
I kinda like this idea as from a user's perspective, entering multiline keys in the yaml under known_hosts is actually quite cumbersome.

@squaremo
Copy link
Member

Rather than bake the github.com, gitlab.com bitbucket.com hosts known_keys into the docker image, maybe a different approach might be to specify the hosts as a list in the yaml values in helm .
Then an init container will run and generate the known hosts at startup and save them into the /root/.ssh/known_keys file.

This would work. But the reason we switch on StrictHostKeyChecking though is that it prevents man-in-the-middle attacks, by making someone supply the key(s) ahead of time[1]. Scanning for the keys on startup undermines this, because you're introducing an opportunity for someone to give you a duff host key.

If you provided the fingerprint alongside the host name in the initial config, that would be enough to avoid that problem, while still being more convenient than assembling the configmap.

[1] We don't do this properly, mind you -- the docs ought to advise that you check the fingerprints; and, we really ought to check in a known_hosts file for github etc., rather than scanning for keys in the build.

@stephenmoloney
Copy link
Contributor Author

stephenmoloney commented Jun 25, 2018

Ok, the Dockerfile gave me the impression that the practice of scanning for the hostkey was ok.

So if it is not ok, the Dockerfile is missing a step to check the host keys - we should open an issue for that so that it is checked in the Dockerfile.

Also, in this case, the idea of an init_container doesn't work.

So using known_hosts is fine.

Also you are right about the known hosts are added to the volume, they should (maybe?) be appended to the existing file rather than outright overriding the existing file. I suppose that operation could be put into an init_container.

@squaremo
Copy link
Member

So if it is not ok, the Dockerfile is missing a step to check the host keys - we should open an issue for that so that it is checked in the Dockerfile.

#1169

@stephenmoloney
Copy link
Contributor Author

I think we'll also need to change the helm-operator in line with #1154, so that mounting into /root/.ssh doesn't wipe out the config from the image.

I've changed it to use a subPath now and a specific file so the /root/.ssh/config crystallized inside the docker image is unaffected.

@stephenmoloney
Copy link
Contributor Author

stephenmoloney commented Jun 28, 2018

Also, would you prefer I squash this PR or leave as is?

Copy link
Member

@squaremo squaremo left a comment

Choose a reason for hiding this comment

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

You could squash the second commit (use a subPath) into the first, but it's OK as-is.

(The required change is to not use template syntax in the example YAML)

@@ -14,6 +14,10 @@ spec:
spec:
serviceAccount: flux
volumes:
- name: sshdir
configMap:
name: {{ template "flux.fullname" . }}-ssh-config

This comment was marked as abuse.

What is this MR for ?

- Mounting the sshdir into the helm operator container

- The known_hosts is only mounted in the flux container thus far.
@squaremo
Copy link
Member

squaremo commented Jun 28, 2018

"uncomment the ssh config settings in helm-operator-deployment.yaml"

^ this ought to read "Comments the ssh config ..." (in the commit message as well)

@stephenmoloney stephenmoloney force-pushed the helm/add_ssh_dir branch 3 times, most recently from 12e10d1 to 87018ce Compare June 28, 2018 14:30
@stephenmoloney
Copy link
Contributor Author

@squaremo I think the git history is a bit cleaner now if you want to have another look.

What does this MR do?

- Adds the changes for the sshdir configmap and volume into the helm-operator-deployment.yaml file
- Comments the sshdir configmap and volume
@squaremo squaremo merged commit e0e6b70 into fluxcd:master Jun 28, 2018
@squaremo
Copy link
Member

Brill, thanks for your perseverance @stephenmoloney.

@stephenmoloney stephenmoloney deleted the helm/add_ssh_dir branch January 2, 2019 11:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants