I am trying to deploy my services on AKS using Azure Devops pipeline. Everything works fine except for applying my latest build on Kubernetes service. I am using following command to deploy the service.
#- script: docker build -f ./ContainerApp/Dockerfile -t $(dockerServer)/$(imageName) .
# displayName: 'Container Build'
#
#- script: docker login -u $(dockerId) -p $(dockerPassword) $(dockerServer)
# displayName: 'Container Service login'
#
#- script: docker push $(dockerServer)/$(imageName)
# displayName: 'Container Push'
#
- script: kubectl apply -f ./azure-kubernetes-deployment.yml
displayName: 'deploying to Kubernetes'
It works fine when i run this command from my local machine, but doesn't work on pipeline. when i run on pipeline following error occures.
can anyone suggest what command i am missing?
2018-11-28T14:19:09.6975888Z Generating script.
2018-11-28T14:19:09.6998755Z Script contents:
2018-11-28T14:19:09.6999302Z kubectl apply -f ./azure-kubernetes-deployment.yaml
2018-11-28T14:19:09.7032788Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/e571ec91-5ac4-4e17-8f48-cd0fd0877683.sh
2018-11-28T14:19:10.0021936Z unable to recognize "./azure-kubernetes-deployment.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
2018-11-28T14:19:10.0023429Z unable to recognize "./azure-kubernetes-deployment.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
2018-11-28T14:19:10.0162142Z ##[error]Bash exited with code '1'.
2018-11-28T14:19:10.0177080Z ##[section]Finishing: deploying to Kubernetes
I don't know the reason for it in your particular use case, but
unable to recognize "...yaml": Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
(a rather unhelpful and confusing message) indicates failure to contact the kubernetes cluster.