private boolean doStart(boolean initial) {
        closeResources();
        updateLock.lock();
        try {
            // Change the updateId to ensure that outdated watchers do not update endpoints.
            updateId++;
            nodeToIp.clear();
            podToNode.clear();
        } finally {
            updateLock.unlock();
        }

        final Service service;
        final NodeList nodes;
        final PodList pods;
        try {
            logger.info("[{}/{}] Fetching the service...", namespace, serviceName);
            if (namespace == null) {
                service = client.services().withName(serviceName).get();
            } else {
                service = client.services().inNamespace(namespace).withName(serviceName).get();
            }
            if (service == null) {
                logger.warn("[{}/{}] Service not found.", namespace, serviceName);
                throw new IllegalStateException(
                        String.format("[%s/%s] Service not found.", namespace, serviceName));
            }
            if (!updateService(service)) {
                throw new IllegalStateException(
                        String.format("[%s/%s] NodePort not found.", namespace, serviceName));
            }

            logger.info("[{}/{}] Fetching the nodes ...", namespace, serviceName);
            nodes = client.nodes().list();
            for (Node node : nodes.getItems()) {
                updateNode(Action.ADDED, node);
            }

            final Map<String, String> selector = service.getSpec().getSelector();
            logger.info("[{}/{}] Fetching the pods with the selector: {}", namespace, serviceName, selector);
            if (namespace == null) {
                pods = client.pods().withLabels(selector).list();
            } else {
                pods = client.pods().inNamespace(namespace).withLabels(selector).list();
            }
            for (Pod pod : pods.getItems()) {
                updatePod(Action.ADDED, pod);
            }
            // Initialize the endpoints.
            maybeUpdateEndpoints();

            watchService(service.getMetadata().getResourceVersion());
            watchNode(updateId, nodes.getMetadata().getResourceVersion());
            watchPod(updateId, pods.getMetadata().getResourceVersion());
        } catch (Exception e) {
            logger.warn("[{}/{}] Failed to start {}. (initial: {})", namespace, serviceName, this, initial, e);
            if (initial) {
                failInit(e);
                // Do not retry if the initialization fails since the error is likely to be persistent.
                return false;
            } else {
                scheduleRestartWithBackoff(++numStartFailures);
                return true;
            }
        }

        if (closed) {
            closeResources();
            return false;
        }
        if (maxWatchAgeMillis > 0) {
            scheduleRestart(maxWatchAgeMillis);
        }
        numStartFailures = 0;
        return true;
    }
Returns a newly created {@link KubernetesEndpointGroupBuilder} with the specified Kubernetes
{@link Config}.
kubernetes/src/main/java/com/linecorp/armeria/client/kubernetes/endpoints/KubernetesEndpointGroup.java