layout | title | date | categories | description | thumbnail | disable_comments | authorbox | toc | mathjax | tags | published | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
post |
Tekton Pipelines |
2019-05-27 |
|
img/placeholder.jpg |
false |
true |
true |
true |
|
true |
In this post, we will go through the basics of Google Tekton and build Tekton pipeline to build container images using Kaniko and publish them to dockerhub. As of now triggering of the build is manual until auto trigger feature is live.
Creating a pipeline for building and publishing Container images.
To start using Tekton, you need to have:
- A GitHub account
- Owner permissions for a project hosted on GitHub.
- Account and Docker Repository in DockerHub.
- Running Kubernetes Environment
Tekton Pipelines is an OpenSource project by Google to Build, Run and Maintain CI/CD pipelines for Kubernetes Apps and provides k8s-style resources declaration for CI/CD-style pipelines. Tekton Pipelines are built using Kubernetes CRD’s, it is based on Operator model.
-
Steps are fundamental blocks of Pipelines. A step is actually an instance of an image and it is Kubernetes container spec. step contains the actual work to be done.
-
Tasks contain a series of steps to be executed in sequential order on the same node, so they can share resources i.e. output/artifacts/parameters of one step to another. Tasks can exist and be invoked completely independently of Pipelines; they are highly cohesive and loosely coupled. Tasks can be invoked via TaskRuns
-
Pipelines lets you put together the tasks, so they can run concurrently/Sequentially. They are not guaranteed to execute on the same node, it depends on K8S’s scheduling of pods. But you can have inputs for one task that come from the output of another task, which is specified in the pipeline. They can be triggered by events or by manually creating PipelineRuns
-
Pipelines and tasks are declared once and they are used again and again. We create TaskRuns and PipelineRuns to invoke Tasks and PipelineRuns.
-
PipelineResources are the artifacts used as inputs and outputs of Tasks.
-
clone
git clone https://github.com/kvenkata986/tekton.git
andcd tekton
-
Install Tekton. This command downloads latest release of tekton and does a
kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.7.0/release.yaml
./install.sh deploy_tekton
-
Create Docker Registry Secret and Service Account
./install.sh docker_registry
-
Now create
PipelineResource
for Github and DockerHub. Here we specify our git repository and Project in DockerHub were images are pushed./install.sh create_PipelineResource
-
Now Create a
Task
which downloads our repo specified in above step from github and using theDockerfile
from the downloaded repo, it builds Image using kaniko../install.sh create_Task
-
Now Create
TaskRun
to run above pipeline./install.sh create_TaskRun