Kubernetes For Beginners

0
242

Kubernetes Main Resources

✔𝗡𝗼𝗱𝗲: A Node is a Kubernetes cluster’s worker computer. Either a physical or virtual machine may be used. The operating and management of the pods is done by the nodes.

✔𝗡𝗮𝗺𝗲𝘀𝗽𝗮𝗰𝗲: The cluster resources can be split up into virtual clusters using namespaces. It gives names a range and enables many teams or projects to share the same physical cluster while isolating their resources.

✔Deployment : simplifies the process of managing and controlling the lifecycle of applications in a Kubernetes cluster, making it easier to deploy and update applications with minimal downtime and manual intervention.

✔𝗥𝗲𝗽𝗹𝗶𝗰𝗮𝗦𝗲𝘁: ReplicaSets are Kubernetes objects that guarantee a certain number of pod replicas are always active. Scaling and managing the number of pods for a certain application are done using it.

✔Ingress: in Kubernetes is an API object that serves as an entry point for external traffic into the cluster, acting as a layer between the external world and the services running inside.

✔𝗦𝗲𝗿𝘃𝗶𝗰𝗲: A logical set of pods and a policy for accessing them are defined by a service, which is an abstraction. For the pods behind it, it offers a reliable network endpoint (IP address) and load balancing.

✔𝗣𝗼𝗱: A Pod is the smallest and most basic unit in Kubernetes. It represents a single instance of a running process or a set of tightly coupled processes running together on a node. Pods are scheduled and managed by Kubernetes.

✔Network policies: in Kubernetes are a set of rules that control the traffic flow between pods within a cluster. Network policies enhance security and provide granular control over network traffic within the cluster.

✔Persistent Volumes (PVs): Kubernetes are storage resources that provide durable and independent storage for applications. PVs enable data persistence and can be dynamically provisioned or statically allocated within the cluster.

✔Persistent Volume Claims : (PVCs) in Kubernetes are requests made by applications for storage resources. PVCs provide a convenient abstraction layer, allowing applications to request and access persistent storage without directly dealing with specific PVs.

✔Service Accounts: in Kubernetes are used to provide an identity and access control for pods within the cluster. Service Accounts facilitate secure communication and authorization between pods and the Kubernetes cluster.

✔Storage Classes : in Kubernetes are used to dynamically provision different types of storage volumes based on predefined configurations.It enable flexibility and scalability in allocating storage for applications within the cluster.

Kubernetes Shortcuts

kubectl get no
kubectl get ns
kubectl get deploy
kubectl get rs
kubectl get ing
kubectl get svc
kubectl get po
kubectl get netpol
kubectl get pv
kubectl get pvc
kubectl get sa
kubectl get sc

Beginner Academy

ResourceShortcutsCommand
Nodenokubectl get no
Namespacenskubectl get ns
Deployment deploykubectl get deploy
Replica Setrskubectl get rs
Ingressingkubectl get ing
Servicessvckubectl get svc
Podpokubectl get po
Network policiesnetpolkubectl get netpol
Persistent Volumespvkubectl get pv
Persistent Volume Claimspvckubectl get pvc
Service Accountssakubectl get sa
Storage Classessckubectl get sc

Kubernetes frequently used Commands

  1. kubectl get: Retrieve information about resources in the cluster.
    kubectl get pods: List all pods.
    kubectl get deployments: List all deployments.
    kubectl get services: List all services.
    kubectl get nodes: List all nodes in the cluster.
kubectl get pods
kubectl get deployments
kubectl get services
kubectl get nodes

2.kubectl describe: Provide detailed information about a specific resource.
kubectl describe pod <pod-name>: Get detailed information about a pod.
kubectl describe deployment <deployment-name>: Get detailed information about a deployment.
kubectl describe service <service-name>: Get detailed information about a service.

kubectl describe pod <pod-name>
kubectl describe deployment <deployment-name>
kubectl describe service <service-name>

3.kubectl create: Create a resource from a YAML or JSON file.
kubectl create -f <filename.yaml>: Create a resource from a YAML file.
kubectl create deployment <deployment-name> — image=<image-name>: Create a deployment using a specified image.

kubectl create -f <filename.yaml>
kubectl create deployment <deployment-name> - image=<image-name>

4.kubectl delete: Delete a resource.
kubectl delete pod <pod-name>: Delete a pod.
kubectl delete deployment <deployment-name>: Delete a deployment.
kubectl delete service <service-name>: Delete a service.

kubectl delete pod <pod-name>
kubectl delete deployment <deployment-name>
kubectl delete service <service-name>

5.kubectl scale: Scale the number of replicas in a deployment.
kubectl scale deployment <deployment-name> — replicas=<number>: Scale the number of replicas for a deployment.

kubectl scale deployment <deployment-name> - replicas=<number>

6.kubectl logs: Print the logs of a pod.
kubectl logs <pod-name>: Print the logs of a pod.

kubectl logs <pod-name>

7.kubectl exec: Execute a command on a pod.
kubectl exec -it <pod-name> — <command>: Execute a command on a pod interactively.

kubectl exec -it <pod-name> - <command>

8.kubectl apply: Apply changes to a resource defined in a YAML or JSON file.
kubectl apply -f <filename.yaml>: Apply changes to a resource using a YAML file.

kubectl apply -f <filename.yaml>