Package org.apache.hadoop.yarn.util
Class DockerClientConfigHandler
java.lang.Object
org.apache.hadoop.yarn.util.DockerClientConfigHandler
Commonly needed actions for handling the Docker client configurations.
Credentials that are used to access private Docker registries are supplied.
Actions include:
- Read the Docker client configuration json file from a
FileSystem. - Extract the authentication information from the configuration into
TokenandCredentialsobjects. - Tokens are commonly shipped via the
ContainerLaunchContextas aByteBuffer, extract theCredentials. - Write the Docker client configuration json back to the local filesystem to be used by the Docker command line.
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.hadoop.security.CredentialsConvert the Token ByteBuffer to the appropriate Credentials object.static org.apache.hadoop.security.CredentialsreadCredentialsFromConfigFile(org.apache.hadoop.fs.Path configFile, org.apache.hadoop.conf.Configuration conf, String applicationId) Read the Docker client configuration and extract the auth tokens into Credentials.static booleanwriteDockerCredentialsToPath(File outConfigFile, org.apache.hadoop.security.Credentials credentials) Extract the Docker related tokens from the Credentials and write the Docker client configuration to the supplied File.
-
Method Details
-
readCredentialsFromConfigFile
public static org.apache.hadoop.security.Credentials readCredentialsFromConfigFile(org.apache.hadoop.fs.Path configFile, org.apache.hadoop.conf.Configuration conf, String applicationId) throws IOException Read the Docker client configuration and extract the auth tokens into Credentials.- Parameters:
configFile- the Path to the Docker client configuration.conf- the Configuration object, needed by the FileSystem.applicationId- the application ID to associate the Credentials with.- Returns:
- the populated Credential object with the Docker Tokens.
- Throws:
IOException- if the file can not be read.
-
getCredentialsFromTokensByteBuffer
public static org.apache.hadoop.security.Credentials getCredentialsFromTokensByteBuffer(ByteBuffer tokens) throws IOException Convert the Token ByteBuffer to the appropriate Credentials object.- Parameters:
tokens- the Tokens from the ContainerLaunchContext.- Returns:
- the Credentials object populated from the Tokens.
- Throws:
IOException- io error occur.
-
writeDockerCredentialsToPath
public static boolean writeDockerCredentialsToPath(File outConfigFile, org.apache.hadoop.security.Credentials credentials) throws IOException Extract the Docker related tokens from the Credentials and write the Docker client configuration to the supplied File.- Parameters:
outConfigFile- the File to write the Docker client configuration to.credentials- the populated Credentials object.- Returns:
- true if a Docker credential is found in the supplied credentials.
- Throws:
IOException- if the write fails.
-