Giter Site home page Giter Site logo

cka-setup-guide's Introduction

Setting up Kubernetes in (not so) hard way

Cluster Preparation Guide for CKA

Using kubeadm

K8s

Consideration

  • Virtual Machines are created in Azure under Azure VNet
  • One client machine has Public IP others are Private
  • IP Range
  • Docker
  • Kubeadm
  • One master VM
    • Weaver as Pod network plugin
  • Two Worker VM
  • One Client VM with Public IP

Architecture

Steps

1-Create Azure Resources

  • Resource Group
  • Storage Account (optional)
  • Virtual Network
  • Subnet
  • NIC
  • Public IP Address
  • Three Virtual Machines (for Kubernetes)
  • One Virtual machine as client to connect the K8s cluster

Azure resources Setup Script

2-Prepare the Virtual Machines

Login to the Client VM using Public IP then connect to the other three Virtual Machines.

Install & Configure [as super user]

  • IP tables
  • Docker
  • Kubectl, Kubeadm, Kubelet

Here is the Script

3-Master Node

Here is the Script

Post-setup for master

Follow the instruction given in the outout of the successful setup,

  • Copy kubeconfig to the folder
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
  • Copy the kubeadm join command
  • Install the pod network plugin kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"

4-Join Worker Node

Using the token generated from previous step connect this to the Kubernetes master.

If you forget it then generate a new one by running sudo kubeadm token create --print-join-command

Worker node setup Script

5-Confirm the Setup

Configure the client machine for kubectl

Best Practices It is not recommended to run kubectl in master or worker node. You should run it from outside of the K8s cluster.

In client machine create a folder ~/.kube by

mkdir -p $HOME/.kube

Then copy the ~/.kube/config from master node to client machine using scp

scp config cka@clientIP:$HOME/.kube

Then run this command in client machine

kubectl get nodes 

If the above shows list of nodes and in ready state then we are good to go.

Create a pod to test,

kubectl run nginx --image=nginx

Then check the list of pods

kubectl get pods

6 - Some useful Azure CLI Commands

Get the list of running VMs in a Resource Group

resourceGroup='rg-cka2'
az vm list -d -g $resourceGroup --query "[].{name:name,powerState:powerState}" -o table

Start all the VMs in a Resrouce Group

resourceGroup='rg-cka2'
az vm start --ids $(az vm list -g $resourceGroup --query "[].id" -o tsv)

Stop (deallocate) all the VMs in a Resource Group

resourceGroup='rg-cka2'
az vm deallocate --ids $(az vm list -g $resourceGroup --query "[].id" -o tsv)

7 - Clean up Azure Resources

If you delete the resource group it will delete all the resources inside

# Will ask for confirmation
az group delete -n wriju

# Anyc delete 
az group delete -n wriju --no-wait 

Resources


Prepared and maintained by Wriju Ghosh for CKA Exam playground

Contribute https://github.com/wrijugh/cka-setup-guide

Web https://wrijugh.github.io/cka-setup-guide/

Tested as of 31-August-2021

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.