-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
e2e podman private registry #17642
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
79844cb
e2e: add tests for using private registry with podman driver
shoenig abaa4fd
packer: use nomad-driver-podman v0.5.0
shoenig 675ad74
e2e: eliminate unnecessary chmod
shoenig 5e2d6be
cr: no need to install nomad twice
shoenig 3777d6d
cl: no need to install docker twice
shoenig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
# This job runs a podman task using a container stored in a private registry | ||
# configured with basic authentication. The registry.hcl job should be running | ||
# and healthy before running this job. The registry_address and registry_port | ||
# HCL variables must be provided. | ||
|
||
variable "registry_address" { | ||
type = string | ||
description = "The HTTP address of the local registry" | ||
default = "localhost" | ||
} | ||
|
||
variable "registry_port" { | ||
type = number | ||
description = "The HTTP port of the local registry" | ||
default = "7511" | ||
} | ||
|
||
variable "registry_username" { | ||
type = string | ||
description = "The Basic Auth username of the local registry" | ||
default = "auth_basic_user" | ||
} | ||
|
||
variable "registry_password" { | ||
type = string | ||
description = "The Basic Auth password of the local registry" | ||
default = "auth_basic_pass" | ||
} | ||
|
||
locals { | ||
registry_auth = base64encode("${var.registry_username}:${var.registry_password}") | ||
} | ||
|
||
job "auth_basic" { | ||
type = "batch" | ||
|
||
constraint { | ||
attribute = "${attr.kernel.name}" | ||
value = "linux" | ||
} | ||
|
||
group "basic" { | ||
reschedule { | ||
attempts = 0 | ||
unlimited = false | ||
} | ||
|
||
network { | ||
mode = "host" | ||
} | ||
|
||
task "echo" { | ||
driver = "podman" | ||
|
||
config { | ||
image = "${var.registry_address}:${var.registry_port}/docker.io/library/bash_auth_basic:private" | ||
args = ["echo", "The auth basic test is OK!"] | ||
auth_soft_fail = true | ||
|
||
auth { | ||
username = "${var.registry_username}" | ||
password = "${var.registry_password}" | ||
tls_verify = false | ||
} | ||
} | ||
|
||
resources { | ||
cpu = 100 | ||
memory = 64 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
# This job runs a podman task using a container stored in a private registry | ||
# configured with credentials helper authentication. The registry.hcl job should | ||
# be running and healthy before running this job. | ||
|
||
variable "registry_address" { | ||
type = string | ||
description = "The HTTP address of the local registry" | ||
default = "localhost" | ||
} | ||
|
||
variable "registry_port" { | ||
type = number | ||
description = "The HTTP port of the local registry" | ||
default = "7511" | ||
} | ||
|
||
job "auth_static" { | ||
type = "batch" | ||
|
||
constraint { | ||
attribute = "${attr.kernel.name}" | ||
value = "linux" | ||
} | ||
|
||
group "helper" { | ||
reschedule { | ||
attempts = 0 | ||
unlimited = false | ||
} | ||
|
||
network { | ||
mode = "host" | ||
} | ||
|
||
task "echo" { | ||
driver = "podman" | ||
|
||
config { | ||
image = "${var.registry_address}:${var.registry_port}/docker.io/library/bash_auth_helper:private" | ||
args = ["echo", "The credentials helper auth test is OK!"] | ||
|
||
auth { | ||
# usename and password come from [docker-credential-]test.sh found on | ||
# $PATH as specified by "helper=test.sh" in plugin config | ||
tls_verify = false | ||
} | ||
} | ||
|
||
resources { | ||
cpu = 100 | ||
memory = 64 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
# This job runs a podman task using a container stored in a private registry | ||
# configured with file config static authentication. The registry.hcl job should | ||
# be running and healthy before running this job. | ||
|
||
variable "registry_address" { | ||
type = string | ||
description = "The HTTP address of the local registry" | ||
default = "localhost" | ||
} | ||
|
||
variable "registry_port" { | ||
type = number | ||
description = "The HTTP port of the local registry" | ||
default = "7511" | ||
} | ||
|
||
job "auth_static" { | ||
type = "batch" | ||
|
||
constraint { | ||
attribute = "${attr.kernel.name}" | ||
value = "linux" | ||
} | ||
|
||
group "static" { | ||
reschedule { | ||
attempts = 0 | ||
unlimited = false | ||
} | ||
|
||
network { | ||
mode = "host" | ||
} | ||
|
||
task "echo" { | ||
driver = "podman" | ||
|
||
config { | ||
image = "${var.registry_address}:${var.registry_port}/docker.io/library/bash_auth_static:private" | ||
args = ["echo", "The static auth test is OK!"] | ||
|
||
auth { | ||
# usename and password come from auth.json in plugin config | ||
tls_verify = false | ||
} | ||
} | ||
|
||
resources { | ||
cpu = 100 | ||
memory = 64 | ||
} | ||
} | ||
} | ||
} | ||
|
||
# auth.json (must be pointed to by config=<path>/auth.json) | ||
# | ||
# { | ||
# "auths": { | ||
# "127.0.0.1:7511/docker.io/library/bash_auth_static": { | ||
# "auth": "YXV0aF9zdGF0aWNfdXNlcjphdXRoX3N0YXRpY19wYXNz" | ||
# } | ||
# } | ||
# } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
# 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 | ||
# - /etc/docker-registry-auth.json | ||
|
||
variable "registry_address" { | ||
type = string | ||
description = "The HTTP address of the local registry" | ||
} | ||
|
||
variable "auth_dir" { | ||
type = string | ||
description = "The destination directory of the auth.json file." | ||
default = "/tmp" | ||
} | ||
|
||
variable "helper_dir" { | ||
type = string | ||
description = "The directory in which test.sh will be written." | ||
default = "/tmp" | ||
} | ||
|
||
variable "user" { | ||
type = string | ||
description = "The user to create files as. Should be root in e2e." | ||
# no default because dealing with root files is annoying locally | ||
# try -var=user=$USER for local development | ||
} | ||
|
||
job "registry-auths" { | ||
type = "sysbatch" | ||
|
||
constraint { | ||
attribute = "${attr.kernel.name}" | ||
value = "linux" | ||
} | ||
|
||
group "create-files" { | ||
reschedule { | ||
attempts = 0 | ||
unlimited = false | ||
} | ||
|
||
# write out the test.sh file into var.helper_dir | ||
task "create-helper-file" { | ||
driver = "pledge" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fun use of |
||
user = "${var.user}" | ||
|
||
config { | ||
command = "cp" | ||
args = ["${NOMAD_TASK_DIR}/test.sh", "${var.helper_dir}/docker-credential-test.sh"] | ||
promises = "stdio rpath wpath cpath" | ||
unveil = ["r:${NOMAD_TASK_DIR}/test.sh", "rwc:${var.helper_dir}"] | ||
} | ||
template { | ||
destination = "local/test.sh" | ||
perms = "755" | ||
data = <<EOH | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
value=$(cat /dev/stdin) | ||
|
||
username="auth_helper_user" | ||
password="auth_helper_pass" | ||
|
||
case "${value}" in | ||
docker.io/*) | ||
echo "must use local registry" | ||
exit 3 | ||
;; | ||
*) | ||
echo "{\"Username\": \"$username\", \"Secret\": \"$password\"}" | ||
exit 0 | ||
;; | ||
esac | ||
EOH | ||
} | ||
resources { | ||
cpu = 100 | ||
memory = 32 | ||
} | ||
} | ||
|
||
# write out the auth.json file into var.auth_dir | ||
task "create-auth-file" { | ||
driver = "pledge" | ||
user = "${var.user}" | ||
|
||
config { | ||
command = "cp" | ||
args = ["${NOMAD_TASK_DIR}/auth.json", "${var.auth_dir}/auth.json"] | ||
promises = "stdio rpath wpath cpath" | ||
unveil = ["r:${NOMAD_TASK_DIR}/auth.json", "rwc:${var.auth_dir}"] | ||
} | ||
template { | ||
perms = "644" | ||
destination = "local/auth.json" | ||
data = <<EOH | ||
{ | ||
"auths": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one's pretty trivial, but I like |
||
"${var.registry_address}:/docker.io/library/bash_auth_static": { | ||
"auth": "YXV0aF9zdGF0aWNfdXNlcjphdXRoX3N0YXRpY19wYXNz" | ||
} | ||
} | ||
} | ||
EOH | ||
} | ||
resources { | ||
cpu = 100 | ||
memory = 32 | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this is "docker-credential-" rather than "podman-credential-" because the registry itself is docker?
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'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.