Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Kubernetes]: The kube server could be used as http-proxy for docker #7469

Merged
merged 17 commits into from
Jun 16, 2021

Conversation

renukamanavalan
Copy link
Contributor

Why I did it

The SONiC switches get their docker images from local repo, populated during install with container images pre-built into SONiC FW. With the introduction of kubernetes, new docker images available in remote repo could be deployed. This requires dockerd to be able to pull images from remote repo.

Depending on the Switch network domain & config, it may or may not be able to reach the remote repo. In the case where remote repo is unreachable, we could potentially make Kubernetes server to also act as http-proxy.

How I did it

When admin explicitly enables, the kubernetes-server could be configured as docker-proxy. But any update to docker-proxy has to be via service-conf file environment variable, implying a "service restart docker" is required. But restart of dockerd is vey expensive, as it would restarts all dockers, including database docker.

To avoid dockerd restart, pre-configure an http_proxy using an unused IP. When k8s server is enabled to act as http-proxy, an IP table entry would be created to direct all traffic to the configured-unused-proxy-ip to the kubernetes-master IP. This way any update to Kubernetes master config would be just manipulating IPTables, which will be transparent to all modules, until dockerd needs to download from remote repo.

How to verify it

Configure a switch such that image repo is unreachable
Pre-configure dockerd with http_proxy.conf using an unused IP (e.g. 172.16.1.1)
Update ctrmgrd.service to invoke ctrmgrd.py with "-p" option.
Configure a k8s server, and deploy an image for feature with set_owner="kube"
Check if switch could successfully download the image or not.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • [ x] 202012

Description for the changelog

A picture of a cute animal (not mandatory but encouraged)

…plicitly.

If enabled, it expects docker to have a http-proxy with an IP (likely a local/private IP)
If docker do have http-proxy, it creates an IPTable entry to direct any traffic
to that IP to the configured Kubernetes master. Undo the IPTables when
kube server is removed.
@lgtm-com
Copy link

lgtm-com bot commented Apr 28, 2021

This pull request introduces 4 alerts when merging bf9fc28 into ccc7bd1 - view on LGTM.com

new alerts:

  • 2 for Except block handles 'BaseException'
  • 1 for Unused local variable
  • 1 for Unused import

No logical code changes.
isabelmsft
isabelmsft previously approved these changes May 7, 2021
@renukamanavalan
Copy link
Contributor Author

Looking at a different way of meeting this requirement. Hence closing.

@lgtm-com
Copy link

lgtm-com bot commented Jun 1, 2021

This pull request introduces 1 alert when merging 6753a0f into a557dbd - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Jun 1, 2021

This pull request introduces 1 alert when merging ce0f672 into a557dbd - view on LGTM.com

new alerts:

  • 1 for Unused import

isabelmsft
isabelmsft previously approved these changes Jun 5, 2021
@isabelmsft isabelmsft self-requested a review June 5, 2021 05:23
@isabelmsft isabelmsft dismissed their stale review June 5, 2021 05:26

syslog spewing errors, not able to test properly. will approve pending further testing

@renukamanavalan renukamanavalan merged commit f7ed82f into sonic-net:master Jun 16, 2021
qiluo-msft pushed a commit that referenced this pull request Jun 17, 2021
…7469)

Why I did it
The SONiC switches get their docker images from local repo, populated during install with container images pre-built into SONiC FW. With the introduction of kubernetes, new docker images available in remote repo could be deployed. This requires dockerd to be able to pull images from remote repo.

Depending on the Switch network domain & config, it may or may not be able to reach the remote repo. In the case where remote repo is unreachable, we could potentially make Kubernetes server to also act as http-proxy.

How I did it
When admin explicitly enables, the kubernetes-server could be configured as docker-proxy. But any update to docker-proxy has to be via service-conf file environment variable, implying a "service restart docker" is required. But restart of dockerd is vey expensive, as it would restarts all dockers, including database docker.

To avoid dockerd restart, pre-configure an http_proxy using an unused IP. When k8s server is enabled to act as http-proxy, an IP table entry would be created to direct all traffic to the configured-unused-proxy-ip to the kubernetes-master IP. This way any update to Kubernetes master config would be just manipulating IPTables, which will be transparent to all modules, until dockerd needs to download from remote repo.

How to verify it
Configure a switch such that image repo is unreachable
Pre-configure dockerd with http_proxy.conf using an unused IP (e.g. 172.16.1.1)
Update ctrmgrd.service to invoke ctrmgrd.py with "-p" option.
Configure a k8s server, and deploy an image for feature with set_owner="kube"
Check if switch could successfully download the image or not.
yxieca added a commit that referenced this pull request Jun 30, 2021
lguohan pushed a commit that referenced this pull request Jun 30, 2021
… docker (#7469)" (#8023)

This change causes nightly test to fail due to the fake proxy IP is not reachable.

Reverts #7469

This reverts commit f7ed82f.
lguohan added a commit that referenced this pull request Jul 2, 2021
renukamanavalan added a commit that referenced this pull request Jul 12, 2021
renukamanavalan added a commit that referenced this pull request Jul 16, 2021
…roxy for docker (#7469)" (#8023)" (#8158)

This reverts commit 7236fa9.

Restore original PR #7469
renukamanavalan added a commit to renukamanavalan/sonic-buildimage that referenced this pull request Jul 20, 2021
carl-nokia pushed a commit to carl-nokia/sonic-buildimage that referenced this pull request Aug 7, 2021
…onic-net#7469)

Why I did it
The SONiC switches get their docker images from local repo, populated during install with container images pre-built into SONiC FW. With the introduction of kubernetes, new docker images available in remote repo could be deployed. This requires dockerd to be able to pull images from remote repo.

Depending on the Switch network domain & config, it may or may not be able to reach the remote repo. In the case where remote repo is unreachable, we could potentially make Kubernetes server to also act as http-proxy.

How I did it
When admin explicitly enables, the kubernetes-server could be configured as docker-proxy. But any update to docker-proxy has to be via service-conf file environment variable, implying a "service restart docker" is required. But restart of dockerd is vey expensive, as it would restarts all dockers, including database docker.

To avoid dockerd restart, pre-configure an http_proxy using an unused IP. When k8s server is enabled to act as http-proxy, an IP table entry would be created to direct all traffic to the configured-unused-proxy-ip to the kubernetes-master IP. This way any update to Kubernetes master config would be just manipulating IPTables, which will be transparent to all modules, until dockerd needs to download from remote repo.

How to verify it
Configure a switch such that image repo is unreachable
Pre-configure dockerd with http_proxy.conf using an unused IP (e.g. 172.16.1.1)
Update ctrmgrd.service to invoke ctrmgrd.py with "-p" option.
Configure a k8s server, and deploy an image for feature with set_owner="kube"
Check if switch could successfully download the image or not.
carl-nokia pushed a commit to carl-nokia/sonic-buildimage that referenced this pull request Aug 7, 2021
… docker (sonic-net#7469)" (sonic-net#8023)

This change causes nightly test to fail due to the fake proxy IP is not reachable.

Reverts sonic-net#7469

This reverts commit f7ed82f.
carl-nokia pushed a commit to carl-nokia/sonic-buildimage that referenced this pull request Aug 7, 2021
@renukamanavalan renukamanavalan deleted the proxy branch April 17, 2022 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants