-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Impossible to watch a kubernetes resource #496
Comments
I see the same thing. Any word on this? |
Are you using the same version of kubernetes? |
No, I'm using latest on GCE which as of this date is 1.4 and the latest client version. (compile 'io.fabric8:kubernetes-client:1.4.17') |
I've just run the following example against Kubernetes 1.4.1 without problems. Can you try it & see if it works for you? import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
public class WatchExample {
private static final Logger logger = LoggerFactory.getLogger(WatchExample.class);
public static void main(String[] args) throws InterruptedException {
final CountDownLatch closeLatch = new CountDownLatch(1);
Config config = new ConfigBuilder().build();
KubernetesClient client = new DefaultKubernetesClient(config);
try {
try (Watch watch = client.pods().inAnyNamespace().watch(new Watcher<Pod>() {
@Override
public void eventReceived(Action action, Pod resource) {
logger.info("Received {}: {}", action, resource.getMetadata().getResourceVersion());
}
@Override
public void onClose(KubernetesClientException e) {
logger.debug("Watcher onClose");
if (e != null) {
logger.error(e.getMessage(), e);
closeLatch.countDown();
}
}
})) {
closeLatch.await(2, TimeUnit.SECONDS);
} catch (KubernetesClientException | InterruptedException e) {
logger.error("Could not watch resources", e);
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
Throwable[] suppressed = e.getSuppressed();
if (suppressed != null) {
for (Throwable t : suppressed) {
logger.error(t.getMessage(), t);
}
}
} finally {
client.close();
}
}
} |
Same error. The only change I made was Config config = new ConfigBuilder().withMasterUrl("http://127.0.0.1:8001").build(); Here's the stack traces:
|
Aha perhaps a kubectl proxy bug not handling websockets properly. |
Thanks for tracking that down! |
This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions! |
Hello,
I encounter an issue when I try to watch a kubernetes resource:
When I send a request with curl, the following HTTP headers are returned:
It seems the API server actually returns a 200 http code.. Do you know a solution for this "issue"?
kubernete-client version: 1.4.4
kubernetes-version: v1.2.0
The text was updated successfully, but these errors were encountered: