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

e2e podman private registry #17642

Merged
merged 5 commits into from
Jul 19, 2023
Merged

e2e podman private registry #17642

merged 5 commits into from
Jul 19, 2023

Conversation

shoenig
Copy link
Member

@shoenig shoenig commented Jun 21, 2023

note: I had to add -k to a few curl commands - I'm fairly sure the base Ubuntu image did a Bad Thing to its own trust store / curl package and we'll need to ignore certificate errors until that is fixed. Also replaced the use of the deprecated apt-key command with the gpg/tee dance recommended by Docker and Hashicorp packaging.


e2e: add a test for using private registry with podman driver

This PR adds e2e tests that stands up a private docker registry
and has a podman tasks run a container from an image in that private
registry.

Tests

  • user:password set in task config
  • auth_soft_fail works for public images when auth is set in driver
  • credentials helper is set in driver auth config
  • config auth.json file is set in driver auth config

Spot check against e2e:

nomad/e2e/podman on e2e-podman-private-registry
➜ go test -v
=== RUN   TestPodman
=== RUN   TestPodman/testRedis
=== RUN   TestPodman/testAuthBasic
=== RUN   TestPodman/testAuthFileStatic
=== RUN   TestPodman/testAuthHelper
    podman_test.go:109: registry 172.31.85.15 20633
--- PASS: TestPodman (76.38s)
    --- PASS: TestPodman/testRedis (19.60s)
    --- PASS: TestPodman/testAuthBasic (10.39s)
    --- PASS: TestPodman/testAuthFileStatic (9.32s)
    --- PASS: TestPodman/testAuthHelper (8.21s)
PASS
ok      github.com/hashicorp/nomad/e2e/podman   76.383s

@shoenig shoenig force-pushed the e2e-podman-private-registry branch from 842e44a to 3227041 Compare June 21, 2023 19:33
@shoenig shoenig force-pushed the e2e-podman-private-registry branch from 3227041 to bebbc16 Compare June 26, 2023 13:29
@shoenig shoenig force-pushed the e2e-podman-private-registry branch from 2ec4660 to bbe48bb Compare July 2, 2023 20:08
@shoenig shoenig force-pushed the e2e-podman-private-registry branch from 946e613 to 026129e Compare July 5, 2023 17:16
@shoenig shoenig force-pushed the e2e-podman-private-registry branch from 490cf77 to 3843526 Compare July 12, 2023 16:58
@shoenig shoenig force-pushed the e2e-podman-private-registry branch from 9472a6b to 23d48ce Compare July 12, 2023 23:47
This PR adds e2e tests that stands up a private docker registry
and has a podman tasks run a container from an image in that private
registry.

Tests
 - user:password set in task config
 - auth_soft_fail works for public images when auth is set in driver
 - credentials helper is set in driver auth config
 - config auth.json file is set in driver auth config
Copy link
Member

@gulducat gulducat left a comment

Choose a reason for hiding this comment

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

LGTM!

# This job runs after the private registry is up and running, when we know
# address and port provided by the bridge network. It is a sysbatch job
# that writes these files on every linux client.
# - /usr/local/bin/docker-credential-test.sh
Copy link
Member

Choose a reason for hiding this comment

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

this is "docker-credential-" rather than "podman-credential-" because the registry itself is docker?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's just because the "official" credentials helpers in the ecosystem are provided by docker and their documentation prefixes everything using "docker-credential-"

https://github.com/docker/docker-credential-helpers/tree/master

I suppose we could search for either prefix, but unless someone actually asks for it I think we should just keep it simple and working with the known tools.


# write out the test.sh file into var.helper_dir
task "create-helper-file" {
driver = "pledge"
Copy link
Member

Choose a reason for hiding this comment

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

fun use of pledge 🧼

destination = "local/auth.json"
data = <<EOH
{
"auths": {
Copy link
Member

Choose a reason for hiding this comment

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

This one's pretty trivial, but I like jsonencode to avoid possibly-invalid raw json.

# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

# This job stands up a private container registry for use in e2e tests.
Copy link
Member

Choose a reason for hiding this comment

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

idle pondering: I wonder if a general version of this might be nice for other things one day.

Copy link
Member Author

Choose a reason for hiding this comment

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

we should at least add similar tests for the docker driver, but that's for another PR

e2e/podman/input/registry.hcl Outdated Show resolved Hide resolved
jobs3.Var("user", "root"),
jobs3.Var("helper_dir", "/usr/local/bin"),
jobs3.Var("auth_dir", "/etc"),
jobs3.WaitComplete("create-files"),
Copy link
Member

Choose a reason for hiding this comment

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

took me a minute to determine that "create-files" here is a task group name?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh good feedback, maybe this could be WaitGroupComplete or something

sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt-get update && sudo apt-get install nomad
Copy link
Member

Choose a reason for hiding this comment

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

nomad is already being installed on line 65 down below with consul-enterprise. could save an apt update here too and let line 60 handle that.

Copy link
Member Author

Choose a reason for hiding this comment

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

nice catch

@shoenig shoenig merged commit 8d28946 into main Jul 19, 2023
5 checks passed
@shoenig shoenig deleted the e2e-podman-private-registry branch July 19, 2023 20:59
jrasell pushed a commit that referenced this pull request Jul 26, 2023
* e2e: add tests for using private registry with podman driver

This PR adds e2e tests that stands up a private docker registry
and has a podman tasks run a container from an image in that private
registry.

Tests
 - user:password set in task config
 - auth_soft_fail works for public images when auth is set in driver
 - credentials helper is set in driver auth config
 - config auth.json file is set in driver auth config

* packer: use nomad-driver-podman v0.5.0

* e2e: eliminate unnecessary chmod

Co-authored-by: Daniel Bennett <dbennett@hashicorp.com>

* cr: no need to install nomad twice

* cl: no need to install docker twice

---------

Co-authored-by: Daniel Bennett <dbennett@hashicorp.com>
This pull request was closed.
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.

2 participants