Skip to content
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

Results of kubectl commands not sorted #2409

Closed
dnoland1 opened this issue Oct 20, 2020 · 4 comments
Closed

Results of kubectl commands not sorted #2409

dnoland1 opened this issue Oct 20, 2020 · 4 comments

Comments

@dnoland1
Copy link
Contributor

Environmental Info:
K3s Version:

1.18.10

Node(s) CPU architecture, OS, and Version:

ubuntu 20.04

Cluster Configuration:

2 masters, MySQL backend DB

Describe the bug:

When running kubectl commands, often the results are not sorted as expected.

Steps To Reproduce:

For example, get nodes should return results in alphabetical order. Ran twice and order is not consistent:

# kubectl get nodes
NAME               STATUS   ROLES    AGE   VERSION
ip-10-10-100-203   Ready    master   13h   v1.18.10+k3s1
ip-10-10-101-91    Ready    master   13h   v1.18.10+k3s1
# kubectl get nodes
NAME               STATUS   ROLES    AGE   VERSION
ip-10-10-101-91    Ready    master   13h   v1.18.10+k3s1
ip-10-10-100-203   Ready    master   13h   v1.18.10+k3s1

Getting all pods should sort by namespace, then pod name. Results are random:

# kubectl get pods -A
NAMESPACE                 NAME                                                       READY   STATUS    RESTARTS   AGE
kube-system               helm-delete-aws-ebs-csi-driver-4w68j                       0/1     Pending   0          6h31m
cattle-prometheus         prometheus-operator-monitoring-operator-7599b96796-lz62f   0/1     Pending   0          6h31m
cattle-system             cattle-node-agent-875tv                                    1/1     Running   2          24h
cattle-system             cattle-cluster-agent-97579ccdd-dt7rl                       1/1     Running   21         14h
kube-system               ebs-csi-node-6sgf4                                         3/3     Running   6          9h
cattle-system             rancher-webhook-669d998d9-cwr2n                            1/1     Running   2          9h
fleet-system              fleet-agent-55f4848f9b-jbpq6                               1/1     Running   2          9h
kube-system               coredns-autoscaler-67f94c4dc6-d8mwt                        1/1     Running   2          9h
cattle-system             system-upgrade-controller-585f9d68f9-lpx7c                 1/1     Running   1          9h
rancher-operator-system   rancher-operator-547dbc9654-trcbw                          1/1     Running   1          9h
kube-system               ebs-snapshot-controller-0                                  1/1     Running   2          9h
fleet-system              fleet-controller-649446f474-6vng2                          1/1     Running   1          9h
fleet-system              gitjob-869546b74d-2gl4s                                    1/1     Running   1          9h
kube-system               metrics-server-7566d596c8-rfz9v                            1/1     Running   2          9h
ingress-nginx             ingress-nginx-controller-nvkhl                             1/1     Running   2          14h
cattle-system             rancher-7d8957455f-56kpk                                   2/2     Running   3          9h
cattle-prometheus         alertmanager-cluster-alerting-0                            2/2     Running   4          9h
kube-system               ebs-csi-controller-5567dfcd4c-ksbk5                        6/6     Running   30         10h
kube-system               coredns-5bfb5f9668-xz5qq                                   1/1     Running   2          9h
kube-system               ebs-csi-controller-5567dfcd4c-2nw95                        6/6     Running   19         9h
ingress-nginx             ingress-nginx-default-backend-7f84d569f8-7s8lc             1/1     Running   2          9h
cattle-system             rancher-7d8957455f-mxqqw                                   2/2     Running   4          9h
cattle-prometheus         prometheus-operator-monitoring-operator-7599b96796-45gpp   0/1     Pending   0          6h24m

Additional context / logs:
Appears to be an issue because k3s is not sorting results. Likely only an issue when backend is relational, since etcd probably returns results sorted by key name.

@brandond
Copy link
Contributor

brandond commented Oct 20, 2020

It you want things sorted by a field, you have to ask for it; I don't believe it's documented as sorted any specific way otherwise. This might be due to kine not sorting the keys in the same way that etcd does, but I don't think that's guaranteed anywhere.

https://medium.com/faun/sorting-output-in-kubernetes-aa4db6894629

@davidnuzik davidnuzik added this to the Not Scheduled milestone Oct 20, 2020
@davidnuzik davidnuzik added this to To Triage in Development [DEPRECATED] via automation Feb 20, 2021
@davidnuzik davidnuzik moved this from To Triage to Unscheduled in Development [DEPRECATED] Feb 20, 2021
@caroline-suse-rancher
Copy link
Contributor

Closing as this is expected behavior

Development [DEPRECATED] automation moved this from Unscheduled to Done Issue / Merged PR Nov 29, 2022
@RafalSkolasinski
Copy link

I don't think it is fair to say this is expected behaviour when almost all other K8s flavours at least returns kubectl get pods -A sorted by namespace.

@brandond
Copy link
Contributor

brandond commented Feb 12, 2023

While it might be common to distros that use etcd, it is an implementation detail and not required by any spec, as discussed above.

If its a problem for you, use embedded etcd instead of kine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

No branches or pull requests

6 participants