Skaffold: Skaffold does not do any port-forwarding

Created on 16 Feb 2019  路  10Comments  路  Source: GoogleContainerTools/skaffold

Expected behavior

As the documentation says, a port-forwarding should be done base on my exposed port container.

Actual behavior

It does not a thing about that:

$ skaffold dev
Generating Tag for [localhost:32000/sweetforeign_web]...
Starting build...
Building [localhost:32000/sweetforeign_web]...
Sending build context to Docker daemon  3.072kB
Step 1/2 : FROM nginx:stable-alpine
 ---> 66952fd0a8ef
Step 2/2 : ADD index.html /usr/share/nginx/html
 ---> Using cache
 ---> f1cb0e1ba59c
Successfully built f1cb0e1ba59c
Successfully tagged localhost:32000/sweetforeign_web:latest
The push refers to repository [localhost:32000/sweetforeign_web]
5245eb10a6da: Preparing
129ba078f157: Preparing
8c8f1eccd524: Preparing
68442845474f: Preparing
503e53e365f3: Preparing
503e53e365f3: Layer already exists
68442845474f: Layer already exists
129ba078f157: Layer already exists
5245eb10a6da: Layer already exists
8c8f1eccd524: Layer already exists
latest: digest: sha256:47dc6256b50971da1e7e78154a919508bf04c9db0bcb9f1622dd71ee62eb1495 size: 1360
Build complete in 134.550577ms
Starting test...
Test complete in 4.058碌s
Starting deploy...
Error: release: "sweetforeign" not found
Helm release sweetforeign not installed. Installing...
No requirements found in ./charts.
NAME:   sweetforeign
LAST DEPLOYED: Sat Feb 16 01:15:12 2019
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/Pod(related)
NAME                          READY  STATUS             RESTARTS  AGE
sweetforeign-cd89f9cf4-9fjc5  0/1    ContainerCreating  0         0s
sweetforeign-cd89f9cf4-vzz88  0/1    Terminating        0         17s

==> v1/Service
NAME          TYPE       CLUSTER-IP     EXTERNAL-IP  PORT(S)  AGE
sweetforeign  ClusterIP  10.152.183.97  <none>       80/TCP   0s

==> v1/Deployment
NAME          DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
sweetforeign  1        1        1           0          0s


NOTES:
1. Get the application URL by running these commands:
  export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=sweetforeign,app.kubernetes.io/instance=sweetforeign" -o jsonpath="{.items[0].metadata.name}")
  echo "Visit http://127.0.0.1:8080 to use your application"
  kubectl port-forward $POD_NAME 8080:80

WARN[0001] error adding label to runtime object: patching resource /sweetforeign-test-connection: pods "sweetforeign-test-connection" not found 
Deploy complete in 1.35663968s
Watching for changes every 1s...

But it works with your helm example.

Information

  • Skaffold version: 0.23.0
  • Operating system: Linux sweethome 4.18.0-15-generic #16-Ubuntu SMP Thu Feb 7 10:56:39 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • Contents of skaffold.yaml: See reproducing steps.

Steps to reproduce the behavior

  1. Clone this branch: https://github.com/Soullivaneuh/skaffold-issues/tree/issue-1663
  2. Run skaffold dev
areportforward deplohelm help wanted kinbug

Most helpful comment

Am experiencing this issue with v0.27.0. containerPort port forwarding is working with build artefacts defined in the skaffold yaml, but not with additional containers defined in the k8s manifests yaml.

All 10 comments

I confirm this. When I rolled back to v0.22.0 it seems to work.

@Pozo Did you test it on my issue branch? I just built v0.22.0 and it does not change a thing. :thinking:

@Soullivaneuh I checked out your branch and replaced the image name with my GCR project. Looks like this is happening because skaffold builds the image as gcr.io/priya-wadhwa/sweetforeign_web:latest@sha256:006f9aa59e6f68781481559cccab095f55750ee44d4931f13470cf185d0038f4, but helm deploys as gcr.io/priya-wadhwa/sweetforeign_web:latest, so our pod selector thinks the images are different and doesn't port forward.

We could potentially solve this by making the image selector less strict, or by adding a port-forward section to the skaffold.yaml to allow users to specify which containers to forward (this would be #1311)

@Soullivaneuh It is not a bug at all. I fall in the same trap.

Take a time to look at Helm example https://github.com/GoogleContainerTools/skaffold/tree/master/examples/helm-deployment

To make it work you have to change your deployment.yaml and values.yaml as well:

containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image }}"
          imagePullPolicy: {{ .Values.pullPolicy }}

After this change, your Chart will use proper image build by skaffold for deployment and port forwarding should work as expected.

@swoldanski I'm experiencing the same behavior without using helm. My app port forwards just fine from 0.22.0-, but as soon as I upgrade to 0.23.0+ it stops. I would expect skaffold to auto port-forward with the following yaml:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: app
  labels:
    app: app
spec:
  replicas: 1
  minReadySeconds: 10
  template:
    metadata:
      name: app-pod
      labels:
        app: app
    spec:
      containers:
      - name: app
        image: company/app:dev
        imagePullPolicy: Never
        ports:
        - name: http
          containerPort: 8000

Again, skaffold auto port-forwards fine with this yaml in <= 0.22.0, but not > 0.22.0.

I can confirm this, port forwarding is broken in skaffold version v0.25.0

This is an actual bug, or code works fine with v0.22.0 but port forwards breaks in v0.25.0

Am experiencing this issue with v0.27.0. containerPort port forwarding is working with build artefacts defined in the skaffold yaml, but not with additional containers defined in the k8s manifests yaml.

With helm the latest version still has some issues (https://github.com/GoogleContainerTools/skaffold/issues/2379) but you can workaround it with explicitly configuring port-forwarding of deployments:

https://skaffold.dev/docs/how-tos/portforward/#user-defined-port-forwarding

I would close this in favor for #2379. Let me know if there is anything else here that justify reopening this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Morriz picture Morriz  路  3Comments

woodcockjosh picture woodcockjosh  路  4Comments

garvincasimir picture garvincasimir  路  4Comments

nathanph picture nathanph  路  3Comments

r2d4 picture r2d4  路  3Comments