diff --git a/kube-state-metrics/README.md b/kube-state-metrics/README.md new file mode 100644 index 0000000..e8a8427 --- /dev/null +++ b/kube-state-metrics/README.md @@ -0,0 +1,37 @@ +This directory contains configuration files for enabling +[kube-state-metrics](https://github.com/kubernetes/kube-state-metrics/) +to report metrics for AppWrappers. + +The file [appwrapper-ksm-cm.yaml](./appwrapper-ksm-cm.yaml) defines +a configuration map that can be volume-mounted into the +kube-state-metrics pod and passed via the `--custom-resource-state-config-file` +command line argument. For development of the AppWrapper metrics, +you may want to add `--custom-resource-state-only=true` to the command +line arguments to suppress generation of metrics for built-in types. + +The file [appwrapper-ksm-rbac.yaml](./appwrapper-ksm-rbac.yaml) defines +a clusterrole and clusterrolebinding that add the RBACs +needed to collect AppWrapper metrics to the `kube-state-metrics` service account. +Alternatively, you could edit the existing kube-state-metrics clusterrole to +add these permissions. + +The changes to the kube-state-metrics deployment are roughly as shown below: +```yaml + ... + spec: + containers: + - args: + - --custom-resource-state-config-file=/appwrapper_ksm.yaml + ... + volumeMounts: + - mountPath: /appwrapper_ksm.yaml + name: appwrapper-ksm + readOnly: true + subPath: appwrapper_ksm.yaml + ... + volumes: + - configMap: + defaultMode: 420 + name: appwrapper-ksm + name: appwrapper-ksm +``` diff --git a/kube-state-metrics/metrics-cm.yaml b/kube-state-metrics/appwrapper-ksm-cm.yaml similarity index 100% rename from kube-state-metrics/metrics-cm.yaml rename to kube-state-metrics/appwrapper-ksm-cm.yaml diff --git a/kube-state-metrics/appwrapper-ksm-rbac.yaml b/kube-state-metrics/appwrapper-ksm-rbac.yaml new file mode 100644 index 0000000..d8c6d53 --- /dev/null +++ b/kube-state-metrics/appwrapper-ksm-rbac.yaml @@ -0,0 +1,32 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: kube-state-metrics-appwrapper +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: kube-state-metrics-appwrapper +subjects: +- kind: ServiceAccount + name: kube-state-metrics + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: kube-state-metrics-appwrapper +rules: +- apiGroups: + - apiextensions.k8s.io + resources: + - customresourcedefinitions + verbs: + - list + - watch +- apiGroups: + - workload.codeflare.dev + resources: + - appwrappers + verbs: + - list + - watch