Error deploying into Kubernetes EKS cluster from Jenkins pipeline using kubernetes-cd plugin

2/25/2020

I am facing issue to deploy into EKS kubernetes from Jenkins pipeline.

I am using kuberneter-cd plugin and getting following error

Loading configuration: /var/lib/jenkins/workspace/jhipprojectmono/kubedeploy.yaml
Api call failed with code 403, detailed message: {
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {

  },
  "status": "Failure",
  "message": "deployments.apps \"jhipprojectmono\" is forbidden: User \"system:anonymous\" cannot get resource \"deployments\" in API group \"apps\" in the namespace \"default\"",
  "reason": "Forbidden",
  "details": {
    "name": "jhipprojectmono",
    "group": "apps",
    "kind": "deployments"
  },
  "code": 403
}

I do understand this is for jenkins user do not have permission. I have created the service role for jenkins ..but still it is not working .. Attaching the kubeconfig for reference also.

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS1...
    server: https://xxxx.yl4.us-east-1.eks.amazonaws.com
  name: arn:aws:eks:us-east-1:yyyy:cluster/finmanagercluster
contexts:
- context:
    cluster: arn:aws:eks:us-east-1:yyyy:cluster/finmanagercluster
    namespace: default
    user: arn:aws:eks:us-east-1:yyyy:cluster/finmanagercluster
  name: arn:aws:eks:us-east-1:yyyy:cluster/finmanagercluster
- context:
    cluster: finmanagercluster
    user: jenkins
  name: finmanagercluster-context
- context:
    cluster: ""
    namespace: default
    user: jenkins
  name: gce
current-context: arn:aws:eks:us-east-1:yyyy:cluster/finmanagercluster
kind: Config
preferences: {}
users:
- name: arn:aws:eks:us-east-1:yyyy:cluster/finmanagercluster
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1alpha1
      args:
      - --region
      - us-east-1
      - eks
      - get-token
      - --cluster-name
      - finmanagercluster
      command: aws
      env: null

Anything I am missing

I am using kubernetes-CD plugin ..

-- ajoy sinha
amazon-eks
jenkins
jenkins-pipeline
kubernetes

0 Answers