New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for non-default namespace #133

Closed
spiddy opened this Issue May 2, 2017 · 10 comments

Comments

Projects
None yet
2 participants
@spiddy

spiddy commented May 2, 2017

What were you trying to do?

Run telepresence when the context namespace is non-default

kube config set-context mycontext --namespace=mynamespace

What did you expect to happen?

run telepresence on mynamespace with the following command:

telepresence --new-deployment test --run-shell

What happened instead?

The telepresence failed to connect to running pod with message Telepresence pod not found for Deployment 'test'.

The pod was created properly inside the mynamespace I suppose the code looks for the pod on the default namespace instead of the mynamespace.

Automatically included information

Command line: ['/usr/local/bin/telepresence', '--new-deployment', 'test', '--run-shell']
Version: 0.42
Python version: 3.6.1 (default, Apr 4 2017, 09:40:51) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
kubectl version: Client Version: v1.6.1
OS: Darwin ds-MacBook-Pro.local 15.6.0 Darwin Kernel Version 15.6.0: Fri Feb 17 10:21:18 PST 2017; root:xnu-3248.60.11.4.1~1/RELEASE_X86_64 x86_64
Traceback:

Traceback (most recent call last):
  File "/usr/local/bin/telepresence", line 782, in call_f
    return f(*args, **kwargs)
  File "/usr/local/bin/telepresence", line 904, in go
    runner, args
  File "/usr/local/bin/telepresence", line 554, in start_proxy
    runner, args.deployment, args.context, args.namespace
  File "/usr/local/bin/telepresence", line 389, in get_remote_info
    format(deployment_name)
RuntimeError: Telepresence pod not found for Deployment 'test'.

Logs:

Running: (['kubectl', 'cluster-info'],)
Running 'ssh -V'...Running: (['which', 'torsocks'],)
Running: (['which', 'sshfs'],)
Running: (['kubectl', 'delete', '--ignore-not-found', 'service,deployment', 'test'],)
Running: (['kubectl', 'run', '--generator', 'deployment/v1beta1', '--limits=memory=256Mi', '--requests=memory=64Mi', 'test', '--image=datawire/telepresence-k8s:0.42'],)
Running: (['kubectl', 'get', 'deployment', '-o', 'json', 'test', '--export'],)
Expected metadata for pods: {'creationTimestamp': None, 'labels': {'run': 'test'}}
Running: (['kubectl', 'get', 'pod', '-o', 'json', '--export'],)
Checking {'pod-template-hash': '3513391872', 'run': 'test'} (phase Pending)...

@spiddy

This comment has been minimized.

spiddy commented May 2, 2017

If I use:

telepresence --new-deployment test --run-shell --namespace mynamespace

It works as expected. Though documentation clearly states what I was expecting but doesn't work as such:

  --namespace NAMESPACE
                        The Kubernetes namespace to use. Defaults to kubectl's
                        default for the current context, which is usually
                        'default'.
@itamarst

This comment has been minimized.

Contributor

itamarst commented May 2, 2017

Sorry that didn't work, and thank you for the bug report. I will investigate.

@itamarst itamarst added this to Next in Telepresence May 2, 2017

@itamarst itamarst added the bug label May 2, 2017

@itamarst itamarst self-assigned this May 2, 2017

@itamarst itamarst moved this from Next to In progress in Telepresence May 3, 2017

@itamarst itamarst moved this from In progress to Done in Telepresence May 3, 2017

@itamarst itamarst moved this from Done to In progress in Telepresence May 3, 2017

@itamarst

This comment has been minimized.

Contributor

itamarst commented May 3, 2017

Reading the code it's possible the error you're seeing was due to another problem. For example, if it's taking too long for Kubernetes to download the image the pod won't get started before the timeout. In which case it worked the second time simply because the image finished downloading.

Next I will try to reproduce this myself.

@spiddy

This comment has been minimized.

spiddy commented May 3, 2017

I though so too, but I've reproduced it some times and it consistently fails on nondefault and works on default namespace.

@itamarst

This comment has been minimized.

Contributor

itamarst commented May 3, 2017

What I'm seeing so far is that set-context doesn't actually impact my kubectl commands:

$ kubectl config set-context telepresence-testing --namespace=test
Context "telepresence-testing" set.
$ kubectl get pod --all-namespaces
NAMESPACE     NAME                                                        READY     STATUS    RESTARTS   AGE
default       myserver-2686457485-3x4d2                                   1/1       Running   0          2h
default       testing-b5a1f69-0-5760853290557861-10841-4163343846-qp9kq   1/1       Running   0          2d
kube-system   fluentd-gcp-v2.0-649t4                                      1/1       Running   0          2d
kube-system   heapster-v1.3.0-4004699650-pdvdb                            2/2       Running   0          2d
kube-system   kube-dns-806549836-tjzv9                                    3/3       Running   0          2d
kube-system   kube-dns-autoscaler-2528518105-71h6z                        1/1       Running   0          2d
kube-system   kube-proxy-gke-telepresence-testing-pool-399ecba5-jmlr      1/1       Running   0          2d
kube-system   kubernetes-dashboard-2917854236-0v9jk                       1/1       Running   0          2d
kube-system   l7-default-backend-1044750973-5xmbn                         1/1       Running   0          2d
$ kubectl get pod --namespace=test
No resources found.
$ kubectl get pod 
NAME                                                        READY     STATUS    RESTARTS   AGE
myserver-2686457485-3x4d2                                   1/1       Running   0          2h
testing-b5a1f69-0-5760853290557861-10841-4163343846-qp9kq   1/1       Running   0          2d
@itamarst

This comment has been minimized.

Contributor

itamarst commented May 3, 2017

Does your call to kubectl get pod use the namespace you set?

@spiddy

This comment has been minimized.

spiddy commented May 3, 2017

yes, it should. Is your current-context that one?

kubectl config current-context
@itamarst

This comment has been minimized.

Contributor

itamarst commented May 3, 2017

Yep, my mistake, just discovered that. OK, will try to reproduce next.

@itamarst

This comment has been minimized.

Contributor

itamarst commented May 3, 2017

OK, found the bug, will fix it and do a release.

@itamarst itamarst closed this in #140 May 4, 2017

itamarst added a commit that referenced this issue May 4, 2017

Merge pull request #140 from datawire/namespace-set-in-context
Always get context and namespace explicitly at startup.

Fixes #133.
@itamarst

This comment has been minimized.

Contributor

itamarst commented May 4, 2017

v0.44 will be out shortly with this bug fix included. Thanks again for the bug report!

@itamarst itamarst moved this from In progress to Done in Telepresence May 4, 2017

@itamarst itamarst removed this from Done in Telepresence Jun 22, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment