jenkins-backup-rbac.yaml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. {{- if .Values.backup.enabled }}
  2. {{- if .Values.backup.serviceAccount.create }}
  3. apiVersion: v1
  4. kind: ServiceAccount
  5. metadata:
  6. name: {{ include "backup.serviceAccountBackupName" . }}
  7. namespace: {{ template "jenkins.namespace" . }}
  8. labels:
  9. "app.kubernetes.io/name": '{{ template "jenkins.name" .}}'
  10. {{- if .Values.renderHelmLabels }}
  11. "helm.sh/chart": "{{ template "jenkins.label" .}}"
  12. {{- end }}
  13. "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
  14. "app.kubernetes.io/instance": "{{ .Release.Name }}"
  15. "app.kubernetes.io/component": "{{ .Values.controller.componentName }}"
  16. {{- if .Values.backup.serviceAccount.annotations }}
  17. annotations:
  18. {{- toYaml .Values.backup.serviceAccount.annotations | nindent 4 }}
  19. {{- end }}
  20. {{- end }}
  21. ---
  22. apiVersion: rbac.authorization.k8s.io/v1
  23. kind: Role
  24. metadata:
  25. name: {{ template "jenkins.fullname" . }}-backup
  26. namespace: {{ template "jenkins.namespace" . }}
  27. labels:
  28. "app.kubernetes.io/name": '{{ template "jenkins.name" .}}'
  29. {{- if .Values.renderHelmLabels }}
  30. "helm.sh/chart": "{{ template "jenkins.label" .}}"
  31. {{- end }}
  32. "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
  33. "app.kubernetes.io/instance": "{{ .Release.Name }}"
  34. "app.kubernetes.io/component": "{{ .Values.controller.componentName }}"
  35. rules:
  36. - apiGroups: [""]
  37. resources: ["pods", "pods/log"]
  38. verbs: ["get", "list"]
  39. - apiGroups: [""]
  40. resources: ["pods/exec"]
  41. verbs: ["create"]
  42. ---
  43. apiVersion: rbac.authorization.k8s.io/v1
  44. kind: RoleBinding
  45. metadata:
  46. name: {{ template "jenkins.fullname" . }}-backup
  47. namespace: {{ template "jenkins.namespace" . }}
  48. labels:
  49. "app.kubernetes.io/name": '{{ template "jenkins.name" .}}'
  50. {{- if .Values.renderHelmLabels }}
  51. "helm.sh/chart": "{{ template "jenkins.label" .}}"
  52. {{- end }}
  53. "app.kubernetes.io/managed-by": "{{ .Release.Service }}"
  54. "app.kubernetes.io/instance": "{{ .Release.Name }}"
  55. "app.kubernetes.io/component": "{{ .Values.controller.componentName }}"
  56. roleRef:
  57. apiGroup: rbac.authorization.k8s.io
  58. kind: Role
  59. name: {{ template "jenkins.fullname" . }}-backup
  60. subjects:
  61. - kind: ServiceAccount
  62. name: {{ include "backup.serviceAccountBackupName" . }}
  63. namespace: {{ template "jenkins.namespace" . }}
  64. {{- end }}