[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-22(UTC)"],[],[],null,["# Use a private image registry\n============================\n\nYour GKE on Azure installation can access public container images by\ndefault. This topic explains how to use GKE on Azure with a\nprivate container image repository, such as [Artifact Registry](/artifact-registry).\n\nBefore you begin\n----------------\n\nTo perform the steps on this page, first complete the following:\n\n- [Create a cluster](/kubernetes-engine/multi-cloud/docs/azure/how-to/create-cluster).\n- [Create a node pool](/kubernetes-engine/multi-cloud/docs/azure/how-to/create-node-pool).\n- [Configure cluster access for kubectl](/kubernetes-engine/multi-cloud/docs/azure/how-to/configure-cluster-access-for-kubectl).\n\n- Build a Docker image and push it to Artifact Registry. The examples in\n this page use the `hello-app` container. To build this container, follow the\n steps to\n [Build a container image](/kubernetes-engine/docs/tutorials/hello-app#building_the_container_image)\n and\n [Push the Docker image to Artifact Registry](/kubernetes-engine/docs/tutorials/hello-app#pushing_the_docker_image_to),\n part of the GKE on Google Cloud documentation.\n\nCheck for images on Artifact Registry\n-------------------------------------\n\nTo complete the rest of these steps, you need a container image. Get the name\nof your container images by performing the following steps:\n\n1. Configure the Docker command-line tool to authenticate to\n [Artifact Registry](/artifact-registry/docs) with Google Cloud SDK:\n\n gcloud auth configure-docker\n\n The `gcloud` command-line tool registers a credential helper for all\n Google-supported Docker registries.\n2. Confirm that your Artifact Registry includes an image with the `docker images`\n command.\n\n docker images\n\n Docker connects to Artifact Registry and returns the images available in your\n repository. For example, the response below shows a container image named\n `hello-app` in the \u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e repository on\n `us-west1-docker.pkg.dev`. \n\n REPOSITORY TAG IMAGE ID CREATED SIZE\n us-west1-docker.pkg.dev/\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e/hello-repo/hello-app v1 f7cfe0d58569 21 minutes ago 11.5MB\n\nIf you do not have a container image ready, create one by following the steps at\n[Deploying a containerized application](/kubernetes-engine/docs/tutorials/hello-app).\n\n### Create a Service Account\n\n| **Note:** The following service account will have access to all images in your project. For more information about restricting access, see [Granting permissions](/artifact-registry/docs/access-control#grant) in the Artifact Registry documentation.\n\nYour clusters authenticate using an Identity and Access Management (IAM)\n[service account](/iam/docs/service-accounts).\n\nTo create a new service account, follow these steps:\n\n1. Create an IAM service account with the Google Cloud CLI.\n\n gcloud iam service-accounts create \u003cvar translate=\"no\"\u003eACCOUNT_NAME\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eACCOUNT_NAME\u003c/var\u003e with the name of the new Google Cloud\n service account.\n2. Grant the service account\n [Artifact Registry permissions](/artifact-registry/docs/access-control#roles).\n\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e \\\n --member serviceAccount:\u003cvar translate=\"no\"\u003eACCOUNT_NAME\u003c/var\u003e@\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e.iam.gserviceaccount.com \\\n --role roles/artifactregistry.reader\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e with your Google Cloud project\n - \u003cvar translate=\"no\"\u003eACCOUNT_NAME\u003c/var\u003e with your Google Cloud service account name\n3. Download the account's service account key.\n\n gcloud iam service-accounts keys create registry-access-key.json \\\n --iam-account \u003cvar translate=\"no\"\u003eACCOUNT_NAME\u003c/var\u003e@\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e.iam.gserviceaccount.com\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e\n - \u003cvar translate=\"no\"\u003eACCOUNT_NAME\u003c/var\u003e\n\n | **Note:** The service account key allows access to privileged resources. Protect the key file after downloading it.\n\nYou are now ready to configure your user cluster to connect to\nArtifact Registry.\n\n### Save the key to your cluster\n\nTo provide the key to authenticate to Artifact Registry, save the service\naccount key as a Kubernetes\n[Secret](https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure)\nwith these steps:\n\n1. Use `kubectl` to create the Secret.\n\n kubectl create secret docker-registry registry-secret \\\n --docker-server=\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e-docker.pkg.dev \\\n --docker-username=_json_key \\\n --docker-email=\u003cvar translate=\"no\"\u003eACCOUNT_NAME\u003c/var\u003e@\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e.iam.gserviceaccount.com \\\n --docker-password=\"$(cat registry-access-key.json)\"\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: the regional or multi-regional [location](/artifact-registry/docs/repo-locations) of the repository.\n - \u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e\n - \u003cvar translate=\"no\"\u003eACCOUNT_NAME\u003c/var\u003e\n2. Delete the local copy of your service account key.\n\n rm registry-access-key.json\n\nYou can now reference this Secret in your workloads.\n\nCreate a workload with a private image\n--------------------------------------\n\nTo use an image from a private container repository with a workload, set\nthe field `spec.imagePullSecrets` to your Secret name. This field is in\ndifferent locations for [Pods](#creating_a_pod) and\n[Deployments](#creating_a_deployment).\n\n### Creating a Pod\n\nTo create a Pod that can access the container registry, you set the field\n`spec.imagePullSecrets` to your Secret name.\n\n1. Create a Pod that specifies `spec.imagePullSecrets`.\n\n apiVersion: v1\n kind: Pod\n metadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003ePOD_NAME\u003c/span\u003e\u003c/var\u003e\n spec:\n containers:\n - name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eCONTAINER_NAME\u003c/span\u003e\u003c/var\u003e\n image: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eLOCATION\u003c/span\u003e\u003c/var\u003e-docker.pkg.dev/\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e/hello-repo/hello-app:v1\n imagePullSecrets:\n - name: registry-secret\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePOD_NAME\u003c/var\u003e: your Pod's name\n - \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e: the name of the container inside the Pod\n - \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e\n - \u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e\n\n For example, to pull the image `hello-app`, copy the following YAML into a\n file named `hello-pod.yaml`. \n\n apiVersion: v1\n kind: Pod\n metadata:\n name: hello-pod\n spec:\n containers:\n - name: hello-container\n image: us-west1-docker.pkg.dev/example-project/hello-repo/hello-app:v1\n imagePullSecrets:\n - name: registry-secret\n\n2. Apply the configuration to your cluster with `kubectl`.\n\n kubectl apply -f hello-pod.yaml\n\n3. Confirm the pod is running with `kubectl get`.\n\n kubectl get pod/hello-pod\n\n The response includes one Pod with a status of `Running`. \n\n NAME READY STATUS RESTARTS AGE\n hello-pod 1/1 Running 0 15s\n\n### Creating a Deployment\n\n1. To use a private repository in a Deployment, you specify the\n `imagePullSecret` inside the template.\n\n For example, to configure a\n [Deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/)\n that uses the `hello-app` image, create a file named `hello-deployment.yaml`\n with the following contents: \n\n apiVersion: apps/v1\n kind: Deployment\n metadata:\n name: hello-app-deployment\n spec:\n selector:\n matchLabels:\n app: products\n department: sales\n replicas: 3\n template:\n metadata:\n labels:\n app: products\n department: sales\n spec:\n containers:\n - name: hello\n image: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eLOCATION\u003c/span\u003e\u003c/var\u003e-docker.pkg.dev/\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e/hello-repo/hello-app:v1\n env:\n - name: \"PORT\"\n value: \"50001\"\n imagePullSecrets:\n - name: registry-secret\n\n | **Note:** `imagePullSecrets` must have the same level of indentation as `containers`.\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e\n - \u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e\n2. Apply the configuration to your cluster with `kubectl`.\n\n kubectl apply -f hello-deployment.yaml\n\n3. Confirm that your Deployment is running with `kubectl pods`.\n\n kubectl get pods --selector=app=products\n\n The output displays three `Running` pods. \n\n NAME READY STATUS RESTARTS AGE\n hello-app-deployment-67d9c6d98c-b69f2 1/1 Running 0 14m\n hello-app-deployment-67d9c6d98c-d6k5c 1/1 Running 0 14m\n hello-app-deployment-67d9c6d98c-p2md5 1/1 Running 0 14m\n\nClean up\n--------\n\nTo remove the resources you created on this page, run these commands: \n\n kubectl apply -f hello-pod.yaml\n kubectl delete -f hello-deployment.yaml\n\nWhat's next\n-----------\n\n- Read the [Artifact Registry overview](/artifact-registry/docs/overview)."]]