tekton TriggerTemplate资源

 欢迎关注我的公众号:

 目前刚开始写一个月,一共写了18篇原创文章,文章目录如下:

istio多集群探秘,部署了50次多集群后我得出的结论

istio多集群链路追踪,附实操视频

istio防故障利器,你知道几个,istio新手不要读,太难!

istio业务权限控制,原来可以这么玩

istio实现非侵入压缩,微服务之间如何实现压缩

不懂envoyfilter也敢说精通istio系列-http-rbac-不要只会用AuthorizationPolicy配置权限

不懂envoyfilter也敢说精通istio系列-02-http-corsFilter-不要只会vs

不懂envoyfilter也敢说精通istio系列-03-http-csrf filter-再也不用再代码里写csrf逻辑了

不懂envoyfilter也敢说精通istio系列http-jwt_authn-不要只会RequestAuthorization

不懂envoyfilter也敢说精通istio系列-05-fault-filter-故障注入不止是vs

不懂envoyfilter也敢说精通istio系列-06-http-match-配置路由不只是vs

不懂envoyfilter也敢说精通istio系列-07-负载均衡配置不止是dr

不懂envoyfilter也敢说精通istio系列-08-连接池和断路器

不懂envoyfilter也敢说精通istio系列-09-http-route filter

不懂envoyfilter也敢说精通istio系列-network filter-redis proxy

不懂envoyfilter也敢说精通istio系列-network filter-HttpConnectionManager

不懂envoyfilter也敢说精通istio系列-ratelimit-istio ratelimit完全手册

 

tekton新课发布:ci/cd之tekton实战--其他视频教程-系统/网络/运维-CSDN程序员研修院

什么是TriggerTemplate

创建资源的模板,比如用来创建 PipelineResource 和 PipelineRun

支持的资源

v1alpha1v1beta1
pipelinespipelines
pipelinerunspipelineruns
taskstasks
taskrunstaskruns
clustertasksclustertasks
conditions
pipelineresources

资源详解

resourcetemplates

tasks

triggerTemplate/task-template.yaml

apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerTemplate
metadata:
  name: template
spec:
  resourcetemplates:
  - apiVersion: tekton.dev/v1beta1
    kind: Task
    metadata:
      name: params-string 
    spec: 
      params:
      - name: directory
        type: string
        description: The directory containing the build context.
        default: /workspace
      steps:
      - image: ubuntu
        command: [pwd]
        workingDir: "$(params.directory)"
        imagePullPolicy: IfNotPresent

taskruns

triggerTemplate/taskruns-template.yaml

apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerTemplate
metadata:
  name: template
spec:
  params:
  - name: array-param
    description: test
  resourcetemplates:
  - apiVersion: tekton.dev/v1beta1
    kind: Task
    metadata:
      name: my-params-array
    spec:
      params:
      - name: array-param
        type: array
        default:
        - a
        - b
        - c
      steps:
      - image: ubuntu
        command: [echo]
        args:
        - "$(params.array-param[*])"
        imagePullPolicy: IfNotPresent
  - apiVersion: tekton.dev/v1beta1
    kind: TaskRun
    metadata:
      generateName: params-
    spec:
      taskRef:
        name: my-params-array
      params:
      - name: array-param
        value: $(tt.params.array-param)

clustertasks

triggerTemplate/clustertasks-template.yaml

apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerTemplate
metadata:
  name: template
spec:
  params:
  - name: array-param
    description: test
  resourcetemplates:
  - apiVersion: tekton.dev/v1beta1
    kind: ClusterTask
    metadata:
      name: my-params-array
    spec:
      params:
      - name: array-param
        type: array
        default:
        - a
        - b
        - c
      steps:
      - image: ubuntu
        command: [echo]
        args:
        - "$(params.array-param[*])"
        imagePullPolicy: IfNotPresent
  - apiVersion: tekton.dev/v1beta1
    kind: TaskRun
    metadata:
      generateName: params-
    spec:
      taskRef:
        name: my-params-array
        kind: ClusterTask
      params:
      - name: array-param
        value: $(tt.params.array-param)

pipelineresources

triggerTemplate/pipelineresources-template.yaml

apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerTemplate
metadata:
  name: template
spec:
  params:
  - name: url
  - name: revision
  resourcetemplates:
  - apiVersion: tekton.dev/v1alpha1
    kind: PipelineResource
    metadata:
      name: workspace
    spec:
      type: git
      params:
      - name: url
        value: $(tt.params.url)
      - name: revision
        value: $(tt.params.revision)

pipelines

triggerTemplate/pipelines-template.yaml

apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerTemplate
metadata:
  name: template
spec:
  resourcetemplates:
  - apiVersion: tekton.dev/v1beta1
    kind: Pipeline
    metadata:
      name: mypipeline
    spec:
      tasks:
      - name: build-app
        taskRef:
          name: build-push-kaniko
        resources:
          inputs:
          - name: workspace
            resource: workspace
          outputs:
          - name: builtImage
            resource: my-image
      - name: deploy-app
        taskRef:
          name: kubectl-deploy
        resources:
          inputs:
          - name: workspace
            resource: workspace
          - name: image
            resource: my-image
            from:
              - build-app
        params:
        - name: script_body
          value: $(params.script_body_pipeline)
      params:
      - name: script_body_pipeline
        type: string
      resources:
        - name: workspace
          type: git
        - name: my-image
          type: image

pipelineruns

triggerTemplate/pipelineruns-template.yaml

apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerTemplate
metadata:
  name: template
spec:
  resourcetemplates:
  - apiVersion: tekton.dev/v1beta1
    kind: PipelineRun
    metadata:
      generateName: mypipeline-run
    spec:
      serviceAccountName: test-task-robot-git-ssh
      pipelineRef:
        name: mypipeline
      params:
      - name: script_body_pipeline
        value: "kubectl apply -f /workspace/workspace/deployment.yaml "
      resources:
        - name: workspace
          resourceRef: 
            name: workspace
        - name: my-image
          resourceRef: 
            name: my-image

conditions

triggerTemplate/conditions-template.yaml

apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerTemplate
metadata:
  name: template
spec:
  resourcetemplates:
  - apiVersion: tekton.dev/v1alpha1
    kind: Condition
    metadata:
      name: is-equal
    spec:
      params:
      - name: left
        type: string
      - name: right
        type: string
      check:
        image: alpine
        script: |
          #!/bin/sh
          if [ $(params.left) = $(params.right) ]; then
            echo "$(params.left) == $(params.right)"
            exit 0
          else
            echo "$(params.left) != $(params.right)"
            exit 1
          fi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hxpjava1

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值