title: kubectl port-forward connection refused [ socat ]
body: <p>I am running pyspark on one of the ports of kubernetes. I am trying to port forward to my local machine. I am getting this error while executing my python file.</p>
  
  <pre><code>Forwarding from 127.0.0.1:7077 -&gt; 7077
  Forwarding from [::1]:7077 -&gt; 7077
  Handling connection for 7077
  E0401 01:08:11.964798   20399 portforward.go:400] an error occurred forwarding 7077 -&gt; 7077: error forwarding port 7077 to pod 68ced395bd081247d1ee6b431776ac2bd3fbfda4d516da156959b6271c2ad90c, uid : exit status 1: 2019/03/31 19:38:11 socat[1748104] E connect(5, AF=2 127.0.0.1:7077, 16): Connection refused
  </code></pre>
  
  <p>this a few lines of my python file. I am getting error in the lines where conf is defined.</p>
  
  <pre><code>from pyspark import SparkContext, SparkConf
  from pyspark.sql import SQLContext
  
  conf = SparkConf().setMaster("spark://localhost:7077").setAppName("Stand Alone Python Script")
  </code></pre>
  
  <p>I already tried installing <code>socat</code> on the kubernetes. I am using spark version 2.4.0 locally. I even tried exposing port 7077 in YAML file. Did not work out.</p>
  
  <p>This is the YAML file used for deployment.</p>
  
  <pre><code>apiVersion: apps/v1beta1
  kind: StatefulSet
  metadata:
    creationTimestamp: 2018-10-07T15:23:35Z
    generation: 16
    labels:
      chart: spark-0.2.1
      component: m3-zeppelin
      heritage: Tiller
      release: m3
    name: m3-zeppelin
    namespace: default
    resourceVersion: "55461362"
    selfLink: /apis/apps/v1beta1/namespaces/default/statefulsets/m3-zeppelin
    uid: f56e86fa-ca44-11e8-af6c-42010a8a00f2
  spec:
    podManagementPolicy: OrderedReady
    replicas: 1
    revisionHistoryLimit: 10
    selector:
      matchLabels:
        component: m3-zeppelin
    serviceName: m3-zeppelin
    template:
      metadata:
        creationTimestamp: null
        labels:
          chart: spark-0.2.1
          component: m3-zeppelin
          heritage: Tiller
          release: m3
      spec:
        containers:
        - args:
          - bash
          - -c
          - wget -qO- https://archive.apache.org/dist/spark/spark-2.2.2/spark-2.2.2-bin-hadoop2.7.tgz
            | tar xz; mv spark-2.2.2-bin-hadoop2.7 spark; curl -sSLO https://storage.googleapis.com/hadoop-lib/gcs/gcs-connector-latest-hadoop2.jar;
            mv gcs-connector-latest-hadoop2.jar lib; ./bin/zeppelin.sh
          env:
          - name: SPARK_MASTER
            value: spark://m3-master:7077
          image: apache/zeppelin:0.8.0
          imagePullPolicy: IfNotPresent
          name: m3-zeppelin
          ports:
          - containerPort: 8080
            name: http
            protocol: TCP
          resources:
            requests:
              cpu: 100m
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
          - mountPath: /zeppelin/conf
            name: m3-zeppelin-config
          - mountPath: /zeppelin/notebook
            name: m3-zeppelin-notebook
        dnsPolicy: ClusterFirst
        restartPolicy: Always
        schedulerName: default-scheduler
        securityContext: {}
        terminationGracePeriodSeconds: 30
    updateStrategy:
      rollingUpdate:
        partition: 0
      type: RollingUpdate
    volumeClaimTemplates:
    - metadata:
        creationTimestamp: null
        name: m3-zeppelin-config
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 10G
        storageClassName: standard
      status:
        phase: Pending
    - metadata:
        creationTimestamp: null
        name: m3-zeppelin-notebook
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 10G
        storageClassName: standard
      status:
        phase: Pending
  status:
    collisionCount: 0
    currentReplicas: 1
    currentRevision: m3-zeppelin-5779b84d99
    observedGeneration: 16
    readyReplicas: 1
    replicas: 1
    updateRevision: m3-zeppelin-5779b84d99
    updatedReplicas: 1
  </code></pre>