@Override
    public ObjectNode encode(K8sHost entity, CodecContext context) {
        checkNotNull(entity, "Kubernetes host cannot be null");

        ObjectNode result = context.mapper().createObjectNode()
                .put(HOST_IP, entity.hostIp().toString())
                .put(STATE, entity.state().name());

        ArrayNode nodes = context.mapper().createArrayNode();
        entity.nodeNames().forEach(nodes::add);
        result.set(NODE_NAMES, nodes);

        return result;
    }
@Test
    public void testK8sHostEncode() {
        K8sHost host = DefaultK8sHost.builder()
                .hostIp(IpAddress.valueOf("192.168.200.10"))
                .state(INIT)
                .nodeNames(ImmutableSet.of("1", "2"))
                .build();

        ObjectNode hostJson = k8sHostCodec.encode(host, context);
        assertThat(hostJson, matchesK8sHost(host));
    }