How to pass argument for a configuration file in JuPyterhub's deployment?

5/21/2019

I want to install envkey in my docker image which requires a key-value pair. I have the key-value pair with me but I am unable to figure out as to how do I install it in my docker image using those arguments and then deploy the same on jupyterhub.

I tried reading other deployments of mine which use envkey. Here is how it goes: 1. I have a Makefile and I run the command sudo make dev config=aviral.cfg 2. The dev command in the Makefile is as follows:

dev:
    docker build -t $(IMAGE) -f Dockerfile.dev . && docker tag $(IMAGE) $(ALIAS)
    @echo "\nCreate docker container.."
    CONFIG=$(config) IMAGE=$(IMAGE) docker-compose -f docker-compose.yml up -d --scale test=0 --scale airflow_worker=0
    @echo "\n$(GREEN)Done.$(NO_COLOR)\n"
    @echo "Try airflow at http://localhost:8080."
    @echo "and flower at http://localhost:5555."
  1. The docker-compose file is:
airflow_worker:
        image: ${IMAGE}:latest
        restart: always
        depends_on:
            - airflow_scheduler
        # ports:
        #     - 8793:8793
        # environment:
            # - GOOGLE_APPLICATION_CREDENTIALS=/gcloud/cloud.json
        env_file:
            - ${CONFIG}
        command: worker

As you can see, the env_file is passed on.

I am unable to deduce how to do this same in the JuPyterHub.

The helm chart is here(https://jupyterhub.github.io/helm-chart/jupyterhub-0.8.2.tgz). And my config is:

proxy:
  secretToken: "yada_yada"
singleuser:
  image:
    name: yada_yada.dkr.ecr.ap-south-1.amazonaws.com/demo
    tag: 12h
  lifecycleHooks:
    postStart:
      exec:
        command: ["/bin/sh", "-c", 'ipython profile create; cd ~/.ipython/profile_default/startup; echo ''run_id = "sample" ''> aviral.py']
  imagePullSecret:
    enabled: true
    registry: yada_yada.dkr.ecr.ap-south-1.amazonaws.com
    username: aws
    email: aviral@yada_yada.com
    password: yada_yada

In my config file, I pass variables as:

ENVKEY=my_personal_envkey

I expect to have my configs passed in the docker, or perhaps I write a proper Makefile for this stuff, as of now, I am facing this error:

Step 19/32 : RUN     curl -s https://raw.githubusercontent.com/envkey/envkey-source/master/install.sh | bash
 ---> Running in 35bc1cf0e1c8
envkey-source 1.2.9 Quick Install
Copyright (c) 2019 Envkey Inc. - MIT License
https://github.com/envkey/envkey-source

Downloading envkey-source binary for linux-amd64
Downloading tarball from https://github.com/envkey/envkey-source/releases/download/v1.2.9/envkey-source_1.2.9_linux_amd64.tar.gz
envkey-source is installed in /usr/local/bin
Installation complete. Info:

bash: line 97:    29 Segmentation fault      envkey-source -h
The command '/bin/sh -c curl -s https://raw.githubusercontent.com/envkey/envkey-source/master/install.sh | bash' returned a non-zero code: 139

Although this question alone should be good enough to give you the picture but for the sake of context(if), here are some of the questions: 1. How do I make jupyter-hub access my private docker image repository? 2. Unable to run a lifecycle command from config.yaml while deploying jupyterhub 3. How to have file written automatically in the startup folder when a new user signs up/in on JuPyter hub?

-- Aviral Srivastava
docker
docker-compose
jupyterhub
kubernetes
kubernetes-helm

1 Answer

5/22/2019

Probably you get this error because install.sh script tries to add envkey-source binary under /usr/local/bin directory and then tries to run envkey-source -h and fails. Check if user(if non-root) have permission to do that or if /usr/local/bin directory exists in container image.

Hope it helps!

-- coolinuxoid
Source: StackOverflow