Skip to content
Yi Wang edited this page Dec 23, 2019 · 2 revisions

fluid

fluid is a transpiler that converts a Python program into a YAML file representing a workflow that can be executed by Tekton Pipelines.

fluid accepts a subset of Python syntax, namely, function definitions and function invocations. A comprehensive understandign of fluid is an Python compiler that outputs Kubernetes-native programs.

Concepts

Tekton Pipelines is a Kubernetes-native workflow engine. When we say Kubernetes-native, we mean that users could submit workflow YAML using the official Kubernetes client kubectl, and any Kubernetes cluster with Tekton Pipelines installed could understand the content of these YAML files.

Kuberenetes Objects

Kubernetes understands YAML files that define Kubernetes objects. Each Kubernetes object includes the following required fields.

  • apiVersion - Which version of the Kubernetes API you’re using to create this object.
  • kind - What kind of object you want to create.
  • metadata - Data that helps uniquely identify the object, including a name string, UID, and optional namespace.
  • spec - What state you desire for the object.

NOTE: Kubernetes objects is also known as Kubernetes resource.

Tekton Pipelines Objects

According to the official document, with Tekton Piplines installed, a Kubernetes cluster could understand the following kinds of Kubernetes objects.

The value of apiVersion of all Tekton Pipelines objects is tekton.dev/v1alpha1. The value of kind is one of the above. The value of metadata and spec depends on the kind.

Task

According to the definition, a Task looks like a a function definition. It consists of

  • inputs, like parameters of a function,
  • outputs, like return values of a funciton, and
  • steps, compose the function body.

The function name is specified in the the field name under metadata.

The following Task object defines a non-working Task/function example-task-name, which takes two inputs, workspace and pathToDockerFile, and a return value, builtImage. The first input is a resource, and the second is a string-typed parameters. A resource can be considered a special kind of function parameter. A parameter has name, type, descriptoin, and default value. The return value has type image, which means a Docker image.

apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: example-task-name
spec:
  inputs:
    resources:
      - name: workspace
        type: git
    params:
      - name: pathToDockerFile
        type: string
        description: The path to the dockerfile to build
        default: /workspace/workspace/Dockerfile
  outputs:
    resources:
      - name: builtImage
        type: image
  steps:
    - name: ubuntu-example
      image: ubuntu
      args: ["ubuntu-build-example", "SECRETS-example.md"]
    - image: gcr.io/example-builders/build-example
      command: ["echo"]
      args: ["$(inputs.params.pathToDockerFile)"]
    - name: dockerfile-pushexample
      image: gcr.io/example-builders/push-example
      args: ["push", "$(outputs.resources.builtImage.url)"]
      volumeMounts:
        - name: docker-socket-example
          mountPath: /var/run/docker.sock
  volumes:
    - name: example-volume
      emptyDir: {}

The Task, or, function example-task-name, consists of three steps. Each step runs a container.

Clone this wiki locally