首页 > 其他分享 >tekton基础

tekton基础

时间:2022-10-26 17:34:43浏览次数:65  
标签:task name script 基础 tekton step hello

task和taskrun示例

[root@master 02-tekton-basics]# cat 01-task-hello.yaml 
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: hello
spec:
  steps:
    - name: say-hello
      image: alpine:3.15
      command: ['/bin/sh']
      args: ['-c', 'echo Hello World']
[root@master 02-tekton-basics]# cat 01-taskrun-hello.yaml 
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  name: hello-run-00001
spec:
  taskRef:
    kind: Task
    name: hello
[root@master 02-tekton-basics]# kubectl apply -f 01-task-hello.yaml -f 01-taskrun-hello.yaml 
task.tekton.dev/hello configured
taskrun.tekton.dev/hello-run-00001 created

 task和taskrun示例

[root@master 02-tekton-basics]# kubectl apply -f 02-task-with-params.yaml 
task.tekton.dev/hello-params created
[root@master 02-tekton-basics]# cat 02-task-with-params.yaml 
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: hello-params
spec:
  params:
    - name: target
      type: string
      description: Name of somebody or something to greet
      default: Yang
  steps:
    - name: say-hello
      image: alpine:3.15
      command:
        - /bin/sh
      args: ['-c', 'echo Hello $(params.target)']
[root@master 02-tekton-basics]# tkn task start hello-params --showlog
? Value for param `target` of type `string`? (Default is `Yang`) Yang
TaskRun started: hello-params-run-lqnz5
Waiting for logs to be available...
[say-hello] Hello Yang
[root@master 02-tekton-basics]# tkn task start hello-params --showlog -p target=Tekton
TaskRun started: hello-params-run-l782c
Waiting for logs to be available...
[say-hello] Hello Tekton

task定义多个step方法

[root@master 02-tekton-basics]# kubectl apply -f 03-task-multi-steps.yaml 
task.tekton.dev/multiple created

[root@master 02-tekton-basics]# cat 03-task-multi-steps.yaml 
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: multiple
spec:
  steps:
    - name: first
      image: alpine:3.15
      command:
        - /bin/sh
      args: ['-c', 'echo First Step']
    - name: second
      image: alpine:3.15
      command:
        - /bin/sh
      args: ['-c', 'echo Second Step']

[root@master 02-tekton-basics]# tkn task start multiple --showlog
TaskRun started: multiple-run-lghg2
Waiting for logs to be available...
[first] First Step

[second] Second Step

 task step定义多行

[root@master 02-tekton-basics]# cat 04-task-step-with-script.yaml 
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: script
spec:
  steps:
    - name: step-with-script
      image: alpine:3.15
      script: |
        #!/bin/sh
        echo "Step with Script..."
        echo "Installing necessary tooling"
        apk add curl
        curl -s www.baidu.com && echo "Success" || echo "Fail" 
        echo "All done!"
[root@master 02-tekton-basics]# kubectl apply -f 04-task-step-with-script.yaml 
task.tekton.dev/script created
[root@master 02-tekton-basics]# tkn task start script --showlog
TaskRun started: script-run-fflhs
Waiting for logs to be available...
[step-with-script] Step with Script...
[step-with-script] Installing necessary tooling
[step-with-script] fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
[step-with-script] fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
[step-with-script] (1/5) Installing ca-certificates (20220614-r0)
[step-with-script] (2/5) Installing brotli-libs (1.0.9-r5)
[step-with-script] (3/5) Installing nghttp2-libs (1.46.0-r0)
[step-with-script] (4/5) Installing libcurl (7.80.0-r3)
[step-with-script] (5/5) Installing curl (7.80.0-r3)
[step-with-script] Executing busybox-1.34.1-r7.trigger
[step-with-script] Executing ca-certificates-20220614-r0.trigger
[step-with-script] OK: 8 MiB in 19 packages
[step-with-script] <!DOCTYPE html>
[step-with-script] <!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>新闻</a> <a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多产品</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>关于百度</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>使用百度前必读</a>&nbsp; <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a>&nbsp;京ICP证030173号&nbsp; <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>
[step-with-script] Success
[step-with-script] All done!

task脚本和参数结合使用

[root@master 02-tekton-basics]# tkn task start logger --showlog -p text="TaskRun finished"
TaskRun started: logger-run-mpjnr
Waiting for logs to be available...
[log] [2022-10-26 16:59:48] - TaskRun finished

[root@master 02-tekton-basics]# cat 05-task-script-and-parameters.yaml 
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: logger
spec:
  params:
    - name: text
      type: string
      description: something to log
      default: "-"
  steps:
    - name: log
      image: alpine:3.15
      script: |
        apk add -q tzdata
        cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
        DATETIME=$(date "+%F %T")
        echo [$DATETIME] - $(params.text)

定义pipeline并引用task hello和multiple,runAfter会先运行,如果注释掉runAfter两个task会同时运行

[root@master 02-tekton-basics]# cat 06-pipeline-demo.yaml 
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: pipeline-demo
spec:
  tasks:
    - name: first-task
      taskRef:
        name: hello
    - name: second-task
      taskRef:
        name: multiple
      runAfter:
        - first-task
[root@master 02-tekton-basics]# kubectl apply -f 06-pipeline-demo.yaml 
pipeline.tekton.dev/pipeline-demo created

[root@master 02-tekton-basics]# tkn pipeline start pipeline-demo --showlog
PipelineRun started: pipeline-demo-run-6l4v8
Waiting for logs to be available...
[first-task : say-hello] Hello World

[second-task : first] First Step

[second-task : second] Second Step

 

标签:task,name,script,基础,tekton,step,hello
From: https://www.cnblogs.com/zyyang1993/p/16829030.html

相关文章

  • 每天三个Linux基础命令-008
    满招损,谦受益。内容不一定精彩,知识不一定你可以用得上,观点不一定准确,还望观者觉得有缺陷欢迎指正,觉得还好的感谢鼓励点赞。8.1man帮助命令主要用法:man后接需要查询的命......
  • Vue3-CompositionAPI-响应式基础
    一、响应式基础前提:你会使用setup函数或<scriptsetup>语法1.reactive我们可以使用reactive()函数创建一个响应式对象或数组:import{reactive}from'vue'c......
  • 麒麟系统开发笔记(九):在国产麒麟系统上搭建宇视摄像头SDK基础环境Demo
    前言  国产麒麟系统开发上,使用宇视摄像头,本篇使用宇视官网的提供的SDK,搭建基础的国产系统上宇视摄像头SDK开发化境Demo。<br>效果演示  <br>宇视SDK下载  官方......
  • MySQL基础篇--全局缓存和线程缓存
    MySQL全局缓存key_buffer_size决定索引处理的速度,尤其是索引读的速度。默认值是16M,通过检查状态值Key_read_requests和Key_reads,可以知道key_buffer_size设置是否合理。比例......
  • MySQL基础篇--执行计划扫描方式详解
    type列全表扫描ALL在查询结果集在达到全表数据>15-30%,优化器有可能会选择全表。在查询条件中出现隐式转换统计信息过旧,不准确。条件列是函数或者计算。使用ISNULL......
  • 文章资源下载小程序的基础配置(以Serverless WordPress为后端)
    引言WordPress的配置。小程序资讯相关类目暂不对个人开放,导致大批个体小程序被暂停服务的解决方案IWordPress的基础配置涉及的相关插件:Pods是一个用于创建,管理和部署自定义......
  • 网络安全和软件开发学哪个好?0基础如何选择?
    在信息化时代,软件开发、网络安全都是互联网行业必不可少的岗位之一。但对初学者而言,在学习之前依然会纠结软件开发和网络安全如何选择?接下来小编通过这篇文章为大家详......
  • python基础
    python1.基础语法1.1标识符在Python里,标识符由字母、数字、下划线组成。在Python中,所有标识符可以包括英文、数字以及下划线(_),但不能以数字开头。Python中的标......
  • VScode-基础编辑-常用快捷键
    基础编辑Basicediting按Press功能FunctionCtrl+X剪切行(空选定)Cutline(emptyselection)Ctrl+C复制行(空选定)Copyline(emptyselection)Alt+↑......
  • java知识8 Java基础语法【多测师】
    一、基础语法类:比如动物对象:狗狗、猫等就是具体的对象状态:狗狗的颜色、名字行为:狗狗叫、吃、摇尾巴方法:方法就是行为一个类可有很多方法逻辑运算数据修改以及所有的动......