Rajan Silwal
  • 👋Welcome to My Personal Page
  • Project
    • 👨‍💼Daily Activities
    • ⚠️Monitoring Tools
    • ✍️Git
    • 🏎️Automation Tools
    • 💻Virtualization
    • 🖥️Immutable Infrastructure
    • 🔶Cloud (AWS)
    • ⛲Container
  • ⚠️Monitoring Tools
    • 💡Prometheus
      • How to Setup Prometheus
      • Setup Node-exporter
      • Setup Prometheus to get metrics
    • 💡Grafana
    • 💡Nagios
  • ✍️Git
    • 🐇CI/CD in Git
      • Setup Git for CICD
  • ⛲Container
    • 📍Docker
      • Docker image
      • Same Docker image in VM
  • 🚗k8s
    • Install K8S
  • 🏎️Automation Tools
    • 🖨️Ansible
      • List of my Ansible Playbook
    • Terraform
      • Setup Terraform in AWS
      • Create VPC using .tf
      • Create EC2 using .tf
      • Command Familiars in Terraform
  • 💻Virtualization
    • 🔄OpenNebula
      • Setup OpenNebula
      • Onehost Server
      • Build VM in OpenNebula
  • 🔶Cloud (AWS)
    • 🌥️EC2
    • 🌥️IAM
    • 🌥️VPC
    • 🌥️Load Balancer
    • 🌥️S3 Bucket
    • 🌥️Route 53
  • 🖥️Immutable Infrastructure
    • 1️⃣1⃣ Content
    • 2️⃣2⃣ Virt-Install
    • 3️⃣3⃣ Base Image
    • 4️⃣4⃣ Golden-Image
    • 5️⃣5⃣ After-Golden-Image
Powered by GitBook
On this page
  • K8S
  • swap kernel
  • intall packages:
  • bootstrap Cluster
  • Network configuration
  • Once all the above steps are ready:
  • From above we can say two nodes are ready for deployment:
  • Lets deploy a container using CMD
  1. k8s

Install K8S

K8S

hostnamectl set-hostname k8sm
vi /etc/resolv.conf
vi /etc/hosts

swap kernel

sudo modprobe overlay sudo modprobe br_netfilter

intall packages:

intsall containerd on both master and node yum install -y kubectl kubeadm kubelet

bootstrap Cluster

kubeadm init --control-plane-endpoint=192.168.1.130 or k8sm1.home.com
mkdir -p $HOME/.kube 
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config 
sudo chown $(id -u):$(id -g) $HOME/.kube/config 
kubectl get nodes

Network configuration

kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml kubectl apply -f calico.yaml

Once all the above steps are ready:

ssh k8smaster:
kubectl get nodes
```sh
[root@k8sm1 wal]# kubectl get nodes
NAME    STATUS   ROLES           AGE    VERSION
k8sm1   Ready    control-plane   187d   v1.28.2
k8sn1   Ready    <none>          187d   v1.28.2
k8sn2   Ready    <none>          187d   v1.28.2
```

From above we can say two nodes are ready for deployment:

There is 2 ways to deploy 
1. Imperrative way:
   1. It is a way to deploy using command line:
      1. kubectl create deployment nginx --image=nginx --replicas=3
      2. It will automatically deploy nginx and replication will be 3
2. Deceletative way:
   1. Using Yaml/Json manifest file

Lets deploy a container using CMD

        kubectl get pod
        kubectl create deployment nginx --image=nginx --replicas=3
        [root@k8sm1 wal]# kubectl get pod
        NAME                     READY   STATUS    RESTARTS   AGE
        nginx-7854ff8877-djvzz   1/1     Running   0          14s
        nginx-7854ff8877-jbr5v   1/1     Running   0          14s
        nginx-7854ff8877-pnjvv   1/1     Running   0          14s
        [root@k8sm1 wal]# 
        kubectl get deployments.apps
        kubectl logs pods {pods_name}
        kubectl exec -it nginx-7854ff8877-pnjvv bash // if you need to go inside container
        kubectl delete deployments.apps nginx
PreviousSame Docker image in VMNextAnsible

Last updated 11 months ago

🚗