zoukankan      html  css  js  c++  java
  • K8s client 使用

    使用的k8s client包:

    <dependency>
    	<groupId>io.fabric8</groupId>
    	<artifactId>kubernetes-client</artifactId>
    	<version>2.6.1</version>
    	<exclusions>
    		<exclusion>
    			<artifactId>slf4j-api</artifactId>
    			<groupId>org.slf4j</groupId>
    		</exclusion>
    	</exclusions>
    </dependency>
    <dependency>
    	<groupId>io.fabric8</groupId>
    	<artifactId>kubernetes-model</artifactId>
    	<version>1.1.4</version>
    </dependency>
    <dependency>
    	<groupId>io.fabric8</groupId>
    	<artifactId>kubernetes-api</artifactId>
    	<version>2.3.5</version>
    	<exclusions>
    		<exclusion>
    			<artifactId>slf4j-api</artifactId>
    			<groupId>org.slf4j</groupId>
    		</exclusion>
    	</exclusions>
    </dependency>
    

      

    使用方式k8sApiUrl为k8s apiserver地址:

    Config config = new ConfigBuilder().withMasterUrl(k8sApiUrl).build();
    DefaultKubernetesClient kubernetesClient = new DefaultKubernetesClient(config);
    

      

    然后可以通过kubernetesClent进行RC创建、删除、scale;service创建删除等等操作,另外就是传入执行命令:

    // 创建RC
    kubernetesClient.replicationControllers().inNamespace(namespace).createOrReplace(rc);
    
    //扩缩容
    kubernetesClient.replicationControllers().inNamespace(namespace).withName(
                    rcName).scale(replicas);
    
    // POD执行命令
    kubernetesClient.pods().withName(podName).exec("command1","command2");
    
    更多方法自行挖掘,比如RC、POD、Endpoints 监听......
    

      

  • 相关阅读:
    完全背包详解
    0-1背包详解
    优先队列 + 模拟
    循环节 + 矩阵快速幂
    并查集 + 路径压缩(经典) UVALive 3027 Corporative Network
    dp
    动态规划分类(完整版)
    (二)Spring框架之JDBC的基本使用(p6spy插件的使用)
    (一)Spring框架基础
    (十六)客户端验证与struts2中的服务器端验证
  • 原文地址:https://www.cnblogs.com/qiang-cnblog/p/7760214.html
Copyright © 2011-2022 走看看