Skip to content

Commit

Permalink
Merge pull request #238 from Cryptophobia/master
Browse files Browse the repository at this point in the history
feat(charts): add update on ns role and template for rbac api
  • Loading branch information
Cryptophobia authored Aug 4, 2021
2 parents 886326e + aaf96ce commit f171905
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ If you don't like this default name or happen to use this configmap for other pu

Use `--annotation=acme.com/fancy-config` to use acme.com/fancy-config as annotation name. However, you'd also need to customize the Helm chart. Patches are welcome!

## Known issues
## Known Issues

Currently space-delimited tags are not supported. For example, instead of `<filter a b>`, you need to use `<filter a>` and `<filter b>`.
This limitation will be addressed in a later version.
Expand Down
24 changes: 24 additions & 0 deletions charts/log-router/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,27 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{/*
Set apiVersion based on .Capabilities.APIVersions
*/}}
{{- define "rbacAPIVersion" -}}
{{- if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1" -}}
rbac.authorization.k8s.io/v1
{{- else if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1beta1" -}}
rbac.authorization.k8s.io/v1beta1
{{- else if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1alpha1" -}}
rbac.authorization.k8s.io/v1alpha1
{{- else -}}
rbac.authorization.k8s.io/v1
{{- end -}}
{{- end -}}
{{- define "APIVersion" -}}
{{- if .Capabilities.APIVersions.Has "apps/v1" -}}
apps/v1
{{- else if .Capabilities.APIVersions.Has "extensions/v1beta1" -}}
extensions/v1beta1
{{- else -}}
apps/v1
{{- end -}}
{{- end -}}
7 changes: 5 additions & 2 deletions charts/log-router/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Copyright © 2018 VMware, Inc. All Rights Reserved.
SPDX-License-Identifier: BSD-2-Clause
*/}}
{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1beta1
{{- if (.Capabilities.APIVersions.Has (include "rbacAPIVersion" .)) -}}
apiVersion: {{ template "rbacAPIVersion" . }}
kind: ClusterRole
metadata:
labels:
Expand All @@ -30,6 +31,7 @@ rules:
- namespaces
verbs:
- patch
- update
{{- if or (eq .Values.datasource "crd") (eq .Values.crdMigrationMode true) }}
- apiGroups: ["apiextensions.k8s.io"]
resources:
Expand All @@ -47,4 +49,5 @@ rules:
- list
- watch
{{- end }}
{{- end }}
{{- end }}
{{- end }}
6 changes: 4 additions & 2 deletions charts/log-router/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Copyright © 2018 VMware, Inc. All Rights Reserved.
SPDX-License-Identifier: BSD-2-Clause
*/}}
{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1beta1
{{- if (.Capabilities.APIVersions.Has (include "rbacAPIVersion" .)) -}}
apiVersion: {{ template "rbacAPIVersion" . }}
kind: ClusterRoleBinding
metadata:
labels:
Expand All @@ -23,4 +24,5 @@ roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "fluentd-router.fullname" . }}
{{- end }}
{{- end }}
{{- end }}

0 comments on commit f171905

Please sign in to comment.