loading...

27/07/2023

k8s Repair

oooo    oooo  .ooooo.                 ooooooooo.                                   o8o           
`888   .8P’  d88′   `8.               `888   `Y88.                                 `”‘           
 888  d8′    Y88..  .8′  .oooo.o       888   .d88′  .ooooo.  oo.ooooo.   .oooo.   oooo  oooo d8b 
 88888[       `88888b.  d88(  “8       888ooo88P’  d88′ `88b  888′ `88b `P  )88b  `888  `888″”8P 
 888`88b.    .8′  “88b `”Y88b.        888`88b.    888ooo888  888   888  .oP”888   888   888     
 888  `88b.  `8.   .88P o.  )88b       888  `88b.  888    .o  888   888 d8(  888   888   888     
o888o  o888o  `boood8′  8″”888P’      o888o  o888o `Y8bod8P’  888bod8P’ `Y888″”8o o888o d888b    
                                                              888                                
                                                             o888o                               
                                                                                                 
 
 
============= The connection to the server 192.168.193.136:6443 was refused ========
# sudo -i
# swapoff -a
# exit
# strace -eopenat kubectl version
 
or
 
# vi /etc/fstab
 
N.B. search for a swap line and add a #
 
# mount -a
swapoff -a
free -h
blkid  
lsblk
 
================The connection to the server localhost:8080 was refused – did you specify the right host or port? ================
—> run this in master node
 
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
 
 
============ View Troubleshooting ============
 
# kubectl get rs
 
# kubectl get nodes
# kubectl describe nodes
 
# kubectl get pods
# kubectl describe pods
 
# kubectl get deployments
# kubectl describe deployment kubernetes-bootcamp
 
# kubectl get node -o wide
# kubectl get pods –all-namespaces
 
# kubectl get svc
 
# kubectl get services
 
# kubectl describe services/kubernetes-bootcamp
 
=============== Get In ====
# kubectl exec -ti kubernetes-bootcamp-d9b4bdd78-mdsjs — bash
 
=============== Expose ==============
# kubectl expose deployment/kubernetes-bootcamp –type=”NodePort” –port 8080
 
 
 
 
 
–> K3s Command
# kubectl get pods -n kube-system
$ cat /etc/kubernetes/manifests/kube-apiserver.yaml
$ cat /etc/systemd/system/kube-apiserver.service
$ ps -aux | grep kube-apiserver
 
 
–> Deploy pods
# kubectl run kaisar –image nginx
# kubectl get pods
# kubectl describe pods nginx
# kubectll get pods –o wide
# kubectl delete pods webapp
# kubectl run redis –image=redis123 –dry-run=client -o yaml
# kubectl apply –f pod.yaml
# kubectl taint nodes –all node-role.kubernetes.io/master-
 
 
==================The connection to the server localhost:8080 was refused – did you specify the right host or port?===============
 
——————–> In Master  Node ————————
 
–> Allow ports in fireall in master node
 
sudo iptables -A INPUT -p tcp –match multiport –dports 10250:10255 -j ACCEPT
sudo iptables -A INPUT -p tcp –dport 10248  -j ACCEPT
sudo iptables -A INPUT -p tcp –match multiport –dports 2379:2380 -j ACCEPT
sudo iptables -A INPUT -p tcp –match multiport –dports 10250:10251 -j ACCEPT
sudo iptables -A INPUT -p tcp –match multiport –dports 10250:10255 -j ACCEPT
sudo iptables -A INPUT -p tcp –match multiport –dports 8472 -j ACCEPT
sudo iptables -A INPUT -p tcp –match multiport –dports 6443 -j ACCEPT
 
# sudo ufw allow 6443
# sudo ufw allow 6443/tcp
 
kubeadm token create –print-join-command
 
——————–> In Worker  Node ————————
 
–> Allow ports in fireall in worker nodes
 
sudo iptables -A INPUT -p tcp –match multiport –dports 30000:32767 -j ACCEPT
sudo iptables -A INPUT -p tcp –dport 10250  -j ACCEPT
 
# kubeadm join 192.168.193.136:6443 –token 6cke7d.wn9c1tya2hh5zkue –discovery-token-ca-cert-hash sha256:e53f6dbdd0d34c9055a9749e5d23265f8cddfc7403455e907485c4fb9ec3cc7e –ignore-preflight-errors
 
Posted in k8sTaggs: