当前位置: 首页 > news >正文

一次性医用口罩价格绍兴seo推广

一次性医用口罩价格,绍兴seo推广,龙岗网站建设公司,上海家装博览会2023年时间Java model 准备 首先使用 crd.yml 和 kubernetes CRD 自动生成 Java model 类,这是一切的前提,之前在这个地方也卡了很久。如何生成在另外一个文章中已经有所记录。 使用 crd.yml 和 kubernetes CRD 自动生成 Java model 类 CustomObjectsApi 文档学习…

Java model 准备

首先使用 crd.yml 和 kubernetes CRD 自动生成 Java model 类,这是一切的前提,之前在这个地方也卡了很久。如何生成在另外一个文章中已经有所记录。
使用 crd.yml 和 kubernetes CRD 自动生成 Java model 类

CustomObjectsApi 文档学习

官网 kubernetes-client/java 的 CustomObjectsApi 介绍使用
在这个里面我们能找到所有关于自定义资源的增删改查的 api 的操作,还有示范的例子,可以根据自己的需求进行相关的改造使用。

示例

1、查看所有的自定义资源列表

public List<V1alpha1xxxx> getxxxList() {log.info("getxxxxList start to work");CustomObjectsApi apiInstance = kubernetesService.getCustomObjectsApi();Object result = null;try {result =apiInstance.listNamespacedCustomObject(group, version, namespace, plural, null, null, null, null, null, null, null, null,null, null);} catch (ApiException e) {log.info("listNamespacedCustomObject api call failed with status code "+ e.getCode()+ ": "+ e.getResponseBody());e.printStackTrace();}ObjectMapper objectMapper = kubernetesApplicationService.getObjectMapper();V1alpha1xxxList v1alpha1xxxList =objectMapper.convertValue(result, V1alpha1xxxList.class);return v1alpha1xxxList.getItems();}

2、得到指定的某一个自定义资源

public V1alpha1xxx getxxx(String name) {log.info("getxxx start to work");//        "name": "admin-1akyr08e9wwt"Object result =kubernetesApplicationService.getCustomObjectsApi(group, version, namespace, plural, name);ObjectMapper objectMapper = kubernetesApplicationService.getObjectMapper();V1alpha1xxx v1alpha1xxx = objectMapper.convertValue(result, V1alpha1xxx.class);return v1alpha1xxx;
}

CustomObjectsApi 去获得指定的某一个自定义资源

public Object getCustomObjectsApi(String group, String version, String namespace, String plural, String name) {CustomObjectsApi apiInstance = kubernetesService.getCustomObjectsApi();Object result = null;try {result = apiInstance.getNamespacedCustomObject(group, version, namespace, plural, name);} catch (ApiException e) {if (e.getCode() == 404) {log.info("custom object {} does not exist", name);} else {log.info("getNamespacedCustomObject api call failed with status code "+ e.getCode()+ ": "+ e.getResponseBody());e.printStackTrace();}}return result;}

3、创建一个自定义资源

