soluble-ai / kubetap

Kubectl plugin to interactively proxy Kubernetes Services with ease
https://soluble-ai.github.io/kubetap/
Apache License 2.0
524 stars 44 forks source link

Can't tap a service tied to a deployment #14

Open marcgarciajr opened 3 years ago

marcgarciajr commented 3 years ago

Description

The following command $ kubectl tap on -n mynamepsace -p443 --https myservice Returns: Error: error resolving Deployment from Service selectors: the Service selector did not match any Deployments

Screenshots or other information

My service and deployment

Go version: Kubernetes client version: Major:"1", Minor:"19", GitVersion:"v1.19.0" Kubernetes server version: Major:"1", Minor:"19", GitVersion:"v1.19.4"

daxxog commented 3 years ago

I had the same issue and it turned out I needed to add the same selector I used in my pod spec selector match labels to the deployment labels. Something like this:

 apiVersion: apps/v1
 kind: Deployment
 metadata:
   name: my-cool-app
   namespace: my-namespace
+  labels:
+    app: my-cool-app
 spec:
   selector:
     matchLabels:
      app: my-cool-app
   template:
     metadata:
       labels:
         app: my-cool-app
 ...
apiVersion: v1
kind: Service
metadata:
  name: my-cool-app
  namespace: my-namespace
spec:
  selector:
    app: my-cool-app
...