Search in sources :

Example 1 with Traced

use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.

the class ImagePullSecretProvisioner method provision.

@Override
@Traced
public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity) throws InfrastructureException {
    TracingTags.WORKSPACE_ID.set(identity::getWorkspaceId);
    DockerAuthConfigs credentials = credentialsProvider.getCredentials();
    if (credentials == null) {
        return;
    }
    Map<String, DockerAuthConfig> authConfigs = credentials.getConfigs();
    if (authConfigs == null || authConfigs.isEmpty()) {
        return;
    }
    String encodedConfig = Base64.getEncoder().encodeToString(generateDockerCfg(authConfigs).getBytes());
    Secret secret = new SecretBuilder().addToData(".dockercfg", encodedConfig).withType("kubernetes.io/dockercfg").withNewMetadata().withName(identity.getWorkspaceId() + SECRET_NAME_SUFFIX).endMetadata().build();
    k8sEnv.getSecrets().put(secret.getMetadata().getName(), secret);
    k8sEnv.getPodsData().values().forEach(p -> addImagePullSecret(secret.getMetadata().getName(), p.getSpec()));
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) SecretBuilder(io.fabric8.kubernetes.api.model.SecretBuilder) DockerAuthConfig(org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.DockerAuthConfig) DockerAuthConfigs(org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.DockerAuthConfigs) Traced(org.eclipse.che.commons.annotation.Traced)

Example 2 with Traced

use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.

the class RestartPolicyRewriter method provision.

@Override
@Traced
public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity) throws InfrastructureException {
    TracingTags.WORKSPACE_ID.set(identity::getWorkspaceId);
    for (PodData podConfig : k8sEnv.getPodsData().values()) {
        final String podName = podConfig.getMetadata().getName();
        final PodSpec podSpec = podConfig.getSpec();
        rewriteRestartPolicy(podSpec, podName, k8sEnv);
    }
}
Also used : PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData) PodSpec(io.fabric8.kubernetes.api.model.PodSpec) Traced(org.eclipse.che.commons.annotation.Traced)

Example 3 with Traced

use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.

the class ServiceAccountProvisioner method provision.

@Override
@Traced
public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity) throws InfrastructureException {
    TracingTags.WORKSPACE_ID.set(identity::getWorkspaceId);
    if (!isNullOrEmpty(serviceAccount)) {
        for (PodData pod : k8sEnv.getPodsData().values()) {
            pod.getSpec().setServiceAccountName(serviceAccount);
            pod.getSpec().setAutomountServiceAccountToken(true);
        }
    }
}
Also used : PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData) Traced(org.eclipse.che.commons.annotation.Traced)

Example 4 with Traced

use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.

the class RouteTlsProvisioner method provision.

@Override
@Traced
public void provision(OpenShiftEnvironment osEnv, RuntimeIdentity identity) {
    TracingTags.WORKSPACE_ID.set(identity::getWorkspaceId);
    if (!isTlsEnabled) {
        return;
    }
    final Set<Route> routes = new HashSet<>(osEnv.getRoutes().values());
    for (Route route : routes) {
        useSecureProtocolForServers(route);
        enableTls(route);
    }
}
Also used : Route(io.fabric8.openshift.api.model.Route) HashSet(java.util.HashSet) Traced(org.eclipse.che.commons.annotation.Traced)

Example 5 with Traced

use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.

the class OpenShiftInternalRuntime method startMachines.

@Override
@Traced
protected void startMachines() throws InfrastructureException {
    OpenShiftEnvironment osEnv = getContext().getEnvironment();
    String workspaceId = getContext().getIdentity().getWorkspaceId();
    createSecrets(osEnv, workspaceId);
    List<ConfigMap> createdConfigMaps = createConfigMaps(osEnv, getContext().getIdentity());
    List<Service> createdServices = createServices(osEnv, workspaceId);
    List<Route> createdRoutes = createRoutes(osEnv, workspaceId);
    listenEvents();
    doStartMachine(serverResolverFactory.create(createdServices, createdRoutes, createdConfigMaps));
}
Also used : OpenShiftEnvironment(org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Service(io.fabric8.kubernetes.api.model.Service) Route(io.fabric8.openshift.api.model.Route) Traced(org.eclipse.che.commons.annotation.Traced)

Aggregations

Traced (org.eclipse.che.commons.annotation.Traced)54 PodData (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData)14 InfrastructureException (org.eclipse.che.api.workspace.server.spi.InfrastructureException)12 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)10 ArrayList (java.util.ArrayList)10 Service (io.fabric8.kubernetes.api.model.Service)8 Map (java.util.Map)8 RuntimeIdentity (org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity)8 InternalMachineConfig (org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig)8 KubernetesEnvironment (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment)8 Beta (com.google.common.annotations.Beta)6 Container (io.fabric8.kubernetes.api.model.Container)6 Route (io.fabric8.openshift.api.model.Route)6 ValidationException (org.eclipse.che.api.core.ValidationException)6 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)6 InternalInfrastructureException (org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException)5 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)4 PersistentVolumeClaim (io.fabric8.kubernetes.api.model.PersistentVolumeClaim)4 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)4 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)4