You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Bound Service Account Token Flow](#bound-service-account-token-flow)
43
+
-[Pushing Credential Management into the CRI](#pushing-credential-management-into-the-cri)
35
44
-[Risks and Mitigations](#risks-and-mitigations)
36
45
-[Design Details](#design-details)
37
46
-[Test Plan](#test-plan)
@@ -44,74 +53,200 @@ status: provisional
44
53
45
54
## Release Signoff Checklist
46
55
47
-
-[] kubernetes/enhancements issue in release milestone, which links to KEP (this should be a link to the KEP location in kubernetes/enhancements, not the initial KEP PR)
48
-
-[] KEP approvers have set the KEP status to `implementable`
49
-
-[] Design details are appropriately documented
50
-
-[] Test plan is in place, giving consideration to SIG Architecture and SIG Testing input
51
-
-[] Graduation criteria is in place
56
+
-[x] kubernetes/enhancements issue in release milestone, which links to KEP (this should be a link to the KEP location in kubernetes/enhancements, not the initial KEP PR)
57
+
-[x] KEP approvers have set the KEP status to `implementable`
58
+
-[x] Design details are appropriately documented
59
+
-[x] Test plan is in place, giving consideration to SIG Architecture and SIG Testing input
60
+
-[x] Graduation criteria is in place
52
61
-[ ] "Implementation History" section is up-to-date for milestone
53
62
-[ ] User-facing documentation has been created in [kubernetes/website], for publication to [kubernetes.io]
54
63
-[ ] Supporting documentation e.g., additional design documents, links to mailing list discussions/SIG meetings, relevant PRs/issues, release notes
55
64
56
65
## Summary
57
66
58
-
Replace the existing in-tree container image registry (registry) credential providers with an external and pluggable credential provider mechanism and remove in-tree credential providers.
67
+
This KEP replaces the existing in-tree container image registry credential providers with an external and pluggable credential provider mechanism and removes the in-tree credential providers.
59
68
60
69
## Motivation
61
70
62
-
kubelet uses cloud provider specific SDKs to obtain credentials when pulling container images from cloud provider specific registries. The use of cloud provider specific SDKs from within the main Kubernetes tree is deprecated by [KEP-0002](https://github.com/kubernetes/enhancements/blob/master/keps/sig-cloud-provider/20180530-cloud-controller-manager.md) and all existing uses need to be migrated out-of-tree. This KEP supports that migration process by removing this SDK usage.
63
-
64
-
In addition to supporting cloud provider migration this KEP supports allowing users to support multiple container registries across different cloud providers by introducing a pluggable interface to cloud specific credential providers such that a single user could run multiple credential providers for different clouds at the same time. Currently this functionality is gated by having only a single, active cloud provider within the API server and kubelet.
71
+
Kubelet uses cloud provider specific SDKs to obtain credentials when pulling container images from cloud provider specific registries. The use of cloud provider specific SDKs from within the main Kubernetes tree is deprecated by [KEP-0002](https://github.com/kubernetes/enhancements/blob/master/keps/sig-cloud-provider/20180530-cloud-controller-manager.md) and all existing uses need to be migrated out-of-tree. This KEP supports that migration process by removing this SDK usage.
65
72
66
73
### Goals
67
74
68
-
* Develop/test/release an API for kubelet to obtain registry credentials from the API server
75
+
* Develop/test/release an interface for kubelet to obtain registry credentials from a cloud provider specific binary
69
76
* Update/test/release the credential acquisition logic within kubelet
70
77
* Build user documentation for out-of-tree credential providers
71
-
*Migrate existing in-tree credential providers to new credential provider interface
72
-
* Remove in-tree credential provider code from kuberentes core
78
+
*Support migration from existing in-tree credential providers to the new credential provider interface, along with dynamic roll back.
79
+
* Remove in-tree credential provider code from Kubernetes core
73
80
74
81
### Non-Goals
75
82
76
-
* Broad removal of cloud SDK usage, this effort falls under the [KEP for removing in-tree providers](https://github.com/kubernetes/enhancements/blob/master/keps/sig-cloud-provider/2019-01-25-removing-in-tree-providers.md).
83
+
* Broad removal of cloud SDK usage falls under the [KEP for removing in-tree providers](https://github.com/kubernetes/enhancements/blob/master/keps/sig-cloud-provider/2019-01-25-removing-in-tree-providers.md).
84
+
* Continuing to support projects that import the credential provider package.
77
85
78
86
## Proposal
79
87
80
-
### API Server Proxy
81
-
82
-
The API server will act as a proxy to an external container registry credential provider that may support multiple cloud providers. The credential provider service will return container runtime compatible responses of the type currently used by the credential provider infrastructure within the kubelet along with credential expiration information to allow the API server to cache credential responses for a period of time.
88
+
### External Credential Provider
89
+
90
+
An executable capable of providing container registry credentials will be pre-installed on each node so that it exists when kubelet starts running. This binary will be executed by the kubelet to obtain container registry credentials in a format compatible with container runtimes. Credential responses may be cached within the kubelet.
91
+
92
+
This architecture is similar to the approach taken by the exec based credential plugin architecture already present in client-go and CNI, and is a well understood pattern. The API types are modeled after the ExecConfig and ExecCredential in client-go which define exec based credential retrieval for similar use cases.
93
+
94
+
A `RegistryCredentialConfig` and `RegistryCredentialProvider` configuration API type (similar to [clientauthentication](https://github.com/kubernetes/kubernetes/tree/0273d43ae9486e9d0be292c01de2dd4143522b86/staging/src/k8s.io/client-go/pkg/apis/clientauthentication/v1beta1)) will be added to Kubernetes:
The RegistryCredentialConfig will be encoded in YAML and located in a file on disk. The exact path of the credential provider configuration file will be passed to kubelet via a new configuration option `RegistryCredentialConfigPath`.
141
+
142
+
We will create new types `RegistryCredentialPluginRequest` and `RegistryCredentialPluginResponse` which will define the interface between the plugin and the kubelet runtime. After the kubelet matches the image property string to a RegistryCredentialProvider, the kubelet will exec the plugin binary, and pass the JSON encoded request to the plugin via stdin. This includes the image that is to be pulled. The plugin will report back the response, which includes the credentials that kubelet needs to pull the image.
143
+
144
+
In the in-tree implementation, the docker keyring, which has N credential providers, returns an `[]AuthConfig` on a Lookup(image string) call. This struct will be populated by the plugin rather than the in-tree provider.
145
+
146
+
```go
147
+
// RegistryCredentialPluginRequest is passed to the plugin via stdin, and includes the image that will be pulled by kubelet.
148
+
typeRegistryCredentialPluginRequeststruct {
149
+
// Image is used when passed to registry credential providers as part of an
150
+
// image pull
151
+
Imagestring`json:"image"`
152
+
}
153
+
154
+
// RegistryCredentialPluginResponse holds credentials for the kubelet runtime
155
+
// to use for image pulls. It is returned from the plugin as stdout.
A registry credential provider configuration for Amazon ECR could look like the following:
182
+
183
+
```yaml
184
+
kind: credentialprovider
185
+
apiVersion: v1alpha1
186
+
providers:
187
+
-
188
+
imageMatchers:
189
+
- *.dkr.ecr.*.amazonaws.com
190
+
- *.dkr.ecr.*.amazonaws.com.cn
191
+
exec:
192
+
command: ecr-creds
193
+
args: token
194
+
apiVersion: v1alpha1
195
+
```
196
+
197
+
Where ecr-creds is a binary that vends ecr credentials. This would execute the binary `ecr-creds` with the argument `token` for the image `012345678910.dkr.ecr.us-east-1.amazonaws.com/my-image`.
198
+
199
+
### Alternatives Considered
200
+
201
+
#### API Server Proxy
202
+
203
+
The API server would act as a proxy to an external container registry credential provider that may support multiple cloud providers. The credential provider service will return container runtime compatible responses of the type currently used by the credential provider infrastructure within the kubelet along with credential expiration information to allow the API server to cache credential responses for a period of time.
83
204
84
205
This limits the cloud-specific privileges required for each node for the purpose of fetching credentials. Centralized caching helps to avoid cloud-specific rate limits for credential acquisition by consolidating that credential acquisition within the API server.
85
206
86
-
### Sidecar Credential Daemon
207
+
We chose not to follow this approach because although less privileges on each node and centralized caching are good, we have not seen enough evidence that these features are commonly requested by users. Also, it is outside the stated goals of this KEP. Lastly, taking the time to design such a system would probably take long enough to push back the date that we could extract the in-tree cloud providers completely from Kubernetes.
208
+
209
+
#### Sidecar Credential Daemon
87
210
88
-
Each node will run a sidecar credential daemon that can obtain cloud-specific container registry credentials and may support multiple cloud providers. This service will be available to the kubelet on the local host and will return container runtime responses compatible with those currently used by the credential provider infrastructure within kubelet. Each daemon will perform its own caching of credentials for the node on which it runs.
211
+
Each node would run a sidecar credential daemon that can obtain cloud-specific container registry credentials and may support multiple cloud providers. This service will be available to the kubelet on the local host and will return container runtime responses compatible with those currently used by the credential provider infrastructure within kubelet. Each daemon will perform its own caching of credentials for the node on which it runs.
89
212
90
-
This architecture is similar to the approach taken by CSI with node plugins and is a well understood deployment pattern.It limits fleet-wide cacheability of credentials.
213
+
The added complexity of running a daemon over executing a binary made this option less desirable to us. If a daemon implementation is necessary for a cloud provider, the binary can talk to one to retrieve credentials upon each execution.
91
214
92
-
###External Non-Daemon Executable
215
+
#### Bound Service Account Token Flow
93
216
94
-
An executable capable of providing container registry credentials will be installed on each node. This binary will be executed by the kubelet to obtain container registry credentials in a format compatible with container runtimes. Credential responses may be cached within the kubelet.
217
+
Suggested in https://github.com/kubernetes/kubernetes/issues/68810, an image pull flow built on bound service account tokens would provide kubelet with credentials to pull images for pods running as a specific service account.
95
218
96
-
This Architecture is similar to the approach taken by CNI and is a well understood deployment pattern. It limits fleet-wide cacheability of credentials.
219
+
This approach might be better suited as a future enhancement to either the credential provider or ImagePullSecrets, but is out of scope for extracting the cloud provider specific code.
220
+
221
+
#### Pushing Credential Management into the CRI
222
+
223
+
Another possibility is moving the credential management logic into the CRI, so that Kubelet doesn't provide any credentials for image pulls. Similarly, this approach is also out of scope for extracting cloud provider code because it would be a more significant redesign but should be considered for a future enhancement.
97
224
98
225
### Risks and Mitigations
99
226
100
-
TODO
227
+
This is a critical feature of kubelet and pods cannot start if it does not work correctly. This functionality will be labeled alpha and hidden behind a feature gate in v1.18. It will use DynamicKubeletConfig so that it can be disabled during runtime if any problems occur.
101
228
102
229
## Design Details
103
230
104
231
### Test Plan
105
232
106
-
TODO
233
+
* Unit tests for image matching logic.
234
+
* E2E tests for image pulls from cloud providers.
107
235
108
236
### Graduation Criteria
109
237
110
-
TODO
238
+
Successful Alpha Criteria
239
+
* Multiple plugin implentations created.
240
+
* One E2E test implemented.
111
241
112
242
### Upgrade / Downgrade Strategy
113
243
114
-
TODO
244
+
Upgrading
245
+
* Add any cloud provider plugin binaries for image repositories that you use to your worker nodes.
246
+
* Enable this feature in kubelet with a feature flag.
247
+
248
+
Downgrading
249
+
* Disable this feature in kubelet with a feature flag.
0 commit comments