Skip to content

Commit

Permalink
Remove shortnames from Tap API resources (#11816)
Browse files Browse the repository at this point in the history
The Tap API resource shortnames were colliding with existing Kubernetes
resources (e.g. `po`, `deploy`, etc), causing warnings from kubectl
v1.29.0+.

Remove the shortnames from the Tap APIService handlers.

To validate:
```bash
bin/k3d cluster create

# install latest edge
curl https://run.linkerd.io/install-edge | sh
linkerd install --crds | kubectl apply -f -
linkerd install        | kubectl apply -f -
linkerd check
linkerd viz install    | kubectl apply -f -
linkerd check

# observe shortnames
kubectl api-resources --api-group=tap.linkerd.io

# with kubectl v1.29.0+, observe "Warning: short name..."
kubectl get po

# replace tap image
TAP_IMAGE=$(bin/docker-build-tap)
bin/k3d image load $TAP_IMAGE
kubectl -n linkerd-viz set image deploy/tap tap=$TAP_IMAGE

# verify shortnames are no longer present
kubectl api-resources --api-group=tap.linkerd.io

# with kubectl v1.29.0+, observe no warning
kubectl get po
```

Fixes #11784

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
  • Loading branch information
siggy committed Jan 4, 2024
1 parent 7cb0e36 commit ff25a71
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions viz/tap/api/handlers.go
Expand Up @@ -55,19 +55,18 @@ var (

resources = []struct {
name string
shortname string
namespaced bool
}{
{"namespaces", "ns", false},
{"pods", "po", true},
{"replicationcontrollers", "rc", true},
{"services", "svc", true},
{"daemonsets", "ds", true},
{"deployments", "deploy", true},
{"replicasets", "rs", true},
{"statefulsets", "sts", true},
{"jobs", "", true},
{"cronjobs", "cj", true},
{"namespaces", false},
{"pods", true},
{"replicationcontrollers", true},
{"services", true},
{"daemonsets", true},
{"deployments", true},
{"replicasets", true},
{"statefulsets", true},
{"jobs", true},
{"cronjobs", true},
}
)

Expand Down Expand Up @@ -257,7 +256,6 @@ func handleAPIResourceList(w http.ResponseWriter, _ *http.Request, _ httprouter.
resList.APIResources = append(resList.APIResources,
metav1.APIResource{
Name: res.name,
ShortNames: []string{res.shortname},
Namespaced: res.namespaced,
Kind: gvk.Kind,
Verbs: metav1.Verbs{"watch"},
Expand Down

0 comments on commit ff25a71

Please sign in to comment.