[[["이해하기 쉬움","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-31(UTC)"],[],[],null,["# Using a private image registry\n\nThis topic describes how to use GKE on AWS with a private\ncontainer image repository, such as\n[Container Registry (GCR)](/container-registry).\n\nBefore you begin\n----------------\n\n\nBefore you start using GKE on AWS, make sure you have performed the following tasks:\n\n- Complete the [Prerequisites](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/prerequisites).\n\n\u003c!-- --\u003e\n\n- Install a [management service](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/installing-management).\n- Create a [user cluster](/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/creating-user-cluster).\n- From your `anthos-aws` directory, use `anthos-gke` to switch context to your user cluster. \n\n ```sh\n cd anthos-aws\n env HTTPS_PROXY=http://localhost:8118 \\\n anthos-gke aws clusters get-credentials CLUSTER_NAME\n ```\n Replace \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e with your user cluster name.\n- Have a Docker image built and pushed to Container Registry. The examples in this topic use the `hello-app` container, built with the steps from [Deploying a containerized application](/kubernetes-engine/docs/tutorials/hello-app) in the GKE on Google Cloud documentation.\n\nPrivate Container Registries\n----------------------------\n\nA container registry stores and distributes\n[container images](https://www.docker.com/resources/what-container).\nYour GKE on AWS installation can access public images by default.\n\n### Check for images on Container Registry\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 [Container Registry](/container-registry) with Google Cloud CLI:\n\n gcloud auth configure-docker\n\n The Google Cloud CLI registers a credential helper for all\n Google-supported Docker registries.\n2. Confirm that your Container Registry includes an image with `docker images`.\n\n docker images\n\n Docker connects to Container Registry and returns the images available in\n your Container Registry repository. For example, the response below\n shows a container image named `hello-app` in the \u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e\n repository. \n\n REPOSITORY TAG IMAGE ID CREATED SIZE\n gcr.io/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/hello-app v1 732f02cea7cb 12 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 Container Registry images in your project. To learn about restricting access, see [Granting IAM permissions](/container-registry/docs/access-control#grant) in the Container Registry documentation.\n\nYour user clusters authenticate using an Identity and Access Management (IAM)\n[service account](/iam/docs/service-accounts).\n\nTo create a new service account, perform the following 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 [access to Container Registry](https://cloud.google.com/container-registry/docs/access-control#permissions_and_roles).\n\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e \\\n --member serviceAccount:\u003cvar translate=\"no\"\u003eaccount-name\u003c/var\u003e@\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e.iam.gserviceaccount.com \\\n --role roles/storage.objectViewer\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eproject-id\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 key.json \\\n --iam-account \u003cvar translate=\"no\"\u003eaccount-name\u003c/var\u003e@\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e.iam.gserviceaccount.com\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e with your Google Cloud project\n - \u003cvar translate=\"no\"\u003eaccount-name\u003c/var\u003e with your Google Cloud service account name\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\nContainer Registry.\n\n### Define a Kubernetes Secret\n\nTo provide the key to authenticate to Container Registry, save the service\naccount key as a Kubernetes\n[Secret](https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure)\nby performing the following steps:\n\n1. Use `kubectl` to create the secret.\n\n env HTTPS_PROXY=http://localhost:8118 \\\n kubectl create secret docker-registry gcr-secret \\\n --docker-server=gcr.io \\\n --docker-username=_json_key \\\n --docker-email=\u003cvar translate=\"no\"\u003eaccount-name\u003c/var\u003e@\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e.iam.gserviceaccount.com \\\n --docker-password=\"$(cat key.json)\"\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e with your Google Cloud project\n - \u003cvar translate=\"no\"\u003eaccount-name\u003c/var\u003e with your Google Cloud service account name\n2. Delete the local copy of your service account key.\n\n rm 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, you 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: gcr.io/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/hello-app:v1\n imagePullSecrets:\n - name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003esecret-name\u003c/span\u003e\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003epod-name\u003c/var\u003e with your Pod's name\n - \u003cvar translate=\"no\"\u003econtainer-name\u003c/var\u003e with the name of the container inside the Pod\n - \u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e with your Google Cloud project\n - \u003cvar translate=\"no\"\u003esecret-name\u003c/var\u003e with the name of your registry secret\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: gcr.io/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/hello-app:v1\n imagePullSecrets:\n - name: gcr-secret\n\n2. Apply the configuration to your cluster with `kubectl`.\n\n env HTTPS_PROXY=http://localhost:8118 \\\n kubectl apply -f hello-pod.yaml\n\n3. Confirm the pod is running with `kubectl get`.\n\n env HTTPS_PROXY=http://localhost:8118 \\\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\n4. To use a private repository in a Deployment, you specify the\n `imagePullSecret` inside the template.\n\n For example, to create a\n [Deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/),\n of the `hello-app` image, create a file named `hello-deployment.yaml` with\n 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: \"gcr.io/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/hello-app:v1\"\n env:\n - name: \"PORT\"\n value: \"50001\"\n imagePullSecrets:\n - name: gcr-secret\n\n | **Note:** `imagePullSecrets` must have the same level of indentation as `containers`.\n5. Apply the configuration to your cluster with `kubectl`.\n\n env HTTPS_PROXY=http://localhost:8118 \\\n kubectl apply -f hello-deployment.yaml\n\n6. Confirm your Deployment is running with `kubectl pods`.\n\n env HTTPS_PROXY=http://localhost:8118 \\\n kubectl get pods --selector=app=products\n\n The output contains 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\nWhat's next\n-----------\n\n- Read the [Container Registry overview](/container-registry/docs/overview)."]]