Junior — Middle
Kuidas saab Kubernetes-klasteris käivitada Docker-pildi?
sobes.tech AI
Vastus AI-lt
In Kubernetes, to start a Docker image, a Pod or Deployment object is usually created, which specifies the required container image.
Main methods:
- Create a Pod directly by specifying the Docker image in a YAML manifest:
apiVersion: v1
kind: Pod
metadata:
name: example-pod
spec:
containers:
- name: example-container
image: your-docker-image:tag
- Use Deployment to manage scaling and updates:
apiVersion: apps/v1
kind: Deployment
metadata:
name: example-deployment
spec:
replicas: 3
selector:
matchLabels:
app: example
template:
metadata:
labels:
app: example
spec:
containers:
- name: example-container
image: your-docker-image:tag
- kubectl run — command to quickly start a container from an image:
kubectl run example-pod --image=your-docker-image:tag
Kubernetes will automatically download the image from Docker Registry and start the container within the cluster.