Wednesday, October 30, 2019

How to delete a pod forcefully in kubernetes.

There might be cases when your pod gets stuck or in terminating state for a long time then the following command can be a great help to forcefully delete the pod.


kubectl delete pod <PODNAME> --grace-period=0 --force --namespace <NAMESPACE>




Monday, October 7, 2019

Delete old files in S3 while excluding few

While S3 provides a life cycle policy by which we can delete files older than certain on of day there may be a case where we want to exclude some files from that lifecycle in that case following script can be used.
The script is listing files according to there date in certain folder and then remove all files older than one month excluding the files which have the latest or revert in their name.
#!/bin/bash
# Script to delete files older than one month.

aws s3 ls s3://bucket-dpkg/deb/ --recursive | sort -n | grep -iv 'latest\|revert' | grep `date --date="1 month ago" "+%Y-%m-%d"` | awk '{print $4}' > /tmp/filesdelete.txt

echo -e "\n-------------------------`date`---------------------------\n" >> /root/s3deletedfiles.log

for i in `cat /tmp/filesdelete.txt`
do

aws s3 rm `echo s3://tokopedia-dpkg/$i`

done >> /root/s3deletedfiles.log



Setup fully configurable EFK Elasticsearch Fluentd Kibana setup in Kubernetes

In the following setup, we will be creating a fully configurable Elasticsearch, Flunetd, Kibana setup better known as EKF setup. There is a...