Kubernetes and OpenShift, several key types of workload resources (deployments or applications) - unix1998/technical_notes GitHub Wiki
In Kubernetes and OpenShift, there are several key types of workload resources (deployments or applications) that you can use to manage and orchestrate containers. Here's an overview of the main types, including those you mentioned and a few others:
-
Pod: The smallest and simplest Kubernetes object. A pod represents a single instance of a running process in your cluster. Pods can contain one or more containers.
-
Deployment: Used to manage stateless applications. A Deployment ensures that a specified number of pod replicas are running at any given time. It can also be used for rolling updates and rollbacks.
apiVersion: apps/v1 kind: Deployment metadata: name: example-deployment spec: replicas: 3 selector: matchLabels: app: myapp template: metadata: labels: app: myapp spec: containers: - name: myapp-container image: myapp:latest
-
StatefulSet: Manages stateful applications, such as databases and message queues. Unlike Deployments, StatefulSets maintain a sticky identity for each pod and provide guarantees about the ordering and uniqueness of these pods.
apiVersion: apps/v1 kind: StatefulSet metadata: name: example-statefulset spec: serviceName: "example" replicas: 3 selector: matchLabels: app: example template: metadata: labels: app: example spec: containers: - name: myapp-container image: myapp:latest
-
DaemonSet: Ensures that a copy of a pod is running on each node (or a subset of nodes). This is useful for deploying system daemons like log collectors and monitoring agents.
apiVersion: apps/v1 kind: DaemonSet metadata: name: example-daemonset spec: selector: matchLabels: app: example template: metadata: labels: app: example spec: containers: - name: myapp-container image: myapp:latest
-
Job: Creates one or more pods and ensures that a specified number of them successfully terminate. Jobs are used for running batch processing tasks.
apiVersion: batch/v1 kind: Job metadata: name: example-job spec: template: spec: containers: - name: myapp-container image: myapp:latest restartPolicy: Never backoffLimit: 4
-
CronJob: Creates jobs on a time-based schedule. CronJobs are useful for periodic tasks like backups and report generation.
apiVersion: batch/v1 kind: CronJob metadata: name: example-cronjob spec: schedule: "*/5 * * * *" jobTemplate: spec: template: spec: containers: - name: myapp-container image: myapp:latest restartPolicy: OnFailure
-
ReplicaSet: Ensures that a specified number of pod replicas are running at any given time. While Deployments manage ReplicaSets, you can also create and manage them directly. However, it is generally recommended to use Deployments instead.
apiVersion: apps/v1 kind: ReplicaSet metadata: name: example-replicaset spec: replicas: 3 selector: matchLabels: app: example template: metadata: labels: app: example spec: containers: - name: myapp-container image: myapp:latest
-
ReplicationController: Similar to ReplicaSet, but with a slightly different API. It ensures that a specified number of pod replicas are running at any given time. ReplicaSet is preferred over ReplicationController.
apiVersion: v1 kind: ReplicationController metadata: name: example-replicationcontroller spec: replicas: 3 selector: app: example template: metadata: labels: app: example spec: containers: - name: myapp-container image: myapp:latest
-
Service: Although not a deployment type, it's essential for exposing your pods. Services provide a stable network endpoint for a set of pods and can load balance traffic to them.
apiVersion: v1 kind: Service metadata: name: example-service spec: selector: app: example ports: - protocol: TCP port: 80 targetPort: 9376
-
Ingress: Manages external access to services, typically HTTP. Ingress can provide load balancing, SSL termination, and name-based virtual hosting.
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
These types of resources allow you to build, deploy, and manage a wide variety of applications and services on Kubernetes and OpenShift, catering to different use cases and requirements.