Running two containers in a single pod via kubectl run does not terminate the pod

Cluster information:

Kubernetes version:1.10.11
Cloud being used:GCP
Installation method: bash script
Host OS:
CNI and version:
CRI and version:

You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.

–!>while getopts n:c:l:i:d:t: option
do
case “${option}”
in
n) CONTAINER_NAMESPACE=$OPTARG;;
c) CONTAINER_CONFIG=$OPTARG;;
l) CONTAINER_LICENSE=$OPTARG;;
i) CONTAINER_IMAGE=$OPTARG;;
d) CONTAINER_CONTAINER_NAME=$OPTARG;;
t) CONTAINER_TOKEN=$OPTARG;;
esac
done

kubectl run $CONTAINER_CONTAINER_NAME -n $CONTAINER_NAMESPACE --restart=Never --overrides=’
{
“apiVersion”: “v1”,
“spec”: {
“imagePullSecrets”: [
{
“name”: “CONTAINER-regsecret”
}
],
“initContainers”: [
{
“name”: “copy-configs”,
“image”: “busybox”,
“command”: [“sh”, “-c”, “cp /tmp/CONTAINER-config-volume/server/* /tmp/ng-rt/config/server/ 2>/dev/null || true; cp /tmp/CONTAINER-license-volume/licenses/* /tmp/ng-rt/config/licenses 2>/dev/null || true”],
“volumeMounts”: [
{
“name”: “CONTAINER-config-volume”,
“mountPath”: “/tmp/CONTAINER-config-volume/server”
},
{
“name”: “’$CONTAINER_CONFIG’”,
“mountPath”: “/tmp/ng-rt/config/server”
},
{
“name”: “CONTAINER-license-volume”,
“mountPath”: “/tmp/CONTAINER-license-volume/licenses”
},
{
“name”: “’$CONTAINER_LICENSE’”,
“mountPath”: “/tmp/ng-rt/config/licenses”
}
]
}
],
“containers”: [
{
“name”: “mongodb-test”,
“image”: “mongo:3.6.8”,
“ports”: [{
“containerPort”: 27017
}],
“readinessProbe”: {
“exec”: {
“command”: [“mongo”, “–eval”, “rs.initiate()”]
}
}
},
{
“env”: [
{
“name”: “AWS_ACCESS_KEY_ID”,
“valueFrom”: {
“secretKeyRef”: {
“key”: “AWS_ACCESS_KEY_ID”,
“name”: “aws-secrets”
}
}
},
{
“name”: “AWS_SECRET_ACCESS_KEY”,
“valueFrom”: {
“secretKeyRef”: {
“key”: “AWS_SECRET_ACCESS_KEY”,
“name”: “aws-secrets”
}
}
},
{
“name”: “AWS_REGION”,
“valueFrom”: {
“secretKeyRef”: {
“key”: “AWS_REGION”,
“name”: “aws-secrets”
}
}
},
{
“name”: “BUILD_ID”,
“valueFrom”: {
“configMapKeyRef”: {
“key”: “BUILD_ID”,
“name”: “tbsp-config”
}
}
}
],
“command”: [
“sh”,
“-c”,
“mkdir -p /tmp/ng-rt/plugins 2\u003e/dev/null && npm test --skipConnectivityTestRethinkDB”
],
“name”: “’$CONTAINER_CONTAINER_NAME’”,
“image”: “’$CONTAINER_IMAGE’”,
“volumeMounts”: [
{
“mountPath”: “/tmp/ng-rt/config/server”,
“name”: “’$CONTAINER_CONFIG’”
},
{
“mountPath”: “/tmp/ng-rt/config/licenses”,
“name”: “’$CONTAINER_LICENSE’”
}
]
}
],
“volumes”: [
{
“name”: “CONTAINER-config-volume”,
“configMap”: {
“name”: “’$CONTAINER_CONFIG’”
}
},
{
“name”: “’$CONTAINER_CONFIG’”,
“emptyDir”: {}
},
{
“name”: “CONTAINER-license-volume”,
“configMap”: {
“name”: “’$CONTAINER_LICENSE’”
}
},
{
“name”: “’$CONTAINER_LICENSE’”,
“emptyDir”: {}
}
]
}
}
’ --image=$CONTAINER_CONTAINER_NAME -ti --rm --token=$CONTAINER_TOKEN

I am using this json embedded yaml to run two containers in a pod .The problem i face is that we have 2 images in a Kubernetes pod whereas we used to have 1 image for this pod previously where it was working perfectly and shutting down the pod gracefully . Now the problem is that with 2 images or containers within the same pod both images are not shutting down at the same time gracefully.