Search in sources :

Example 1 with V1SecretVolumeSourceBuilder

use of io.kubernetes.client.openapi.models.V1SecretVolumeSourceBuilder in project heron by twitter.

the class V1Controller method mountSecretsAsVolumes.

/**
 * Adds <code>Volume Mounts</code> for <code>Secrets</code> to a pod.
 * @param podSpec <code>Pod Spec</code> to add secrets to.
 */
private void mountSecretsAsVolumes(V1PodSpec podSpec) {
    final Config config = getConfiguration();
    final Map<String, String> secrets = KubernetesContext.getPodSecretsToMount(config);
    for (Map.Entry<String, String> secret : secrets.entrySet()) {
        final V1VolumeMount mount = new V1VolumeMount().name(secret.getKey()).mountPath(secret.getValue());
        final V1Volume secretVolume = new V1Volume().name(secret.getKey()).secret(new V1SecretVolumeSourceBuilder().withSecretName(secret.getKey()).build());
        podSpec.addVolumesItem(secretVolume);
        for (V1Container container : podSpec.getContainers()) {
            container.addVolumeMountsItem(mount);
        }
    }
}
Also used : V1Container(io.kubernetes.client.openapi.models.V1Container) V1SecretVolumeSourceBuilder(io.kubernetes.client.openapi.models.V1SecretVolumeSourceBuilder) V1Volume(io.kubernetes.client.openapi.models.V1Volume) Config(org.apache.heron.spi.common.Config) Map(java.util.Map) HashMap(java.util.HashMap) V1ConfigMap(io.kubernetes.client.openapi.models.V1ConfigMap) V1VolumeMount(io.kubernetes.client.openapi.models.V1VolumeMount)

Example 2 with V1SecretVolumeSourceBuilder

use of io.kubernetes.client.openapi.models.V1SecretVolumeSourceBuilder in project pravega by pravega.

the class K8SequentialExecutor method getTestPod.

private V1Pod getTestPod(String className, String methodName, String podName) {
    log.info("Running test pod with security enabled :{}, transport enabled: {}", Utils.AUTH_ENABLED, Utils.TLS_AND_AUTH_ENABLED);
    V1Pod pod = new V1PodBuilder().withNewMetadata().withName(podName).withNamespace(NAMESPACE).withLabels(ImmutableMap.of("POD_NAME", podName, "app", APP)).endMetadata().withNewSpec().withServiceAccountName(SERVICE_ACCOUNT).withAutomountServiceAccountToken(true).withVolumes(new V1VolumeBuilder().withName("task-pv-storage").withPersistentVolumeClaim(new V1PersistentVolumeClaimVolumeSourceBuilder().withClaimName("task-pv-claim").build()).build()).addNewContainer().withName(// container name is same as that of the pod.
    podName).withImage(TEST_POD_IMAGE).withImagePullPolicy("IfNotPresent").withCommand("/bin/sh").withArgs("-c", "java" + getArgs() + " -cp /data/test-collection.jar io.pravega.test.system.SingleJUnitTestRunner " + className + "#" + methodName + /*+ " > server.log 2>&1 */
    "; exit $?").withVolumeMounts(new V1VolumeMountBuilder().withMountPath("/data").withName("task-pv-storage").build()).endContainer().withRestartPolicy("Never").endSpec().build();
    if (Utils.TLS_AND_AUTH_ENABLED) {
        pod = new V1PodBuilder(pod).editSpec().withVolumes(new V1VolumeBuilder().withName("tls-certs").withSecret(new V1SecretVolumeSourceBuilder().withSecretName(Utils.TLS_SECRET_NAME).build()).build()).editContainer(0).withVolumeMounts(new V1VolumeMountBuilder().withMountPath(Utils.TLS_MOUNT_PATH).withName("tls-secret").build()).endContainer().endSpec().build();
    }
    return pod;
}
Also used : V1VolumeBuilder(io.kubernetes.client.openapi.models.V1VolumeBuilder) V1SecretVolumeSourceBuilder(io.kubernetes.client.openapi.models.V1SecretVolumeSourceBuilder) V1PodBuilder(io.kubernetes.client.openapi.models.V1PodBuilder) V1Pod(io.kubernetes.client.openapi.models.V1Pod) V1VolumeMountBuilder(io.kubernetes.client.openapi.models.V1VolumeMountBuilder) V1PersistentVolumeClaimVolumeSourceBuilder(io.kubernetes.client.openapi.models.V1PersistentVolumeClaimVolumeSourceBuilder)

Aggregations

V1SecretVolumeSourceBuilder (io.kubernetes.client.openapi.models.V1SecretVolumeSourceBuilder)2 V1ConfigMap (io.kubernetes.client.openapi.models.V1ConfigMap)1 V1Container (io.kubernetes.client.openapi.models.V1Container)1 V1PersistentVolumeClaimVolumeSourceBuilder (io.kubernetes.client.openapi.models.V1PersistentVolumeClaimVolumeSourceBuilder)1 V1Pod (io.kubernetes.client.openapi.models.V1Pod)1 V1PodBuilder (io.kubernetes.client.openapi.models.V1PodBuilder)1 V1Volume (io.kubernetes.client.openapi.models.V1Volume)1 V1VolumeBuilder (io.kubernetes.client.openapi.models.V1VolumeBuilder)1 V1VolumeMount (io.kubernetes.client.openapi.models.V1VolumeMount)1 V1VolumeMountBuilder (io.kubernetes.client.openapi.models.V1VolumeMountBuilder)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Config (org.apache.heron.spi.common.Config)1