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

Commit ca32566

Browse files
authored
Merge pull request #838 from Random-Liu/add-auth-config
Add auth config
2 parents 5ad95b2 + 1d9a754 commit ca32566

99 files changed

Lines changed: 1152 additions & 5302 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/installation.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<!-- TODO(now) -->
21
# Install Containerd with Release Tarball
32
This document provides the steps to install `containerd` and its dependencies with the release tarball, and bring up a Kubernetes cluster using kubeadm.
43

docs/registry.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Configure Image Registry
22
This document describes the method to configure the image registry for `containerd` for use with the `cri` plugin.
33

4+
## Configure Registry Endpoint
45
With containerd, `docker.io` is the default image registry. You can also set up other image registries similar to docker.
56

67
To configure image registries create/modify the `/etc/containerd/config.toml` as follows:
@@ -19,4 +20,26 @@ The default configuration can be generated by `containerd config default > /etc/
1920
The endpoint is a list that can contain multiple image registry URLs split by commas. When pulling an image
2021
from a registry, containerd will try these endpoint URLs one by one, and use the first working one.
2122

22-
After modify the config file, you need restart the `containerd` service.
23+
After modify this config, you need restart the `containerd` service.
24+
25+
## Configure Registry Credentials
26+
27+
`cri` plugin also supports docker like registry credential config.
28+
29+
To configure a credential for a specific registry endpoint, create/modify the
30+
`/etc/containerd/config.toml` as follows:
31+
```toml
32+
[plugins.cri.registry.auths]
33+
[plugins.cri.registry.auths."https://gcr.io"]
34+
username = ""
35+
password = ""
36+
auth = ""
37+
identitytoken = ""
38+
```
39+
The meaning of each field is the same with the corresponding field in `.docker/config.json`.
40+
41+
Please note that auth config passed by CRI takes precedence over this config.
42+
The registry credential in this config will only be used when auth config is
43+
not specified by Kubernetes via CRI.
44+
45+
After modify this config, you need restart the `containerd` service.

hack/verify-lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ set -o pipefail
2020
for d in $(find . -type d -a \( -iwholename './pkg*' -o -iwholename './cmd*' \) -not -iwholename './pkg/api*'); do
2121
echo for directory ${d} ...
2222
gometalinter \
23-
--exclude='error return value not checked.*(Close|Log|Print).*\(errcheck\)$' \
23+
--exclude='error return value not checked.*(Close|Log|Print|Fprint).*\(errcheck\)$' \
2424
--exclude='.*_test\.go:.*error return value not checked.*\(errcheck\)$' \
2525
--exclude='duplicate of.*_test.go.*\(dupl\)$' \
2626
--exclude='.*/mock_.*\.go:.*\(golint\)$' \

pkg/config/config.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,32 @@ type CniConfig struct {
6161
// Mirror contains the config related to the registry mirror
6262
type Mirror struct {
6363
// Endpoints are endpoints for a namespace. CRI plugin will try the endpoints
64-
// one by one until a working one is found.
64+
// one by one until a working one is found. The endpoint must be a valid url
65+
// with host specified.
6566
Endpoints []string `toml:"endpoint" json:"endpoint"`
66-
// TODO (Abhi) We might need to add auth per namespace. Looks like
67-
// image auth information is passed by kube itself.
67+
}
68+
69+
// AuthConfig contains the config related to authentication to a specific registry
70+
type AuthConfig struct {
71+
// Username is the username to login the registry.
72+
Username string `toml:"username" json:"username"`
73+
// Password is the password to login the registry.
74+
Password string `toml:"password" json:"password"`
75+
// Auth is a base64 encoded string from the concatenation of the username,
76+
// a colon, and the password.
77+
Auth string `toml:"auth" json:"auth"`
78+
// IdentityToken is used to authenticate the user and get
79+
// an access token for the registry.
80+
IdentityToken string `toml:"identitytoken" json:"identitytoken"`
6881
}
6982

7083
// Registry is registry settings configured
7184
type Registry struct {
7285
// Mirrors are namespace to mirror mapping for all namespaces.
7386
Mirrors map[string]Mirror `toml:"mirrors" json:"mirrors"`
87+
// Auths are registry endpoint to auth config mapping. The registry endpoint must
88+
// be a valid url with host specified.
89+
Auths map[string]AuthConfig `toml:"auths" json:"auths"`
7490
}
7591

7692
// PluginConfig contains toml config related to CRI plugin,
@@ -81,7 +97,7 @@ type PluginConfig struct {
8197
// CniConfig contains config related to cni
8298
CniConfig `toml:"cni" json:"cni"`
8399
// Registry contains config related to the registry
84-
Registry `toml:"registry" json:"registry"`
100+
Registry Registry `toml:"registry" json:"registry"`
85101
// StreamServerAddress is the ip address streaming server is listening on.
86102
StreamServerAddress string `toml:"stream_server_address" json:"streamServerAddress"`
87103
// StreamServerPort is the port streaming server is listening on.

pkg/containerd/resolver/auth.go

Lines changed: 0 additions & 202 deletions
This file was deleted.

0 commit comments

Comments
 (0)