@Override
    public ObjectNode encode(K8sNode node, CodecContext context) {
        checkNotNull(node, "Kubernetes node cannot be null");

        ObjectNode result = context.mapper().createObjectNode()
                .put(CLUSTER_NAME, node.clusterName())
                .put(HOSTNAME, node.hostname())
                .put(TYPE, node.type().name())
                .put(MODE, node.mode().name())
                .put(SEGMENT_ID, node.segmentId())
                .put(STATE, node.state().name())
                .put(MANAGEMENT_IP, node.managementIp().toString())
                .put(NODE_IP, node.nodeIp().toString());

        if (node.intgBridge() != null) {
            result.put(INTEGRATION_BRIDGE, node.intgBridge().toString());
        }

        if (node.extBridge() != null) {
            result.put(EXTERNAL_BRIDGE, node.extBridge().toString());
        }

        if (node.localBridge() != null) {
            result.put(LOCAL_BRIDGE, node.localBridge().toString());
        }

        if (node.tunBridge() != null) {
            result.put(TUNNEL_BRIDGE, node.tunBridge().toString());
        }

        if (node.dataIp() != null) {
            result.put(DATA_IP, node.dataIp().toString());
        }

        if (node.nodeMac() != null) {
            result.put(NODE_MAC, node.nodeMac().toString());
        }

        if (node.extIntf() != null) {
            result.put(EXTERNAL_INTF, node.extIntf());
        }

        if (node.extBridgeIp() != null) {
            result.put(EXTERNAL_BRIDGE_IP, node.extBridgeIp().toString());
        }

        if (node.extGatewayIp() != null) {
            result.put(EXTERNAL_GATEWAY_IP, node.extGatewayIp().toString());
        }

        if (node.extGatewayMac() != null) {
            result.put(EXTERNAL_GATEWAY_MAC, node.extGatewayMac().toString());
        }

        return result;
    }
@Test
    public void testK8sMinionNodeEncode() {
        K8sNode node = DefaultK8sNode.builder()
                .clusterName("kubernetes")
                .hostname("minion")
                .type(K8sNode.Type.MINION)
                .segmentId(100)
                .state(K8sNodeState.INIT)
                .managementIp(IpAddress.valueOf("10.10.10.1"))
                .dataIp(IpAddress.valueOf("20.20.20.2"))
                .nodeInfo(new K8sNodeInfo(IpAddress.valueOf("30.30.30.3"), null))
                .intgBridge(DeviceId.deviceId("kbr-int"))
                .extIntf("eth1")
                .extBridgeIp(IpAddress.valueOf("10.10.10.5"))
                .extGatewayIp(IpAddress.valueOf("10.10.10.1"))
                .extGatewayMac(MacAddress.valueOf("FF:FF:FF:FF:FF:FF"))
                .build();

        ObjectNode nodeJson = k8sNodeCodec.encode(node, context);
        assertThat(nodeJson, matchesK8sNode(node));
    }