0
votes

I am new to Azure kubernetes. I'm trying to deploy a simple .net core web api to Azure Kubernetes. I just created the default weather project in VS 2019. I am able to run it in Docker locally fine. I am also able to push the image to a Azure container repository without a problem.

I get the error when I do:

kubectl apply -f .\deployment.yml  

When I run kubectl get pods after the deploy I see this.

| NAME | READY | STATUS | RESTARTS | AGE |

| test-deployment-7564d94c8f-fdz9q | 0/1 | ImagePullBackOff |
0 | 74s |

so then I ran kubectl describe pod test-deployment-7564d94c8f-fdz9q

and these are the errors coming back

Warning Failed (x4 over 15s) kubelet, aks-agentpool-30270636-vmss000000

Failed to pull image "ipaspoccontreg.azurecr.io/test:dev": [rpc error: code = Unknown desc = image operating system "windows" cannot be used on this platform, rpc error:code = Unknown desc = Error response from daemon: Get https://ipaspoccontreg.azurecr.io/v2/test/manifests/dev: unauthorized: authentication required]

My deployment.yml is

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-deployment
spec:
  selector:
    matchLabels:
      app: test-pod
  template:
    metadata:
      labels:
        app: test-pod
    spec:
      containers:
      - name: test-container
        image: ipaspoccontreg.azurecr.io/test:dev
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
        ports:
        - containerPort: 80

and my service.yml is

apiVersion: v1
kind: Service
metadata:
  name: test-service
spec:
  selector:
    app: test-pod
  ports:
  - port: 8080
    targetPort: 80
  type: LoadBalancer
1
The error shows the authentication required problem. So you need to add the credential for your deployment. For the ACR, the simplest way is the grant the permission of ACR to the AKS, see the document. - Charles Xu
Any more questions? Does it solve the problem? - Charles Xu

1 Answers

0
votes

You need to create a secret in Kubernetes which will contain your container registry credentials.