Score:0

Is it possible to set env vars for containerd?

vn flag

I am currently trying to switch my K8 nodes from using dockerd to containerd. For environment-specific reasons, I ned to specify http_proxy.

In the dockerd world, I can specify environment variables by using the following steps.

  1. Putting lines such as the following into /etc/environment-systemd:
http_proxy=http://dns_name_of_my_proxy
  1. Adding the following line to /usr/lib/systemd/system/docker.service:
EnvironmentFile=-/etc/environment-systemd

How can I do the equivalent operation for containerd?

I looked at the man page for containerd's config and did not see any thing about setting environment variables for proxies.

in flag
It [certainly seems](https://github.com/containerd/containerd/issues/1990#issuecomment-403414959) the same `EnvironmentFile` trick should work, although it's possible containerd needs the variable to be uppercase and likely needs to be `HTTPS_PROXY=` if your upstream registry is over TLS (I always recommend setting them both to the same value since the good thing about standards ...)
merlin2011 avatar
vn flag
@mdaniel There is no `Service` section documented in the man page. Is that issue referring to a different configuration file for `containerd`?
Veera Nagireddy avatar
nl flag
You can set environment variables in a service’s containers with the environment attribute in your Compose file. It works in the same way as docker run **-e VARIABLE=VALUE ...**. See how to [Use the environment attribute](https://docs.docker.com/compose/environment-variables/set-environment-variables/#use-the-environment-attribute) for details.
Veera Nagireddy avatar
nl flag
Refer to official k8s doc on how to [Configure the kubelet to use containerd as its container runtime](https://kubernetes.io/docs/tasks/administer-cluster/migrating-from-dockershim/change-runtime-containerd/#configure-the-kubelet-to-use-containerd-as-its-container-runtime). If your using Amazon EKS, See [how to configure HTTP proxy for Amazon EKS containerd nodes](https://repost.aws/knowledge-center/eks-http-proxy-containerd-automation) for details.
merlin2011 avatar
vn flag
@VeeraNagireddy The second link addressed my question. Thanks!
Veera Nagireddy avatar
nl flag
Glad to hear that @merlin2011. Posting it as an answer for better community visibility.
Score:1
merlin2011 avatar
vn flag
Accepting this answer because it addresses the question. I should note that the Stackoverflow community prefers to have the content directly in the answer (vs a link-only answer), but I do not know much about the ServerFault community.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.