Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Development Guide for Kubernetes1.14.1

Shulou Source: shulou.com Published: 2022-06-02 04:03:47 11月09日 Update

This article mainly explains "the Development Guide of Kubernetes1.14.1". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn the "Kubernetes1.14.1 Development Guide"!

Generate objects from 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.ApiClientimport io.kubernetes.client.apis.CoreV1Apiimport 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 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) objMap.get (kind));}} so far, I believe you have a deeper understanding of the "Kubernetes1.14.1 Development Guide". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Development guide guide development content learning practical deeper interest practical object simple operation method more friends website channel query generation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Apple MySQL Shulou Technology vpn