public V1alpha1xxx createxxx(V1alpha1xxx v1alpha1xxxb) {log.info("createxxx start to work");Object customObject =kubernetesApplicationService.createNamespacedCustomObject(group,version,namespace,plural,v1alpha1xxx.getMetadata().getName(),v1alpha1xxx);return v1alpha1xxx;

CustomObjectsApi去创建一个自定义的资源

public Object createNamespacedCustomObject(String group,String version,String namespace,String plural,String name,KubernetesObject kubernetesObject) {CustomObjectsApi apiInstance = kubernetesService.getCustomObjectsApi();Object customObject = null;try {customObject =apiInstance.createNamespacedCustomObject(group, version, namespace, plural, kubernetesObject, null, null, null);log.info("createNamespacedCustomObject {}", name);} catch (ApiException e) {log.info("createNamespacedCustomObject api call failed with status code "+ e.getCode()+ ": "+ e.getResponseBody());e.printStackTrace();}return customObject;}

4、删除自定义资源

 public void deleteBayesJob(String name) {log.info("deletexxx {} start to work", name);V1alpha1xxx xxx = getxxx(name);if (xxx == null) {log.error("can not get xxx {}", name);return;}kubernetesApplicationService.deleteNamespacedCustomObject(group, version, namespace, plural, name);}

CustomObjectsApi删除指定的自定义资源

public void deleteNamespacedCustomObject(String group, String version, String namespace, String plural, String name) {V1DeleteOptions body = new V1DeleteOptions();CustomObjectsApi apiInstance = kubernetesService.getCustomObjectsApi();try {Object result =apiInstance.deleteNamespacedCustomObject(group, version, namespace, plural, name, null, null, null, null, body);log.info("delete namespaced customObject {}", name);} catch (ApiException e) {log.info("deleteNamespacedCustomObject api call failed with status code "+ e.getCode()+ ": "+ e.getResponseBody());e.printStackTrace();}}

5、修改自定义资源

public void killxxx(String name) {log.info("killxxx start to work");CustomObjectsApi apiInstance = kubernetesService.getCustomObjectsApi();V1alpha1xxx bxxx = getBaxxx(name);if (bxxx== null) {log.error("can not get bxxx {}", name);throw new InvalidRequestException("invalid name " + name);}Map<String, String> annotations = bxxx.getMetadata().getAnnotations();if (annotations == null) {bxxx.getMetadata().setAnnotations(new HashMap<>() {{put("xxxxx/terminate", "true");}});} else {bxxx.getMetadata().getAnnotations().put("xxxx/terminate", "true");}ObjectMapper objectMapper = kubernetesApplicationService.getObjectMapper();String bxxxAsString = null;try {bxxxAsString = objectMapper.writeValueAsString(bxxx);} catch (JsonProcessingException e) {log.error("killxxx writeValueAsString error {}", e.getMessage());e.printStackTrace();throw new RuntimeException(e);}Gson gson = new Gson();JsonObject jsonObject = gson.fromJson(bayesJobAsString, JsonObject.class);kubernetesApplicationService.replaceNamespacedCustomObject(group, version, namespace, plural, jsonObject, name);
}

CustomObjectsApi replace某一个自定义资源

public void replaceNamespacedCustomObject(String group,String version,String namespace,String plural,JsonObject jsonObject,String name) {log.info("replaceNamespacedCustomObject name {} ,jsonObject {}", name, jsonObject);CustomObjectsApi apiInstance = kubernetesService.getCustomObjectsApi();try {Object result =apiInstance.replaceNamespacedCustomObject(group, version, namespace, plural, name, jsonObject, null, null);log.info("replaceNamespacedCustomObject name {} result {}", name, result);} catch (ApiException e) {log.error("Exception when calling CustomObjectsApi#replaceNamespacedCustomObject");log.error("Status code: {} , Reason: {}", e.getCode(), e.getResponseBody());e.printStackTrace();}}

这个是先查找自定义资源A是否存在,如果存在的话,修改自定义资源A的某些属性,然后将其A进行序列化。之后 gson.fromJson 然后再进行自定义资源A的replace

http://www.ds6.com.cn/news/120317.html

相关文章:

  • 深圳手机网站开发什么企业需要网络营销和网络推广
  • 娱乐网站名字企业宣传
  • 不用编程做网站阿里云com域名注册
  • 国外logo设计网站推荐产品推广计划怎么写
  • 义乌做网站多少钱查销售数据的网站
  • 北京网站优化常识太原seo关键词排名优化
  • 武汉网站快照推广如何利用网络广告进行推广
  • 网页设计html代码大全指定颜色seo 优化一般包括哪些内容
  • 企业组网设计杭州seo网站排名
  • 建立网站成本网络营销推广方式包括哪几种
  • 网站推广做百度还是360seo公司关键词
  • 网站建设淘宝评价智能建站模板
  • 重庆网站设计方案关键词有哪些关联词
  • 中国菲律宾领土纠纷seo网络优化师就业前景
  • 内蒙古网站建站怎么做产品推广和宣传
  • 淘宝建设网站靠谱吗app广告联盟
  • 宣讲家网站李慎明两学一做网络推广营销培训机构
  • 静态网站怎么做新平台推广赚钱
  • 获得网页源码怎么做网站惠州网络推广平台
  • 网站录入培训学校资质办理条件
  • vs网站开发源码广告公司取名字参考大全
  • 做旅游平台网站找哪家好百度收录的网站
  • 加强企业网站建设的通知手机百度app
  • 如何用工控做网站优化网站平台
  • 大数据做网站app推广好做吗
  • 网站右击无效是怎么做的谷歌seo软件
  • 显示官网字样的网站怎么做seo案例分析及解析
  • 武汉网站制作公司seo是指什么意思
  • web前端的就业前景成都自动seo
  • 网站制作公司服务seo优化报告