kubernates(K8s) resources Overview

Category : Kubernetes | Sub Category : Kubernetes With Java | By Prasad Bonam Last updated: 2023-11-17 08:12:14 Viewed : 212


kubernates(K8s) resources Overview:

the fundamental components and concepts within the Kubernetes container orchestration platform. Here is an overview:

  1. Node:

    • A physical or virtual machine that runs containers. Each node in a Kubernetes cluster must have container runtime software installed, such as Docker or containerd.
  2. Pod:

    • The smallest deployable unit in Kubernetes. A pod represents a single instance of a running process in a cluster and can contain one or multiple containers that share the same network namespace, storage, and IP address.
  3. Service:

    • An abstraction that defines a logical set of pods and a policy by which to access them. Services enable the discovery of pods and allow communication between them.
  4. Deployment:

    • A higher-level abstraction that manages the deployment of replicated applications or microservices. It enables declarative updates to applications, such as rolling updates or rollbacks.
  5. ReplicaSet:

    • Ensures that a specified number of replicas of a pod are running at all times. It is often used by Deployments to maintain the desired number of replicas.
  6. Namespace:

    • A way to partition resources, both physically and virtually, in a Kubernetes cluster. It allows multiple virtual clusters to be created within the same physical cluster.
  7. ConfigMap:

    • An API object that allows you to store configuration data separately from application code. This can be used to store non-sensitive configuration data in key-value pairs.
  8. Secret:

    • Similar to ConfigMaps, Secrets are used to store sensitive information, such as passwords, OAuth tokens, and SSH keys.
  9. Volume:

    • A directory that is accessible to the containers in a pod. It allows data to persist beyond the lifetime of a pod.
  10. Namespace:

    • A way to divide cluster resources between multiple users or teams. It is commonly used to create isolation between different projects or environments.
  11. Ingress:

    • An API object that provides HTTP and HTTPS routing to services based on rules. It allows external access to services in a cluster.

These are just some of the core resources in Kubernetes. The platform has a rich ecosystem of other resources and features, including StatefulSets, DaemonSets, Jobs, and more, that cater to different use cases and scenarios in container orchestration.

Here is an overview of some key Kubernetes resources:

  1. Node:

    • A worker machine in the Kubernetes cluster, which can be a physical machine or a virtual machine.
  2. Pod:

    • The smallest deployable unit in Kubernetes, representing a single instance of a running process. Pods can contain one or more containers that share network and storage.
  3. Service:

    • An abstraction that defines a logical set of Pods and a policy by which to access them. Services enable network access to a set of Pods.
  4. Namespace:

    • A way to divide cluster resources between multiple users or teams, providing a scope for names.
  5. Deployment:

    • A higher-level abstraction over Pods and ReplicaSets, allowing declarative updates to applications. It enables features like rolling updates and rollbacks.
  6. ReplicaSet:

    • Ensures a specified number of replicas of a Pod are running. It is often used by Deployments.
  7. ConfigMap:

    • A configuration resource that allows you to decouple configuration artifacts from image content.
  8. Secret:

    • An object used to store sensitive information, such as passwords, OAuth tokens, and SSH keys.
  9. Volume:

    • A directory that is accessible to containers in a Pod, used for data persistence.
  10. Ingress:

    • An API object that manages external access to services in a cluster, typically HTTP.
  11. StatefulSet:

    • Manages the deployment and scaling of a set of Pods with unique, persistent identities.
  12. DaemonSet:

    • Ensures that all (or some) Nodes run a copy of a Pod, typically used for running cluster-wide daemons.
  13. Job:

    • A supervisor process that ensures a specified number of parallel running Pods succeed.
  14. CronJob:

    • A time-based job scheduler in Kubernetes that runs Jobs at specified intervals.
  15. PersistentVolume (PV):

    • A piece of networked storage in the cluster that can be dynamically provisioned by a PersistentVolumeClaim (PVC).
  16. PersistentVolumeClaim (PVC):

    • A request for storage by a user, used to claim a PersistentVolume.
  17. ServiceAccount:

    • Provides an identity for processes that run in a Pod.
  18. Role and RoleBinding:

    • Define access permissions for resources within a namespace.
  19. ClusterRole and ClusterRoleBinding:

    • Define access permissions for resources across the entire cluster.

This list covers some of the fundamental resources in Kubernetes. Each resource plays a specific role in managing and orchestrating containerized applications within a cluster. The combination and configuration of these resources enable the deployment, scaling, and management of containerized workloads.

Lets go through each Kubernetes resource with examples and explanations:

1. Pod:

yaml
apiVersion: v1 kind: Pod metadata: name: example-pod spec: containers: - name: nginx-container image: nginx

Explanation:

  • A Pod is the smallest deployable unit in Kubernetes, representing a single instance of a running process.
  • This example defines a Pod named "example-pod" with a single container named "nginx-container" using the NGINX image.

2. Service:

yaml
apiVersion: v1 kind: Service metadata: name: example-service spec: selector: app: example-app ports: - protocol: TCP port: 80 targetPort: 8080

Explanation:

  • A Service defines a logical set of Pods and a policy by which to access them.
  • This example creates a service named "example-service" that selects Pods labeled with "app: example-app" and exposes port 80, forwarding traffic to port 8080 on the selected Pods.

3. Namespace:

yaml
apiVersion: v1 kind: Namespace metadata: name: example-namespace

Explanation:

  • A Namespace provides a way to divide cluster resources between multiple users or teams.
  • This example creates a Namespace named "example-namespace."

4. Deployment:

yaml
apiVersion: apps/v1 kind: Deployment metadata: name: example-deployment spec: replicas: 3 selector: matchLabels: app: example-app template: metadata: labels: app: example-app spec: containers: - name: nginx-container image: nginx

Explanation:

  • A Deployment provides declarative updates to applications, such as rolling updates or rollbacks.
  • This example deploys three replicas of a Pod with the NGINX container and labels them with "app: example-app."

5. ReplicaSet:

yaml
apiVersion: apps/v1 kind: ReplicaSet metadata: name: example-replicaset spec: replicas: 2 selector: matchLabels: app: example-app template: metadata: labels: app: example-app spec: containers: - name: nginx-container image: nginx

Explanation:

  • A ReplicaSet ensures a specified number of replicas of a Pod are running.
  • This example creates a ReplicaSet with two replicas of a Pod using the NGINX container, labeled with "app: example-app."

6. ConfigMap:

yaml
apiVersion: v1 kind: ConfigMap metadata: name: example-configmap data: key1: value1 key2: value2

Explanation:

  • A ConfigMap allows you to decouple configuration artifacts from the container image.
  • This example creates a ConfigMap named "example-configmap" with key-value pairs "key1: value1" and "key2: value2."

7. Secret:

yaml
apiVersion: v1 kind: Secret metadata: name: example-secret type: Opaque data: username: <base64-encoded-username> password: <base64-encoded-password>

Explanation:

  • A Secret is used to store sensitive information securely.
  • This example creates a Secret named "example-secret" with base64-encoded "username" and "password" data.

8. Volume:

yaml
apiVersion: v1 kind: Pod metadata: name: example-pod spec: containers: - name: nginx-container image: nginx volumeMounts: - name: example-volume mountPath: /usr/share/nginx/html volumes: - name: example-volume emptyDir: {}

Explanation:

  • A Volume is a directory accessible to containers in a Pod, used for data persistence.
  • This example mounts an emptyDir volume to the "/usr/share/nginx/html" path in a Pod running the NGINX container.

9. Ingress:

yaml
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: example-ingress spec: rules: - host: example.com http: paths: - path: / pathType: Prefix backend: service: name: example-service port: number: 80

Explanation:

  • An Ingress manages external access to services in a cluster, typically HTTP.
  • This example creates an Ingress named "example-ingress" that directs traffic from "example.com" to the "example-service" on port 80.

These examples cover some of the fundamental Kubernetes resources and how they are configured. They demonstrate the basic building blocks for deploying and managing applications in a Kubernetes cluster.

Search
Related Articles

Leave a Comment: