-
Notifications
You must be signed in to change notification settings - Fork 1
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
Set up CA #19
Set up CA #19
Conversation
1. Rename and add Firewall-rules with tags 2. Change the image of gateway-vm to ubuntu with docker 3. Build containerssh-guest-image on Sacrificial-vm
This reverts commit 292877b.
1. install ssh-container-guest-image directly with docker pull. 2. add ca_cert for client and server (need to be tested, if it works with another server with different fqdn) 3. unclean!
added some small changes
This comment was marked as off-topic.
This comment was marked as off-topic.
packer/scripts/update.sh
Outdated
sudo shutdown -r +1 | ||
sleep 5m |
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.
changed it because ...
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 will fix the disconnected issue :)
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.
Just changed it back to reboot
as it's much faster and works now... (I tested it for > 10 times)
(maybe because of
provisioner "shell" {
script = "./scripts/update_apt_packages.sh"
+ expect_disconnect = true
}
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.
Notes:
-
hostname -f
: get the fqdn
Use FQDN for $HOST in docker manual commands to generate .pem -
config.yaml not working yet
-
docker key gen still manual process. Need to automate it.
Decided to make CA work first to control the PR size.
- make small changes in firewall rule (open port 9090 and 9091 only for logger-vm) - add new script to run container in gateway-vm as Janos's Suggestion (not work correctly yet; the container keep exit instead of running in background)
the script run docker container inside our VM (container will run in background) and will mount the settings for containerssh
packer/variables.pkr.hcl
Outdated
|
||
variable "project_id" { | ||
type = string | ||
default = "containerssh-352007" |
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.
Enter your project ID 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.
Will move it to variables.auto.pkrvars.hcl
as recommended by
https://www.packer.io/guides/hcl/variables#from-a-file
allow { | ||
protocol = "tcp" | ||
ports = ["22", "9091"] | ||
ports = ["22"] |
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.
Open port 22 for all VM (for SSH), so that it's easier to control
TODO Later: open port 22 only for gateway-vm
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.
We can finalize firewall rules in #5 after everything works
"./scripts/download_node_exporter.sh", | ||
"./scripts/run_node_exporter.sh" | ||
"./scripts/run_node_exporter.sh", | ||
"./scripts/run_docker_container.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.
as per Janos's suggestion, running container inside gateway-vm to run sshcontainer
packer/README.md
Outdated
@@ -30,7 +30,7 @@ What you need: | |||
|
|||
> Note: if you want to use a different file name or location, change `account_file` in [`./main.pkr.hcl`](./main.pkr.hcl) accordingly | |||
|
|||
3. Update `project-id` in `main.pkr.hcl` to match yours | |||
3. Update `project-id` in `variables.pkr.hcl` to match yours |
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.
Update readme file to match the changes
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.
moved to *.auto.pkr.hcl
file as packer recommended
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.
Finished CA set up with manual configuration.
Will do next steps in future PRs.
TODOs before merge:
- check out answers to open questions and update our code if needed
- remove
ca*.tar
files and relevant config - verify CA set up again with readme
.gitignore
Outdated
terraform/variables.tf | ||
terraform/.terraform.lock.hcl | ||
packer/files/Neuer Ordner/ | ||
terraform/variables.tf |
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.
Removed this file for the following reasons:
Maybe we shouldn't ignore these files.
-
for
.terraform.lock.hcl
file, refer to
https://stackoverflow.com/a/67975490We should update the file instead of ignore it. (done in this PR)
terraform providers lock -platform=windows_amd64 -platform=darwin_amd64 -platform=linux_amd64
-
for
Neuer Ordner
, it's neither a common file to ignore nor a project relevant file, so maybe a bit off topic here? -
variables.tf
declares variables and their types, and should be checked into the repo.
packer/variables.pkr.hcl
Outdated
|
||
variable "project_id" { | ||
type = string | ||
default = "containerssh-352007" |
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.
Will move it to variables.auto.pkrvars.hcl
as recommended by
https://www.packer.io/guides/hcl/variables#from-a-file
packer/variables.pkr.hcl
Outdated
type = string | ||
default = "containerssh-352007" | ||
// Sensitive vars are hidden from output as of Packer v1.6.5 | ||
sensitive = true |
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.
Removed sensitive
as project id should not be sensitive.
packer/README.md
Outdated
@@ -30,7 +30,7 @@ What you need: | |||
|
|||
> Note: if you want to use a different file name or location, change `account_file` in [`./main.pkr.hcl`](./main.pkr.hcl) accordingly | |||
|
|||
3. Update `project-id` in `main.pkr.hcl` to match yours | |||
3. Update `project-id` in `variables.pkr.hcl` to match yours |
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.
moved to *.auto.pkr.hcl
file as packer recommended
packer/scripts/update.sh
Outdated
sudo shutdown -r +1 | ||
sleep 5m |
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.
Just changed it back to reboot
as it's much faster and works now... (I tested it for > 10 times)
(maybe because of
provisioner "shell" {
script = "./scripts/update_apt_packages.sh"
+ expect_disconnect = true
}
allow { | ||
protocol = "tcp" | ||
ports = ["22", "9091"] | ||
ports = ["22"] |
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.
We can finalize firewall rules in #5 after everything works
Description
This PR will
Testing the PR
You can verify the PR by following
/terraform/README.md#Set-up-CA
and set up the CA manually.Future improvements
Developers notes
sacrificial-vm
($ hostname
) instead of$ hostname -f
.Reason:
$ hostname -f
is different for different GCP accounts, so we cannot hardcode the hostname, which makes the configuration more cumbersome.Takeaways
How to connect to a remote docker engine
Method 1: Create a docker context
Now your
docker
will work directly on the remote host.Method 2 (Our case): set
DOCKER_HOST
Docker supports remote connection via SSH, TCP, TCP with TLS (our case)
export DOCKER_HOST=ssh://username@host remote-engine
This will directly send requests to the remote host using the current context.
Others
see unresolved comments below
Q&A
Regarding Container SSH documentation - Step 4:
Answers from Janos:
Q1: SSH vs. TLS
The document recommended us to connect to remote Docker engine over TLS. Why not over SSH? (SSH seems much easier to set up)
A1: SSH is unstable and should only be used for human access.
Q2:
docker run -H
doesn't workThe command on documentation doesn't work.
Is the command wrong? It works with
when
~/.docker
is set up as Docker - Secure by defaultA2: Janos: It should work with
docker -H <command>
Q3: Do we need Docker daemon to also run on port
2375
?Step 4 gives two ports for Docker connection, but only
2376
seems to be used in other places in the doc.A3: Janos: typically
2376
for encrypted connection,2375
for unencrypted.Action: Our
2375
is not open. We can probably ignore it.