Create Containers
In Kubernetes (K8s), containers are the fundamental units for building and running applications. A container is a lightweight, standalone, executable package that includes everything required to run an application—code, runtime, system tools, system libraries, and configuration. Containers are created and managed through container runtimes such as Docker, containerd, or CRI-O.
Deploy Containers Using Pods
In Kubernetes, containers are managed and executed inside Pods. A Pod is the smallest deployable unit in Kubernetes and may contain one or more tightly coupled containers. All containers within a Pod share the same network namespace and storage volumes.
If your container requires GPU resources, refer to GPU Resources.
Example
apiVersion: v1
kind: Pod
metadata:
name: your-pod-name
namespace: your-namespace
spec:
imagePullSecrets:
- name: ydyd-harbor-secret
containers:
- name: your-container-name
image: your-image
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /mnt/test
name: your-volume-name
command: ['/bin/bash', '-c', 'while true; do sleep 30; done']
volumes:
- name: your-volume-name
persistentVolumeClaim:
claimName: your-pvc-name
Manage Pods Using Deployments
In Kubernetes, a Deployment is a higher-level resource used for managing stateless applications. A Deployment provides a declarative way to define the desired state of an application and ensures that the actual cluster state matches that desired configuration. With Deployments, you can easily perform rollout, scaling, updates, and rollbacks. n real-world scenarios, Deployments are commonly used to manage Pods.
Example
apiVersion: apps/v1
kind: Deployment
metadata:
name: your-deploy-name
namespace: your-namespace
spec:
replicas: 1
selector:
matchLabels:
app: wedding-ai-api
template:
metadata:
labels:
app: wedding-ai-api
spec:
imagePullSecrets:
- name: ydyd-harbor-secret
containers:
- name: your-container-name
image: your-image
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /mnt/test
name: your-volume-name
command: ['/bin/bash', '-c', 'while true; do sleep 30; done']
volumes:
- name: your-volume-name
persistentVolumeClaim:
claimName: your-pvc-name