本篇內(nèi)容主要講解“Kubernetes1.14.1的開發(fā)指南”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學(xué)習(xí)“Kubernetes1.14.1的開發(fā)指南”吧!
成都創(chuàng)新互聯(lián)主要從事成都網(wǎng)站設(shè)計、成都網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)相山,十載網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792
從yaml
生成對象
Yaml yaml = new Yaml(); ExtensionsV1beta1Deployment body = yaml.loadAs(new FileReader("deployment.yaml"), ExtensionsV1beta1Deployment.class); ExtensionsV1beta1Api api = new ExtensionsV1beta1Api(); api.createNamespacedDeployment("default", body, "");
import io.kubernetes.client.ApiClient import io.kubernetes.client.apis.CoreV1Api import io.kubernetes.client.util.Config def setKubeApiClient() throws IOException, ApiException { StringReader reader = new StringReader(this.kubeConfig) ApiClient apiClient = Config.fromConfig(reader) Configuration.setDefaultApiClient(apiClient) this.api = new CoreV1Api() } Where kubeConfig is a yaml.
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import org.yaml.snakeyaml.Yaml; import io.kubernetes.client.ApiException; import io.kubernetes.client.models.ExtensionsV1beta1Deployment; import io.kubernetes.client.models.V1Namespace; import io.kubernetes.client.models.V1Service; public class Solution { private static final String yaml_file = "/home/karthik/Desktop/cloud/java/kubernetes/1.yaml"; static MapobjMap = new HashMap<>(); static Yaml yaml = new Yaml(); static { objMap.put("Deployment", ExtensionsV1beta1Deployment.class); objMap.put("Namespace",V1Namespace.class); objMap.put("Service", V1Service.class); //fill the hashmap } public static void main(String[] args) throws FileNotFoundException, ApiException { FileReader fr =new FileReader(yaml_file); InputStream input = new FileInputStream(new File(yaml_file)); Map map = (Map) yaml.load(input); ExtensionsV1beta1Deployment body = (ExtensionsV1beta1Deployment) convertyamlToObject(fr, (String) map.get("kind")); ExtensionsV1beta1Api api = new ExtensionsV1beta1Api(); System.out.println(body); } public static Object convertyamlToObject(FileReader fr, String kind) { return yaml.loadAs(fr, (Class
到此,相信大家對“Kubernetes1.14.1的開發(fā)指南”有了更深的了解,不妨來實際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進入相關(guān)頻道進行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!