I am reading the book "Microservices in .NET second edition". In the third chapter of the book the author tries to set up a microk8s cluster on localhost to host a web service. The code for the configuration of the Kubernetes is this:
kind: Deployment
apiVersion: apps/v1
metadata:
name: shopping-cart
spec:
replicas: 1
selector:
matchLabels:
app: shopping-cart
template:
metadata:
labels:
app: shopping-cart
spec:
containers:
- name: shopping-cart
image: your_unique_registry_name.azurecr.io/shopping-cart:1.0.0
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: shopping-cart
spec:
type: LoadBalancer
ports:
- name: shopping-cart
port: 5000
targetPort: 80
selector:
app: shopping-cart
I issue the command
kubectl apply -f shopping-cart.yaml
When I do
kubectl get all
to see if everything runs well I get the following output:
NAME READY STATUS RESTARTS AGE pod/shopping-cart-784b775b94-v5ddl 0/1 ImagePullBackOff 0 25m pod/shopping-cart-6bd7897fd5-bnlvh 0/1 ImagePullBackOff 0 36m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 13d service/shopping-cart LoadBalancer 10.152.183.254 <pending> 5000:32238/TCP 36m NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/shopping-cart 0/1 1 0 36m NAME DESIRED CURRENT READY AGE replicaset.apps/shopping-cart-6bd7897fd5 1 1 0 36m replicaset.apps/shopping-cart-784b775b94 1 1 0 25m
Any ideas on how to solve this problem? The full code of the book is on https://github.com/horsdal/microservices-in-dotnet-book-second-edition look for chapter 3. I use Manjaro linux for development and .NET 7, the book is written for .NET 5. Also although it says ImagePullBackOff eventually it becomes ErrImagePull as the title of the post says.
I also want to add the following output:
kubectl describe pod shopping-cart INT ✘ Name: shopping-cart-784b775b94-v5ddl Namespace: default Priority: 0 Service Account: default Node: dso-z68xud5b3/192.168.1.9 Start Time: Sat, 31 Dec 2022 11:37:04 +0200 Labels: app=shopping-cart pod-template-hash=784b775b94 Annotations: cni.projectcalico.org/containerID: 2f73bffa63650fc7bf3497b7255172f8d80f7834de0a7e2738e26579006261c2 cni.projectcalico.org/podIP: 10.1.59.225/32 cni.projectcalico.org/podIPs: 10.1.59.225/32 Status: Pending IP: 10.1.59.225 IPs: IP: 10.1.59.225 Controlled By: ReplicaSet/shopping-cart-784b775b94 Containers: shopping-cart: Container ID: Image: your_unique_registry_name.azurecr.io/shopping-cart:1.0.0 Image ID: Port: 80/TCP Host Port: 0/TCP State: Waiting Reason: ImagePullBackOff Ready: False Restart Count: 0 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-6cghz (ro) Conditions: Type Status Initialized True Ready False ContainersReady False PodScheduled True Volumes: kube-api-access-6cghz: Type: Projected (a volume that contains injected data from multiple sources) TokenExpirationSeconds: 3607 ConfigMapName: kube-root-ca.crt ConfigMapOptional: <nil> DownwardAPI: true QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Warning MissingClusterDNS 3m32s (x71 over 18m) kubelet pod: "shopping-cart-784b775b94-v5ddl_default(1e24b5d3-d921-45a1-b5ec-2edc35e651e4)". kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to "Default" policy. Name: shopping-cart-6bd7897fd5-bnlvh Namespace: default Priority: 0 Service Account: default Node: dso-z68xud5b3/192.168.1.9 Start Time: Sat, 31 Dec 2022 11:26:03 +0200 Labels: app=shopping-cart pod-template-hash=6bd7897fd5 Annotations: cni.projectcalico.org/containerID: a859a48851ce4eecb8311318cc71b6057fab2ad2c74e5e41b1bff419d3f210ae cni.projectcalico.org/podIP: 10.1.59.224/32 cni.projectcalico.org/podIPs: 10.1.59.224/32 Status: Pending IP: 10.1.59.224 IPs: IP: 10.1.59.224 Controlled By: ReplicaSet/shopping-cart-6bd7897fd5 Containers: shopping-cart: Container ID: Image: shopping-cart Image ID: Port: 80/TCP Host Port: 0/TCP State: Waiting Reason: ImagePullBackOff Ready: False Restart Count: 0 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-hcmnb (ro) Conditions: Type Status Initialized True Ready False ContainersReady False PodScheduled True Volumes: kube-api-access-hcmnb: Type: Projected (a volume that contains injected data from multiple sources) TokenExpirationSeconds: 3607 ConfigMapName: kube-root-ca.crt ConfigMapOptional: <nil> DownwardAPI: true QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Warning MissingClusterDNS 3m24s (x71 over 18m) kubelet pod: "shopping-cart-6bd7897fd5-bnlvh_default(5309b220-a258-4930-bf64-9b1cf0cbafc7)". kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to "Default" policy.
your_unique_registry_name.azurecr.io
with the address of the Azure Container Registry (or any other Docker registry) you created, yes?docker pull
with the exact same image name (ideally on the same PC), does that work? From K8s docs: “If you don't specify a registry hostname, Kubernetes assumes that you mean the Docker public registry.”docker login your_unique_registry_name.azurecr.io
. For Kube to pull the image, setup image pull secrets