Search in sources :

Example 1 with V1SecretKeySelector

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

the class V1Controller method setSecretKeyRefs.

/**
 * Adds <code>Secret Key</code> references to a <code>container</code>.
 * @param container <code>container</code> to be configured.
 */
private void setSecretKeyRefs(V1Container container) {
    final Config config = getConfiguration();
    final Map<String, String> podSecretKeyRefs = KubernetesContext.getPodSecretKeyRefs(config);
    for (Map.Entry<String, String> secret : podSecretKeyRefs.entrySet()) {
        final String[] keyRefParts = secret.getValue().split(":");
        if (keyRefParts.length != 2) {
            LOG.log(Level.SEVERE, "SecretKeyRef must be in the form name:key. <" + secret.getValue() + ">");
            throw new TopologyRuntimeManagementException("SecretKeyRef must be in the form name:key. <" + secret.getValue() + ">");
        }
        String name = keyRefParts[0];
        String key = keyRefParts[1];
        final V1EnvVar envVar = new V1EnvVar().name(secret.getKey()).valueFrom(new V1EnvVarSource().secretKeyRef(new V1SecretKeySelector().key(key).name(name)));
        container.addEnvItem(envVar);
    }
}
Also used : V1EnvVarSource(io.kubernetes.client.openapi.models.V1EnvVarSource) TopologyRuntimeManagementException(org.apache.heron.scheduler.TopologyRuntimeManagementException) Config(org.apache.heron.spi.common.Config) V1SecretKeySelector(io.kubernetes.client.openapi.models.V1SecretKeySelector) V1EnvVar(io.kubernetes.client.openapi.models.V1EnvVar) Map(java.util.Map) HashMap(java.util.HashMap) V1ConfigMap(io.kubernetes.client.openapi.models.V1ConfigMap)

Aggregations

V1ConfigMap (io.kubernetes.client.openapi.models.V1ConfigMap)1 V1EnvVar (io.kubernetes.client.openapi.models.V1EnvVar)1 V1EnvVarSource (io.kubernetes.client.openapi.models.V1EnvVarSource)1 V1SecretKeySelector (io.kubernetes.client.openapi.models.V1SecretKeySelector)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TopologyRuntimeManagementException (org.apache.heron.scheduler.TopologyRuntimeManagementException)1 Config (org.apache.heron.spi.common.Config)1