diff --git a/Dockerfile.loadtester b/Dockerfile.loadtester index 220c2738..a214e9b4 100644 --- a/Dockerfile.loadtester +++ b/Dockerfile.loadtester @@ -9,8 +9,9 @@ WORKDIR /home/app RUN curl -sSLo hey "https://storage.googleapis.com/jblabs/dist/hey_linux_v0.1.2" && \ chmod +x hey && mv hey /usr/local/bin/hey -RUN curl -sSL "https://get.helm.sh/helm-v2.12.3-linux-amd64.tar.gz" | tar xvz && \ +RUN curl -sSL "https://get.helm.sh/helm-v2.14.3-linux-amd64.tar.gz" | tar xvz && \ chmod +x linux-amd64/helm && mv linux-amd64/helm /usr/local/bin/helm && \ +chmod +x linux-amd64/tiller && mv linux-amd64/tiller /usr/local/bin/tiller && \ rm -rf linux-amd64 RUN curl -sSL "https://github.com/bojand/ghz/releases/download/v0.39.0/ghz_0.39.0_Linux_x86_64.tar.gz" | tar xz -C /tmp && \ @@ -24,4 +25,7 @@ RUN chown -R app:app ./ USER app +RUN curl -sSL "https://github.com/rimusz/helm-tiller/archive/v0.8.3.tar.gz" | tar xvz && \ +helm init --client-only && helm plugin install helm-tiller-0.8.3 && helm plugin list + ENTRYPOINT ["./loadtester"] diff --git a/charts/loadtester/templates/deployment.yaml b/charts/loadtester/templates/deployment.yaml index ec7fef88..17c04870 100644 --- a/charts/loadtester/templates/deployment.yaml +++ b/charts/loadtester/templates/deployment.yaml @@ -21,6 +21,8 @@ spec: spec: {{- if .Values.serviceAccountName }} serviceAccountName: {{ .Values.serviceAccountName }} + {{- else if .Values.rbac.create }} + serviceAccountName: {{ include "loadtester.fullname" . }} {{- end }} containers: - name: {{ .Chart.Name }} diff --git a/charts/loadtester/templates/rbac.yaml b/charts/loadtester/templates/rbac.yaml new file mode 100644 index 00000000..725dc677 --- /dev/null +++ b/charts/loadtester/templates/rbac.yaml @@ -0,0 +1,54 @@ +--- +{{- if .Values.rbac.create }} +apiVersion: rbac.authorization.k8s.io/v1 +{{- if eq .Values.rbac.scope "cluster" }} +kind: ClusterRole +{{- else }} +kind: Role +{{- end }} +metadata: + name: {{ template "loadtester.fullname" . }} + labels: + helm.sh/chart: {{ template "loadtester.chart" . }} + app.kubernetes.io/name: {{ template "loadtester.name" . }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} +rules: +{{ toYaml .Values.rbac.rules | indent 2 }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +{{- if eq .Values.rbac.scope "cluster" }} +kind: ClusterRoleBinding +{{- else }} +kind: RoleBinding +{{- end }} +metadata: + name: {{ template "loadtester.fullname" . }} + labels: + helm.sh/chart: {{ template "loadtester.chart" . }} + app.kubernetes.io/name: {{ template "loadtester.name" . }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} +roleRef: + apiGroup: rbac.authorization.k8s.io + {{- if eq .Values.rbac.scope "cluster" }} + kind: ClusterRole + {{- else }} + kind: Role + {{- end }} + name: {{ template "loadtester.fullname" . }} +subjects: + - kind: ServiceAccount + name: {{ template "loadtester.fullname" . }} + namespace: {{ .Release.Namespace }} +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "loadtester.fullname" . }} + labels: + helm.sh/chart: {{ template "loadtester.chart" . }} + app.kubernetes.io/name: {{ template "loadtester.name" . }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/charts/loadtester/values.yaml b/charts/loadtester/values.yaml index 36ff9bf1..2cbae313 100644 --- a/charts/loadtester/values.yaml +++ b/charts/loadtester/values.yaml @@ -27,6 +27,20 @@ tolerations: [] affinity: {} +rbac: + # rbac.create: `true` if rbac resources should be created + create: false + # rbac.scope: `cluster` to create cluster-scope rbac resources (ClusterRole/ClusterRoleBinding) + # otherwise, namespace-scope rbac resources will be created (Role/RoleBinding) + scope: + # rbac.rules: array of rules to apply to the role. example: + # rules: + # - apiGroups: [""] + # resources: ["pods"] + # verbs: ["list", "get"] + rules: [] + +# name of an existing service account to use - if not creating rbac resources serviceAccountName: "" # App Mesh virtual node settings