---
# System prepended metadata

title: 跨專案artifact
tags: [GCP, cicd]

---

# 跨專案artifact
https://cloud.google.com/artifact-registry/docs/access-control?hl=zh-cn#gcloud
# 先創建服務帳號,且賦予權限,再將服務帳號的key載下來
# 再叢集中加入key
```
kubectl create secret docker-registry artifact-registry \
--docker-server=https://asia-southeast1-docker.pkg.dev \
--docker-email=test@developer.gserviceaccount.com \
--docker-username=_json_key \
--docker-password="$(cat test-gke-jp-0ec332185a65.json)"
```
# 編輯default服務帳號
```
kubectl edit serviceaccount default --namespace default
```
# 將此段加入文件中

```
imagePullSecrets:
- name: artifact-registry
```