Showing posts with label centos7. Show all posts
Showing posts with label centos7. Show all posts

Wednesday, August 3, 2022

#Install #docker on #Centos7, #Centos9, #Ubuntu20

Tested OSs: Centos7, Centos9 and Ubuntu 20


Step-1 (Optional)

*Note: Ignore this step, if you are not in installing docker in the University of Tartu's private cloud

- Create the daemon file manually. This is because of some conflict in University's Openstack Environment.

sudo mkdir -p /etc/docker && cd /etc/docker

- Create and update docker daemon file

1
2
3
4
5
6
sudo tee /etc/docker/daemon.json <<EOF
{
	
"default-address-pools": [{"base":"172.80.0.0/16","size":24}]
}
EOF

Step-2

  • Now run this command. It will add the official Docker repository, download the latest version of Docker, and install it:
curl -fsSL https://get.docker.com/ | sh
  • After installation has completed, start the Docker daemon:
sudo systemctl start docker
  • Verify that it’s running:
sudo systemctl status docker
  • Enable docker

    sudo systemctl enable docker

Step-3

To run docker commands with non-root privileges

  • Create a docker group (If it's already created then ignore): sudo groupadd docker
  • Add a user to docker group: sudo usermod -aG docker $USER
  • Activate the changes: newgrp docker
  • Check the installation by displaying docker version: docker --version

 

 

 - That's all for now.

Thursday, October 7, 2021

Installing python3 and pip3 on Centos7

Here I have no python3 installed

The most simplest way to install python3
=================
sudo yum install python3

Make python 3.6 as default one
=================
sudo alternatives --install /usr/bin/python python /usr/bin/python3.6 60
sudo alternatives --config python

Check the python version
==================

Check the pip version
==================

Check the pip3 version
==================

Upgrade pip3
=================
pip3 install --upgrade pip --user



 

Check the pip version

==================


Bonus: Fixing yum package manager

Now lets try to install a random package to check the yum package manager

Install nano
=============
sudo yum install nano
you will get following error

To fix this, Open the /usr/bin/yum file and in the first line, change python to python2
OLD:


NEW:

If again you got similar issue with different file, for example:

Open this file (sudo vi /usr/libexec/urlgrabber-ext-down ) and in the first line change "python" to "python2"

 

Here is the Youtube demo:


 

 

-That's all for now

Monday, September 20, 2021

Managing Kubernetes clusters using Rancher [20Sept2021]


 
Here is the Environment for me. You may go with single worker node 

Created Tuesday 07 September 2021

Rancher node: Centos 7 (better to keep this separate from cluster nodes), flavor: m3.xsmall
Master Node: Centos 7, m3.xsmall
Worker Node-1: Centos 7, m3.xsmall
Worker Node-2: Centos 7, m3.xsmall

Both Master and Work Node have allow-all security group attached
Minimal ports required are 80/TCP, 443/TCP

[src: https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/deployment/quickstart-manual-setup/

Common installation

  1. Install Docker

  • Create the daemon file manually. This is also because of some conflict in University's Openstack Environment.

        sudo mkdir -p /etc/docker
        sudo tee /etc/docker/daemon.json <<EOF
	{
	  "exec-opts": ["native.cgroupdriver=systemd"],
	  "log-driver": "json-file",
	  "log-opts": {
	    "max-size": "100m"
	  },
	  "storage-driver": "overlay2",
	  "storage-opts": [
	    "overlay2.override_kernel_check=true"
	  ],

"default-address-pools": [{"base":"172.80.0.0/16","size":24}]

	}
	EOF

  • Now run this command. It will add the official Docker repository, download the latest version of Docker, and install it:
curl -fsSL https://get.docker.com/ | sh
  • After installation has completed, start the Docker daemon:
sudo systemctl start docker
ERROR if docker is unable to start, try to check the /etc/docker/daemon.json file
  • Verify that it’s running:
sudo systemctl status docker
  • enable docker to start on boot:
sudo systemctl enable docker
  • To run docker commands with non-root privileges

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

Rancher node

  1. Enter the following command to run rancher container
sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher
  1. Go to the web browser and hit https://<SERVER_IP_Rancher_Node>
  2. Follow the wizard for initial setup
Once it is done, you should be able to see the dashboard with local as the cluster name

Create a new cluster

src: https://rancher.com/docs/rancher/v2.5/en/quick-start-guide/deployment/quickstart-manual-setup/

  1. Go to the browser and access Rancher Dashboard
  2. From the dashboard, click on Create
  3. Click on Custom
  4. Give Cluster Name as cluster-1 and skipp other infos
  5. Click on Next
  6. Select etcd , Control Plane , Worker
  7. Select the Registration command
    1. The registration command should look like:
sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.6.0 --server https://172.17.90.86 --token bflxwjlsvsrtbnvp8nj5xq82xx2sr5npjsxm82mbtdcfkc9g65x5d8 --ca-checksum f9bc8c23fff67155023fde69026ec83a77f632657f1049fd6ca9ae5732cf59d3 --etcd --controlplane --worker
  1. Go to master node terminal and execute the registration command

At this point you need to wait for few minutes...

  1. After this, you will see in the browser that 1 New node has registered.
  2. Now click on Done
  3. Repeat Step 6 to get the registration command for worker node. For worker node you just need to select Worker

Deleting a node

[src: https://rancher.com/docs/rancher/v2.5/en/cluster-admin/cleaning-cluster-nodes/]
Deleting Docker Containers, Images, and Volumes

Based on what role you assigned to the node, there are Kubernetes components in containers, containers belonging to overlay networking, DNS, ingress controller and Rancher agent. (and pods you created that have been scheduled to this node)

To clean all Docker containers, images and volumes:

docker rm -f $(docker ps -qa)
docker rmi -f $(docker images -q)
docker volume rm $(docker volume ls -q)

Clean the related directories

sudo rm -rf /etc/ceph \
	   /etc/cni \
	   /etc/kubernetes \
	   /opt/cni \
	   /opt/rke \
	   /run/secrets/kubernetes.io \
	   /run/calico \
	   /run/flannel \
	   /var/lib/calico \
	   /var/lib/etcd \
	   /var/lib/cni \
	   /var/lib/kubelet \
	   /var/lib/rancher/rke/log \
	   /var/log/containers \
	   /var/log/kube-audit \
	   /var/log/pods \
	   /var/run/calico

It is now good to reboot the VM with following command:

sudo reboot



-That's all