ArgoCD imagePullSecrets
2 min readNov 24, 2023
Note on image pulling in ArgoCD from private gitlab repo.
It’s Private Repo so you must use deploy token. Add Deploy token in your gitlab project then you can use deploy token to pull image from ArgoCD.
First, add Deploy Token. Select Setting > Repository
Expand Deploy tokens and create deploy token.
Fill in Name, Username and check read_repository and read_registry.
You will get a new token.
Next, Add a secret to your K8S.
kubectl create secret docker-registry regcred-frontend \
--namespace=test-frontend \
--docker-server=https://registry.gitlab.com \
--docker-username=dev01 \
--docker-password=82xxW78WJscyMbPsYFhe \
--docker-email=dev01@gmail.com
Then, Your deployment.yml will be something like this.
kind: Deployment
apiVersion: apps/v1
metadata:
name: frontend-web
labels:
app: frontend-web
namespace: test-frontend
spec:
replicas: 1
selector:
matchLabels:
app: frontend-web
template:
metadata:
labels:
app: frontend-web
spec:
containers:
- name: frontend-web
image: registry.gitlab.com/krisadas/mytest/frontend:v0.0.11
ports:
- name: frontend-web
containerPort: 3000
env:
- name: BASE_PATH_API
valueFrom:
configMapKeyRef:
name: frontend-env
key: BASE_PATH_API
- name: BASE_API
valueFrom:
configMapKeyRef:
name: frontend-env
key: BASE_API
imagePullSecrets:
- name: regcred-frontend
Your ArgoCD now can pull from private gitlab repo.