-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli: "trace" command #744
Comments
Assigning to myself for tracking purposes, but I am not starting work on this right now. |
Here is my proposal:
This command will provide debugging information for Crossplane resources by tracing the related objects and printing helpful information. To achieve this, we need a way to find the next/related object(s) for a given one. There are different types of relations between Crossplane resources and need to be handled separately. Command can be invoked for any object in the chain and information for resources down to last object will be shown as output. Relation Chain: Stack Instance -> Questions:
Implementation: Just like existing Crossplane cli commands, kubectl plugin mechanism will be used. Existing commands implemented in bash and in general, it makes sense to switch to a more powerful language like go or python. However bash seems to be good enough for this command as well, thanks to kubectl output format options like We can consider implementing two different flavours, as follows: Possible output for a fictitious state: $ kubectl crossplane trace kubernetesapplication wordpress-app-64edc6f9-7c70-43ed-bd1d-1c26e09e0a45
KUBERNETES APPLICATIONS
---
NAME CLUSTER STATUS DESIRED SUBMITTED
wordpress-app-64edc6f9-7c70-43ed-bd1d-1c26e09e0a45 wordpress-cluster-64edc6f9-7c70-43ed-bd1d-1c26e09e0a45 Submitted 3 3
Status Conditions:
TYPE STATUS REASON
Synced True Successfully reconciled managed resource
-----------------------
KUBERNETES APPLICATION RESOURCES
NAME TEMPLATE-KIND TEMPLATE-NAME CLUSTER STATUS
wordpress-demo-deployment-64edc6f9-7c70-43ed-bd1d-1c26e09e0a45 Deployment wordpress wordpress-cluster-64edc6f9-7c70-43ed-bd1d-1c26e09e0a45 Submitted
Status Conditions:
Synced True 2019-10-10T06:52:15Z Successfully reconciled managed resource
Remote
AVAILABLE-REPLICAS READY-REPLICAS REPLICAS UPDATED-REPLICAS
1 1 1 1
Remote Conditions:
TYPE STATUS REASON MESSAGE
Progressing True NewReplicaSetAvailable ReplicaSet "wordpress-68d579bcb4" has successfully progressed.
Available True MinimumReplicasAvailable Deployment has minimum availability.
---
NAME TEMPLATE-KIND TEMPLATE-NAME CLUSTER STATUS
wordpress-demo-namespace-64edc6f9-7c70-43ed-bd1d-1c26e09e0a45 Namespace wordpress wordpress-cluster-64edc6f9-7c70-43ed-bd1d-1c26e09e0a45 Submitted
Status Conditions:
TYPE STATUS LAST-TRANSITION-TIME REASON
Synced True 2019-10-10T06:52:15Z Successfully reconciled managed resource
Remote:
PHASE
Active
---
NAME TEMPLATE-KIND TEMPLATE-NAME CLUSTER STATUS
wordpress-demo-service-64edc6f9-7c70-43ed-bd1d-1c26e09e0a45 Service wordpress wordpress-cluster-64edc6f9-7c70-43ed-bd1d-1c26e09e0a45 Submitted
Status Conditions:
TYPE STATUS LAST-TRANSITION-TIME REASON
Synced True 2019-10-10T06:52:15Z Successfully reconciled managed resource
Remote:
LOADBALANCER-INGRESS-IP
35.222.234.64
--------------------------------
KUBERNETES CLUSTER
---
NAME STATUS CLUSTER-CLASS CLUSTER-REF AGE
wordpress-cluster-64edc6f9-7c70-43ed-bd1d-1c26e09e0a45 Bound standard-cluster 24h
Status Conditions:
TYPE STATUS LAST-TRANSITION-TIME REASON
Synced True 2019-10-10T06:52:15Z Successfully reconciled managed resource
Ready True 2019-10-10T06:55:55Z Managed resource is available for use
|||
NAME STATUS STATE CLUSTER-NAME ENDPOINT CLUSTER-CLASS LOCATION RECLAIM-POLICY AGE
kubernetescluster-5c843147-069e-4a94-81d3-188c9e0fbd9c Bound ERROR gke-0b9ec875-4ee9-409d-886a-94751fb1a32e 35.193.166.52 standard-gke us-central1-b Delete 24h
Status Conditions:
TYPE STATUS LAST-TRANSITION-TIME REASON MESSAGE
Synced True 2019-10-10T06:52:15Z Successfully reconciled managed resource
Ready False 2019-10-10T06:55:55Z Managed resource is not available for use gke cluster is in ERROR state with message: Retry budget exhausted (10 attempts): Services range "services" in network "example-network", subnetwork "example-subnetwork" is already used by another cluster.
-----------------
MANAGED RESOURCES
---
MySQLInstance
NAME STATUS CLASS VERSION AGE
wordpress-mysql-64edc6f9-7c70-43ed-bd1d-1c26e09e0a45 Bound standard-mysql 5.7 25h
Status Conditions:
TYPE STATUS LAST-TRANSITION-TIME REASON
Synced True 2019-10-10T06:52:15Z Successfully reconciled managed resource
Ready True 2019-10-10T06:55:55Z Managed resource is available for use
|||
NAME STATUS STATE CLASS VERSION AGE
mysqlinstance-e3460958-271d-4cf7-a468-fa21f360b334 Bound RUNNABLE standard-cloudsql MYSQL_5_7 25h
Status Conditions:
TYPE STATUS LAST-TRANSITION-TIME REASON
Synced True 2019-10-10T06:52:15Z Successfully reconciled managed resource
Ready True 2019-10-10T06:55:55Z Managed resource is available for use |
Awesome! I'm thinking there are a couple more types of chains not covered by the existing list that we might want to follow:
For the question of:
I wouldn't worry about this for now, since the main improvement offered by For the question of:
I would say yes, these definitely add value when debugging.
I am imagining that the output of this tool could be input for another tool (in the spirit of the Unix Philosophy), so I would try to put all relevant information on individual lines where possible. That said, we can always start with something we think is pretty close, and change things in the future : ). Based on the sample output, it sounds like you are imagining output which feels very similar to
You may have a better idea of what a bash implementation may look like at this point than I do, but I am thinking the chain-walking logic may be tricky to do cleanly in bash. But maybe not!
I was imagining that we could probably design a labeling scheme that made this walk much simpler to follow from |
I understand you suggest a more general purpose debugging tool rather than a simple "find related next object and print some info" tool which definitely makes sense. In this case, it would be hard to scale with
Yeah, this is something that I also considered but not all
Representing resource chain/relations with a data structure makes more sense considering scalability of this tool. So, I agree bash is not a good option here, I will go with go :) |
In general I agree with this, BUT, I am wondering whether the data structure could be embedded in the Kubernetes objects. For example: what if all objects related to a particular workload had a label on them, like |
Also, I do want to clarify that it is totally fine to make a simple and very limited tool now, play with it to learn more about what we want, and then improve it in the future to support other use-cases. I would much rather have a simple tool that we can use now than wait longer for a more sophisticated tool. For example, a use-case that came up multiple times in the last couple of days is debugging a resource claim, so making something quickly that helps with debugging claims seems like a good place to start. It's even fine for that to be in bash if that makes things easier, even if we think golang will be the direction we want to go in the future. Because our vision of the future will change as people use our tool and we learn more about the use-cases. |
What seems to be the problem?
During problem solving and troubleshooting of issues (especially with workloads), I often end up doing a
kubectl get
on the relevant resource, then a bunch ofget
s on related resources, to see the statuses of everything related to what I was trying to do.How can Crossplane help?
It seems like it'd be useful to have a
trace
command which would walk the related objects and print out statuses for me. I imagine it working something likekubectl crossplane trace mysqlinstance wordpressdatabase
. I believe thecrossplane
portion of the invocation is not necessary, but it may make sense to start with it. I could also imagine a--maxdepth
type option.Because grabbing information on objects related to a particular object seems like a common troubleshooting use-case, it is possible that a tool to do this already exists or is in development elsewhere.
The text was updated successfully, but these errors were encountered: