Jenkins Not able to Deploy the application inside EKS cluster

Viewed 83
  1. Having EKS cluster and up and running with single node group with version of 1.20
  2. Then from Jenkins i configured cloud k8 to connect to my API server endpoint connection test also successes.
  3. I deployed Jenkins via kubernetes yaml file and i have created dedicated namespace for Jenkins as well.

Here the complete file for jenkins role, rolebinding, serviceaccount and ns.

namespace.yaml

apiVersion: v1
kind: Namespace
metadata:
  name: jenkins

RoleBinding.yaml

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: jenkins-role-binding
  namespace: jenkins
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: jenkins-role
subjects:
- kind: ServiceAccount
  name: jenkins-account
  namespace: jenkins

role.yaml

kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: jenkins-role
  namespace: jenkins
rules:
- apiGroups: [“”]
  resources: [“pods”]
  verbs: [“create”,”delete”,”get”,”list”,”patch”,”update”,”watch”]
- apiGroups: [“”]
  resources: [“pods/exec”]
  verbs: [“create”,”delete”,”get”,”list”,”patch”,”update”,”watch”]
- apiGroups: [“”]
  resources: [“pods/log”]
  verbs: [“get”,”list”,”watch”]
- apiGroups: [“”]
  resources: [“secrets”]
  verbs: [“get”]
- apiGroups: ["extensions", "apps"]
  #
  # at the HTTP level, the name of the resource for accessing Deployment
  # objects is "deployments"
  resources: ["deployments"]
  verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]

service.account.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
 name: jenkins-account
 namespace: jenkins
 annotations:
  eks.amazonaws.com/role-arn: arn:aws:sts::my-arn:assumed-role/DEVELOPER

Then finally I verified role as well

[root@ip-10-1-2-3 auto]# kubectl describe role jenkins-role -n jenkins
Name:         jenkins-role
Labels:       <none>
Annotations:  <none>
PolicyRule:
  Resources               Non-Resource URLs  Resource Names  Verbs
  ---------               -----------------  --------------  -----
  deployments.apps        []                 []              [get list watch create update patch delete]
  deployments.extensions  []                 []              [get list watch create update patch delete]
  “pods.“”/exec”          []                 []              [“create” ”delete” ”get” ”list” ”patch” ”update” ”watch”]
  “pods”.“”               []                 []              [“create” ”delete” ”get” ”list” ”patch” ”update” ”watch”]
  “pods.“”/log”           []                 []              [“get” ”list” ”watch”]
  “secrets”.“”            []                 []              [“get”]

its seems everything looking fine but still jenkins not able to get right for the deployment while running pipeline build getting failed with below error.

Masking supported pattern matches of $KUBECONFIG
[Pipeline] {
[Pipeline] echo
deploy to deployment!!
[Pipeline] sh
**+ kubectl auth can-i create deployments -n jenkins
no**
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
0 Answers
Related