{"id":32905,"date":"2023-02-24T07:50:31","date_gmt":"2023-02-24T07:50:31","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=32905"},"modified":"2025-01-23T12:45:19","modified_gmt":"2025-01-23T12:45:19","slug":"kubernetes-pull-an-image-from-a-private-registry-using-yaml-and-helm-file","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/kubernetes-pull-an-image-from-a-private-registry-using-yaml-and-helm-file\/","title":{"rendered":"Kubernetes: Pull an Image from a Private Registry using Yaml and Helm File"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Method 1 &#8211; Change docker config default registry<\/h2>\n\n\n\n<p>To change the default registry for Docker to a private registry that requires authentication, you can follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create or edit the <code>\/etc\/docker\/daemon.json<\/code> file on your Docker host machine.<\/li>\n\n\n\n<li>Add the following lines to the file, replacing <code>your-registry<\/code> with the URL of your private registry and <code>your-username<\/code> and <code>your-password<\/code> with your registry credentials:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>{\n  \"auths\": {\n    \"your-registry\": {\n      \"auth\": \"your-username:your-password\"\n    }\n  },\n  \"registry-mirrors\": [\"https:\/\/your-registry\"]\n}\n<\/code><\/pre>\n\n\n\n<p>Note that the <code>auths<\/code> key is used to specify the credentials for your private registry, and the <code>registry-mirrors<\/code> key is used to specify the URL of the registry.<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>Save the file and exit.<\/li>\n\n\n\n<li>Restart the Docker daemon to apply the changes:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">$ <code>sudo systemctl restart docker\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li>Verify that the configuration has been applied by running the <code>docker info<\/code> command. You should see the URL of your registry listed under &#8220;Registry Mirrors&#8221;.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>$ docker info\n...\nRegistry Mirrors:\n  https:\/\/your-registry\/\n...\n<\/code><\/pre>\n\n\n\n<p>With this configuration, Docker will use your private registry as the default registry for pulling images and will authenticate with your registry credentials.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method 2 &#8211; Create a Secret based on existing credentials using in Pod Spec<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/kubernetes.io\/docs\/tasks\/configure-pod-container\/pull-image-private-registry\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/kubernetes.io\/docs\/tasks\/configure-pod-container\/pull-image-private-registry\/<\/a><\/li>\n\n\n\n<li>https:\/\/docs.gitlab.com\/runner\/install\/kubernetes.html#using-an-image-from-a-private-registry<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Method 3 &#8211; Create a Secret based on existing credentials using Helm chart<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"494\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/02\/helm-secret-registry-1024x494.jpg\" alt=\"\" class=\"wp-image-32915\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/02\/helm-secret-registry-1024x494.jpg 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/02\/helm-secret-registry-300x145.jpg 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/02\/helm-secret-registry-768x370.jpg 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/02\/helm-secret-registry.jpg 1041w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>https:\/\/stackoverflow.com\/questions\/49669077\/helm-chart-deployment-and-private-docker-repository<\/li>\n<\/ul>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/b670b6df2da35be2776a44d84224d2d6.js\"><\/script>\n","protected":false},"excerpt":{"rendered":"<p>Method 1 &#8211; Change docker config default registry To change the default registry for Docker to a private registry that requires authentication, you can follow these steps: { &#8220;auths&#8221;: {&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[4859],"tags":[],"class_list":["post-32905","post","type-post","status-publish","format-standard","hentry","category-kubernetes"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=32905"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32905\/revisions"}],"predecessor-version":[{"id":32916,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32905\/revisions\/32916"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=32905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=32905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=32905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}