Skip to content

Commit

Permalink
#61 fix name collisions
Browse files Browse the repository at this point in the history
the cluster role had a static name and
 therefore collided with other ces
 installations.
 Also the name was too long. We should
 shorten all names. We don't need
 `controller-manager` as a suffix everywhere
  • Loading branch information
alexander-dammeier committed Jul 22, 2024
1 parent 67d4292 commit c9681f6
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 10 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,11 @@ helm-repo-config-local: ## Creates a configMap and a local config.json for the h
print-debug-info: ## Generates info and the list of environment variables required to start the operator in debug mode.
@echo "The target generates a list of env variables required to start the operator in debug mode. These can be pasted directly into the 'go build' run configuration in IntelliJ to run and debug the operator on-demand."
@echo "STAGE=$(STAGE);LOG_LEVEL=$(LOG_LEVEL);KUBECONFIG=$(KUBECONFIG);NAMESPACE=$(NAMESPACE)"

.PHONY: upload-to-k8s-testing
upload-to-k8s-testing: helm-package compile
gcloud auth configure-docker europe-west3-docker.pkg.dev -q
helm push target/k8s/helm/$(ARTIFACT_ID)-$(VERSION).tgz oci://europe-west3-docker.pkg.dev/ces-coder-workspaces/ces-test-docker-helm-repo/charts
helm push target/k8s/helm/$(ARTIFACT_ID)-$(VERSION).tgz oci://registry.cloudogu.com/k8s-testing
docker build . -t europe-west3-docker.pkg.dev/ces-coder-workspaces/ces-test-docker-helm-repo/images/$(ARTIFACT_ID):$(VERSION)
docker push europe-west3-docker.pkg.dev/ces-coder-workspaces/ces-test-docker-helm-repo/images/$(ARTIFACT_ID):$(VERSION)
2 changes: 1 addition & 1 deletion k8s/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
Kubernetes 1.4+.
*/}}
{{- define "k8s-component-operator.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{ .Release.Namespace }}-{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}


Expand Down
4 changes: 2 additions & 2 deletions k8s/helm/templates/cluster-role-binding-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ metadata:
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: k8s-component-operator-cluster-role
name: {{ include "k8s-component-operator.name" . }}-cluster-role
subjects:
- kind: ServiceAccount
name: k8s-component-operator-controller-manager
name: {{ include "k8s-component-operator.name" . }}-sa
namespace: '{{ .Release.Namespace }}'
4 changes: 2 additions & 2 deletions k8s/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "k8s-component-operator.name" . }}-controller-manager
name: {{ include "k8s-component-operator.name" . }}
labels:
control-plane: controller-manager
{{- include "k8s-component-operator.labels" . | nindent 4 }}
Expand Down Expand Up @@ -81,7 +81,7 @@ spec:
readOnly: true
securityContext:
runAsNonRoot: true
serviceAccountName: {{ include "k8s-component-operator.name" . }}-controller-manager
serviceAccountName: {{ include "k8s-component-operator.name" . }}-sa
terminationGracePeriodSeconds: 10
volumes:
- name: component-operator-helm-registry
Expand Down
2 changes: 1 addition & 1 deletion k8s/helm/templates/leader-election-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ roleRef:
name: '{{ include "k8s-component-operator.name" . }}-leader-election-role'
subjects:
- kind: ServiceAccount
name: '{{ include "k8s-component-operator.name" . }}-controller-manager'
name: '{{ include "k8s-component-operator.name" . }}-sa'
namespace: '{{ .Release.Namespace }}'
2 changes: 1 addition & 1 deletion k8s/helm/templates/manager-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ roleRef:
name: '{{ include "k8s-component-operator.name" . }}-manager-role'
subjects:
- kind: ServiceAccount
name: '{{ include "k8s-component-operator.name" . }}-controller-manager'
name: '{{ include "k8s-component-operator.name" . }}-sa'
namespace: '{{ .Release.Namespace }}'
3 changes: 2 additions & 1 deletion k8s/helm/templates/metrics-service.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "k8s-component-operator.name" . }}-controller-manager-metrics-service
# name was too long (max 63 chars)
name: {{ include "k8s-component-operator.name" . }}-metrics-service
labels:
control-plane: controller-manager
{{- include "k8s-component-operator.labels" . | nindent 4 }}
Expand Down
2 changes: 1 addition & 1 deletion k8s/helm/templates/proxy-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ roleRef:
name: '{{ include "k8s-component-operator.name" . }}-proxy-role'
subjects:
- kind: ServiceAccount
name: '{{ include "k8s-component-operator.name" . }}-controller-manager'
name: '{{ include "k8s-component-operator.name" . }}-sa'
namespace: '{{ .Release.Namespace }}'
2 changes: 1 addition & 1 deletion k8s/helm/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "k8s-component-operator.name" . }}-controller-manager
name: {{ include "k8s-component-operator.name" . }}-sa
labels:
{{- include "k8s-component-operator.labels" . | nindent 4 }}

0 comments on commit c9681f6

Please sign in to comment.