last day (15 days later) » 

2:44 PM
0
Q: Unable to run a lifecycle command from config.yaml while deploying jupyterhub

Aviral SrivastavaI want to run a command as soon as a pod is created and starts running. I am deploying jupyterhub but the config that I am using is: proxy: secretToken: "yada yada" singleuser: image: # Get the latest image tag at: # https://hub.docker.com/r/jupyter/datascience-notebook/tags/ # I...

 
Hi, can you run kubectl describe pod $POD_NAME ?
 
Are there any events ? there is not event sections, usually it describe the sequence of events
 
If you want to take a look at helm: jupyterhub.github.io/helm-chart
@SureshVishnoi Yes there are, I deleted it from the file, apologies. The events are: pastebin.com/a4CMEMMN
 
command: - /bin/sh - -c - echo "Hello from the postStart handler" > /usr/share/message
can you try this format ?
I did not see any events related to postStart
 
2:45 PM
Yes
that is my concern too
Also, did you take a look at the helm charts and templates?
I guess, I have given the command in the values.yaml and this is why it is not executing it at all.
 
It tries to download to my pc
can you post your deployment file
 
I meant deployment.yaml file
its inside hub folder
 
I have only one config file, which is available here: pastebin.com/NwEizxcD
oh okay, wait a sec
^ the above file is the deployment.yaml file in the root_dir/templates/hub folder
 
opps sorry we are looking at the wrong pod
 
2:50 PM
ok
 
wait a second , in which pod this hook need to execute
what is the name of the pod
 
the whole list of pods is:
```
➜ hub kubectl get pods -n jhub
NAME READY STATUS RESTARTS AGE
hub-776c457d95-sbtd9 1/1 Running 0 34m
jupyter-may16-5f3 1/1 Running 0 33m
proxy-cd549b885-95bbr 1/1 Running 0 3h
```
 
let's check each pod
kubectl get pods -o yaml
 
in the pod -> jupyter-may16-5f3 1/1 Running 0 33m , I need the hook to be executed. Note: this pod gets initiated and started when a new user logs in on JuPyterhub.
 
ohh ok
I understand now
kubectl get pods jupyter-may16-5f3 -o yaml
lets check its spec
 
2:54 PM
wait
the above url is for all, sending you the may16 one's in a min
 
there is no postStart object inside the pod
this is the problem
 
https://pastebin.com/JJvEsY2i
This is the asked yaml
the above url is for the pod may16, the one that you had asked for.
 
lifecycle: {}
 
Hey, just to be clear, the url for may16 pod is pastebin.com/JJvEsY2i
 
its empty
 
2:57 PM
I see
so, while passing the same in my config.yaml, it is not being passed there and hence lifecycle is empty.
How can I make it happen?
 
we can edit it
kubectl edit deployment $deployment name
 
and what would be the permanent solution?
Right now, I deploy using the command:
```
# Suggested values: advanced users of Kubernetes and Helm should feel
# free to use different values.
RELEASE=jhub
NAMESPACE=jhub

helm upgrade --install $RELEASE jupyterhub/jupyterhub \
--namespace $NAMESPACE \
--version=0.8.0 \
--values jupyter-hub-config.yaml
```
And the jupyter-hub-config.yaml is:
```
proxy:
secretToken: "57d23bfa8f3106dfebb1c5a138c92d10971c822450ad4fd17ee03f45348faac2"
singleuser:
image:
 
lets try to edit deployment
then we can modify the helm chart
 
Also, just to state once more, pods like may16 get created whenever a new user signs in. There is something like singleUser in the deployments that oversee this.
>lets try to edit deployment
Ok
 
kubectl get deployment
 
3:02 PM
➜ hub kubectl get deployments -n jhub
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
hub 1 1 1 1 6d
proxy 1 1 1 1 6d
editing hub
and what should i edit?
 
I am going through the github helm chart
whenever new use login there is a deployment
 
yes, true
 
but i do not see any deployment file in singleuser folder
where is that deployment file
i am new to jypyter hub
 
yes, there is not any deployment file in the singleuser folder
```
```
.
├── NOTES.txt
├── _helpers.tpl
├── hub
│   ├── configmap.yaml
│   ├── deployment.yaml
│   ├── image-credentials-secret.yaml
│   ├── netpol.yaml
│   ├── pdb.yaml
│   ├── pvc.yaml
│   ├── rbac.yaml
│   ├── secret.yaml
│   └── service.yaml
├── image-puller
│   ├── _daemonset-helper.yaml
│   ├── daemonset.yaml
│   ├── job.yaml
│   └── rbac.yaml
├── ingress.yaml
├── proxy
│   ├── autohttps
│   │   ├── _README.txt
│   │   ├── configmap-nginx.yaml
│   │   ├── deployment.yaml
│   │   ├── ingress-internal.yaml
>i am new to jypyter hub

I understand, what can I do for you to bridge the gap here?
 
can you check what is the deployment file in scheduling folder
 
3:07 PM
yeah sure, give me a sec
https://pastebin.com/xLkj5U9s
This is the deployment file in `scheduling/user-scheduler`.
I don't understand why are we looking at deployment file of scheduling/user-scheduler?
 
Its also wrong
I am searching for the deployment file
from where the pods is created
so we can edit that file
 
ok, have you seen the tree of the directory?
 
this is the tree for your reference:
```
.
├── Chart.yaml
├── Dockerfile
├── deployment.sh
├── jupyter-hub-config.yaml
├── requirements.lock
├── schema.yaml
├── templates
│   ├── NOTES.txt
│   ├── _helpers.tpl
│   ├── hub
│   │   ├── configmap.yaml
│   │   ├── deployment.yaml
│   │   ├── image-credentials-secret.yaml
│   │   ├── netpol.yaml
│   │   ├── pdb.yaml
│   │   ├── pvc.yaml
│   │   ├── rbac.yaml
│   │   ├── secret.yaml
│   │   └── service.yaml
│   ├── image-puller
│   │   ├── _daemonset-helper.yaml
 
