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

Fix kubernetes cert connections #4519

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions codalab/worker/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,9 @@ def main():
# Create temp file to store kubernetes cert, as we need to pass in a file path.
# TODO: Delete the file afterwards (upon CodaLab service stop?)
with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
f.write(
args.kubernetes_cert.replace(r'\n', '\n')
) # Properly add newlines, which appear as "\n" if specified in the environment variable.
f.write(args.kubernetes_cert)
kubernetes_cert_path = f.name
logger.info('Temporarily writing kubernetes cert to: %s', kubernetes_cert_path)
logger.info('Temporarily writing kubernetes cert to: %s', kubernetes_cert_path)
else:
kubernetes_cert_path = args.kubernetes_cert_path
bundle_runtime_class = KubernetesRuntime(
Expand Down
12 changes: 6 additions & 6 deletions codalab/worker_manager/kubernetes_worker_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ def add_arguments_to_subparser(subparser: ArgumentParser) -> None:
'--cert-path',
type=str,
help='Path to the SSL cert for the Kubernetes cluster',
required=True,
required=False,
default=os.getenv('CODALAB_CERT_PATH', '/dev/null'),
)
subparser.add_argument(
'--cert',
type=str,
help='Contents of the SSL cert for the Kubernetes cluster',
required=True,
required=False,
default=os.getenv('CODALAB_CERT', '/dev/null'),
)
subparser.add_argument(
'--nfs-volume-name', type=str, help='Name of the persistent volume for the NFS server.',
Expand Down Expand Up @@ -94,11 +96,9 @@ def __init__(self, args):
# Create temp file to store kubernetes cert, as we need to pass in a file path.
# TODO: Delete the file afterwards (upon CodaLab service stop?)
with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
f.write(
args.cert.replace(r'\n', '\n')
) # Properly add newlines, which appear as "\n" if specified in the environment variable.
f.write(args.cert)
cert_path = f.name
logger.info('Temporarily writing kubernetes cert to: %s', cert_path)
logger.info('Temporarily writing kubernetes cert to: %s', cert_path)
else:
cert_path = args.cert_path
configuration.ssl_ca_cert = cert_path
Expand Down
14 changes: 10 additions & 4 deletions docker_config/compose_files/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,15 @@ services:
--bundle-runtime ${CODALAB_WORKER_MANAGER_CPU_BUNDLE_RUNTIME}
--cluster-host ${CODALAB_WORKER_MANAGER_CPU_KUBERNETES_CLUSTER_HOST}
--auth-token ${CODALAB_WORKER_MANAGER_CPU_KUBERNETES_AUTH_TOKEN}
--cert-path ${CODALAB_WORKER_MANAGER_CPU_KUBERNETES_CERT_PATH}
--cert ${CODALAB_WORKER_MANAGER_CPU_KUBERNETES_CERT}
--cpus ${CODALAB_WORKER_MANAGER_CPU_DEFAULT_CPUS}
--memory-mb ${CODALAB_WORKER_MANAGER_CPU_DEFAULT_MEMORY_MB}
<<: *codalab-base
<<: *codalab-server
environment:
- CODALAB_USERNAME=${CODALAB_USERNAME}
- CODALAB_PASSWORD=${CODALAB_PASSWORD}
- CODALAB_CERT_PATH=${CODALAB_WORKER_MANAGER_CPU_KUBERNETES_CERT_PATH}
- CODALAB_CERT=${CODALAB_WORKER_MANAGER_CPU_KUBERNETES_CERT}
volumes:
- "${CODALAB_HOME}:${CODALAB_HOME}"
- ${CODALAB_WORKER_MANAGER_CPU_KUBERNETES_CERT_PATH}:${CODALAB_WORKER_MANAGER_CPU_KUBERNETES_CERT_PATH}:ro
Expand Down Expand Up @@ -336,13 +339,16 @@ services:
--bundle-runtime ${CODALAB_WORKER_MANAGER_GPU_BUNDLE_RUNTIME}
--cluster-host ${CODALAB_WORKER_MANAGER_GPU_KUBERNETES_CLUSTER_HOST}
--auth-token ${CODALAB_WORKER_MANAGER_GPU_KUBERNETES_AUTH_TOKEN}
--cert-path ${CODALAB_WORKER_MANAGER_GPU_KUBERNETES_CERT_PATH}
--cert ${CODALAB_WORKER_MANAGER_GPU_KUBERNETES_CERT}
--cpus ${CODALAB_WORKER_MANAGER_GPU_DEFAULT_CPUS}
--gpus ${CODALAB_WORKER_MANAGER_DEFAULT_GPUS}
--memory-mb ${CODALAB_WORKER_MANAGER_GPU_DEFAULT_MEMORY_MB}
<<: *codalab-base
<<: *codalab-server
environment:
- CODALAB_USERNAME=${CODALAB_USERNAME}
- CODALAB_PASSWORD=${CODALAB_PASSWORD}
- CODALAB_CERT_PATH=${CODALAB_WORKER_MANAGER_GPU_KUBERNETES_CERT_PATH}
- CODALAB_CERT=${CODALAB_WORKER_MANAGER_GPU_KUBERNETES_CERT}
volumes:
- "${CODALAB_HOME}:${CODALAB_HOME}"
- ${CODALAB_WORKER_MANAGER_GPU_KUBERNETES_CERT_PATH}:${CODALAB_WORKER_MANAGER_GPU_KUBERNETES_CERT_PATH}:ro
Expand Down
Loading