I'm running Jenkins locally and this is the last stage of my Jenkinsfile (after following this tutorial):
stage('Deploy to K8s') {
steps {
sshagent(credentials: ['k8s_key']) {
sh 'scp -r -o StrictHostKeyChecking=no localPath/deployment-remes-be.yaml <user>@<ip_address>:/opt/kubernetes-system/backend'
script {
try {
sh 'ssh <user>@<ip_address> kubectl apply -f /opt/kubernetes-system/backend/deployment-remes-be.yaml --kubeconfig=~/.kube/config'
}
catch(error) {
}
}
}
}
}
When I run the pipeline it completes without any blocking errors, but when I check the logs I can see this:
The copy before the apply command is working. I have microk8s installed on the Debian server I'm trying to deploy to and if I run the apply command manually then it's working fine. I've created the .kube/config file as shown here but using the --kubeconfig
file doesn't make any difference. It also doesn't matter if I use microk8s.kubectl
, I always get this message.
I have these plugins installed:
What can I do here to make the apply work from the pipeline?