Skip to content

Commit e0b505e

Browse files
committed
Add helm chart to rotate registry creds
1 parent 09e06ac commit e0b505e

8 files changed

Lines changed: 25 additions & 25 deletions

File tree

src/kubernetes/jit_ecr/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
apiVersion: v2
22
name: jit_ecr
33
version: 0.1.0
4-
description: Helm chart to manage ECR credentials for JIT using authentication APIs
4+
description: Helm chart to manage registry credentials for JIT using authentication APIs

src/kubernetes/jit_ecr/templates/NOTES.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{{- if .Values.client_id }}
22
{{- if .Values.secret }}
3-
Congratulations! You've installed the JIT ECR credentials manager.
3+
Congratulations! You've installed the JIT registry credentials manager.
44

55
To verify that the initial login was successful, run the following command:
66

77
kubectl logs -n {{ .Values.namespace }} $(kubectl get pods -n {{ .Values.namespace }} -l job-name=jit-ecr-initial-login --sort-by=.metadata.creationTimestamp --output=jsonpath='{.items[-1:].metadata.name}')
88

9-
This command will display the logs of the most recently created pod for the initial login job. Look for the message "ECR credentials updated successfully on <date>" at the end of the logs.
9+
This command will display the logs of the most recently created pod for the initial login job. Look for the message "registry credentials updated successfully on <date>" at the end of the logs.
1010

1111
If you don't see the success message or encounter any errors, you can describe the job for more information:
1212
kubectl describe job jit-ecr-initial-login -n {{ .Values.namespace }}
1313

14-
The ECR credentials secret has been created as {{ .Values.jit_ecr_secret_name }} in the {{ .Values.namespace }} namespace.
14+
The registry credentials secret has been created as {{ .Values.jit_ecr_secret_name }} in the {{ .Values.namespace }} namespace.
1515

1616
To verify the created secret, run:
1717
kubectl get secret {{ .Values.jit_ecr_secret_name }} --namespace {{ .Values.namespace }}
@@ -25,4 +25,4 @@ Error: "secret" value is mandatory.
2525
{{- end }}
2626
{{- else }}
2727
Error: "client_id" value is mandatory.
28-
{{- end }}
28+
{{- end }}

src/kubernetes/jit_ecr/templates/cronjob.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ spec:
4040
name: jit-ecr-script
4141
restartPolicy: OnFailure
4242
{{- end }}
43-
{{- end }}
43+
{{- end }}

src/kubernetes/jit_ecr/templates/jit_creds_secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ stringData:
1010
client_id: "{{ .Values.client_id }}"
1111
secret: "{{ .Values.secret }}"
1212
{{- end }}
13-
{{- end }}
13+
{{- end }

src/kubernetes/jit_ecr/templates/job.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ spec:
3535
name: jit-ecr-script
3636
restartPolicy: OnFailure
3737
{{- end }}
38-
{{- end }}
38+
{{- end }}

src/kubernetes/jit_ecr/templates/rolebinding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ subjects:
1111
roleRef:
1212
kind: Role
1313
name: role-access-to-jit-ecr-secret
14-
apiGroup: ""
14+
apiGroup: ""

src/kubernetes/jit_ecr/templates/script-configmap.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,28 @@ data:
4545
4646
echo "Access token obtained successfully"
4747
48-
# Use access token to get ECR credentials
49-
echo "Requesting ECR token..."
50-
ECR_RESPONSE=$(curl -s -w "\n%{http_code}" -X POST {{ .Values.jit_base_url }}/authentication/registry/login \
48+
# Use access token to get registry credentials
49+
echo "Requesting registry token..."
50+
REGISTRY_RESPONSE=$(curl -s -w "\n%{http_code}" -X POST {{ .Values.jit_base_url }}/authentication/registry/login \
5151
-H "Authorization: Bearer $ACCESS_TOKEN")
52-
ECR_STATUS=$(echo "$ECR_RESPONSE" | tail -n1)
53-
ECR_BODY=$(echo "$ECR_RESPONSE" | sed '$d')
52+
REGISTRY_STATUS=$(echo "$REGISTRY_RESPONSE" | tail -n1)
53+
REGISTRY_BODY=$(echo "$REGISTRY_RESPONSE" | sed '$d')
5454
55-
if [ "$ECR_STATUS" -ne 200 ]; then
56-
echo "Failed to obtain ECR token. HTTP Status: $ECR_STATUS"
57-
echo "Response body: $ECR_BODY"
55+
if [ "$REGISTRY_STATUS" -ne 200 ]; then
56+
echo "Failed to obtain registry token. HTTP Status: $REGISTRY_STATUS"
57+
echo "Response body: $REGISTRY_BODY"
5858
exit 1
5959
fi
6060
61-
ECR_TOKEN="$ECR_BODY"
61+
REGISTRY_TOKEN="$REGISTRY_BODY"
6262
63-
if [ -z "$ECR_TOKEN" ]; then
64-
echo "Failed to obtain ECR token"
65-
echo "Response body: $ECR_BODY"
63+
if [ -z "$REGISTRY_TOKEN" ]; then
64+
echo "Failed to obtain registry token"
65+
echo "Response body: $REGISTRY_BODY"
6666
exit 1
6767
fi
6868
69-
echo "ECR token obtained successfully"
69+
echo "registry token obtained successfully"
7070
7171
# Delete existing Kubernetes Docker registry secret (ignore if not found)
7272
echo "Deleting existing Kubernetes secret (if any)..."
@@ -77,10 +77,10 @@ data:
7777
kubectl create secret docker-registry {{ .Values.jit_ecr_secret_name }} \
7878
--docker-server={{ .Values.registry_name }} \
7979
--docker-username=AWS \
80-
--docker-password="$ECR_TOKEN" \
80+
--docker-password="$REGISTRY_TOKEN" \
8181
--namespace={{ .Values.namespace }}
8282
8383
# Get current date and time
8484
CURRENT_DATE=$(date "+%Y-%m-%d %H:%M:%S")
8585
86-
echo "ECR credentials updated successfully on $CURRENT_DATE"
86+
echo "Registry credentials updated successfully on $CURRENT_DATE"

src/kubernetes/jit_ecr/templates/serviceaccount.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ apiVersion: v1
22
kind: ServiceAccount
33
metadata:
44
name: sa-jit-ecr
5-
namespace: {{ .Values.namespace }}
5+
namespace: {{ .Values.namespace }}

0 commit comments

Comments
 (0)