lensapp / lens

Lens - The way the world runs Kubernetes
https://k8slens.dev/
MIT License
22.49k stars 1.46k forks source link

Port forwarding issue #6259

Open ragsns opened 2 years ago

ragsns commented 2 years ago

Describe the bug

Works fine on other providers but not on LDK.

Workshop:

https://github.com/datastaxdevs/quarkus-astra-intro-demo.git

Instructions:

https://github.com/datastaxdevs/workshop-intro-quarkus-cassandra#10-containerizing

YML file:

---
apiVersion: v1
kind: Service
metadata:
  annotations:
    app.quarkus.io/commit-id: eef114c88d5798802dd012c5b199a060badd7ebe
    app.quarkus.io/build-timestamp: 2022-09-15 - 13:16:14 +0000
    prometheus.io/scrape: "true"
    prometheus.io/path: /q/metrics
    prometheus.io/port: "8080"
    prometheus.io/scheme: http
  labels:
    app.kubernetes.io/name: quarkus-cassandra
    app.kubernetes.io/version: "0.01"
  name: quarkus-cassandra
spec:
  ports:
    - name: http
      port: 80
      targetPort: 8080
  selector:
    app.kubernetes.io/name: quarkus-cassandra
    app.kubernetes.io/version: "0.01"
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    app.quarkus.io/commit-id: eef114c88d5798802dd012c5b199a060badd7ebe
    app.quarkus.io/build-timestamp: 2022-09-15 - 13:16:14 +0000
    prometheus.io/scrape: "true"
    prometheus.io/path: /q/metrics
    prometheus.io/port: "8080"
    prometheus.io/scheme: http
  labels:
    app.kubernetes.io/name: quarkus-cassandra
    app.kubernetes.io/version: "0.01"
  name: quarkus-cassandra
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: quarkus-cassandra
      app.kubernetes.io/version: "0.01"
  template:
    metadata:
      annotations:
        app.quarkus.io/commit-id: eef114c88d5798802dd012c5b199a060badd7ebe
        app.quarkus.io/build-timestamp: 2022-09-15 - 13:16:14 +0000
        prometheus.io/scrape: "true"
        prometheus.io/path: /q/metrics
        prometheus.io/port: "8080"
        prometheus.io/scheme: http
      labels:
        app.kubernetes.io/name: quarkus-cassandra
        app.kubernetes.io/version: "0.01"
    spec:
      containers:
        - env:
            - name: KUBERNETES_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          envFrom:
            - secretRef:
                name: astra
          image: docker.io/ragsns/quarkus-cassandra:0.01
          imagePullPolicy: Always
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /q/health/live
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 0
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 10
          name: quarkus-cassandra
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /q/health/ready
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 0
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 10

To Reproduce

On Lens:

➜  ~ kubectl get all
NAME                                    READY   STATUS    RESTARTS   AGE
pod/quarkus-cassandra-fd969944d-bjdm6   1/1     Running   0          20m

NAME                        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
service/kubernetes          ClusterIP   10.96.0.1        <none>        443/TCP   21m
service/quarkus-cassandra   ClusterIP   10.105.235.194   <none>        80/TCP    20m

NAME                                READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/quarkus-cassandra   1/1     1            1           20m

NAME                                          DESIRED   CURRENT   READY   AGE
replicaset.apps/quarkus-cassandra-fd969944d   1         1         1       20m
➜  ~ kubectl port-forward service/quarkus-cassandra 8080:80 &
[1] 29218
➜  ~ Forwarding from [::1]:8080 -> 8080

➜  ~ curl localhost:8080
Handling connection for 8080
E0915 13:12:01.758553   29218 portforward.go:406] an error occurred forwarding 8080 -> 8080: error forwarding port 8080 to pod 9738f3019fa6a129fe9fe1c330d109ae276e23514f7eabcc0e9181f0735182e8, uid : unable to do port forwarding: socat not found
E0915 13:12:01.758810   29218 portforward.go:234] lost connection to pod
curl: (52) Empty reply from server
[1]  + 29218 done       kubectl port-forward service/quarkus-cassandra 8080:80                     
➜  ~

Expected behavior To be able to connect to app.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Logs: When you run the application executable from command line you will see some logging output. Please paste them here:

Your logs go here...

Kubeconfig: Quite often the problems are caused by malformed kubeconfig which the application tries to load. Please share your kubeconfig, remember to remove any secret and sensitive information.

your kubeconfig here

Additional context Add any other context about the problem here.

ragsns commented 2 years ago

I don't think it's a socat issue since I run into same problem on deploying

https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/

panuhorsmalahti commented 2 years ago

There is a fix in the upcoming (released later today or tomorrow) alpha of Lens that will likely fix this issue.

EDIT: You can try 2022.10.31204-alpha