-
Notifications
You must be signed in to change notification settings - Fork 521
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
models, containerd, ecs-agent, host-ctr: support registry credentials #1955
Merged
etungsten
merged 6 commits into
bottlerocket-os:develop
from
etungsten:registry-credentials
Mar 7, 2022
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a185b30
models, containerd, ecs-agent: add 'container-registry.credentials'
etungsten 068bb47
host-ctr: move registryHosts to the registry pkg
etungsten 3d7b770
host-ctr: configure resolver's registry auth based on registry config
etungsten b70f945
ecs-agent, host-ctr, containerd: add mount units for configuration di…
etungsten 20a7ddd
README: add info about "settings.container-registry.credentials"
etungsten 6f59a59
migrations: add migrations for 'settings.container-registry.credentials'
etungsten 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
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
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
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,16 @@ | ||
[Unit] | ||
Description=Containerd Configuration Directory (/etc/containerd) | ||
DefaultDependencies=no | ||
Conflicts=umount.target | ||
Before=local-fs.target umount.target | ||
After=selinux-policy-files.service | ||
Wants=selinux-policy-files.service | ||
|
||
[Mount] | ||
What=tmpfs | ||
Where=/etc/containerd | ||
Type=tmpfs | ||
Options=nosuid,nodev,noexec,noatime,context=system_u:object_r:secret_t:s0 | ||
|
||
[Install] | ||
WantedBy=preconfigured.target |
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 |
---|---|---|
@@ -1,2 +1,18 @@ | ||
ECS_LOGFILE=/var/log/ecs/ecs-agent.log | ||
ECS_LOGLEVEL="{{settings.ecs.loglevel}}" | ||
{{#if settings.container-registry.credentials~}} | ||
ECS_ENGINE_AUTH_TYPE=dockercfg | ||
ECS_ENGINE_AUTH_DATA='{ | ||
{{~#each settings.container-registry.credentials~}} | ||
{{~#unless @first~}},{{~/unless~}} | ||
{{~#if (eq registry "docker.io" )~}} | ||
"https://index.docker.io/v1/": | ||
{{~else~}} | ||
"{{registry}}": | ||
{{~/if~}} | ||
{"email": "." | ||
{{~#if auth~}},"auth": "{{{auth}}}"{{/if}} | ||
{{~#if username~}},"username": "{{{username}}}"{{/if}} | ||
{{~#if password~}},"password": "{{{password}}}"}{{/if}} | ||
{{~/each~}}}}' | ||
{{/if}} |
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,16 @@ | ||
[Unit] | ||
Description=ECS agent Configuration Directory (/etc/ecs) | ||
DefaultDependencies=no | ||
Conflicts=umount.target | ||
Before=local-fs.target umount.target | ||
After=selinux-policy-files.service | ||
Wants=selinux-policy-files.service | ||
|
||
[Mount] | ||
What=tmpfs | ||
Where=/etc/ecs | ||
Type=tmpfs | ||
Options=nosuid,nodev,noexec,noatime,context=system_u:object_r:secret_t:s0 | ||
|
||
[Install] | ||
WantedBy=preconfigured.target |
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,5 @@ | ||
[clarify."sigs.k8s.io/yaml"] | ||
expression = "MIT AND BSD-3-Clause" | ||
license-files = [ | ||
{ path = "LICENSE", hash = 0xcdf3ae00 }, | ||
] |
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,16 @@ | ||
[Unit] | ||
Description=Host containers Configuration Directory (/etc/host-containers) | ||
DefaultDependencies=no | ||
Conflicts=umount.target | ||
Before=local-fs.target umount.target | ||
After=selinux-policy-files.service | ||
Wants=selinux-policy-files.service | ||
|
||
[Mount] | ||
What=tmpfs | ||
Where=/etc/host-containers | ||
Type=tmpfs | ||
Options=nosuid,nodev,noexec,noatime,context=system_u:object_r:secret_t:s0 | ||
|
||
[Install] | ||
WantedBy=preconfigured.target |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
10 changes: 10 additions & 0 deletions
10
sources/api/migration/migrations/v1.6.2/container-registry-credentials-metadata/Cargo.toml
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,10 @@ | ||
[package] | ||
name = "container-registry-credentials-metadata" | ||
version = "0.1.0" | ||
authors = ["Erikson Tung <etung@amazon.com>"] | ||
license = "Apache-2.0 OR MIT" | ||
edition = "2018" | ||
publish = false | ||
|
||
[dependencies] | ||
migration-helpers = { path = "../../../migration-helpers", version = "0.1.0"} |
31 changes: 31 additions & 0 deletions
31
sources/api/migration/migrations/v1.6.2/container-registry-credentials-metadata/src/main.rs
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,31 @@ | ||
#![deny(rust_2018_idioms)] | ||
|
||
use migration_helpers::common_migrations::{AddMetadataMigration, SettingMetadata}; | ||
use migration_helpers::{migrate, Result}; | ||
use std::process; | ||
|
||
/// We added a new setting and `affected-services` metadata for `container-registry.credentials` | ||
/// We subdivided metadata for `container-registry` into `container-registry.mirrors` and `container-registry.credentials` | ||
/// This is for the docker variants where don't want to restart the docker daemon when credentials settings change. | ||
fn run() -> Result<()> { | ||
migrate(AddMetadataMigration(&[ | ||
SettingMetadata { | ||
metadata: &["affected-services"], | ||
setting: "settings.container-registry.credentials", | ||
}, | ||
SettingMetadata { | ||
metadata: &["affected-services"], | ||
setting: "settings.container-registry.mirrors", | ||
}, | ||
])) | ||
} | ||
|
||
// Returning a Result from main makes it print a Debug representation of the error, but with Snafu | ||
// we have nice Display representations of the error, so we wrap "main" (run) and print any error. | ||
// /~https://github.com/shepmaster/snafu/issues/110 | ||
fn main() { | ||
if let Err(e) = run() { | ||
eprintln!("{}", e); | ||
process::exit(1); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
sources/api/migration/migrations/v1.6.2/container-registry-credentials/Cargo.toml
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,10 @@ | ||
[package] | ||
name = "container-registry-credentials" | ||
version = "0.1.0" | ||
authors = ["Erikson Tung <etung@amazon.com>"] | ||
license = "Apache-2.0 OR MIT" | ||
edition = "2018" | ||
publish = false | ||
|
||
[dependencies] | ||
migration-helpers = { path = "../../../migration-helpers", version = "0.1.0"} |
22 changes: 22 additions & 0 deletions
22
sources/api/migration/migrations/v1.6.2/container-registry-credentials/src/main.rs
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,22 @@ | ||
#![deny(rust_2018_idioms)] | ||
|
||
use migration_helpers::common_migrations::AddPrefixesMigration; | ||
use migration_helpers::{migrate, Result}; | ||
use std::process; | ||
|
||
/// We added a new setting for configuring image credentials, `settings.container-registry.credentials` | ||
fn run() -> Result<()> { | ||
migrate(AddPrefixesMigration(vec![ | ||
"settings.container-registry.credentials", | ||
])) | ||
} | ||
|
||
// Returning a Result from main makes it print a Debug representation of the error, but with Snafu | ||
// we have nice Display representations of the error, so we wrap "main" (run) and print any error. | ||
// /~https://github.com/shepmaster/snafu/issues/110 | ||
fn main() { | ||
if let Err(e) = run() { | ||
eprintln!("{}", e); | ||
process::exit(1); | ||
} | ||
} |
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.
There's a potential edge case if someone specifies
docker.io
andregistry-1.docker.io
, where we'd end up with two entries. Not sure if that's worth handling though, especially if it doesn't cause an error in the client. I'd be OK with undefined or non-deterministic behavior.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.
Good call out. I tested this and containerd does complain about duplicate entries and then refuse to start:
But I kinda see setting both
docker.io
andregistry-1.docker.io
akin to setting the same registry twice which would also make containerd fail.We do not enforce uniqueness of the registries in the
container-registry.credentials
settings model. We would essentially need to wrapVec<RegistryCredential>
into its own settings model type that would special casedocker.io
and enforce uniqueness of theregistry
field. Lemme know what you think!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.
Alternatively, I can remove this conditional and we can just make users specify
registry-1.docker.io
when they want to set up credentials for dockerhub. And for ECS variants,https://index.docker.io/v1/
.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.
I'm good with your current approach, after further thought and based on our discussion out of band.
Without the conditional, on
aws-ecs-1
to override registry credentials for Docker Hub, you'd need to specify both so thathost-ctr
andecs-agent
both get the form they expect (and ignore the other form). That's awkward and confusing enough that it's worth the extra bit implementation effort to paper over it.