Showing posts with label CentOS. Show all posts
Showing posts with label CentOS. Show all posts

Friday, August 28, 2020

Get insight into a Linux machine using Cockpit

Cockpit is an interactive Linux server admin interface. You can use it to monitor/ manage a Linux node through a web browser.


Install Cockpit on the Linux machine


yum install cockpit -y

systemctl start cockpit

systemctl enable --now cockpit.socket

Saturday, February 15, 2020

Kubernetes 101 - Part2 - Basic operations

In this article, I will walk you through basic kubectl commands for working with K8s clusters.

kubectl cluster-info

kubectl version --short

kubectl get namespaces

kubectl get nodes -o wide

kubectl get pods -o wide --all-namespaces

kubectl get pods --show-labels
kubectl get nodes --show-labels

Deploy a pod

Following is a sample yaml file for deploying a CentOS pod:

apiVersion: v1
kind: Pod
metadata:
 name: centos-pod
 labels:
  zone: test
  version: v1
spec:
 containers:
 - name: centos-pod
   image: centos:latest
   command: ["sleep"]
   args: ["1d"]
 nodeSelector:
    kubernetes.io/hostname: w2


To deploy the pod:
kubectl create -f centos-pod.yml

kubectl describe pod centos-pod

SSH into the pod:
kubectl exec -it centos-pod sh

kubectl delete pod centos-pod

Hope it was useful. Cheers!

Kubernetes 101 - Part1 - Create K8s cluster with kubeadm


Deploy 3 CentOS 7 VMs. One will be the master and the other two will be workers/ slaves.
Master is "m1" and workers are "w1" and "w2".

Plan IP address
192.168.105.100 - m1
192.168.105.101 - w1
192.168.105.102 - w2
Step1: on all 3 nodes
vi /etc/hosts
192.168.105.100 m1
192.168.105.101 w1
192.168.105.102 w2
Step2: on all 3 nodes
#Disable firewall
sudo firewall-cmd --state
sudo systemctl stop firewalld
sudo systemctl disable firewalld
sudo systemctl status firewalld
setenforce 0
sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
Step3: on all 3 nodes
#Configure iptables for Kubernetes
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
Step4: on all 3 nodes
#Disable swap
swapoff -a
vi /etc/fstab (Edit fstab file and comment(#) swap partition)

reboot all 3 nodes
Step5: on all 3 nodes
#configure kubernetes repo
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
enabled=1
gpgcheck=1
repo_gpgcheck=1
EOF
Step6: Install docker on all 3 nodes
yum install docker -y
Step7: on all 3 nodes
yum install -y kubeadm kubectl kubelet --disableexcludes=kubernetes
systemctl daemon-reload
systemctl restart docker && systemctl enable --now docker
systemctl restart kubelet && systemctl enable --now kubelet
Step8: on master
kubeadm init --pod-network-cidr 10.244.0.0/16
Step9: on master
$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
Step10: on master
Step11: on all worker nodes
Use the join token from master to join worker nodes to the K8s cluster.
Example:
kubeadm join 192.168.105.100:6443 --token 4j1cjv.gcj2hx9suq5akc7v \
--discovery-token-ca-cert-hash sha256:b2ead930d772d8af2e45ca8c86c3895b092484c10f8034e52f917e71dc4c3fea

Wednesday, October 23, 2019

Docker 101 - Part3 - Persisting data using volumes

In this article, I will explain how to use Docker volumes for persisting data generated by and used by containers with --mount flag. Volumes use the Docker area and it can be found under /var/lib/docker/volumes/ directory of the Docker host.

Example:

docker run -dit --name centos_volume_test --mount source=data_volume01,target=/datavol01 centos sleep 1800

The above command will run a CentOS container and mounts a volume at /datavol01 inside the container. It uses source /var/lib/docker/volumes/data_volume01. The below screenshot shows the necessary steps to verify it.



Hope it was useful. Cheers!

Related posts


Docker 101 - Part2 - Basic operations

Docker 101 - Part1 - Installation


References




Friday, October 18, 2019

Docker 101 - Part1 - Installation

Enter cloud native! In this article, I will briefly explain how to build a virtual Docker host. Here I am installing Docker on a CentOS 7.4 virtual machine running on ESXi 6.5 which is part of a VMware vSAN cluster.

Prerequisites:
  • Deploy a basic CentOS 7.4 VM
  • Assign IP address and ensure the VM has internet connectivity
  • You should have root creds

Installation:
  • SSH to the CentOS VM as root
  • yum check-update
  • yum install -y yum-utils device-mapper-persistent-data lvm2
  • yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  • yum install docker-ce
  • systemctl start docker
  • systemctl enable docker
  • systemctl status docker

Verify version:
  • docker version

Run your first container:
  • docker run hello-world

Hope it was useful. Cheers! In the next part, I will explain basic Docker commands and operations.

Related posts


References