Git Product home page Git Product logo

k8s-resource's Introduction

k8s-resource

Kubernetes Cluster installation using kubeadm

Follow this documentation to set up a Kubernetes cluster on REDHAT machines.

This documentation guides you in setting up a cluster with one master node and two worker nodes.

Prerequisites:

  1. System Requirements

    Master: t2.medium (2 CPUs and 2GB Memory)
    Worker Nodes: t2.micro

  2. Open Below ports in the Security Group.

    Master node:

    6443 32750 10250 4443 443 8080 179

    On Worker node:

    179

    On Both Master and Worker:

  3. Perform all the commands as root user unless otherwise specified

    Install, Enable and start docker service. Use the Docker repository to install docker.

    If you use docker from CentOS OS repository, the docker version might be old to work with Kubernetes v1.13.0 and above

    sudo yum install -y yum-utils
    sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
  4. Start Docker services

    systemctl enable docker
    systemctl start docker
  5. Disable SELinux

    setenforce 0
    sed -i --follow-symlinks 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux
  6. Disable Firewall

    systemctl disable firewalld
    systemctl stop firewalld
  7. Disable swap

    sed -i '/swap/d' /etc/fstab
    swapoff -a
  8. Update sysctl settings for Kubernetes networking

    sudo tee /etc/sysctl.d/kubernetes.conf<<EOF
    net.bridge.bridge-nf-call-ip6tables = 1
    net.bridge.bridge-nf-call-iptables = 1
    EOF
    sysctl --system

Kubernetes Setup

  1. Add yum repository for kubernetes packages
    sudo tee /etc/yum.repos.d/kubernetes.repo<<EOF
    [kubernetes]
    name=Kubernetes
    baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
    enabled=1
    gpgcheck=1
    repo_gpgcheck=1
    gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
    EOF
  2. Install Kubernetes
    yum install -y kubeadm kubelet kubectl
  3. Enable and Start kubelet service
    systemctl enable kubelet
    systemctl start kubelet

On Master Node Only:

  1. Initialize Kubernetes Cluster

    kubeadm init --apiserver-advertise-address=<MasterServerIP> --pod-network-cidr=192.168.0.0/16
  2. Create a user for kubernetes administration and copy kube config file.
    To be able to use kubectl command to connect and interact with the cluster, the user needs kube config file.
    In this case, we are creating a user called kubeadmin

    useradd kubeadmin 
    mkdir /home/kubeadmin/.kube
    cp /etc/kubernetes/admin.conf /home/kubeadmin/.kube/config
    chown -R kubeadmin:kubeadmin /home/kubeadmin/.kube
  3. Deploy Calico network as a kubeadmin user.

    This should be executed as a user (heare as a kubeadmin )

    sudo su - kubeadmin 
    curl https://docs.projectcalico.org/manifests/calico.yaml -o calico.yaml
    kubectl apply -f calico.yaml
  4. Cluster join command

    kubeadm token create --print-join-command

On Worker Node Only:

  1. Add worker nodes to cluster

    Use the output from kubeadm token create command in previous step from the master server and run here.

On Master Node:

  1. Verifying the cluster To Get Nodes status
    kubectl get nodes
    To Get component status
    kubectl get cs

RUN-TIME ERROR HANDLE

rm -rf /etc/containerd/config.toml

systemctl restart containerd


For label change

kubectl label node ip-172-31-86-115.ec2.internal kubernetes.io/role=worker --overwrite=true

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.