Alaya NeW Cloud

Create a Container

Deploy and manage containerized applications in VKS using Pods and Deployments

In Kubernetes, a container is the basic unit for building and running applications. A container is a lightweight, independent, executable software package that contains everything needed to run an application: code, runtime, system tools, system libraries, and settings. Containers are created and managed by a container runtime (Docker, containerd, CRI-O, etc.).

Deploy a container in a Pod

In Kubernetes, containers are managed and run inside Pods. The Pod is the smallest deployable unit, and may contain one or more containers. All containers in a Pod share the same network namespace and storage volumes.

If your container needs GPU resources, see 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 with a Deployment

A Deployment is a higher-level resource for managing stateless applications. It declaratively defines the desired state, and the controller reconciles actual state to match. Deployment makes it easy to deploy, scale, update, and roll back. In practice you'll typically use a Deployment 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

Last updated on

Was this page helpful?

On this page