How to Integrate Amazon EKS and Jenkins

前提是你 提交于 2020-12-06 16:09:50

问题


I'm currently using Kubernetes Client Plugin in Jenkins but still it's confusing to configure, because it looks for Kubernetes config, and those credetials are not available even I configured them in the credentials section.

Please see the screenshot below for my credentials which are configure in my Jenkins.

When I do try to add those credentials from Jenkins side, which is not listed under the Kubernetes credentials. The red colored are has no kist of my credentials.

How can I configure this Kubernetes plugin in Jenkins ? or any other alternative methods to configure Jenkins + Amazon EKS ?

Thanks.

Plugin : https://wiki.jenkins.io/display/JENKINS/Kubernetes+Plugin


回答1:


To reproduce your issue I have installed EKS using Deploying a Kubernetes Cluster with Amazon EKS article.

After adding worker nodes next steps were performed:

1) install helm

2) install jenkins from stable/jenkins chart.

curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller
helm search jenkins
helm install stable/jenkins --name myjenkins

If you want to change any parameters before deploying helm chart, you can first download and edit values.
helm inspect values stable/jenkins > /tmp/jenkins.values
helm install stable/jenkins --values /tmp/stable_jenkins.values --name myjenkins

Wait until everything will be deployed, you can check via watch kubectl get all --all-namespaces

kubectl get all --all-namespaces
NAMESPACE     NAME                                READY   STATUS    RESTARTS   AGE
default       pod/myjenkins-c9bc6bbbc-hvdzg       1/1     Running   0          19m
kube-system   pod/aws-node-5swq5                  1/1     Running   0          21m
kube-system   pod/aws-node-h5vl7                  1/1     Running   0          20m
kube-system   pod/aws-node-ttkgn                  1/1     Running   0          21m
kube-system   pod/coredns-7fb855c998-7lglx        1/1     Running   0          48m
kube-system   pod/coredns-7fb855c998-h7stl        1/1     Running   0          48m
kube-system   pod/kube-proxy-drvc2                1/1     Running   0          21m
kube-system   pod/kube-proxy-gfwh8                1/1     Running   0          20m
kube-system   pod/kube-proxy-kscm8                1/1     Running   0          21m
kube-system   pod/tiller-deploy-5d6cc99fc-7mv88   1/1     Running   0          45m


NAMESPACE     NAME                      TYPE           CLUSTER-IP       EXTERNAL-IP                                                               PORT(S)          AGE
default       service/kubernetes        ClusterIP      10.100.0.1       <none>                                                                    443/TCP          48m
default       service/myjenkins         LoadBalancer   10.100.9.131     ***********************************-*******.eu-west-1.elb.amazonaws.com   8080:30878/TCP   19m
default       service/myjenkins-agent   ClusterIP      10.100.28.95     <none>                                                                    50000/TCP        19m
kube-system   service/kube-dns          ClusterIP      10.100.0.10      <none>                                                                    53/UDP,53/TCP    48m
kube-system   service/tiller-deploy     ClusterIP      10.100.250.226   <none>                                                                    44134/TCP        45m

NAMESPACE     NAME                        DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
kube-system   daemonset.apps/aws-node     3         3         3       3            3           <none>          48m
kube-system   daemonset.apps/kube-proxy   3         3         3       3            3           <none>          48m

NAMESPACE     NAME                            READY   UP-TO-DATE   AVAILABLE   AGE
default       deployment.apps/myjenkins       1/1     1            1           19m
kube-system   deployment.apps/coredns         2/2     2            2           48m
kube-system   deployment.apps/tiller-deploy   1/1     1            1           45m

NAMESPACE     NAME                                      DESIRED   CURRENT   READY   AGE
default       replicaset.apps/myjenkins-c9bc6bbbc       1         1         1       19m
kube-system   replicaset.apps/coredns-7fb855c998        2         2         2       48m
kube-system   replicaset.apps/tiller-deploy-5d6cc99fc   1         1         1       45m

Next

1. Get your 'admin' user password by running:
  printf $(kubectl get secret --namespace default myjenkins -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode);echo
2. Get the Jenkins URL to visit by running these commands in the same shell:
  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        You can watch the status of by running 'kubectl get svc --namespace default -w myjenkins'
  export SERVICE_IP=$(kubectl get svc --namespace default myjenkins --template "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}")
  echo http://$SERVICE_IP:8080/login

3. Login with the password from step 1 and the username: admin
  • Open browser, login and go to "Manage Jenkins"-->"Configure System"--> Cloud Section

  • Click Add - Jenkins

  • Choose Kubernetes Service Account and click add..

  • Next chose "Secret Text" in drop down menu left to Add button, Test connection, apply and save.

-Check Credentials:

-Check again "Manage Jenkins"-->"Configure System"--> Cloud Section

Hope it helps...



来源:https://stackoverflow.com/questions/57240391/how-to-integrate-amazon-eks-and-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!