kubernetes-copyFromPod
import com.google.common.io.ByteStreams; import io.kubernetes.client.Copy; import io.kubernetes.client.openapi.ApiClient; import io.kubernetes.client.openapi.ApiException; import java.io.IOException; import java.io.InputStream; import java.nio.file.Paths; public class CopyExample { public static void main(String[] args) throws IOException, ApiException { ApiClient k8sApiClient = new ApiClient(); k8sApiClient.setVerifyingSsl(false); k8sApiClient.setApiKeyPrefix("Bearer"); k8sApiClient.setDebugging(true); k8sApiClient.setApiKey("1hKnD2IAp_WWiB-opvibmCwSFQ-jBPw5-L6Br-Oj7BGLRm1UQr7DqxphgVjQRAdMJJWpCL0ArT-U2qjp4SqAT1jbwi3zA-2cj0EsyX6jROUtbOwY_nJCPj3hhOnlj90-fgILRBCZjiNRLS9WYqaJcsWeEn6yEx7Rtm70BaUX3nwJP6ybKkEhprnAiK8CbaViMlRktSo9nBhiyxR0scFBfHNduX2-epIqZyOtQ5sJg"); k8sApiClient.setBasePath("https://10.222.22.222:8043"); String podName = "base"; String namespace = "app"; Copy copy = new Copy(k8sApiClient); InputStream dataStream = copy.copyFileFromPod(namespace, podName, "/config/application-prod.yaml"); ByteStreams.copy(dataStream, System.out); copy.copyDirectoryFromPod(namespace, podName, null, "/config", Paths.get("/tmp/config")); System.out.println("Done!"); } }
不要小瞧女程序员