Search in sources :

Example 51 with Configuration

use of io.fabric8.maven.core.model.Configuration in project fabric8 by jboss-fuse.

the class AbstractManagedContainer method stop.

@Override
public final synchronized void stop() throws LifecycleException {
    assertNotDestroyed();
    try {
        if (state == State.STARTED) {
            doStop(configuration);
            state = State.STOPPED;
        }
    } catch (Exception ex) {
        throw new LifecycleException("Cannot stop container", ex);
    }
}
Also used : LifecycleException(io.fabric8.runtime.container.LifecycleException) LifecycleException(io.fabric8.runtime.container.LifecycleException) IOException(java.io.IOException)

Example 52 with Configuration

use of io.fabric8.maven.core.model.Configuration in project flink by apache.

the class HadoopConfMountDecorator method buildAccompanyingKubernetesResources.

@Override
public List<HasMetadata> buildAccompanyingKubernetesResources() throws IOException {
    if (kubernetesParameters.getExistingHadoopConfigurationConfigMap().isPresent()) {
        return Collections.emptyList();
    }
    final Optional<String> localHadoopConfigurationDirectory = kubernetesParameters.getLocalHadoopConfigurationDirectory();
    if (!localHadoopConfigurationDirectory.isPresent()) {
        return Collections.emptyList();
    }
    final List<File> hadoopConfigurationFileItems = getHadoopConfigurationFileItems(localHadoopConfigurationDirectory.get());
    if (hadoopConfigurationFileItems.isEmpty()) {
        LOG.warn("Found 0 files in directory {}, skip to create the Hadoop Configuration ConfigMap.", localHadoopConfigurationDirectory.get());
        return Collections.emptyList();
    }
    final Map<String, String> data = new HashMap<>();
    for (File file : hadoopConfigurationFileItems) {
        data.put(file.getName(), FileUtils.readFileUtf8(file));
    }
    final ConfigMap hadoopConfigMap = new ConfigMapBuilder().withApiVersion(Constants.API_VERSION).withNewMetadata().withName(getHadoopConfConfigMapName(kubernetesParameters.getClusterId())).withLabels(kubernetesParameters.getCommonLabels()).endMetadata().addToData(data).build();
    return Collections.singletonList(hadoopConfigMap);
}
Also used : ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) HashMap(java.util.HashMap) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) File(java.io.File)

Example 53 with Configuration

use of io.fabric8.maven.core.model.Configuration in project flink by apache.

the class HadoopConfMountDecorator method decorateFlinkPod.

