I use config connector https://cloud.google.com/config-connector/docs/overview
I create gcp resources with CRDs that config connector provides:
kind: IAMServiceAccount
kind: StorageBucket
etc
Now what I'd really like is to be able to get a simple list of each resource and its status (if it was created successfully or not). Where each resource is a single line that's something like: kind, name, status, etc
Is there a way with kubectl to get a list of all resources that were created by an operator like this? I suppose I could manually label all these resources and try to select with a label but I really don't want to do that
Edit
Per the comment I could do this, but curious if there is a less unwieldy command
kubectl get crds --selector cnrm.cloud.google.com/managed-by-kcc=true \
-o=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | xargs -n 1 \
kubectl get -Ao jsonpath='{range .items[*]}{" Kind: "}{@.kind}{"Name: "}{@.metadata.name}{" Status: "}{@.status.conditions[].status}{" Reason: "}{@.status.conditions[].reason}{"\n"}{end}' --ignore-not-found
I've made a bit of research on this topic and I found 2 possible solutions to retrieve all the resources that were created by
config-connector
:$ kubectl api-resources
way$ kubectl get-all
/ketall
way withlabels
(please see the explanation as it's not installed by default)The discussion that is referencing similar issue can be found here:
$ kubectl api-resources
As pointed in the comment I made you can use the following expression:
Dissecting this solution:
kubectl get crds --selector cnrm.cloud.google.com/managed-by-kcc=true
Customer Resource Definitions
that have a matching selector-o=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}'
jsonpath
to retrieve only the value stored in.metadata.name
key (get the name of the crd)| xargs -n 1 kubectl get
CRD
retrieved from previous command to run$ kubectl get <RESOURCE>
--ignore-not-found
This command could also be altered to suit the specific needs as it's shown in the question.
$ kubectl get-all
/ketall
Above commands can be used to retrieve all of the resources in the cluster. They are not available in default
kubectl
and they need additional configuration.More reference about the installation can be found in this github page:
Using the approach described in the official Kubernetes documentation:
You can label those resources created by config connector (I know that you would like to avoid it) and look for this resources like:
$ kubectl get-all -l look=here
Additional resources: