Add CLIs for k8s endpoins, pods and services, sync & purge states

Change-Id: I931ad76077639e80045f106c0014f113c76354d6
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sEndpointsListCommand.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sEndpointsListCommand.java
new file mode 100644
index 0000000..6b4c997
--- /dev/null
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sEndpointsListCommand.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.k8snetworking.cli;
+
+import com.google.common.collect.Lists;
+import io.fabric8.kubernetes.api.model.Endpoints;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.k8snetworking.api.K8sEndpointsService;
+
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Lists kubernetes endpoints.
+ */
+@Service
+@Command(scope = "onos", name = "k8s-endpoints",
+        description = "Lists all kubernetes endpoints")
+public class K8sEndpointsListCommand extends AbstractShellCommand {
+
+    private static final String FORMAT = "%-50s%-50s%-20s";
+
+    @Override
+    protected void doExecute() {
+        K8sEndpointsService service = get(K8sEndpointsService.class);
+        List<Endpoints> endpointses = Lists.newArrayList(service.endpointses());
+        endpointses.sort(Comparator.comparing(e -> e.getMetadata().getName()));
+
+        print(FORMAT, "Name", "IP Addresses", "Ports");
+
+        for (Endpoints endpoints : endpointses) {
+
+            List<String> ips = Lists.newArrayList();
+            List<Integer> ports = Lists.newArrayList();
+
+            endpoints.getSubsets().forEach(e -> {
+                e.getAddresses().forEach(a -> ips.add(a.getIp()));
+                e.getPorts().forEach(p -> ports.add(p.getPort()));
+            });
+
+            print(FORMAT,
+                    endpoints.getMetadata().getName(),
+                    ips.isEmpty() ? "" : ips,
+                    ports.isEmpty() ? "" : ports);
+        }
+    }
+}
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sPodListCommand.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sPodListCommand.java
new file mode 100644
index 0000000..c1bb526
--- /dev/null
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sPodListCommand.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.k8snetworking.cli;
+
+import com.google.common.collect.Lists;
+import io.fabric8.kubernetes.api.model.Pod;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.k8snetworking.api.K8sPodService;
+
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Lists kubernetes pods.
+ */
+@Service
+@Command(scope = "onos", name = "k8s-pods",
+        description = "Lists all kubernetes pods")
+public class K8sPodListCommand extends AbstractShellCommand {
+
+    private static final String FORMAT = "%-50s%-15s%-15s%-30s";
+
+    @Override
+    protected void doExecute() {
+        K8sPodService service = get(K8sPodService.class);
+        List<Pod> pods = Lists.newArrayList(service.pods());
+        pods.sort(Comparator.comparing(p -> p.getMetadata().getName()));
+
+        print(FORMAT, "Name", "Namespace", "IP", "Containers");
+
+        for (Pod pod : pods) {
+
+            List<String> containers = Lists.newArrayList();
+
+            pod.getSpec().getContainers().forEach(c -> containers.add(c.getName()));
+
+            print(FORMAT,
+                    pod.getMetadata().getName(),
+                    pod.getMetadata().getNamespace(),
+                    pod.getStatus().getPodIP(),
+                    containers.isEmpty() ? "" : containers);
+        }
+    }
+}
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sPurgeState.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sPurgeState.java
new file mode 100644
index 0000000..ccff90a
--- /dev/null
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sPurgeState.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.k8snetworking.cli;
+
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.k8snetworking.api.K8sEndpointsAdminService;
+import org.onosproject.k8snetworking.api.K8sPodAdminService;
+import org.onosproject.k8snetworking.api.K8sServiceAdminService;
+
+/**
+ * Purges all existing kubernetes states.
+ */
+@Service
+@Command(scope = "onos", name = "k8s-purge-states",
+        description = "Purges all kubernetes states")
+public class K8sPurgeState extends AbstractShellCommand {
+    @Override
+    protected void doExecute() {
+        get(K8sPodAdminService.class).clear();
+        get(K8sEndpointsAdminService.class).clear();
+        get(K8sServiceAdminService.class).clear();
+    }
+}
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sServiceListCommand.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sServiceListCommand.java
new file mode 100644
index 0000000..800a1ab
--- /dev/null
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sServiceListCommand.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.k8snetworking.cli;
+
+import com.google.common.collect.Lists;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.k8snetworking.api.K8sServiceService;
+
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Lists kubernetes services.
+ */
+@Service
+@Command(scope = "onos", name = "k8s-services",
+        description = "Lists all kubernetes services")
+public class K8sServiceListCommand extends AbstractShellCommand {
+
+    private static final String FORMAT = "%-50s%-30s%-30s";
+
+    @Override
+    protected void doExecute() {
+        K8sServiceService service = get(K8sServiceService.class);
+        List<io.fabric8.kubernetes.api.model.Service> services =
+                Lists.newArrayList(service.services());
+        services.sort(Comparator.comparing(s -> s.getMetadata().getName()));
+
+        print(FORMAT, "Name", "Cluster IP", "Ports");
+
+        for (io.fabric8.kubernetes.api.model.Service svc : services) {
+
+            List<Integer> ports = Lists.newArrayList();
+
+            svc.getSpec().getPorts().forEach(p -> ports.add(p.getPort()));
+
+            print(FORMAT,
+                    svc.getMetadata().getName(),
+                    svc.getSpec().getClusterIP(),
+                    ports.isEmpty() ? "" : ports);
+        }
+    }
+}
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sSyncStateCommand.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sSyncStateCommand.java
new file mode 100644
index 0000000..1592755
--- /dev/null
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/cli/K8sSyncStateCommand.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.k8snetworking.cli;
+
+import com.google.common.collect.Lists;
+import io.fabric8.kubernetes.api.model.Endpoints;
+import io.fabric8.kubernetes.api.model.Pod;
+import io.fabric8.kubernetes.client.KubernetesClient;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.k8snetworking.api.K8sEndpointsAdminService;
+import org.onosproject.k8snetworking.api.K8sPodAdminService;
+import org.onosproject.k8snetworking.api.K8sServiceAdminService;
+import org.onosproject.k8snetworking.util.K8sNetworkingUtil;
+import org.onosproject.k8snode.api.K8sApiConfig;
+import org.onosproject.k8snode.api.K8sApiConfigService;
+
+import java.util.List;
+
+/**
+ * Synchronizes kubernetes states.
+ */
+@Service
+@Command(scope = "onos", name = "k8s-sync-states",
+        description = "Synchronizes all kubernetes states")
+public class K8sSyncStateCommand extends AbstractShellCommand {
+
+    private static final String POD_FORMAT = "%-50s%-15s%-15s%-30s";
+    private static final String SERVICE_FORMAT = "%-50s%-30s%-30s";
+    private static final String ENDPOINTS_FORMAT = "%-50s%-50s%-20s";
+
+    @Override
+    protected void doExecute() {
+        K8sApiConfigService configService = get(K8sApiConfigService.class);
+        K8sPodAdminService podAdminService = get(K8sPodAdminService.class);
+        K8sServiceAdminService serviceAdminService =
+                get(K8sServiceAdminService.class);
+        K8sEndpointsAdminService endpointsAdminService =
+                get(K8sEndpointsAdminService.class);
+
+        K8sApiConfig config =
+                configService.apiConfigs().stream().findAny().orElse(null);
+        if (config == null) {
+            log.error("Failed to find valid kubernetes API configuration.");
+            return;
+        }
+
+        KubernetesClient client = K8sNetworkingUtil.k8sClient(config);
+
+        if (client == null) {
+            log.error("Failed to connect to kubernetes API server.");
+            return;
+        }
+
+        print("Synchronizing kubernetes services");
+        print(SERVICE_FORMAT, "Name", "Cluster IP", "Ports");
+        client.services().list().getItems().forEach(svc -> {
+            if (serviceAdminService.service(svc.getMetadata().getUid()) != null) {
+                serviceAdminService.updateService(svc);
+            } else {
+                serviceAdminService.createService(svc);
+            }
+            printService(svc);
+        });
+
+        print("\nSynchronizing kubernetes endpoints");
+        print(ENDPOINTS_FORMAT, "Name", "IP Addresses", "Ports");
+        client.endpoints().list().getItems().forEach(ep -> {
+            if (endpointsAdminService.endpoints(ep.getMetadata().getUid()) != null) {
+                endpointsAdminService.updateEndpoints(ep);
+            } else {
+                endpointsAdminService.createEndpoints(ep);
+            }
+            printEndpoints(ep);
+        });
+
+        print("\nSynchronizing kubernetes pods");
+        print(POD_FORMAT, "Name", "Namespace", "IP", "Containers");
+        client.pods().list().getItems().forEach(pod -> {
+            if (podAdminService.pod(pod.getMetadata().getUid()) != null) {
+                podAdminService.updatePod(pod);
+            } else {
+                podAdminService.createPod(pod);
+            }
+            printPod(pod);
+        });
+    }
+
+    private void printEndpoints(Endpoints endpoints) {
+        List<String> ips = Lists.newArrayList();
+        List<Integer> ports = Lists.newArrayList();
+
+        endpoints.getSubsets().forEach(e -> {
+            e.getAddresses().forEach(a -> ips.add(a.getIp()));
+            e.getPorts().forEach(p -> ports.add(p.getPort()));
+        });
+
+        print(ENDPOINTS_FORMAT,
+                endpoints.getMetadata().getName(),
+                ips.isEmpty() ? "" : ips,
+                ports.isEmpty() ? "" : ports);
+    }
+
+    private void printService(io.fabric8.kubernetes.api.model.Service service) {
+
+        List<Integer> ports = Lists.newArrayList();
+
+        service.getSpec().getPorts().forEach(p -> ports.add(p.getPort()));
+
+        print(SERVICE_FORMAT,
+                service.getMetadata().getName(),
+                service.getSpec().getClusterIP(),
+                ports.isEmpty() ? "" : ports);
+    }
+
+    private void printPod(Pod pod) {
+
+        List<String> containers = Lists.newArrayList();
+
+        pod.getSpec().getContainers().forEach(c -> containers.add(c.getName()));
+
+        print(POD_FORMAT,
+                pod.getMetadata().getName(),
+                pod.getMetadata().getNamespace(),
+                pod.getStatus().getPodIP(),
+                containers.isEmpty() ? "" : containers);
+    }
+}
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/DistributedK8sEndpointsStore.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/DistributedK8sEndpointsStore.java
index 6327451..3bb88e4 100644
--- a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/DistributedK8sEndpointsStore.java
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/DistributedK8sEndpointsStore.java
@@ -21,6 +21,7 @@
 import io.fabric8.kubernetes.api.model.EndpointSubset;
 import io.fabric8.kubernetes.api.model.Endpoints;
 import io.fabric8.kubernetes.api.model.ObjectMeta;
