千家信息网

kubernetes中如何安装jenkins

发表于:2025-01-31 作者:千家信息网编辑
千家信息网最后更新 2025年01月31日,本篇文章为大家展示了kubernetes中如何安装jenkins,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。安装完后,登陆jenkins做kubernete
千家信息网最后更新 2025年01月31日kubernetes中如何安装jenkins

本篇文章为大家展示了kubernetes中如何安装jenkins,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

安装完后,登陆jenkins做kubernetes的链接测试发现如下报错:

Error testing connection https://kubernetes.default: Failure executing: GET at: https://kubernetes.default/api/v1/namespaces/default/pods. Message: Forbidden!Configured service account doesn't have access. Service account may have been revoked. pods is forbidden: User "system:serviceaccount:george:default" cannot list pods in the namespace "default".

究其原因是创建账户绑定的角色不对:

完整brac如下:

# In GKE need to get RBAC permissions first with# kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin [--user=|--group=]---apiVersion: v1kind: ServiceAccountmetadata:  name: jenkins  namespace: default---kind: RoleapiVersion: rbac.authorization.k8s.io/v1beta1metadata:  name: jenkins  namespace: defaultrules:- 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"]---apiVersion: rbac.authorization.k8s.io/v1beta1kind: RoleBindingmetadata:  name: jenkinsroleRef:  apiGroup: rbac.authorization.k8s.io  kind: Role  name: jenkinssubjects:- kind: ServiceAccount  name: jenkins  namespace: default  ---kind: ClusterRoleapiVersion: rbac.authorization.k8s.io/v1beta1metadata:  name: jenkinsClusterRole  namespace: defaultrules:- 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"]---apiVersion: rbac.authorization.k8s.io/v1beta1kind: RoleBindingmetadata:  name: jenkinsClusterRuleBindingroleRef:  apiGroup: rbac.authorization.k8s.io  kind: ClusterRole  name: jenkinsClusterRolesubjects:- kind: ServiceAccount  name: jenkins  namespace: default

上述内容就是kubernetes中如何安装jenkins,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注行业资讯频道。

0