cluster-template-examples icon indicating copy to clipboard operation
cluster-template-examples copied to clipboard

clustertemplate role binding namespace not found

Open guaychou opened this issue 2 years ago • 4 comments

hey guys i wanna to ask you is the template really valid ? because with that i cannot find my namespaces

namespace: c-m-{{ trunc 8 (sha256sum (printf "%s/%s" $root.Release.Namespace $root.Values.cluster.name)) }}

guaychou avatar Jun 13 '22 07:06 guaychou

Hi!

Rancher 2.7 seems to have change to a random id since https://github.com/rancher/rancher/commit/cc9f7eed4264a9805c69efcbd9b7856a24dbc6b1

Make it much harder to do project and fix permissions for the created clusters.

sennerholm avatar Nov 22 '22 19:11 sennerholm

+1 still a problem in rancher v2.7.3

bpanesar avatar May 11 '23 20:05 bpanesar

+1

thawkson avatar May 11 '23 20:05 thawkson

Still a problem on Rancher v2.7.5

Is there a workaround? How is the Rancher cattle-management cluster name generated? Simply truncating the sha256sum of the release namespace concatted with / + cluster name is no longer valid.

clusterroletemplatebinding.yaml

  1 {{ $root := . }}                                                                                                  
  2 {{- range $index, $member := .Values.clusterMembers }}
  3 apiVersion: management.cattle.io/v3
  4 clusterName: c-m-{{ trunc 8 (sha256sum (printf "%s/%s" $root.Release.Namespace $root.Values.cluster.name)) }}
  5 kind: ClusterRoleTemplateBinding
  6 metadata:
  7   name: ctrb-{{ trunc 8 (sha256sum (printf "%s/%s" $root.Release.Namespace $member.principalName )) }}
  8   namespace: c-m-{{ trunc 8 (sha256sum (printf "%s/%s" $root.Release.Namespace $root.Values.cluster.name)) }}
  9 roleTemplateName: {{ $member.roleTemplateName }}
 10 userPrincipalName: {{ $member.principalName }}
 11 principalId: {{ $member.principalId }}
 12 {{- end }}

Example deploying cluster template:

Valid Namespace: c-m-ppthnkp5

Output:

$ helm  upgrade -i  -n fleet-default --values ./charts/values.yaml $(CLUSTER) ./charts 
Error: UPGRADE FAILED: failed to create resource: namespaces "c-m-b41e0870" not found

apnoono avatar Aug 24 '23 17:08 apnoono