0

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.

merlin2011
  • 273
  • 1
  • 12
  • 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 ...) – mdaniel Apr 04 '23 at 01:40
  • @mdaniel There is no `Service` section documented in the man page. Is that issue referring to a different configuration file for `containerd`? – merlin2011 Apr 04 '23 at 03:37
  • 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 Apr 04 '23 at 08:02
  • 1
    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. – Veera Nagireddy Apr 04 '23 at 09:42
  • 1
    @VeeraNagireddy The second link addressed my question. Thanks! – merlin2011 Apr 05 '23 at 03:47
  • Glad to hear that @merlin2011. Posting it as an answer for better community visibility. – Veera Nagireddy Apr 05 '23 at 03:52

1 Answers1

1

Refer to How to automate HTTP proxy configuration for Amazon EKS containerd nodes for more information.

Veera Nagireddy
  • 523
  • 2
  • 6
  • 1
    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. – merlin2011 Apr 05 '23 at 04:09