+import io.fabric8.kubernetes.api.model.ObjectReference;
 import org.onlab.util.KryoNamespace;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
@@ -43,6 +44,7 @@
 import org.slf4j.Logger;
 
 import java.util.Collection;
+import java.util.LinkedHashMap;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
 
@@ -75,7 +77,9 @@
             .register(ObjectMeta.class)
             .register(EndpointSubset.class)
             .register(EndpointAddress.class)
+            .register(ObjectReference.class)
             .register(EndpointPort.class)
+            .register(LinkedHashMap.class)
             .register(Collection.class)
             .build();
 
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/DistributedK8sPodStore.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/DistributedK8sPodStore.java
index 9c943cc..fe16346 100644
--- a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/DistributedK8sPodStore.java
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/DistributedK8sPodStore.java
@@ -16,10 +16,51 @@
 package org.onosproject.k8snetworking.impl;
 
 import com.google.common.collect.ImmutableSet;
+import io.fabric8.kubernetes.api.model.Capabilities;
+import io.fabric8.kubernetes.api.model.ConfigMapEnvSource;
+import io.fabric8.kubernetes.api.model.ConfigMapKeySelector;
+import io.fabric8.kubernetes.api.model.ConfigMapVolumeSource;
+import io.fabric8.kubernetes.api.model.Container;
+import io.fabric8.kubernetes.api.model.ContainerPort;
+import io.fabric8.kubernetes.api.model.ContainerState;
+import io.fabric8.kubernetes.api.model.ContainerStateRunning;
+import io.fabric8.kubernetes.api.model.ContainerStateTerminated;
+import io.fabric8.kubernetes.api.model.ContainerStateWaiting;
+import io.fabric8.kubernetes.api.model.ContainerStatus;
+import io.fabric8.kubernetes.api.model.EmptyDirVolumeSource;
+import io.fabric8.kubernetes.api.model.EnvFromSource;
+import io.fabric8.kubernetes.api.model.EnvVar;
+import io.fabric8.kubernetes.api.model.EnvVarSource;
+import io.fabric8.kubernetes.api.model.ExecAction;
+import io.fabric8.kubernetes.api.model.HTTPGetAction;
+import io.fabric8.kubernetes.api.model.HTTPHeader;
+import io.fabric8.kubernetes.api.model.HostPathVolumeSource;
+import io.fabric8.kubernetes.api.model.IntOrString;
+import io.fabric8.kubernetes.api.model.KeyToPath;
+import io.fabric8.kubernetes.api.model.Lifecycle;
+import io.fabric8.kubernetes.api.model.ObjectFieldSelector;
 import io.fabric8.kubernetes.api.model.ObjectMeta;
+import io.fabric8.kubernetes.api.model.OwnerReference;
+import io.fabric8.kubernetes.api.model.PersistentVolumeClaimVolumeSource;
 import io.fabric8.kubernetes.api.model.Pod;
+import io.fabric8.kubernetes.api.model.PodCondition;
+import io.fabric8.kubernetes.api.model.PodSecurityContext;
 import io.fabric8.kubernetes.api.model.PodSpec;
 import io.fabric8.kubernetes.api.model.PodStatus;
+import io.fabric8.kubernetes.api.model.Probe;
+import io.fabric8.kubernetes.api.model.Quantity;
+import io.fabric8.kubernetes.api.model.ResourceFieldSelector;
+import io.fabric8.kubernetes.api.model.ResourceRequirements;
+import io.fabric8.kubernetes.api.model.SELinuxOptions;
+import io.fabric8.kubernetes.api.model.SecretEnvSource;
+import io.fabric8.kubernetes.api.model.SecretKeySelector;
+import io.fabric8.kubernetes.api.model.SecretVolumeSource;
+import io.fabric8.kubernetes.api.model.SecurityContext;
+import io.fabric8.kubernetes.api.model.TCPSocketAction;
+import io.fabric8.kubernetes.api.model.Toleration;
+import io.fabric8.kubernetes.api.model.Volume;
+import io.fabric8.kubernetes.api.model.VolumeDevice;
+import io.fabric8.kubernetes.api.model.VolumeMount;
 import org.onlab.util.KryoNamespace;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
