现在的位置:主页 > 综合新闻 >

Kubernetes 新玩法:在 yaml 中编程(3)

来源:电脑编程技巧与维护 【在线投稿】 栏目:综合新闻 时间:2020-09-24

【作者】网站采编

【关键词】

【摘要】操作原理的实现示例: // PodAnnotations is an operation used to check whether annotations of Pod are PodAnnotations(ctx , data PodAnnotationsData) error { kclient, ok := ().() if !ok { return

操作原理的实现示例:

// PodAnnotations is an operation used to check whether annotations of Pod are  PodAnnotations(ctx , data PodAnnotationsData) error {    kclient, ok := ().()    if !ok {        return     }    pods, err := ().Pods().List({})    if err != nil {        return (\"failed to list pods in ns %s: %s\", , err)    }    for _, pod := range  {        if  == nil {            return (\"pod %s in ns %s has no annotations\", pod.Name, )        }        for _, annotation := range  {            if _, exists := [annotation]; !exists {                return (\"annotation %s does not exist in pod %s in ns %s\", annotation, pod.Name, )            }        }        for k, v := range  {            if [k] != v {                return (\"value of annotation %s is not %s in pod %s in ns %s\", k, v, pod.Name, )            }        }    }    return nil}

目前阿里云容器服务团队内部已经实现了初版,已用于部分云产品的内部性能测试以及常规的回归测试,很大程度上提升了我们的工作效率。

在 yaml 中编程,是对云原生场景下声明式操作的体现,也是对声明式服务的一种实践。对于常规工作场景中重复编码或重复操作,可考虑类似的方式进行满足。

欢迎大家对这样的服务形态和项目进行讨论,探索这种模式的价值。

作者 | 悟鹏

本文为阿里云原创内容,未经允许不得转载。

文章来源:《电脑编程技巧与维护》 网址: http://www.dnbcjqywh.cn/zonghexinwen/2020/0924/505.html

上一篇:C/C++编程笔记:计算机网络基础知识总结!超全面
下一篇:百万年薪必备!AI行业常用编程语言大盘点,看看

电脑编程技巧与维护投稿 | 电脑编程技巧与维护编辑部| 电脑编程技巧与维护版面费 | 电脑编程技巧与维护论文发表 | 电脑编程技巧与维护最新目录
Copyright © 2018 《电脑编程技巧与维护》杂志社 版权所有
投稿电话: 投稿邮箱: