Hassan Shamshir
Hassan Shamshir

Reputation: 123

Kubernetes commands are not running inside the Jenkins container

enter image description hereI have deployed Jenkins container inside the k8s cluster successfuly but I can't able to execute "kubectl get pod -A" where as kubectl also installed inside the Jenkins container. How can I run k8s command inside the Jenkins container so I can able to apply CI/CD for k8s. Below is the errors when I run k8s command inside the Jenkins container which is running inside the k8s pod.

Upvotes: 0

Views: 299

Answers (1)

Amit Meena
Amit Meena

Reputation: 4444

You need to create the cluster role binding for the service account jenkins.

  1. Create a file with the name sa.yaml and add below content in it
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: jenkins-role-binding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: jenkins
  namespace: jenkins
  1. Create the role binding using the command.
kubectl apply -f sa.yaml

Upvotes: 1

Related Questions