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);
}
}
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);
}
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();
}
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();
}
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();
}
Aggregations