Skip to content

Commit

Permalink
feat: allow for imagePullSecrets
Browse files Browse the repository at this point in the history
  • Loading branch information
bodom0015 committed May 21, 2024
1 parent d14a2c9 commit f78d996
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/kube.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ def create_userapp(username, email, userapp, spec_map):
'args': stack_service['args'] if 'args' in stack_service else app_spec[
'args'] if 'args' in app_spec else None,
'image': stack_service['image'] if 'image' in stack_service else app_spec['image'],
'imagePullPolicy': 'Always',
'configmap': resource_name,
'security_context': app_spec['securityContext'] if 'securityContext' in app_spec else None,
'volume_mounts': volume_mounts,
Expand Down Expand Up @@ -624,6 +623,7 @@ def create_userapp(username, email, userapp, spec_map):
init_containers=init_containers,
labels=svc_labels,
containers=[container],
image_pull_secrets=app_spec['image']['secrets'] if 'image' in app_spec and 'secrets' in app_spec['image'] else None,
collocate=userapp_id if 'collocate' in app_spec and app_spec['collocate'] else False)

# Create one ingress per-stack
Expand All @@ -650,7 +650,8 @@ def create_userapp(username, email, userapp, spec_map):

if should_run_as_single_pod:
service_account = backend_config['userapps']['service_account_name'] if 'userapps' in backend_config and 'service_account_name' in backend_config['userapps'] else None

app_spec = spec_map.get(userapp_key, None)

# No need to collocate, since all will run in single pod
# Create one deployment per-stack (start with 0 replicas, aka "Stopped")
create_deployment(deployment_name=get_resource_name(get_username(username), userapp_id, userapp_key),
Expand All @@ -659,6 +660,7 @@ def create_userapp(username, email, userapp, spec_map):
service_account=service_account,
username=get_username(username),
labels=labels,
image_pull_secrets=app_spec['image']['secrets'] if 'image' in app_spec and 'secrets' in app_spec['image'] else None,
# TODO: how to wait for deps in singlepod mode?
# init_containers=init_containers,
containers=containers)
Expand Down Expand Up @@ -952,7 +954,7 @@ def get_home_storage_class():

# Containers:
# "busybox" -> { name, configmap, image, lifecycle, ports, command }
def create_deployment(deployment_name, containers, labels, username, **kwargs):
def create_deployment(deployment_name, containers, labels, username, image_pull_secrets=None, **kwargs):
appv1 = client.AppsV1Api()

# TODO: Validation
Expand Down Expand Up @@ -1003,6 +1005,7 @@ def create_deployment(deployment_name, containers, labels, username, **kwargs):

# Build a podspec from given containers and other parameters
podspec = client.V1PodSpec(
image_pull_secrets=image_pull_secrets,
service_account_name=service_account_name,
volumes=shared_volumes,
init_containers=init_containers,
Expand Down Expand Up @@ -1041,6 +1044,7 @@ def create_deployment(deployment_name, containers, labels, username, **kwargs):
# TODO: support container.lifecycle?
lifecycle=container['lifecycle'] if 'lifecycle' in container else None,
image=get_image_string(container['image']),
image_pull_policy='Always',
ports=[
client.V1ContainerPort(
name='%s%s' % (port['protocol'] if 'protocol' in port else 'tcp', str(port['port'])),
Expand Down

0 comments on commit f78d996

Please sign in to comment.