@Override
public FlinkPod decorateFlinkPod(FlinkPod flinkPod) {
    Volume hadoopConfVolume;
    final Optional<String> existingConfigMap = kubernetesParameters.getExistingHadoopConfigurationConfigMap();
    if (existingConfigMap.isPresent()) {
        hadoopConfVolume = new VolumeBuilder().withName(Constants.HADOOP_CONF_VOLUME).withNewConfigMap().withName(existingConfigMap.get()).endConfigMap().build();
    } else {
        final Optional<String> localHadoopConfigurationDirectory = kubernetesParameters.getLocalHadoopConfigurationDirectory();
        if (!localHadoopConfigurationDirectory.isPresent()) {
            return flinkPod;
        }
        final List<File> hadoopConfigurationFileItems = getHadoopConfigurationFileItems(localHadoopConfigurationDirectory.get());
        if (hadoopConfigurationFileItems.isEmpty()) {
            LOG.warn("Found 0 files in directory {}, skip to mount the Hadoop Configuration ConfigMap.", localHadoopConfigurationDirectory.get());
            return flinkPod;
        }
        final List<KeyToPath> keyToPaths = hadoopConfigurationFileItems.stream().map(file -> new KeyToPathBuilder().withKey(file.getName()).withPath(file.getName()).build()).collect(Collectors.toList());
        hadoopConfVolume = new VolumeBuilder().withName(Constants.HADOOP_CONF_VOLUME).withNewConfigMap().withName(getHadoopConfConfigMapName(kubernetesParameters.getClusterId())).withItems(keyToPaths).endConfigMap().build();
    }
    final Pod podWithHadoopConf = new PodBuilder(flinkPod.getPodWithoutMainContainer()).editOrNewSpec().addNewVolumeLike(hadoopConfVolume).endVolume().endSpec().build();
    final Container containerWithHadoopConf = new ContainerBuilder(flinkPod.getMainContainer()).addNewVolumeMount().withName(Constants.HADOOP_CONF_VOLUME).withMountPath(Constants.HADOOP_CONF_DIR_IN_POD).endVolumeMount().addNewEnv().withName(Constants.ENV_HADOOP_CONF_DIR).withValue(Constants.HADOOP_CONF_DIR_IN_POD).endEnv().build();
    return new FlinkPod.Builder(flinkPod).withPod(podWithHadoopConf).withMainContainer(containerWithHadoopConf).build();
}
Also used : Arrays(java.util.Arrays) Container(io.fabric8.kubernetes.api.model.Container) FileUtils(org.apache.flink.util.FileUtils) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AbstractKubernetesParameters(org.apache.flink.kubernetes.kubeclient.parameters.AbstractKubernetesParameters) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) Map(java.util.Map) KeyToPathBuilder(io.fabric8.kubernetes.api.model.KeyToPathBuilder) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) Preconditions.checkNotNull(org.apache.flink.util.Preconditions.checkNotNull) Volume(io.fabric8.kubernetes.api.model.Volume) KeyToPath(io.fabric8.kubernetes.api.model.KeyToPath) Logger(org.slf4j.Logger) Pod(io.fabric8.kubernetes.api.model.Pod) IOException(java.io.IOException) VolumeBuilder(io.fabric8.kubernetes.api.model.VolumeBuilder) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) Collectors(java.util.stream.Collectors) File(java.io.File) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) List(java.util.List) Optional(java.util.Optional) Constants(org.apache.flink.kubernetes.utils.Constants) Collections(java.util.Collections) Pod(io.fabric8.kubernetes.api.model.Pod) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) VolumeBuilder(io.fabric8.kubernetes.api.model.VolumeBuilder) KeyToPath(io.fabric8.kubernetes.api.model.KeyToPath) Container(io.fabric8.kubernetes.api.model.Container) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) Volume(io.fabric8.kubernetes.api.model.Volume) KeyToPathBuilder(io.fabric8.kubernetes.api.model.KeyToPathBuilder) File(java.io.File)

Example 54 with Configuration

use of io.fabric8.maven.core.model.Configuration in project alluxio by Alluxio.

the class ManagerProcessContext method updateConfigurationFor.

/**
 * Updates the configuration for a set of Alluxio nodes.
 *
 * @param type the type of node to write the configuration to
 * @param conf the configuration to write
 * @return a set of the nodes which had their configuration updated
 */
public Set<HubNodeAddress> updateConfigurationFor(AlluxioNodeType type, AlluxioConfigurationSet conf) {
    Set<HubNodeAddress> nodes = mHubCluster.nodesFromAlluxio(mAlluxioCluster, type);
    Map<HubNodeAddress, AgentWriteConfigurationSetResponse> confSet = mHubCluster.exec(nodes, mConf, (client) -> client.writeConfigurationSet(AgentWriteConfigurationSetRequest.newBuilder().setConfSet(conf).build()), mSvc);
    // update the file system client to reflect the new conf
    if (type.equals(AlluxioNodeType.MASTER)) {
        updateFileSystemClient(conf);
    }
    // if running in K8s, update configmap
    if (mK8sConfig != null && (type.equals(AlluxioNodeType.MASTER) || type.equals(AlluxioNodeType.ALL))) {
        // We maintain a single configMap for all pods, so the config set is symmetric
        LOG.info("Persist configuration to K8s configMap {}", mK8sConfigMapName);
        try (KubernetesClient client = new DefaultKubernetesClient(mK8sConfig)) {
            String namespace = client.getNamespace();
            if (namespace == null) {
                LOG.info("Use K8s default namespace ");
                namespace = "default";
            }
            // Update configMap
            ConfigMap existingConfig = client.configMaps().inNamespace(namespace).withName(mK8sConfigMapName).get();
            if (existingConfig != null) {
                ConfigMapBuilder builder = new ConfigMapBuilder().withMetadata(existingConfig.getMetadata()).withData(existingConfig.getData());
                // Replace log4 properties
                builder.addToData(K8S_CONFIG_MAP_ENV_LOG4J, conf.getLog4JProperties());
                // Replace site properties
                builder.addToData(K8S_CONFIG_MAP_ENV_SITE, conf.getSiteProperties());
                // Replace environment variables
                for (Map.Entry<String, String> entry : HubUtil.getEnvVarsFromFile(conf.getAlluxioEnv(), LOG).entrySet()) {
                    builder.addToData(entry.getKey(), entry.getValue());
                }
                // Write config map
                client.configMaps().inNamespace(namespace).withName(mK8sConfigMapName).replace(builder.build());
                LOG.info("Updated K8s configMap {}", mK8sConfigMapName);
            }
        } catch (Exception e) {
            LOG.error("Unable to persist configuration to K8s configMap {}", mK8sConfigMapName, e);
        }
    }
    return confSet.keySet();
}
Also used : HubNodeAddress(alluxio.hub.proto.HubNodeAddress) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) AgentWriteConfigurationSetResponse(alluxio.hub.proto.AgentWriteConfigurationSetResponse) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) ByteString(com.google.protobuf.ByteString) Map(java.util.Map) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) AlluxioException(alluxio.exception.AlluxioException) IOException(java.io.IOException) InvalidPathException(alluxio.exception.InvalidPathException) FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException)

