Skip to content

Commit 90593ef

Browse files
authored
Merge pull request #2 from CentML/gflarity/doc_fixes
improve documentation
2 parents ce16a73 + 39814d1 commit 90593ef

File tree

3 files changed

+71
-5
lines changed

3 files changed

+71
-5
lines changed

README.md

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,91 @@ From an operational perspective:
1616

1717
## Quick Start
1818

19+
You'll need a credentials that can assume a role with the following policy. Note, you can substitute `*` with the ARN of the repository if you want to limit the role to a specific repository. For multiple specific repos, use add more statement with different ARNs.
20+
21+
```json
22+
{
23+
"Version": "2012-10-17",
24+
"Statement": [
25+
{
26+
"Effect": "Allow",
27+
"Action": [
28+
"ecr:GetAuthorizationToken",
29+
"ecr:GetDownloadUrlForLayer",
30+
"ecr:BatchGetImage",
31+
"ecr:BatchCheckLayerAvailability"
32+
],
33+
"Resource": "*"
34+
}
35+
]
36+
}
37+
```
38+
39+
1940
Setup your values.yaml for the helm chart. Specifically include the AWS credentials using the standard AWS SDK environment variables. The easiest way to issue long lived AWS credentials, the most secure way is to use [AWS OIDC](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc.html) with [Spiffe](https://spiffe.io/). The best reference for AWS SDK environment variables seems to be in the [AWS CLI documentation](https://docs.aws.amazon.com/cli/v1/userguide/cli-configure-envvars.html).
2041

21-
```yaml
2242

43+
```yaml
2344
pod:
2445
container:
2546
env:
47+
# How you authenticate to AWS is up to you, see AWS CLI documentation for more options
2648
- name: AWS_ACCESS_KEY_ID
2749
value: "EXAMPLE"
2850
- name: AWS_SECRET_ACCESS_KEY
2951
value: "EXAMPLE"
52+
53+
# Recommended that you assume a role with the policy above
54+
- name: AWS_ROLE_ARN
55+
value: "ARN of role with ECR permissions"
56+
57+
# Important, this must match the region in the image name(s)
3058
- name: AWS_REGION
31-
#important, this must match the region in the image name
3259
value: "us-east-1"
60+
61+
62+
3363
```
3464

3565

3666
```sh
37-
helm install ecr-anywhere ./charts/ecr-anywhere -f values.yaml
67+
helm repo add ecr-anywhere https://centml.github.io/ecr-anywhere
68+
helm repo update
69+
helm install ecr-anywhere ecr-anywhere/ecr-anywhere -f values.yaml
3870
```
3971

72+
Once deployed, you can test it by creating a namespace with the label `ecr-anywhere.centml.ai/namespace: "enabled"`, then a secret of type `kubernetes.io/dockerconfigjson` with the label `ecr-anywhere.centml.ai/managed: "true"`. It doesn't matter what the secret contains, the mutating webhook will overwrite it with fresh ECR credentials.
73+
74+
```yaml
75+
apiVersion: v1
76+
kind: Namespace
77+
metadata:
78+
name: test
79+
labels:
80+
ecr-anywhere.centml.ai/namespace: "enabled"
81+
---
82+
apiVersion: v1
83+
kind: Secret
84+
metadata:
85+
name: ecr-secret
86+
namespace: test
87+
labels:
88+
ecr-anywhere.centml.ai/managed: "true"
89+
type: kubernetes.io/dockerconfigjson
90+
data:
91+
.dockerconfigjson: "FAKE"
92+
---
93+
apiVersion: v1
94+
kind: Pod
95+
metadata:
96+
name: test-pod
97+
namespace: test
98+
labels:
99+
app: test
100+
spec:
101+
containers:
102+
- name: test-container
103+
image: 544849402588.dkr.ecr.us-east-1.amazonaws.com/test:923442bcd004d94c1f7447e1ae14f36d39d77b0e
104+
imagePullSecrets:
105+
- name: ecr-secret
106+
```yaml

charts/ecr-anywhere/values.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ mutatingWebhookConfiguration:
2020
annotations: {}
2121

2222
image:
23-
# TODO Temporary personal repo
2423
repository: ghcr.io/centml/ecr-anywhere
2524
tag: v1.0.0
2625
imagePullPolicy: Always

pkg/credentials/credentials.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func NewECRCredentialInjector(ecrClient ECRClient, loggers *loggers.Loggers) Cre
7676
}
7777
}
7878

79-
// InjectionPermitted determines whether a mutation is required for the specified pod and if so
79+
// InjectionPermitted determines whether a mutation is required for the specified secret and if so
8080
// which mutation to use
8181
func (ic *ecrCredentialInjector) InjectionPermitted(ignoredList []string, metadata *metav1.ObjectMeta) bool {
8282
// skip special kubernete system namespaces

0 commit comments

Comments
 (0)