Skip to content

Instantly share code, notes, and snippets.

View mshafiee's full-sized avatar

Mohammad Shafiee mshafiee

View GitHub Profile
# Problem Description:
How to resolve scheduler and controller-manager unhealthy state in Kubernetes
# Symptom:
$ kubectl get cs / kubectl get componentstatuses
Warning: v1 ComponentStatus is deprecated in v1.19+
NAME STATUS MESSAGE ERROR
controller-manager Unhealthy Get "http://127.0.0.1:10252/healthz": dial tcp 127.0.0.1:10252: connect: connection refused
scheduler Unhealthy Get "http://127.0.0.1:10251/healthz": dial tcp 127.0.0.1:10251: connect: connection refused
etcd-0 Healthy {"health":"true"}
(
NAMESPACE=your-rogue-namespace
kubectl proxy &
kubectl get namespace $NAMESPACE -o json |jq '.spec = {"finalizers":[]}' >temp.json
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/$NAMESPACE/finalize
)
@mshafiee
mshafiee / backup-my.cnf
Created February 6, 2020 10:07
Backup Percona MySQL Galera Cluster
[client]
user=backup
password=ffgf43rger43gtregrt43hr23
[mysqld]
socket=/var/run/mysqld/mysqld.sock
datadir=/var/lib/mysql
innodb_log_group_home_dir=/var/lib/mysql
@mshafiee
mshafiee / DRBD master-slave setup
Created December 12, 2019 07:59
DRBD master/slave setup
DRBD (Distributed Replicated Block Device) is a really cool cluster solution to have radundant data on two or more nodes. Everybody know RAID, DRBD is like RAID 1 over network.
Install DRBD virtual package (This will work on Debian and Ubuntu):
apt-get install drbd-utils
I my case DRBD is running under control of my cluster-software, that means DRBD will be managed by corosync. I remove DRBD from upstart:
insserv -v -r drbd remove
We need to start the driver and tell Linux to load it the next time when it boots:
@mshafiee
mshafiee / sysctl.conf
Created December 5, 2019 07:37 — forked from techgaun/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
@mshafiee
mshafiee / ipsec.server.to.site
Last active August 3, 2023 16:39
Setup a Server to Site IPSec VPN with strongSwan on Ubuntu
sudo apt update && sudo apt upgrade -y
sudo apt install strongswan -y
sudo vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
sudo sysctl -p /etc/sysctl.conf
openssl rand -base64 64
@mshafiee
mshafiee / nginx.conf
Created March 10, 2019 10:28
Php behind HTTPS/SSL Proxy (nginx, fastcgi)
##
# nginx server with http + ssl/https (Front)
# /etc/nginx/sites-available/example.com
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://no-ssl:8080;
proxy_set_header Host $host;
#!/bin/bash
while IFS='' read -r line || [[ -n "$line" ]]; do
echo '' | db2struct --host localhost -d farayad --package farayad -p --user root --struct=$line -t $line --gorm --guregu
done < "$1"
usage:
1-show tables;
2-store table name in tablename.txt file.
3- run: bash mysql2go.sh tablename.txt
[mysqld]
# Path to Galera library
wsrep_provider=/usr/lib/galera3/libgalera_smm.so
# Cluster connection URL contains IPs of nodes
#If no IP is found, this implies that a new cluster needs to be created,
#in order to do that you need to bootstrap this node
wsrep_cluster_address=gcomm://172.16.10.20,172.16.20.20,172.16.30.20
# In order for Galera to work correctly binlog format should be ROW
# Template my.cnf for PXC
# Edit to your requirements.
[mysqld]
server-id=1
datadir=/var/lib/mysql
socket=/var/run/mysqld/mysqld.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
log-bin
log_slave_updates