Example 55 with Configuration

use of io.fabric8.maven.core.model.Configuration in project kie-wb-common by kiegroup.

the class OpenShiftAccessInterfaceImpl method buildOpenShiftConfig.

// package-protected for junit testing purposes (from inside the package)
static OpenShiftConfig buildOpenShiftConfig(OpenShiftProviderConfig config) {
    OpenShiftConfigBuilder builder = new OpenShiftConfigBuilder(OpenShiftConfig.wrap(Config.autoConfigure(null)));
    /*
         * Kubernetes configuration properties; see io.fabric8.kubernetes.client.Config
         */
    String allProxy = trimToNull(config.getAllProxy());
    if (allProxy != null) {
        builder = builder.withHttpProxy(allProxy);
        builder = builder.withHttpsProxy(allProxy);
    }
    String httpProxy = trimToNull(config.getHttpProxy());
    if (httpProxy != null) {
        // NOTE: overrides allProxy above
        builder = builder.withHttpProxy(httpProxy);
    }
    String httpsProxy = trimToNull(config.getHttpsProxy());
    if (httpsProxy != null) {
        // NOTE: overrides allProxy above
        builder = builder.withHttpsProxy(httpsProxy);
    }
    String kubernetesApiVersion = trimToNull(config.getKubernetesApiVersion());
    if (kubernetesApiVersion != null) {
        builder = builder.withApiVersion(kubernetesApiVersion);
    }
    String kubernetesAuthBasicPassword = trimToNull(config.getKubernetesAuthBasicPassword());
    if (kubernetesAuthBasicPassword != null) {
        builder = builder.withPassword(kubernetesAuthBasicPassword);
    }
    String kubernetesAuthBasicUsername = trimToNull(config.getKubernetesAuthBasicUsername());
    if (kubernetesAuthBasicUsername != null) {
        builder = builder.withUsername(kubernetesAuthBasicUsername);
    }
    String kubernetesAuthToken = trimToNull(config.getKubernetesAuthToken());
    if (kubernetesAuthToken != null) {
        builder = builder.withOauthToken(kubernetesAuthToken);
    }
    String kubernetesCertsCaData = trimToNull(config.getKubernetesCertsCaData());
    if (kubernetesCertsCaData != null) {
        builder = builder.withCaCertData(kubernetesCertsCaData);
    }
    String kubernetesCertsCaFile = trimToNull(config.getKubernetesCertsCaFile());
    if (kubernetesCertsCaFile != null) {
        builder = builder.withCaCertFile(kubernetesCertsCaFile);
    }
    String kubernetesCertsClientData = trimToNull(config.getKubernetesCertsClientData());
    if (kubernetesCertsClientData != null) {
        builder = builder.withClientCertData(kubernetesCertsClientData);
    }
    String kubernetesCertsClientFile = trimToNull(config.getKubernetesCertsClientFile());
    if (kubernetesCertsClientFile != null) {
        builder = builder.withClientCertFile(kubernetesCertsClientFile);
    }
    String kubernetesCertsClientKeyAlgo = trimToNull(config.getKubernetesCertsClientKeyAlgo());
    if (kubernetesCertsClientKeyAlgo != null) {
        builder = builder.withClientKeyAlgo(kubernetesCertsClientKeyAlgo);
    }
    String kubernetesCertsClientKeyData = trimToNull(config.getKubernetesCertsClientKeyData());
    if (kubernetesCertsClientKeyData != null) {
        builder = builder.withClientKeyData(kubernetesCertsClientKeyData);
    }
    String kubernetesCertsClientKeyFile = trimToNull(config.getKubernetesCertsClientKeyFile());
    if (kubernetesCertsClientKeyFile != null) {
        builder = builder.withClientKeyFile(kubernetesCertsClientKeyFile);
    }
    String kubernetesCertsClientKeyPassphrase = trimToNull(config.getKubernetesCertsClientKeyPassphrase());
    if (kubernetesCertsClientKeyPassphrase != null) {
        builder = builder.withClientKeyPassphrase(kubernetesCertsClientKeyPassphrase);
    }
    String kubernetesConnectionTimeout = trimToNull(config.getKubernetesConnectionTimeout());
    if (kubernetesConnectionTimeout != null) {
        builder = builder.withConnectionTimeout(Integer.parseInt(kubernetesConnectionTimeout));
    }
    String kubernetesKeystoreFile = trimToNull(config.getKubernetesKeystoreFile());
    if (kubernetesKeystoreFile != null) {
        builder = builder.withKeyStoreFile(kubernetesKeystoreFile);
    }
    String kubernetesKeystorePassphrase = trimToNull(config.getKubernetesKeystorePassphrase());
    if (kubernetesKeystorePassphrase != null) {
        builder = builder.withKeyStorePassphrase(kubernetesKeystorePassphrase);
    }
    String kubernetesLoggingInterval = trimToNull(config.getKubernetesLoggingInterval());
    if (kubernetesLoggingInterval != null) {
        builder = builder.withLoggingInterval(Integer.parseInt(kubernetesLoggingInterval));
    }
    String kubernetesMain = trimToNull(config.getKubernetesMain());
    if (kubernetesMain != null) {
        builder = builder.withMasterUrl(kubernetesMain);
    }
    String kubernetesNamespace = trimToNull(config.getKubernetesNamespace());
    if (kubernetesNamespace != null) {
        builder = builder.withNamespace(kubernetesNamespace);
    }
    String kubernetesRequestTimeout = trimToNull(config.getKubernetesRequestTimeout());
    if (kubernetesRequestTimeout != null) {
        builder = builder.withRequestTimeout(Integer.parseInt(kubernetesRequestTimeout));
    }
    String kubernetesRollingTimeout = trimToNull(config.getKubernetesRollingTimeout());
    if (kubernetesRollingTimeout != null) {
        builder = builder.withRollingTimeout(Long.parseLong(kubernetesRollingTimeout));
    }
    String kubernetesScaleTimeout = trimToNull(config.getKubernetesScaleTimeout());
    if (kubernetesScaleTimeout != null) {
        builder = builder.withScaleTimeout(Long.parseLong(kubernetesScaleTimeout));
    }
    String kubernetesTlsVersions = trimToNull(config.getKubernetesTlsVersions());
    if (kubernetesTlsVersions != null) {
        String[] split = kubernetesTlsVersions.split(",");
        TlsVersion[] vers = new TlsVersion[split.length];
        for (int i = 0; i < split.length; i++) {
            vers[i] = TlsVersion.forJavaName(split[i]);
        }
        builder.withTlsVersions(vers);
    }
    String kubernetesTrustCertificates = trimToNull(config.getKubernetesTrustCertificates());
    if (kubernetesTrustCertificates != null) {
        builder = builder.withTrustCerts(Boolean.parseBoolean(kubernetesTrustCertificates));
    }
    String kubernetesTruststoreFile = trimToNull(config.getKubernetesTruststoreFile());
    if (kubernetesTruststoreFile != null) {
        builder = builder.withTrustStoreFile(kubernetesTruststoreFile);
    }
    String kubernetesTruststorePassphrase = trimToNull(config.getKubernetesTruststorePassphrase());
    if (kubernetesTruststorePassphrase != null) {
        builder = builder.withTrustStorePassphrase(kubernetesTruststorePassphrase);
    }
    String kubernetesUserAgent = trimToNull(config.getKubernetesUserAgent());
    if (kubernetesUserAgent != null) {
        builder = builder.withUserAgent(kubernetesUserAgent);
    }
    String kubernetesWatchReconnectInterval = trimToNull(config.getKubernetesWatchReconnectInterval());
    if (kubernetesWatchReconnectInterval != null) {
        builder = builder.withWatchReconnectInterval(Integer.parseInt(kubernetesWatchReconnectInterval));
    }
    String kubernetesWatchReconnectLimit = trimToNull(config.getKubernetesWatchReconnectLimit());
    if (kubernetesWatchReconnectLimit != null) {
        builder = builder.withWatchReconnectLimit(Integer.parseInt(kubernetesWatchReconnectLimit));
    }
    String kubernetesWebsocketPingInterval = trimToNull(config.getKubernetesWebsocketPingInterval());
    if (kubernetesWebsocketPingInterval != null) {
        builder = builder.withWebsocketPingInterval(Long.parseLong(kubernetesWebsocketPingInterval));
    }
    String kubernetesWebsocketTimeout = trimToNull(config.getKubernetesWebsocketTimeout());
    if (kubernetesWebsocketTimeout != null) {
        builder = builder.withWebsocketTimeout(Long.parseLong(kubernetesWebsocketTimeout));
    }
    String noProxy = trimToNull(config.getNoProxy());
    if (noProxy != null) {
        builder = builder.withNoProxy(noProxy.split(","));
    }
    String proxyPassword = trimToNull(config.getProxyPassword());
    if (proxyPassword != null) {
        builder = builder.withProxyPassword(proxyPassword);
    }
    String proxyUsername = trimToNull(config.getProxyUsername());
    if (proxyUsername != null) {
        builder = builder.withProxyUsername(proxyUsername);
    }
    /*
         * OpenShift configuration properties; see io.fabric8.openshift.client.OpenShiftConfig
         */
    String kubernetesOapiVersion = trimToNull(config.getKubernetesOapiVersion());
    if (kubernetesOapiVersion != null) {
        builder = builder.withOapiVersion(kubernetesOapiVersion);
    }
    String openshiftBuildTimeout = trimToNull(config.getOpenshiftBuildTimeout());
    if (openshiftBuildTimeout != null) {
        builder = builder.withBuildTimeout(Long.parseLong(openshiftBuildTimeout));
    }
    String openshiftUrl = trimToNull(config.getOpenshiftUrl());
    if (openshiftUrl != null) {
        // The OPENSHIFT_URL environment variable may be set to the root url (i.e. without the '/oapi/version' path) in some configurations
        if (isRootUrl(openshiftUrl)) {
            openshiftUrl = URLUtils.join(openshiftUrl, "oapi", builder.getOapiVersion());
        }
        builder = builder.withOpenShiftUrl(openshiftUrl);
    } else {
        builder.withOpenShiftUrl(URLUtils.join(builder.getMasterUrl(), "oapi", builder.getOapiVersion()));
    }
    return builder.build();
}
Also used : TlsVersion(okhttp3.TlsVersion) OpenShiftConfigBuilder(io.fabric8.openshift.client.OpenShiftConfigBuilder)

Aggregations

ParallelTest (io.strimzi.test.annotations.ParallelTest)142 Kafka (io.strimzi.api.kafka.model.Kafka)138 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)132 HashMap (java.util.HashMap)97 IOException (java.io.IOException)86 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)83 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)80 Map (java.util.Map)79 StatefulSet (io.fabric8.kubernetes.api.model.apps.StatefulSet)76 ArrayList (java.util.ArrayList)76 List (java.util.List)70 TopologySpreadConstraint (io.fabric8.kubernetes.api.model.TopologySpreadConstraint)66 GenericKafkaListenerBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder)66 Matchers.containsString (org.hamcrest.Matchers.containsString)58 Service (io.fabric8.kubernetes.api.model.Service)55 Collectors (java.util.stream.Collectors)55 Container (io.fabric8.kubernetes.api.model.Container)54 PersistentVolumeClaim (io.fabric8.kubernetes.api.model.PersistentVolumeClaim)50 Quantity (io.fabric8.kubernetes.api.model.Quantity)48 File (java.io.File)47