I installed minikube on a VirtualBox(ubuntu) to simulate a deploy environment and used Jenkins pipeline. On my jenkins container i also installed kubectl command to control minikube.
So i create the following stage:
stage("k8s command test") {
withCredentials([usernamePassword(credentialsId: 'cbcba826-ef01-4b18-856f-e6dc4eb27c1f', usernameVariable: 'my-user', passwordVariable: 'PASSWORD')]) {
sh """
kubectl config view
kubectl create -f /home/my-user/file-svc.yml
"""
}
}
First thing my cluster seems to be empty in output i have :
+ kubectl config view
apiVersion: v1
clusters: []
contexts: []
current-context: ""
kind: Config
preferences: {}
users: []
if i check .kube/config i have the following config :
apiVersion: v1
clusters:
- cluster:
certificate-authority: /home/my-user/.minikube/ca.crt
server: https://127.0.0.1:8443
name: minikube
contexts:
- context:
cluster: minikube
user: minikube
name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
user:
as-user-extra: {}
client-certificate: /home/my-user/.minikube/client.crt
client-key: /home/my-user/.minikube/client.key
As i'm new on kubernetes i need help to understand how to make possible the communication between jenkins and minikube.
consequently kubectl create -f /home/my-user/file-svc.yml raised an error about authentication. I read many article kubectl need certificate to be connected to the API server how can i do that in jenkins