FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(k3s): add configuration parameter for disabling cgroup mount to avoid "unable to apply cgroup configuration" by alexanderankin · Pull Request #592 · testcontainers/testcontainers-python · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
9 changes: 7 additions & 2 deletions modules/k3s/testcontainers/k3s/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# License for the specific language governing permissions and limitations
# under the License.

import logging

from testcontainers.core.config import testcontainers_config
from testcontainers.core.container import DockerContainer
from testcontainers.core.waiting_utils import wait_for_logs
Expand All @@ -37,13 +39,16 @@ class K3SContainer(DockerContainer):
KUBE_SECURE_PORT = 6443
RANCHER_WEBHOOK_PORT = 8443

def __init__(self, image="rancher/k3s:latest", **kwargs) -> None:
def __init__(self, image="rancher/k3s:latest", enable_cgroup_mount=True, **kwargs) -> None:
super().__init__(image, **kwargs)
self.with_exposed_ports(self.KUBE_SECURE_PORT, self.RANCHER_WEBHOOK_PORT)
self.with_env("K3S_URL", f"https://{self.get_container_host_ip()}:{self.KUBE_SECURE_PORT}")
self.with_command("server --disable traefik --tls-san=" + self.get_container_host_ip())
self.with_kwargs(privileged=True, tmpfs={"/run": "", "/var/run": ""})
self.with_volume_mapping("/sys/fs/cgroup", "/sys/fs/cgroup", "rw")
if enable_cgroup_mount:
self.with_volume_mapping("/sys/fs/cgroup", "/sys/fs/cgroup", "rw")
else:
logging.warning("'enable_cgroup_mount' is experimental, see testcontainers/testcontainers-python#591)")

def _connect(self) -> None:
wait_for_logs(self, predicate="Node controller sync successful", timeout=testcontainers_config.timeout)
Expand Down

Back | FazBrowse Home | New Git URL