Skip to content

Commit

Permalink
Use standard service account name in OCCM helm chart (#2332)
Browse files Browse the repository at this point in the history
This removes the `openstack-` prefix from the service account name
used by the cloud-controller-manager and moves the default values into
the values file.

The change is motivated by the following:

- Create suitable service accounts, cluster roles and cluster role
  bindings for use with `--use-service-accounts-credentials=true`
- Normalise service account names in the helm chart and plain
  manifests
- Adhere to naming conventions across external cloud controller
  managers for different clouds (e.g. AWS, GCP, ...)

Specifically the first point deserves further details. Prior to this
change, users who install the cloud controller manager with helm,
would run into the following error when creating load balancers:

```
E0818 08:27:33.802407      11 controller.go:291] error processing service default/hello-bug (will retry): failed to ensure load balancer: failed to patch service object default/hello-bug: services "hello-bug" is forbidden: User "system:serviceaccount:kube-system:cloud-controller-manager" cannot patch resource "services" in API group "" in the namespace "default"
```

Which is due to the fact that the controller is running with the
`cloud-controller-manager` service account because
`--use-service-account-credentials` is set to `true` by default and
the client is initialised with:

```
clientset := clientBuilder.ClientOrDie("cloud-controller-manager")
```

Whilst users can work around this by passing
`--use-service-account-credentials=false`, the desired behaviour would
be to install suitable RBAC in the first place.

See:

- https://kubernetes.io/docs/concepts/architecture/cloud-controller/
- https://kubernetes.io/docs/tasks/administer-cluster/running-cloud-controller/
- #2049
- #1722
- #1755

Signed-off-by: Wolodja Wentland <[email protected]>
  • Loading branch information
wwentland authored Aug 28, 2023
1 parent 36d73ea commit c02269d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: system:openstack-cloud-controller-manager
name: {{ .Values.clusterRoleName }}
annotations:
{{- with .Values.commonAnnotations }}
{{- toYaml . | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: system:openstack-cloud-controller-manager
name: {{ .Values.clusterRoleName }}
annotations:
{{- with .Values.commonAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:openstack-cloud-controller-manager
name: {{ .Values.clusterRoleName }}
subjects:
- kind: ServiceAccount
name: openstack-cloud-controller-manager
name: {{ .Values.serviceAccountName }}
namespace: {{ .Release.Namespace | quote }}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: openstack-cloud-controller-manager
serviceAccountName: {{ .Values.serviceAccountName }}
containers:
- name: openstack-cloud-controller-manager
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: openstack-cloud-controller-manager
name: {{ .Values.serviceAccountName }}
namespace: {{ .Release.Namespace }}
annotations:
{{- with .Values.commonAnnotations }}
Expand Down
4 changes: 4 additions & 0 deletions charts/openstack-cloud-controller-manager/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,7 @@ extraVolumeMounts:
# cluster name that used for created cluster
cluster:
name: kubernetes

clusterRoleName : system:cloud-controller-manager

serviceAccountName: cloud-controller-manager

0 comments on commit c02269d

Please sign in to comment.