如何整合Amazon EKS和Jenkins [英] How to Integrate Amazon EKS and Jenkins

查看:142
本文介绍了如何整合Amazon EKS和Jenkins的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在Jenkins中使用Kubernetes Client Plugin,但配置仍然令人困惑,因为它会查找Kubernetes配置,即使在凭据部分中配置了这些凭据,这些凭据也不可用.

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.

请参阅下面的屏幕快照,了解在我的Jenkins中配置的我的凭据.

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

当我尝试从Jenkins端添加这些凭据时,该凭据未在Kubernetes凭据下列出.红色没有我的凭据.

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.

如何在Jenkins中配置此Kubernetes插件?或任何其他替代方法来配置Jenkins + Amazon EKS?

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

谢谢.

插件: https://wiki.jenkins.io/display/JENKINS/Kubernetes +插件

推荐答案

要重现您的问题,我已使用

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)安装头盔

2)从稳定/詹金斯图表中安装詹金斯.

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

在一切部署完成之前,您可以通过watch kubectl get all --all-namespaces

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

下一步

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

  • 打开浏览器,登录并转到管理Jenkins"->配置系统"->云部分

    • Open browser, login and go to "Manage Jenkins"-->"Configure System"--> Cloud Section

      单击添加-Jenkins

      Click Add - Jenkins

      选择Kubernetes Service Account,然后单击添加.

      Choose Kubernetes Service Account and click add..

      接下来,在左侧的下拉菜单中选择秘密文本",然后单击添加按钮,测试连接,应用并保存.

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

      -检查凭据:

      -再次检查"Manage Jenkins"->配置系统"->云"部分

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

      希望有帮助...

      这篇关于如何整合Amazon EKS和Jenkins的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