Skip to content

Instantly share code, notes, and snippets.

@xsqian
xsqian / alter-kafka-partitions.sh
Last active October 11, 2023 19:04
How to alter kafka partitions
# create a topic with specified partitons
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --create --partitions 2 --topic test-partitions
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --describe --topic test-partitions
# create a topic with default partitions
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --create --topic test-def-partitions
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --describe --topic test-def-partitions
# alter the number of partitions of an existing topic
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --alter --topic test-def-partitions --partitions 3
@xsqian
xsqian / delete-all-completed-pods.sh
Last active September 14, 2023 17:41
How to delete all the pods that are in Completed status in a k8s
kubectl get pod --field-selector=status.phase==Succeeded
kubectl delete pod --field-selector=status.phase==Succeeded
kubectl delete pod --field-selector=status.phase==Failed
kubectl delete pods $(kubectl get pod --all-namespaces -o jsonpath='{.items[?(@.status.containerStatuses[*].state.waiting.reason=="CrashLoopBackOff")].metadata.name}')
@xsqian
xsqian / gist:cdcef2d2b7767fb5c67170e197168289
Created August 15, 2023 21:37
how to set the default namespace
kubectl config set-context --current --namespace=<insert-namespace-name-here>
# Validate it
kubectl config view --minify | grep namespace:
@xsqian
xsqian / brew-install-sshpass.sh
Created August 15, 2023 21:14
how to install sshpass with brew
brew install hudochenkov/sshpass/sshpass
@xsqian
xsqian / install-go-ec2.sh
Created February 16, 2023 17:57
how to install go on an AWS linux
sudo yum install golang -y
go version
@xsqian
xsqian / install-docker-on-ec2.sh
Last active February 16, 2023 17:19
how to install docker on to an AWS EC2 instance with AWS linux AMI
sudo amazon-linux-extras install docker
sudo systemctl enable docker
sudo systemctl start docker
sudo usermod -aG docker ec2-user # allows you to run `docker` commands without `sudo`
sudo reboot
docker info
@xsqian
xsqian / search-and_replace.sh
Last active January 11, 2023 17:57
search and replace with sed
sed 's/<search regex>/<replacement>/g' <input file> <output file>
@xsqian
xsqian / docker-compose-on-redhat-kafka.sh
Last active March 10, 2022 23:20
Install Docker, Docker Compose and Kafka on RedHat
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf repolist -v
dnf list docker-ce --showduplicates | sort -r
sudo dnf install --nobest docker-ce
sudo systemctl disable firewalld
@xsqian
xsqian / curl-output-to-json
Created December 23, 2021 18:28
how to format a curl output to json in a jupyter notebook
!curl http://docker-registry.default-tenant.app.us-sales-32.iguazio-cd0.com/v2/_catalog | json_pp
@xsqian
xsqian / kubectl-create-scret.sh
Created December 19, 2021 05:21
decode a kubernetes secret
echo red | base64
# cmVkCg==
echo "cmVkCg==" | base64 -D
# red