@@ -42,6 +83,7 @@
 import org.slf4j.Logger;
 
 import java.util.Collection;
+import java.util.LinkedHashMap;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
 
@@ -74,6 +116,48 @@
             .register(ObjectMeta.class)
             .register(PodSpec.class)
             .register(PodStatus.class)
+            .register(PodCondition.class)
+            .register(Container.class)
+            .register(EnvVar.class)
+            .register(EnvVarSource.class)
+            .register(EnvFromSource.class)
+            .register(ConfigMapEnvSource.class)
+            .register(ConfigMapKeySelector.class)
+            .register(ObjectFieldSelector.class)
+            .register(ResourceFieldSelector.class)
+            .register(SecretKeySelector.class)
+            .register(Lifecycle.class)
+            .register(SecretEnvSource.class)
+            .register(ContainerStatus.class)
+            .register(ContainerState.class)
+            .register(ContainerStateRunning.class)
+            .register(ContainerStateTerminated.class)
+            .register(ContainerStateWaiting.class)
+            .register(OwnerReference.class)
+            .register(Probe.class)
+            .register(ExecAction.class)
+            .register(HTTPGetAction.class)
+            .register(HTTPHeader.class)
+            .register(TCPSocketAction.class)
+            .register(ContainerPort.class)
+            .register(ResourceRequirements.class)
+            .register(SecurityContext.class)
+            .register(PodSecurityContext.class)
+            .register(SELinuxOptions.class)
+            .register(Volume.class)
+            .register(VolumeDevice.class)
+            .register(VolumeMount.class)
+            .register(IntOrString.class)
+            .register(Toleration.class)
+            .register(PersistentVolumeClaimVolumeSource.class)
+            .register(SecretVolumeSource.class)
+            .register(EmptyDirVolumeSource.class)
+            .register(Quantity.class)
+            .register(Capabilities.class)
+            .register(ConfigMapVolumeSource.class)
+            .register(KeyToPath.class)
+            .register(HostPathVolumeSource.class)
+            .register(LinkedHashMap.class)
             .register(Collection.class)
             .build();
 
diff --git a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/DistributedK8sServiceStore.java b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/DistributedK8sServiceStore.java
index 116f535..cda25e2 100644
--- a/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/DistributedK8sServiceStore.java
+++ b/apps/k8s-networking/app/src/main/java/org/onosproject/k8snetworking/impl/DistributedK8sServiceStore.java
@@ -16,10 +16,16 @@
 package org.onosproject.k8snetworking.impl;
 
 import com.google.common.collect.ImmutableSet;
+import io.fabric8.kubernetes.api.model.ClientIPConfig;
+import io.fabric8.kubernetes.api.model.IntOrString;
+import io.fabric8.kubernetes.api.model.LoadBalancerIngress;
+import io.fabric8.kubernetes.api.model.LoadBalancerStatus;
 import io.fabric8.kubernetes.api.model.ObjectMeta;
 import io.fabric8.kubernetes.api.model.Service;
+import io.fabric8.kubernetes.api.model.ServicePort;
 import io.fabric8.kubernetes.api.model.ServiceSpec;
 import io.fabric8.kubernetes.api.model.ServiceStatus;
+import io.fabric8.kubernetes.api.model.SessionAffinityConfig;
 import org.onlab.util.KryoNamespace;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
@@ -42,6 +48,7 @@
 import org.slf4j.Logger;
 
 import java.util.Collection;
+import java.util.LinkedHashMap;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
 
@@ -74,6 +81,13 @@
             .register(ObjectMeta.class)
             .register(ServiceSpec.class)
             .register(ServiceStatus.class)
+            .register(LoadBalancerStatus.class)
+            .register(LoadBalancerIngress.class)
+            .register(ServicePort.class)
+            .register(IntOrString.class)
+            .register(SessionAffinityConfig.class)
+            .register(ClientIPConfig.class)
+            .register(LinkedHashMap.class)
             .register(Collection.class)
             .build();