Installing kubernetes using kube-adm on Azure
you are an kuberenetes expert
I'm a begineer in kubernetes
I'm trying to install k8s 1.34 using kube-adm with single master and one node
my virtual machines are in Azure and both of them are ubuntu 22.04 using CRI which is docker and CNI which is calico.
Give me details from system requirements to installation steps and checks to ensure k8s is working correctly
- Watch classroom recording
kubectl basics
- kubectl is a cli tool which helps in interacting with kuberentes cluster.
- kubectl interacts with api server,
- kubeapi-server is https (secured http) and for kubectl to interact with k8s cluster needs tokens/keydata/credentials
- As part of k8s installation we executed the following commands 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
- The
~/.kube/config file contains information about
- where k8s cluster is
- name of the cluster
- credential information.
- kubectl cli reference
- Refer Here for cheat sheet.
- On linux machines enable autocomplete
source <(kubectl completion bash) # set up autocomplete in bash into the current shell, bash-completion package should be installed first.
echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.
Pod
- This is atomic object/workload which k8s creates
- Pod contains container(s) in it.
- A Pod expects container to be in running state, if it exits pod restarts the container.
- If the pod is restarting the container continously this state is referred as
crashloopbackoff
- A pod can contian one or more containers.
- In Pod the first container where we run the application is referred as maincar and all the other containers are referred as sidecar’s
Writing Manifest
- Generally this involves writing yaml file
- In most manifest files we have the following structure
apiVersion: <your input>
kind: <your input>
metadata: <your input>
spec: <your input>
- once we apply k8s adds the fifth section
apiVersion: <your input>
kind: <your input>
metadata: <your input>
spec: <your input>
status: <filled by k8s>
-
To fill this manifest, we need to understand REST API, API Versions
-
K8s exposes its functionality over REST API.
- K8s API Versioning
- K8s API Groups:
<group>/<version>
- core =>
<version>
- apps =>
apps/v1, batch/v1
- kind => This refers to type of object (Resources/workloads) which we are creating (nouns of k8s)
- ON the resources we can generally perform 4 basic operations
- metadata: For every resource we create we need to give name or some metadata
- spec: This is specification of what we wnat
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
labels:
app: nginx
spec:
containers:
- name: nginx-container
image: nginx:1.14.2
ports:
- containerPort: 80
-
To see all the possibilites of writing yaml specs, k8s gives api reference. Refer Here
-
Lets fill first two values for
- pod
apiVersion: v1
kind: Pod
apiVersion: apps/v1
kind: DaemonSet
apiVersion: v1
kind: Service
apiVersion: v1
kind: PersistentVolumeClaim
apiVersion: policy/v1
kind: PodDisruptionBudget
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: test
image: httpd
Like this:
Like Loading...