Skip to content

Instantly share code, notes, and snippets.

@jovemfelix
Created December 2, 2020 18:28
Show Gist options
  • Select an option

  • Save jovemfelix/919e48139ec0986cf93888340ac1f231 to your computer and use it in GitHub Desktop.

Select an option

Save jovemfelix/919e48139ec0986cf93888340ac1f231 to your computer and use it in GitHub Desktop.
Compute DateTime of Pod's in Openshif
v_values=$(oc get pods --all-namespaces --field-selector status.phase==Running -o wide | awk 'FNR > 1 {printf $1;printf ";";printf $2;printf ";";printf $8;printf "\n"}' )
for v_pod_and_node in $(echo $v_values); do
v_namespace=$(echo $v_pod_and_node | awk -F ";" '{print $1}')
v_pod=$(echo $v_pod_and_node | awk -F ";" '{print $2}')
v_node=$(echo $v_pod_and_node | awk -F ";" '{print $3}')
oc -n $v_namespace rsh $v_pod /bin/sh -i -c 'printf "$(date '+%Y%m%d%H%M%S')"'
printf ";$v_pod;$v_namespace;$v_node\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment