本篇內(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 Map<String,Object> objMap = 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<Object>) objMap.get(kind)); } }
到此,相信大家對“Kubernetes1.14.1的開發(fā)指南”有了更深的了解,不妨來實際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進入相關(guān)頻道進行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
當(dāng)前標(biāo)題:Kubernetes1.14.1的開發(fā)指南
網(wǎng)站網(wǎng)址:http://muchs.cn/article8/gjsiop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)、搜索引擎優(yōu)化、網(wǎng)站改版、品牌網(wǎng)站制作、網(wǎng)站營銷、網(wǎng)站維護
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)