Wednesday, May 16, 2018

Check whether all nodes are in sync(timewise)




To check whether time is in sync (ntp) you can make use of ansible.

First fillup your inventory file with all nodes.

Then,

ansible all -m shell -a "date"

all here will contact all the nodes in inventory and get time.


If it varies widely you have an issue. check whether ntp service like
chronyd/ntpd running in the nodes.



Running out of space in /var directory due to docker images



docker images are stored under /var/lib/docker

If you run out of space in /var partition.?

ok move /var/lib/docker directory to /root (considering space is available under /root) and create a symlink from /var/lib/docker to /root/docker.

Ensure you stop docker service before moving and verify docker daemon works fine after creating symlink.

so, all the commands put together:

systemctl stop docker

mv /var/lib/docker /root/

ln -sf  /root/docker /var/lib/docker

systemctl start docker

systemctl status  docker

thats it :) 

git push only the current branch




# This will make git push to push only the current branch

git config --global push.default simple

Tuesday, May 8, 2018

Delete all evicted pods in openshift


Delete all evicted pods in openshift


# for the current namespace
eval "$(oc get pods -o json | jq -r '.items[] | select(.status.phase == "Failed" and .status.reason == "Evicted") | "oc delete pod --namespace " + .metadata.namespace + " " + .metadata.name')"


# for all namespaces
eval "$(oc get pods -o json --all-namespaces | jq -r '.items[] | select(.status.phase == "Failed" and .status.reason == "Evicted") | "oc delete pod --namespace " + .metadata.namespace + " " + .metadata.name')"


Here,  jq - commandline JSON processor
You need to install jq first.


ref: https://stackoverflow.com/questions/46419163/what-will-happen-to-evicted-pods-in-kubernetes 

Friday, May 4, 2018

Show only stopped docker containers

# show running containers
docker ps


# show running and stopped containers
docker ps -a


# adding q make it quiter :o)
docker ps -q
docker ps -q -a


# Now show only the stopped container
diff <(docker ps -a -q) <(docker ps -q )
 
   This shows difference between the two commands and
in this case the difference is stopped containers.