Skip to main content

Posts

Horizontal Pod Autoscale & Metrics Server installation in K8S

In K8s inorder to create the HPA we just need to give a below kubectl command like below: # kubectl autoscale deployment myapp  --min=1 --max=4 --cpu-percent=80 But this will give a series of errors like below if metrics API is not registered. ######################################## ubuntu@namenode:~$ kubectl get hpa NAME           REFERENCE                 TARGETS         MINPODS   MAXPODS   REPLICAS   AGE myapp   Deployment/myapp   < unknown> /80%   1         4         2          43h ubuntu@namenode:~$ kubectl describe horizontalpodautoscaler.autoscaling/myapp | grep Warning   Warning  FailedComputeMetricsReplicas  32m (x10333 over 43h)   horizontal-pod-autoscaler  invalid metrics (1 inva...

Proper way of Kubeadm reset

Login to the Master Node: ##################### sudo kubeadm reset sudo systemctl stop docker && sudo systemctl stop kubelet sudo rm -rf /etc/kubernetes/ sudo rm -rf .kube/ sudo rm -rf /var/lib/kubelet/ sudo rm -rf /var/lib/cni/ sudo rm -rf /etc/cni/ sudo rm -rf /var/lib/etcd/ ifconfig cni0 down ifconfig flannel.1 down ifconfig docker0 down sudo ip link delete cni0 sudo ip link delete flannel.1 kubeadm reset  does not delete  any  of the iptables rules it originally created. In other words, if you try to bootstrap your cluster with a different pod networking CIDR range or different networking options, you might run into trouble. Please note if you are using a firewall configuration tool like  ufw , which uses iptables as system-of-record, the commands below might render your system inaccessible. Because of this, we recommend that you flush all iptables rules: iptables -F && iptables -t nat -F && iptable...

Docker Private Registry Setup (Manual - Without any automation scripts like trow)

Pre-requisites: >> k8s cluster setup with 1 Master and 2 Worker Nodes. >> docker is install in all the nodes. >> static ips for each nodes. Add the blow entries in the /etc/hosts file of all the nodes. 10.0.1.13 registryserver.mydomain.com 10.0.1.12 registryclient01.mydomain.com 10.0.1.14 registryclient02.mydomain.com Then in the Registry server node, issue the below command: Install Docker Registry ####################### Before starting, you will need a Docker private Registry on registry-server instance. First, download the registry image from the Docker Hub using the following command: # docker pull registry:2 Once the registry image downloaded, you will need to generate a self-signed certificate for securing Docker Registry. Because, Docker node uses a secure connection over TLS to upload or download images to or from the private registry. Go to the registry-server and run the following command to generate certificate: # mkdir /etc/certs...

Nginx Ingress controller setup in K8S MultiNode Cluster with HA-Proxy as External LB

https://github.com/nginxinc/kubernetes-ingress/blob/master/docs/installation.md Pre-requisites: ############### >> K8s cluster setup with 1 Master and 2 Worker nodes. >> Deployed an application with Deployment name "client-sb" >> Also you need to create an HA-proxy server by spinning an Ec2 instance. After login the Ha-proxy server. # yum install haproxy # vi /etc/haproxy/haproxy.cfg delete everything after the global and defaults starting from "Main front-end which proxys to the backend" paste the below code in the end of the file: --------------------- frontend http_front   bind *:80   stats uri /haproxy?stats   default_backend http_back backend http_back   balance roundrobin   server kube 10.0.1.14:80   server kube 10.0.1.12:80 --------------------- # systemctl status haproxy # systemctl enable haproxy # systemctl start haproxy 1. Create a Namespace, a SA, the Default Secret, the Customization Confi...

Persistent Volume in K8s Multinode cluster with NFS

nfs - server (10.0.1.9) ############ Amazon machine linux # yum update # yum install nfs-utils -y # systemctl enable nfs-server # systemctl start nfs-server # mkdir -p /srv/nfs/k8sdata # chmod -R 777 /srv/nfs/k8sdata # vi /etc/exports /srv/nfs/k8sdata *(rw,no_subtree_check,no_root_squash,insecure) :wq! # exportfs -rav # exportfs -v /srv/nfs/k8sdata (rw,sync,wdelay,hide,no_subtree_check,sec=sys,insecure,no_root_squash,no_all_squash) Now in NFS- Client: ################# Ubuntu 16.04 # sudo apt-get update # sudo apt-get install nfs-common # showmount -e 10.0.1.9 Export list for 10.0.1.9: /srv/nfs/k8sdata * Testing ------- # sudo mount -t nfs 10.0.1.9:/srv/nfs/k8sdata /mnt # root@dn1:~# df -h | grep nfs 10.0.1.9:/srv/nfs/k8sdata  8.0G  1.8G  6.3G  22% /mnt # umount /mnt Now in the kubectl terminal issue the pv and pvc create with yamls cat > 4-pv-nfs.yaml apiVersion: v1 kind: PersistentVolume metadata:   name...

Certbot install in AWS EC2 instance Amazon machine image for HA Proxy LB Server

If you try to install certbot you will get a message like below in Amazon machine image EC2 instance. ------------------------------------------------------------ Sorry, I don't know how to bootstrap Certbot on your operating system! You will need to install OS dependencies, configure virtualenv, and run pip install manually. Please see https://letsencrypt.readthedocs.org/en/latest/contributing.html#prerequisites ------------------------------------------------------------ Fix: ###  Amazon Linux 2 doesn't have  epel-release  in its repositories, but I've found you can install the EPEL RPM package itself, and then you'll be able to install  certbot  or  certbot-nginx  from there. Download the RPM curl -O http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm Then install it sudo yum install epel-release-latest-7.noarch.rpm Now you can install certbot sudo yum install certbot And then run it as usual sudo certb...

Setting up Helm chart for K8s cluster

Helm is a powerful and flexible package-management and operations tool for Kubernetes. There are two parts to Helm: The Helm client (helm) and the Helm server (Tiller). https://helm.sh/docs/using_helm/#installing-helm 1) ssh to your k8s master node 2) Download the helm client from the url : https://github.com/helm/helm/releases Linux amd64 (checksum) # wget https://get.helm.sh/helm-v2.15.1-linux-amd64.tar.gz # tar -xzvf helm-v2.15.1-linux-amd64.tar.gz # mv linux-amd64/helm /usr/local/bin # which helm # helm version --client --short 3) Now we need to initialize the helm server (Tiller) in the k8s cluster. For this,  > first we need to create a serviceaccount called tiller in the kube-system namespace.  > then create a clusterrolebinding called tiller and attach the clusterrole cluster-admin to the serviceaccount tiller.  # kubectl -n kube-system create serviceaccount tiller  # kubectl create clusterrolebinding tiller --clusterrole clus...