cat values.yaml | grep -i lifecycle
 
3:13 PM
this is what i got:
```
➜ jupyterhub cat values.yaml | grep -i lifecycle

lifecycleHooks:
```
 
so this is the placeholder
 
So, I am thinking of writing lifecycleHooks in `jupyter-hub-config.yaml` so that it overrides the default.
Should we try this?
 
yea
lets do it
 
the assumption is that in the command:
```
# Suggested values: advanced users of Kubernetes and Helm should feel
# free to use different values.
RELEASE=jhub
NAMESPACE=jhub

helm upgrade --install $RELEASE jupyterhub/jupyterhub \
--namespace $NAMESPACE \
--version=0.8.0 \
--values jupyter-hub-config.yaml
```

file given to values argument will override the values.yaml in which the lifecycleHooks is empty. meaning, it will override the given params
what would be the format?
this is the config.yaml file:
```
proxy:
secretToken: "57d23bfa8f3106dfebb1c5a138c92d10971c822450ad4fd17ee03f45348faac2"
singleuser:
image:
# Get the latest image tag at:
# https://hub.docker.com/r/jupyter/datascience-notebook/tags/
# Inspect the Dockerfile at:
# https://github.com/jupyter/docker-stacks/tree/master/datascience-notebook/Dockerfile
name: jupyter/datascience-notebook
# name: ${IMAGE}
tag: 177037d09156
command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
This is the config that I am using, my question is, where and how do I place the lifecycleHook param?
https://pastebin.com/V2285Rdr
@SureshVishnoi
 
```
singleuser:
postStart:
exec:
command:
```
shit
we need to edit it with the right identation
 
3:19 PM
you can paste the final config file on pastebin, with yaml #fyi :)
 
do not delete other fields
hehe
this will be the complete one
@AviralSrivastava
what's the status ?
 
i got it, now its crashloopbackoff because of permission denied
at least we have reached to the point of executing the command, however, it is failing due to permissions, what should we do?
Would sudo work here?
 
kubectl describe pod $POd_name
it will provide more information
 
3:27 PM
```
➜ jupyterhub kubectl describe pod jupyter-may16-5f6 -n jhub
Name: jupyter-may16-5f6
Namespace: jhub
Priority: 0
PriorityClassName: <none>
Node: ip-172-16-11-131.ap-south-1.compute.internal/172.16.11.131
Start Time: Thu, 16 May 2019 20:53:40 +0530
Labels: app=jupyterhub
chart=jupyterhub-0.8.0
component=singleuser-server
heritage=jupyterhub
hub.jupyter.org/network-access-hub=true
release=jhub
Annotations: hub.jupyter.org/username: may16_6
i hope you are able to see this message clearly
 
yea
I think we need to try this way
 
which way?
 
echo "Hello from the postStart handler" > /usr/share/message
echo Hello from the postStart handler > /usr/share/message
 
wait, after execing in the pod?
 
the last one is worng
command: ["/bin/sh", "-c", "echo Hello > /usr/share/message"]
can you use this line in the values file
let see if it work
 
3:33 PM
but that would give us the permission issue, right?
 
yea
this is my understanding
 
wait, we were writing in /usr/share. Now, I am trying to write in the home. Let's see.
 
yea
are you running it on openshift
btw I answered the question with the correct key
 
Dude
it worked!
 
awesome
so you are also a vitian
 
3:38 PM
writing in the home directory worked. now, i am figuring out the complete commands, i.e. running multiple commands.
i know i have asked you a lot, can you tell me how to paste multiple commands
?
 
command: ["/bin/sh", "-c", "command1;command2"]
do you mean like this ?
 
"so you are also a vitian"
Also? yeah man, you are also a vitian?
Let me know your email id and other profiles?
 
yea I did it in 2015
2011-2015
command: ["/bin/sh", "-c", "command one; command two && command three"]
is the correct one
@AviralSrivastava
updates ?
 
yes
sorry, yaml escaping is giving me a tough time
command: ["/bin/sh", "-c", 'ipython profile locate; cd ~/.ipython/profile_default/startup; echo "run_id = 'sample' " > aviral.py']
 
so I need to go now, my time is up , can you accpet the answer
i will try to catch you later
 
3:49 PM
han sure
 

last day (15 days later) »