Setting environment variable in kubernetes before pulling an imageECR IAM policy document for EKS node accessHow to estimate storage and traffic used for docker images in AWS ECR?Errors when using Google Container Engine (GKE) with Google Container Registry (GCR)kube-dns fails open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directoryCan't see pod logs in Stackdriver UI for cluster deployed on GKEAWS could not get token: AccessDenied: User: ARN is not authorized to perform: sts:AssumeRole on resource: Role:ARNWhat makes a kubernetes node unhealthy?In Kubernetes, how can a container created from a CronJob find out when it was scheduled?Kubernetes CrashLoopBackOff after pod create pulling image from Docker HubImagePullBackOff Kubernetes from Google Cloud Container RegistryECR IAM policy document for EKS node access

Transfer over $10k

Has any spacecraft ever had the ability to directly communicate with civilian air traffic control?

Why was Germany not as successful as other Europeans in establishing overseas colonies?

What happened to Ghost?

Airbnb - host wants to reduce rooms, can we get refund?

Is it the same airport YUL and YMQ in Canada?

Does the time required to copy a spell into a spellbook have to be consecutive, or is that just the cumulative time required?

Can fracking help reduce CO2?

A non-technological, repeating, visible object in the sky, holding its position in the sky for hours

When do aircrafts become solarcrafts?

How to avoid grep command finding commented out strings in the source file?

Write to EXCEL from SQL DB using VBA script

Selecting a secure PIN for building access

Visualizing a complicated Region

Surprising behavior of Part[ ]

How did Arya manage to disguise herself?

Is this homebrew race based on Draco Volans balanced?

Authors and contributors of forked project

Short story about people living in a different time streams

How to compensate for height when using a ranged attack

Survey Confirmation - Emphasize the question or the answer?

Floor tile layout process?

Is lying to get "gardening leave" fraud?

You look catfish vs You look like a catfish?



Setting environment variable in kubernetes before pulling an image


ECR IAM policy document for EKS node accessHow to estimate storage and traffic used for docker images in AWS ECR?Errors when using Google Container Engine (GKE) with Google Container Registry (GCR)kube-dns fails open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directoryCan't see pod logs in Stackdriver UI for cluster deployed on GKEAWS could not get token: AccessDenied: User: ARN is not authorized to perform: sts:AssumeRole on resource: Role:ARNWhat makes a kubernetes node unhealthy?In Kubernetes, how can a container created from a CronJob find out when it was scheduled?Kubernetes CrashLoopBackOff after pod create pulling image from Docker HubImagePullBackOff Kubernetes from Google Cloud Container RegistryECR IAM policy document for EKS node access






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Is there a way to set the environment variables in kubernetes before it pulls the container image?



