0

In my jenkins pipeline, I've configured like that one.

    stage('Deploying into k8s'){
        steps{
            sh 'kubectl set image deployment/my-api my-api=ppshein/myapi:${BUILD_NUMBER} -n my-ns --record'
        }
    }

and when I've run Jenkins pipeline, I've encountered following error message:

error: the server doesn't have a resource type "deployment"

But when I ssh to my EC2 instance and run same command, it was working successfully.

Please let me know I missed something to configure in Jenkins or somehow user authentication in my server?

PPShein
  • 13,309
  • 42
  • 142
  • 227
  • Does this answer your question https://stackoverflow.com/questions/51874577/kubernetes-set-image-missing-resource-type-deployment – Arghya Sadhu Sep 14 '20 at 15:52
  • @ArghyaSadhu it was not correct that I found yesterday as well. – PPShein Sep 15 '20 at 02:25
  • @PPShein could you clarify for me your last comment? Have this link showed you that your configuration was incorrect or solutions posted in this link were incorrect. – Dawid Kruk Sep 15 '20 at 13:43
  • 1
    @DawidKruk Problem is when I ssh to my jenkins instance and type `kubectl set image deployment/my-api my-api=ppshein/myapi:${BUILD_NUMBER} -n my-ns --record`, it was working. But in Jenkins pipeline, that command is not working. – PPShein Sep 15 '20 at 14:14
  • Have you tried to run other command like `$ kubectl create deployment nginx --image=nginx` instead of the one you provided? Have you run into any issues using it? – Dawid Kruk Sep 17 '20 at 06:22

1 Answers1

0

User Jenkins' home directory must have .kube/config,for example /var/lib/jenkins/.kube/config