0

I am experiencing some odd behaviors when executing a script in a k8s/Argo workflow step.

To start with, where I start the Metamap Tagger servers (see code snippet below), instead of waiting till each has completed before executing the next command, they all just fire off immediately (my kludgey solution was to put a /bin/bash/sleep 120 command between each).

The other oddity is that if I run a script from within a script that sets a bunch of environment variables (in this case source set_uima.sh does this), the environment variable are not set accordingly. I have tested this outside of the k8 workflow and it all works as desired.

Is there something about k8 that makes this script not run the same in a non-TTY session (k8) as it does from a TTY session (from my local workstation)?

#!/bin/bash

export DATA_DIRECTORY=/data
export METAMAP_OUT=$DATA_DIRECTORY/metamap_out
export SAMPLE_FILE=$DATA_DIRECTORY/nlptab_manifest.txt
export DATA_IN=$DATA_DIRECTORY/in
export METAMAP_HOME=/usr/share/public_mm # /usr/share/public_mm

export JAVA_TOOL_OPTIONS=‘-Xms2G -Xmx6G -XX:MinHeapFreeRatio=25 -XX:+UseG1GC’

##### Start Metamap Tagger Servers #####
skrmedpostctl start

wsdserverctl start

mmserver &


##### Run UIMA against Metamap taggers #####
source ./setup_uima.sh
horcle_buzz
  • 175
  • 3
  • 10

1 Answers1

1

It is not strange that your script runs in bash without TTY in your docker container in K8s.

To start a pod with TTY, you need to add tty: true in deployment:

spec: 
  containers: 
    - name: test 
      tty: true 

and then run the script.

You can create env variables in your deployment: Deployment will look like:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: envtest
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: envtest
    spec:
      containers:
      - name: envtest
        image: gcr.io/<PROJECT_ID>/envtest
        ports:
        - containerPort: 3000
        env:
        - name: DATA_DIRECTORY
          value: "/data"
        - name: METAMAP_OUT
          value: "/data/metamap_out"            
        - name: SAMPLE_FILE
          value: "/data/nlptab_manifest.txt"
        - name: DATA_IN
          value: "/data/in"            
        - name: METAMAP_HOME
          value: "/usr/share/public_mm"
        - name: JAVA_TOOL_OPTIONS
          value: " -Xms2G -Xmx6G -XX:MinHeapFreeRatio=25 -XX:+UseG1GC"

But this method might be bulky.

Nick Rak
  • 167
  • 7