apiVersion: apps/v1
kind: Deployment
metadata:
name: simple-app
labels:
app: backend
spec:
replicas: 1
selector:
matchLabels:
app: backend-app
template:
metadata:
name: simple-backend-app
labels:
app: backend-app
spec:
containers:
- name: simple-backend-app
image: sample_app
imagePullPolicy: Never
ports:
- containerPort: 5000
env:
- name: url
value: <db_url>
- name: db_name
value: <db_name>
resources:
requests:
memory: "128Mi"
cpu: "250m"
limits:
memory: "256Mi"
cpu: "500m"
restartPolicy: Always
If you do crictl image | grep sample_app
, do you see that the image is in fact available to Kubernetes? That’s the first thing to try. What do you see?
How did you set up your Kubernetes cluster locally? If you’re using Minikube, your local Docker image isn’t automatically available inside the cluster. You need to run the command minikube image load
to make it accessible.
However, I recommend pushing your image to Docker Hub using your personal account. Then, configure Kubernetes to pull the image using a secret with your Docker credentials. This is the standard approach we use in real-world Kubernetes deployments.
Thanks, @raymond.baoly. I’ve tried both pushing the image to Docker Hub and pulling it locally. It seems that with Minikube, I need to build the image directly within the Minikube environment, otherwise, it won’t pull the image successfully.