I’ve a config map which I need to read from K8S via api
I Created a cluster role
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: zrole
rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "list"]
and cluster role binding
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: z-role-binding
subjects:
- kind: Group
name: system:serviceaccounts
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: zrole
Config Map
apiVersion: v1
kind: ConfigMap
metadata:
name: z-config
namespace: fdrs
data:
avr: client1
fuss: xurbz
The code is used like
clientSet.CoreV1().ConfigMaps(uNamespcae)
when I run the code locally (and provide to the the GO api the kubeconfig) I was able to get the config map data,
However when I run the code inside the cluster I got error: invalid token , any idea what am I missing here?
zrolerole - you must create a service account and attach it to a container.