For some context, I'm looking for alternatives to what I've asked in ECR IAM policy document for EKS node access. According to the kubernetes docs (https://kubernetes.io/docs/concepts/containers/images/#using-aws-ec2-container-registry), it sounds like what I want to do is not possible by default since if I give the node role permission to read from ECR, any user that can create jobs/pods on the EKS cluster will be able to pull any image that the node role can pick up. The line from the k8s docs in question is:




All users of the cluster who can create pods will be able to run pods that use any of the images in the ECR registry.




As an alternative, I'm trying to see if there's a way to set the environment variables (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) in the pod before it pulls the image. I'm not entirely sure on the implementation/integration for kubernetes with ECR, but if I think if I'm able to set those environment variables and the image pull process does a aws ecr get-login ... before actually pulling the image, then I might be able to restrict which images can be pulled by setting those variables.



I found some documentation on how to set variables in the container after the image has been pulled but nothing before.



  • envFrom/SecretEnvSource: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#envfromsource-v1-core

  • env: https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#define-an-environment-variable-for-a-container









share|improve this question






















  • Probably this might work for your use case : medium.com/merapar/… Hope it helps!

    – Piyush Baderia
    12 hours ago

















0















Is there a way to set the environment variables in kubernetes before it pulls the container image?



For some context, I'm looking for alternatives to what I've asked in ECR IAM policy document for EKS node access. According to the kubernetes docs (https://kubernetes.io/docs/concepts/containers/images/#using-aws-ec2-container-registry), it sounds like what I want to do is not possible by default since if I give the node role permission to read from ECR, any user that can create jobs/pods on the EKS cluster will be able to pull any image that the node role can pick up. The line from the k8s docs in question is:




All users of the cluster who can create pods will be able to run pods that use any of the images in the ECR registry.




As an alternative, I'm trying to see if there's a way to set the environment variables (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) in the pod before it pulls the image. I'm not entirely sure on the implementation/integration for kubernetes with ECR, but if I think if I'm able to set those environment variables and the image pull process does a aws ecr get-login ... before actually pulling the image, then I might be able to restrict which images can be pulled by setting those variables.



I found some documentation on how to set variables in the container after the image has been pulled but nothing before.



  • envFrom/SecretEnvSource: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#envfromsource-v1-core

  • env: https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#define-an-environment-variable-for-a-container









share|improve this question






















  • Probably this might work for your use case : medium.com/merapar/… Hope it helps!

    – Piyush Baderia
    12 hours ago













0












0








0








Is there a way to set the environment variables in kubernetes before it pulls the container image?



For some context, I'm looking for alternatives to what I've asked in ECR IAM policy document for EKS node access. According to the kubernetes docs (https://kubernetes.io/docs/concepts/containers/images/#using-aws-ec2-container-registry), it sounds like what I want to do is not possible by default since if I give the node role permission to read from ECR, any user that can create jobs/pods on the EKS cluster will be able to pull any image that the node role can pick up. The line from the k8s docs in question is:




All users of the cluster who can create pods will be able to run pods that use any of the images in the ECR registry.




As an alternative, I'm trying to see if there's a way to set the environment variables (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) in the pod before it pulls the image. I'm not entirely sure on the implementation/integration for kubernetes with ECR, but if I think if I'm able to set those environment variables and the image pull process does a aws ecr get-login ... before actually pulling the image, then I might be able to restrict which images can be pulled by setting those variables.



I found some documentation on how to set variables in the container after the image has been pulled but nothing before.



  • envFrom/SecretEnvSource: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#envfromsource-v1-core

  • env: https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#define-an-environment-variable-for-a-container









share|improve this question














Is there a way to set the environment variables in kubernetes before it pulls the container image?



For some context, I'm looking for alternatives to what I've asked in ECR IAM policy document for EKS node access. According to the kubernetes docs (https://kubernetes.io/docs/concepts/containers/images/#using-aws-ec2-container-registry), it sounds like what I want to do is not possible by default since if I give the node role permission to read from ECR, any user that can create jobs/pods on the EKS cluster will be able to pull any image that the node role can pick up. The line from the k8s docs in question is:




All users of the cluster who can create pods will be able to run pods that use any of the images in the ECR registry.




As an alternative, I'm trying to see if there's a way to set the environment variables (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) in the pod before it pulls the image. I'm not entirely sure on the implementation/integration for kubernetes with ECR, but if I think if I'm able to set those environment variables and the image pull process does a aws ecr get-login ... before actually pulling the image, then I might be able to restrict which images can be pulled by setting those variables.



I found some documentation on how to set variables in the container after the image has been pulled but nothing before.



  • envFrom/SecretEnvSource: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#envfromsource-v1-core

  • env: https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#define-an-environment-variable-for-a-container






amazon-web-services kubernetes amazon-ecr






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 22 at 12:54









Ai SuAi Su

61




61












  • Probably this might work for your use case : medium.com/merapar/… Hope it helps!

    – Piyush Baderia
    12 hours ago

















  • Probably this might work for your use case : medium.com/merapar/… Hope it helps!

    – Piyush Baderia
    12 hours ago
















Probably this might work for your use case : medium.com/merapar/… Hope it helps!

– Piyush Baderia
12 hours ago





Probably this might work for your use case : medium.com/merapar/… Hope it helps!

– Piyush Baderia
12 hours ago










0






active

oldest

votes












Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f964057%2fsetting-environment-variable-in-kubernetes-before-pulling-an-image%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Server Fault!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f964057%2fsetting-environment-variable-in-kubernetes-before-pulling-an-image%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

Esgonzo ibérico Índice Descrición Distribución Hábitat Ameazas Notas Véxase tamén "Acerca dos nomes dos anfibios e réptiles galegos""Chalcides bedriagai"Chalcides bedriagai en Carrascal, L. M. Salvador, A. (Eds). Enciclopedia virtual de los vertebrados españoles. Museo Nacional de Ciencias Naturales, Madrid. España.Fotos