Skip to content

Commit

Permalink
fix serviceaccount list flowcontrol forbidden
Browse files Browse the repository at this point in the history
  • Loading branch information
wjiec committed Aug 3, 2023
1 parent efcf352 commit d83e915
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ OS ?= $(shell $(GO) env GOOS)
ARCH ?= $(shell $(GO) env GOARCH)

IMAGE_NAME := wjiec/alidns-webhook
IMAGE_TAG := latest
IMAGE_TAG := $(shell cat VERSION)

KUBE_VERSION=1.25.0

Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
2 changes: 1 addition & 1 deletion charts/alidns-webhook/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ Create the name of the service account to use
{{- end -}}

{{- define "alidns-webhook.servingCertificate" -}}
{{ printf "%s-webhook-tls" (include "alidns-webhook.fullname" .) }}
{{ printf "%s-tls" (include "alidns-webhook.fullname" .) }}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/alidns-webhook/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.Version }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- --tls-cert-file=/tls/tls.crt
Expand Down
66 changes: 63 additions & 3 deletions charts/alidns-webhook/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
{{- include "alidns-webhook.labels" . | nindent 4 }}
---
# Grant the webhook permission to read the ConfigMap containing the Kubernetes
# apiserver's requestheader-ca-certificate.
# apiserver"s requestheader-ca-certificate.
# This ConfigMap is automatically created by the Kubernetes apiserver.
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
Expand Down Expand Up @@ -44,6 +44,36 @@ subjects:
name: {{ include "alidns-webhook.fullname" . }}
namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "alidns-webhook.fullname" . }}:flowcontrol
labels:
{{- include "alidns-webhook.labels" . | nindent 4 }}
rules:
- apiGroups:
- flowcontrol.apiserver.k8s.io
resources:
- "*"
verbs:
- "list"
- "get"
- "watch"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "alidns-webhook.fullname" . }}:flowcontrol
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "alidns-webhook.fullname" . }}:flowcontrol
subjects:
- apiGroup: ""
kind: ServiceAccount
name: {{ include "alidns-webhook.fullname" . }}
namespace: {{ .Release.Namespace }}
---
# Grant cert-manager permission to validate using our apiserver
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand All @@ -55,9 +85,9 @@ rules:
- apiGroups:
- {{ .Values.groupName }}
resources:
- '*'
- "*"
verbs:
- 'create'
- "create"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand All @@ -74,3 +104,33 @@ subjects:
kind: ServiceAccount
name: {{ .Values.certManager.serviceAccountName }}
namespace: {{ .Values.certManager.namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "alidns-webhook.fullname" . }}:secrets
labels:
{{- include "alidns-webhook.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
resources:
- "secrets"
verbs:
- "get"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "alidns-webhook.fullname" . }}:secrets
labels:
{{- include "alidns-webhook.labels" . | nindent 4 }}
roleRef:
apiGroup: ""
kind: ClusterRole
name: {{ include "alidns-webhook.fullname" . }}:secrets
subjects:
- apiGroup: ""
kind: ServiceAccount
name: {{ include "alidns-webhook.fullname" . }}
namespace: {{ .Release.Namespace }}
2 changes: 1 addition & 1 deletion charts/alidns-webhook/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ replicaCount: 1

image:
repository: wjiec/alidns-webhook
tag: latest
tag: ""
pullPolicy: IfNotPresent

nameOverride: ""
Expand Down

0 comments on commit d83e915

Please sign in to comment.