How to create a NetworkPolicy usingt he Fabric8 java client for Kubernetes

1/5/2018

I am reading the Kubernetes docs here https://kubernetes.io/docs/concepts/services-networking/network-policies/

I would assume there is an equivalent object ofr a NetworkPolicy but I didnt find one in the source code or any examples setting the network policy on groups of pods.

Am I looking at the right place?

-- user_mda
fabric8
java
kubernetes
networking

2 Answers

1/6/2018

There’s a handler for it in https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/handlers/NetworkPolicyHandler.java, so I guess it’s supported. The actual NetworkPolicy class seems to be in a dependency library, kubernetes-model.

-- kewne
Source: StackOverflow

1/6/2018

Here is an example of creating NetworkPolicy using fabric8 kubernetes client.

https://github.com/fabric8io/kubernetes-client/pull/976

To select group of pods you can use PodSelector in NetworkPolicySpec.

-- Hrishikesh
Source: StackOverflow