{"id":144553,"date":"2019-05-14T08:13:34","date_gmt":"2019-05-14T00:13:34","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=144553"},"modified":"2019-05-13T09:15:33","modified_gmt":"2019-05-13T01:15:33","slug":"tektoncd-pipeline-kubernetes","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/tektoncd-pipeline-kubernetes.html","title":{"rendered":"kubernetes\u539f\u751fpipeline"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nTekton Pipeline,\u662f\u4e00\u4e2ak8s native\u7684pipeline, \u4efb\u52a1\u8dd1\u5728pod\u4e2d\uff0c\u901a\u8fc7\u81ea\u5b9a\u4e49CRD\u53bb\u7ba1\u7406\u4efb\u52a1\u4e0e\u5de5\u4f5c\u6d41\u7b49\u7b49\uff0c\u6211\u770b\u5b8ctekton\u4e4b\u540e\u611f\u89c9\u662f\u529f\u80fd\u5f88\u5f3a\u5927\uff0c\u4f46\u662f\u6709\u70b9\u8fc7\u5ea6\u8bbe\u8ba1\u4e86\uff0c\u6ca1\u6709drone\u7684\u7b80\u7ea6\u5927\u65b9\u7075\u6d3b\u4e4b\u611f\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
Task<\/strong><\/span><\/div>\n

Tekton Pipelines\u7684\u4e3b\u8981\u76ee\u6807\u662f\u5355\u72ec\u8fd0\u884c\u60a8\u7684\u4efb\u52a1\u6216\u4f5c\u4e3a\u7ba1\u9053\u7684\u4e00\u90e8\u5206\u8fd0\u884c\u3002\u6bcf\u4e2a\u4efb\u52a1\u90fd\u5728Kubernetes\u96c6\u7fa4\u4e0a\u4f5c\u4e3aPod\u8fd0\u884c\uff0c\u6bcf\u4e2a\u6b65\u9aa4\u90fd\u4f5c\u4e3a\u81ea\u5df1\u7684\u5bb9\u5668\u3002\u8fd9\u70b9\u6df1\u5f97drone\u601d\u60f3\u7cbe\u9ad3\uff0c\u5176\u5b9edrone\u4e5f\u6709\u8ba1\u5212\u5c06kubernetes\u4f5c\u4e3a\u4efb\u52a1\u6267\u884c\u5f15\u64ce\uff0c\u53ea\u662f\u6ca1\u6709\u4e0b\u6587\u4e86\u3002<\/p>\n

A Task\u5b9a\u4e49\u4e86\u9700\u8981\u6267\u884c\u7684\u5de5\u4f5c\uff0c\u4f8b\u5982\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4efb\u52a1\uff1a<\/p>\n

\r\napiVersion: tekton.dev\/v1alpha1\r\nkind: Task\r\nmetadata:\r\n  name: echo-hello-world\r\nspec:\r\n  steps:\r\n    - name: echo\r\n      image: ubuntu\r\n      command:\r\n        - echo\r\n      args:\r\n        - \"hello world\"\r\n<\/pre>\n

\u8fd9steps\u662f\u4e00\u7cfb\u5217\u7531\u4efb\u52a1\u987a\u5e8f\u6267\u884c\u7684\u547d\u4ee4\u3002\u8fd9\u4e2asteps\u5185\u7684\u914d\u7f6e\u51e0\u4e4e\u4e0edrone\u5982\u51fa\u4e00\u8f99\uff0cTask\u5b9a\u4e49\u597d\u5e76\u6ca1\u6709\u88ab\u6267\u884c\uff0c\u521b\u5efaTaskRun\u65f6\u624d\u4f1a\u6267\u884c\u3002\u8fd9\u662f\u5408\u7406\u7684\uff0c\u76f8\u5f53\u4e8e\u662f\u4e00\u4e2a\u89e6\u53d1<\/p>\n

\r\napiVersion: tekton.dev\/v1alpha1\r\nkind: TaskRun\r\nmetadata:\r\n  name: echo-hello-world-task-run\r\nspec:\r\n  taskRef:\r\n    name: echo-hello-world\r\n  trigger:\r\n    type: manual\r\nkubectl apply -f < name-of-file.yaml >\r\n<\/pre>\n

\u67e5\u770bTaskRun kubectl get taskruns \/ echo-hello-world-task-run -o yaml<\/p>\n

\r\napiVersion: tekton.dev\/v1alpha1\r\nkind: TaskRun\r\nmetadata:\r\n  creationTimestamp: 2018-12-11T15:49:13Z\r\n  generation: 1\r\n  name: echo-hello-world-task-run\r\n  namespace: default\r\n  resourceVersion: \"6706789\"\r\n  selfLink: \/apis\/tekton.dev\/v1alpha1\/namespaces\/default\/taskruns\/echo-hello-world-task-run\r\n  uid: 4e96e9c6-fd5c-11e8-9129-42010a8a0fdc\r\nspec:\r\n  generation: 1\r\n  inputs: {}\r\n  outputs: {}\r\n  taskRef:\r\n    name: echo-hello-world\r\n  taskSpec: null\r\n  trigger:\r\n    type: manual\r\nstatus:\r\n  conditions:\r\n    - lastTransitionTime: 2018-12-11T15:50:09Z\r\n      status: \"True\"\r\n      type: Succeeded\r\n  podName: echo-hello-world-task-run-pod-85ca51\r\n  startTime: 2018-12-11T15:49:39Z\r\n  steps:\r\n    - terminated:\r\n        containerID: docker:\/\/fcfe4a004...6729d6d2ad53faff41\r\n        exitCode: 0\r\n        finishedAt: 2018-12-11T15:50:01Z\r\n        reason: Completed\r\n        startedAt: 2018-12-11T15:50:01Z\r\n    - terminated:\r\n        containerID: docker:\/\/fe86fc5f7...eb429697b44ce4a5b\r\n        exitCode: 0\r\n        finishedAt: 2018-12-11T15:50:02Z\r\n        reason: Completed\r\n        startedAt: 2018-12-11T15:50:02Z\r\n<\/pre>\n

\u72b6\u6001Succeeded = True\u663e\u793a\u4efb\u52a1\u5df2\u6210\u529f\u8fd0\u884c\u3002<\/p>\n

\u4efb\u52a1\u8f93\u5165\u548c\u8f93\u51fa<\/strong><\/span><\/div>\n

\u5728\u66f4\u5e38\u89c1\u7684\u573a\u666f\u4e2d\uff0c\u4efb\u52a1\u9700\u8981\u591a\u4e2a\u6b65\u9aa4\u6765\u5904\u7406\u8f93\u5165\u548c\u8f93\u51fa\u8d44\u6e90\u3002\u4f8b\u5982\uff0cTask\u53ef\u4ee5\u4eceGitHub\u5b58\u50a8\u5e93\u83b7\u53d6\u6e90\u4ee3\u7801\u5e76\u4ece\u4e2d\u6784\u5efaDocker\u955c\u50cf\u3002<\/p>\n

PipelinesResources\u7528\u4e8e\u5b9a\u4e49\u4efb\u52a1\u7684\u8f93\u5165(\u5982\u4ee3\u7801)\u4e0e\u8f93\u51fa(\u5982Docker\u955c\u50cf)\u3002\u6709\u4e00\u4e9b\u7cfb\u7edf\u5b9a\u4e49\u7684\u8d44\u6e90\u7c7b\u578b\u53ef\u4f9b\u4f7f\u7528\uff0c\u4ee5\u4e0b\u662f\u901a\u5e38\u9700\u8981\u7684\u4e24\u4e2a\u8d44\u6e90\u793a\u4f8b\u3002<\/p>\n

\u8be5git\u8d44\u6e90\u53ef\u4ee5\u662f\u4f60\u8981\u7f16\u8bd1\u7684\u4ee3\u7801\uff1a<\/p>\n

\r\napiVersion: tekton.dev\/v1alpha1\r\nkind: PipelineResource\r\nmetadata:\r\n  name: skaffold-git\r\nspec:\r\n  type: git\r\n  params:\r\n    - name: revision\r\n      value: master\r\n    - name: url\r\n      value: https:\/\/github.com\/GoogleContainerTools\/skaffold\r\n<\/pre>\n

\u8be5image\u8d44\u6e90\u4ee3\u8868\u8981\u88ab\u4efb\u52a1\u7f16\u8bd1\u6210\u7684\u955c\u50cf\uff1a<\/p>\n

\r\napiVersion: tekton.dev\/v1alpha1\r\nkind: PipelineResource\r\nmetadata:\r\n  name: skaffold-image-leeroy-web\r\nspec:\r\n  type: image\r\n  params:\r\n    - name: url\r\n      value: gcr.io\/\/leeroy-web\r\n<\/use><\/pre>\n

\u4ee5\u4e0b\u662fTask\u8f93\u5165\u548c\u8f93\u51fa\u3002\u8f93\u5165\u8d44\u6e90\u662fGitHub\u5b58\u50a8\u5e93\uff0c\u8f93\u51fa\u662f\u4ece\u8be5\u6e90\u751f\u6210\u7684\u56fe\u50cf\u3002\u4efb\u52a1\u547d\u4ee4\u7684\u53c2\u6570\u652f\u6301\u6a21\u677f\u5316\uff0c\u56e0\u6b64\u4efb\u52a1\u7684\u5b9a\u4e49\u662f\u5e38\u91cf\uff0c\u53c2\u6570\u7684\u503c\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u66f4\u6539\u3002<\/p>\n

\r\napiVersion: tekton.dev\/v1alpha1\r\nkind: Task\r\nmetadata:\r\n  name: build-docker-image-from-git-source\r\nspec:\r\n  inputs:\r\n    resources:\r\n      - name: docker-source\r\n        type: git\r\n    params:\r\n      - name: pathToDockerFile       # \u8fd9\u4e9b\u53c2\u6570\u90fd\u662f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u7684\r\n        description: The path to the dockerfile to build\r\n        default: \/workspace\/docker-source\/Dockerfile\r\n      - name: pathToContext\r\n        description:\r\n          The build context used by Kaniko\r\n          (https:\/\/github.com\/GoogleContainerTools\/kaniko#kaniko-build-contexts)\r\n        default: \/workspace\/docker-source\r\n  outputs:\r\n    resources:\r\n      - name: builtImage\r\n        type: image\r\n  steps:\r\n    - name: build-and-push\r\n      image: gcr.io\/kaniko-project\/executor  # \u7279\u5b9a\u529f\u80fd\u7684\u955c\u50cf\uff0c\u53ef\u4ee5\u7528\u6765docker build\r\n      command:\r\n        - \/kaniko\/executor\r\n      args:\r\n        - --dockerfile=${inputs.params.pathToDockerFile}   # \u8fd9\u65f6\u539fpathToDockerFile\u5c31\u662f\u4e0a\u9762\u5b9a\u4e49\u7684\u53c2\u6570\r\n        - --destination=${outputs.resources.builtImage.url}\r\n        - --context=${inputs.params.pathToContext}\r\n<\/pre>\n

TaskRun\u5c06\u8f93\u5165\u548c\u8f93\u51fa\u7ed1\u5b9a\u5230\u5df2\u5b9a\u4e49\u7684PipelineResources\u503c\uff0c\u9664\u4e86\u6267\u884c\u4efb\u52a1\u6b65\u9aa4\u5916\uff0c\u8fd8\u5c06\u503c\u8bbe\u7f6e\u4e3a\u7528\u4e8e\u6a21\u677f\u5316\u7684\u53c2\u6570\u3002<\/p>\n

\r\napiVersion: tekton.dev\/v1alpha1\r\nkind: TaskRun\r\nmetadata:\r\n  name: build-docker-image-from-git-source-task-run\r\nspec:\r\n  taskRef:\r\n    name: build-docker-image-from-git-source\r\n  trigger:\r\n    type: manual\r\n  inputs:\r\n    resources:\r\n      - name: docker-source\r\n        resourceRef:\r\n          name: skaffold-git\r\n    params:                       # \u6267\u884c\u65f6\u628a\u53c2\u6570\u4f20\u7ed9Task\uff0c\u8fd9\u6837\u5c31\u4e0d\u9700\u8981\u91cd\u590d\u5b9a\u4e49task\uff0c\u53ea\u9700\u8981\u589e\u52a0input output \u548ctaskrun \u5c31\u53ef\u4ee5\u8dd1\u4e00\u4e2a\u522b\u7684\u5de5\u7a0b, \u4ece\u89e3\u8026\u8fd9\u4e2a\u89d2\u5ea6\u5230\u8bf4\u6bd4drone\u66f4\u597d\uff0c\u4efb\u52a1\u6d41\u7a0b\u53ef\u4ee5\u590d\u7528\r\n      - name: pathToDockerFile\r\n        value: Dockerfile\r\n      - name: pathToContext\r\n        value: \/workspace\/docker-source\/examples\/microservices\/leeroy-web #configure: may change according to your source\r\n  outputs:\r\n    resources:\r\n      - name: builtImage\r\n        resourceRef:\r\n          name: skaffold-image-leeroy-web  # \u8fd9\u4e5f\u662f\u4e0a\u9762\u6307\u5b9a\u7684\u8d44\u6e90\r\n<\/pre>\n

PS: inputs outputs\u5e94\u5f53\u4e0d\u9650\u5236\u6b7b\u5fc5\u987b\u53eb\u8fd9\u4e24\u4e2a\u540d\u5b57\uff0c\u53ea\u8981\u662f\u80fd\u652f\u6301\u53c2\u6570\u5c31\u597d\u3002\u6bd4\u5982\u5b9a\u4e49\u4e00\u4e2a\u53ebbuild\u7684\u8d44\u6e90\u53bb\u6307\u5b9adocker build\u7684\u955c\u50cf\uff1a<\/p>\n

\r\napiVersion: tekton.dev\/v1alpha1\r\nkind: PipelineResource\r\nmetadata:\r\n  name: skaffold-image-leeroy-web\r\nspec:\r\n  type: image\r\n  params:\r\n    - name: url\r\n      value: docker-in-docker:latest\r\n<\/pre>\n

Task \u91cc\uff1a<\/p>\n

\r\napiVersion: tekton.dev\/v1alpha1\r\nkind: Task\r\nmetadata:\r\n  name: build-docker-image-from-git-source\r\nspec:\r\n  build:\r\n     resources:\r\n     - name: build\r\n       type: image\r\n  params:\r\n  - name: build-image\r\n    default: docker-in-docker:latest\r\n  steps:\r\n      - name: build-and-push\r\n      image: ${build.params.build-image}    \r\n<\/pre>\n

\u6211\u662f\u89c9\u5f97\u9700\u8981\u80fd\u8fdb\u884c\u8fd9\u6837\u7684\u6269\u5c55\u4e86, \u4ec5\u662finputs outputs\u5c31\u72ed\u4e49\u4e86<\/p>\n

\u83b7\u53d6pipeline\u5168\u90e8\u4fe1\u606f kubectl get build-pipeline<\/p>\n

\r\nNAME                                                   AGE\r\ntaskruns\/build-docker-image-from-git-source-task-run   30s\r\n\r\nNAME                                          AGE\r\npipelineresources\/skaffold-git                6m\r\npipelineresources\/skaffold-image-leeroy-web   7m\r\n\r\nNAME                                       AGE\r\ntasks\/build-docker-image-from-git-source   7m\r\n\r\n<\/pre>\n

\u8981\u67e5\u770bTaskRun\u7684\u8f93\u51fa\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\r\nkubectl get taskruns \/ build-docker-image-from-git-source-task-run -o yaml\r\n<\/pre>\n
\r\napiVersion: tekton.dev\/v1alpha1\r\nkind: TaskRun\r\nmetadata:\r\n  creationTimestamp: 2018-12-11T18:14:29Z\r\n  generation: 1\r\n  name: build-docker-image-from-git-source-task-run\r\n  namespace: default\r\n  resourceVersion: \"6733537\"\r\n  selfLink: \/apis\/tekton.dev\/v1alpha1\/namespaces\/default\/taskruns\/build-docker-image-from-git-source-task-run\r\n  uid: 99d297fd-fd70-11e8-9129-42010a8a0fdc\r\nspec:\r\n  generation: 1\r\n  inputs:\r\n    params:\r\n      - name: pathToDockerFile\r\n        value: Dockerfile\r\n      - name: pathToContext\r\n        value: \/workspace\/git-source\/examples\/microservices\/leeroy-web #configure: may change depending on your source\r\n    resources:\r\n      - name: git-source\r\n        paths: null\r\n        resourceRef:\r\n          name: skaffold-git\r\n  outputs:\r\n    resources:\r\n      - name: builtImage\r\n        paths: null\r\n        resourceRef:\r\n          name: skaffold-image-leeroy-web\r\n  taskRef:\r\n    name: build-docker-image-from-git-source\r\n  taskSpec: null\r\n  trigger:\r\n    type: manual\r\nstatus:\r\n  conditions:\r\n    - lastTransitionTime: 2018-12-11T18:15:09Z\r\n      status: \"True\"\r\n      type: Succeeded\r\n  podName: build-docker-image-from-git-source-task-run-pod-24d414\r\n  startTime: 2018-12-11T18:14:29Z\r\n  steps:\r\n    - terminated:\r\n        containerID: docker:\/\/138ce30c722eed....c830c9d9005a0542\r\n        exitCode: 0\r\n        finishedAt: 2018-12-11T18:14:47Z\r\n        reason: Completed\r\n        startedAt: 2018-12-11T18:14:47Z\r\n    - terminated:\r\n        containerID: docker:\/\/4a75136c029fb1....4c94b348d4f67744\r\n        exitCode: 0\r\n        finishedAt: 2018-12-11T18:14:48Z\r\n        reason: Completed\r\n        startedAt: 2018-12-11T18:14:48Z\r\n<\/pre>\n

\u7c7b\u578b\u7684\u72b6\u6001Succeeded = True\u663e\u793aTask\u5df2\u6210\u529f\u8fd0\u884c\uff0c\u60a8\u8fd8\u53ef\u4ee5\u9a8c\u8bc1Docker\u955c\u50cf\u662f\u5426\u751f\u6210\u3002<\/p>\n

Pipeline<\/strong><\/span><\/div>\n

Pipeline\u5b9a\u4e49\u8981\u6309\u987a\u5e8f\u6267\u884c\u7684\u4efb\u52a1\u5217\u8868\uff0c\u540c\u65f6\u8fd8\u901a\u8fc7\u4f7f\u7528\u8be5from\u5b57\u6bb5\u6307\u793a\u662f\u5426\u5e94\u5c06\u4efb\u4f55\u8f93\u51fa\u7528\u4f5c\u540e\u7eed\u4efb\u52a1\u7684\u8f93\u5165\uff0c\u5e76\u6307\u793a\u6267\u884c\u7684\u987a\u5e8f\uff08\u4f7f\u7528runAfter\u548cfrom\u5b57\u6bb5\uff09\u3002\u60a8\u5728\u4efb\u52a1\u4e2d\u4f7f\u7528\u7684\u76f8\u540c\u6a21\u677f\u4e5f\u53ef\u4ee5\u5728\u7ba1\u9053\u4e2d\u4f7f\u7528\u3002<\/p>\n

\r\napiVersion: tekton.dev\/v1alpha1\r\nkind: Pipeline\r\nmetadata:\r\n  name: tutorial-pipeline\r\nspec:\r\n  resources:\r\n    - name: source-repo\r\n      type: git\r\n    - name: web-image\r\n      type: image\r\n  tasks:\r\n    - name: build-skaffold-web # \u7f16\u8bd1\u4e0e\u6253\u955c\u50cf\u4efb\u52a1\uff0c\u4e0a\u9762\u5df2\u7ecf\u4ecb\u7ecd\u8fc7\r\n      taskRef:\r\n        name: build-docker-image-from-git-source\r\n      params:\r\n        - name: pathToDockerFile\r\n          value: Dockerfile\r\n        - name: pathToContext\r\n          value: \/workspace\/examples\/microservices\/leeroy-web #configure: may change according to your source\r\n      resources:\r\n        inputs:\r\n          - name: workspace\r\n            resource: source-repo\r\n        outputs:\r\n          - name: image\r\n            resource: web-image\r\n    - name: deploy-web          # \u90e8\u7f72\r\n      taskRef:\r\n        name: deploy-using-kubectl # \u8fd9\u91cc\u5f15\u5165\u4e86\u4e00\u4e2a\u901a\u8fc7k8s\u90e8\u7f72\u7684Task\uff0c\u6211\u4eec\u5728\u4e0b\u6587\u770b\u5b83\u662f\u4ec0\u4e48\r\n      resources:\r\n        inputs:                    # \u5b9a\u4e49\u8f93\u5165\uff0c\u8fd9\u91cc\u7684\u8f93\u5165\u5176\u5b9e\u662f\u4e0a\u4e2a\u4efb\u52a1\u7684\u8f93\u51fa\r\n          - name: workspace\r\n            resource: source-repo\r\n          - name: image            # \u6bd4\u5982\u8fd9\u4e2a\u955c\u50cf\uff0c\u5c31\u662f\u4e0a\u4e2a\u4efb\u52a1\u4ea7\u751f\u7684\r\n            resource: web-image\r\n            from:                  # from\u5c31\u5982\u540c\u7ba1\u9053\u4e00\u6837\uff0c\u628a\u4e0a\u4e2a\u4efb\u52a1\u7684\u8f93\u51fa\u4f5c\u4e3a\u8fd9\u4e2a\u4efb\u52a1\u7684\u8f93\u5165\r\n              - build-skaffold-web\r\n      params:                      # \u7559\u610f\u8fd9\u4e9b\u53c2\u6570\u90fd\u662f\u4f20\u7ed9Task\u6a21\u677f\u7684,\u8986\u76d6inputs\u91cc\u7684\u53c2\u6570\r\n        - name: path\r\n          value: \/workspace\/examples\/microservices\/leeroy-web\/kubernetes\/deployment.yaml #configure: may change according to your source\r\n        - name: yqArg\r\n          value: \"-d1\"\r\n        - name: yamlPathToImage\r\n          value: \"spec.template.spec.containers[0].image\"\r\n<\/pre>\n

\u4ee5\u4e0aPipeline\u662f\u5f15\u7528\u4e00\u4e2aTask\u88ab\u53eb\u7684deploy-using-kubectl\uff1a<\/p>\n

\r\napiVersion: tekton.dev\/v1alpha1\r\nkind: Task\r\nmetadata:\r\n  name: deploy-using-kubectl\r\nspec:\r\n  inputs:\r\n    resources:\r\n      - name: workspace\r\n        type: git\r\n      - name: image\r\n        type: image\r\n    params:\r\n      - name: path\r\n        description: Path to the manifest to apply\r\n      - name: yqArg\r\n        description:\r\n          Okay this is a hack, but I didn't feel right hard-coding `-d1` down\r\n          below\r\n      - name: yamlPathToImage\r\n        description:\r\n          The path to the image to replace in the yaml manifest (arg to yq)\r\n  steps:\r\n    - name: replace-image  # \u7b2c\u4e00\u6b65\u66ff\u6362\u955c\u50cf\r\n      image: mikefarah\/yq  # \u7279\u5b9a\u529f\u80fd\u7684\u955c\u50cf\uff0c\u548cdrone\u540c\u7406\uff0c\u8fd9\u91cc\u4e3b\u8981\u5c31\u662f\u4e2a\u6a21\u677f\u6e32\u67d3\r\n      command: [\"yq\"]\r\n      args:\r\n        - \"w\"\r\n        - \"-i\"\r\n        - \"${inputs.params.yqArg}\"\r\n        - \"${inputs.params.path}\"\r\n        - \"${inputs.params.yamlPathToImage}\"\r\n        - \"${inputs.resources.image.url}\"\r\n    - name: run-kubectl                 # \u7b2c\u4e8c\u6b65\u6267\u884ckubectl\r\n      image: lachlanevenson\/k8s-kubectl\r\n      command: [\"kubectl\"]\r\n      args:\r\n        - \"apply\"\r\n        - \"-f\"\r\n        - \"${inputs.params.path}\"   # \u8fd9\u5c31\u662fyaml\u6587\u4ef6\u7684\u4f4d\u7f6e\r\n<\/pre>\n

\u8981\u8fd0\u884cPipeline\uff0c\u8bf7\u521b\u5efaPipelineRun\u5982\u4e0b\uff1a<\/p>\n

\r\napiVersion: tekton.dev\/v1alpha1\r\nkind: PipelineRun\r\nmetadata:\r\n  name: tutorial-pipeline-run-1\r\nspec:\r\n  pipelineRef:\r\n    name: tutorial-pipeline\r\n  trigger:\r\n    type: manual\r\n  resources:\r\n    - name: source-repo\r\n      resourceRef:\r\n        name: skaffold-git\r\n    - name: web-image\r\n      resourceRef:\r\n        name: skaffold-image-leeroy-web\r\n<\/pre>\n
\u6267\u884c\u4e0e\u67e5\u770bpipeline<\/strong><\/span><\/div>\n
\r\nkubectl apply -f < name-of-file.yaml > kubectl\u83b7\u53d6pipelineruns \/ tutorial-pipeline-run-1 -o yaml\r\n<\/pre>\n
\u603b\u7ed3<\/strong><\/span><\/div>\n

\u521d\u5b66\u8005\u4f1a\u89c9\u5f97\u6709\u70b9\u7ed5\uff0c\u4f46\u662f\u8fd9\u79cd\u8bbe\u8ba1\u4e5f\u662f\u4e3a\u4e86\u89e3\u8026\u5408\uff0c\u6211\u4e2a\u4eba\u89c9\u5f97\u4f18\u52a3\u5982\u4e0b\uff1a<\/p>\n

\u4f18\u52bf<\/strong><\/span><\/div>\n

\u53ef\u4ee5\u628ak8s\u96c6\u7fa4\u4f5c\u4e3a\u4efb\u52a1\u6267\u884c\u5f15\u64ce\uff0c\u8fd9\u6837\u53ef\u4ee5\u66f4\u597d\u7684\u5229\u7528\u8d44\u6e90\uff0c\u6bd4\u5982\u628a\u7ebf\u4e0a\u591c\u95f4\u95f2\u7f6e\u8d44\u6e90\u7528\u6765\u8dd1\u4efb\u52a1\uff0c\u6784\u5efa\u955c\u50cf \u79bb\u7ebf\u5206\u6790 \u751a\u81f3\u673a\u5668\u5b66\u4e60\u3002\u89e3\u8026\u505a\u7684\u6bd4\u8f83\u597d\uff0c\u4efb\u52a1\u6a21\u677f\u53ef\u4ee5\u62ff\u6765\u590d\u7528\uff0c\u800c\u4e0d\u9700\u8981\u5927\u5bb6\u90fd\u53bb\u91cd\u590d\u5b9a\u4e49,\u8f93\u5165\u8f93\u51fa\u7406\u5ff5\uff0c\u4e00\u4e2a\u4efb\u52a1\u7684\u8f93\u5165\u4f5c\u4e3a\u53e6\u4e2a\u4efb\u52a1\u7684\u8f93\u51fa\u4e0d\u9519\u3002<\/p>\n

\u52a3\u52bf<\/strong><\/span><\/div>\n

\u6709\u70b9\u8fc7\u5ea6\u8bbe\u8ba1\uff0c\u4e00\u4e9b\u7b80\u5355\u7684\u573a\u666f\u53ef\u80fd\u89c9\u5f97\u914d\u7f6e\u8d77\u6765\u6709\u70b9\u7ed5\u4e86,\u8f93\u5165\u8f93\u51fa\u4f9d\u8d56\u5206\u5e03\u5f0f\u7cfb\u7edf\uff0c\u5bf9\u6bd4drone\u4e00\u4e2apipeline\u4e2d\u7684\u5bb9\u5668\u662f\u5171\u4eab\u4e86\u4e00\u4e2a\u6570\u636e\u5377\u7684\uff0c\u8fd9\u6837\u4e0a\u4e2a\u4efb\u52a1\u4ea7\u751f\u7684\u6587\u4ef6\u5f88\u65b9\u4fbf\u7684\u7ed9\u4e0b\u4e2a\u4efb\u52a1\u7528\uff0c\u800c\u57fa\u4e8e\u96c6\u7fa4\u7684\u4efb\u52a1\u5c31\u53ef\u80fd\u5f97\u4f9d\u8d56git docker\u955c\u50cf\u4ed3\u5e93\u7b49\u505a\u8f93\u5165\u8f93\u51fa\uff0c\u6709\u70b9\u9ebb\u70e6\uff0c\u597d\u7684\u89e3\u51b3\u529e\u6cd5\u662f\u5229\u7528k8s\u5206\u5e03\u8bd5\u5b58\u50a8\u7ed9pipeline\u8bbe\u7f6e\u4e00\u4e2a\u5171\u4eab\u5377\uff0c\u65b9\u4fbf\u4efb\u52a1\u95f4\u4f20\u8f93\u6570\u636e;\u603b\u4f53\u6765\u8bf4\u8def\u5b50\u662f\u5bf9\u7684\u800c\u4e14\u8fd8\u662f\u6709\u5f88\u591a\u573a\u666f\u53ef\u4ee5\u7528\u7684\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Tekton Pipelines\u7684\u4e3b\u8981\u76ee\u6807\u662f\u5355\u72ec\u8fd0\u884c\u60a8\u7684\u4efb\u52a1\u6216\u4f5c\u4e3a\u7ba1\u9053\u7684\u4e00\u90e8\u5206\u8fd0\u884c\u3002\u6bcf\u4e2a\u4efb\u52a1\u90fd\u5728Kuberne […]<\/p>\n","protected":false},"author":668,"featured_media":87481,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-144553","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/144553","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=144553"}],"version-history":[{"count":6,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/144553\/revisions"}],"predecessor-version":[{"id":144755,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/144553\/revisions\/144755"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/87481"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=144553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=144553"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=144553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}