A simple CI/CD pipeline built with Tekton that clones a Git repo, builds a Dockerfile and uploads the resulting image to a registry.
Install Tekton Core Components
kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
Install Tekton Dashboard
kubectl apply --filename https://github.com/tektoncd/dashboard/releases/latest/download/tekton-dashboard-release.yaml
Assuming tekton-pipelines is the install namespace for the Dashboard, run the following command:
kubectl --namespace tekton-pipelines port-forward svc/tekton-dashboard 9097:9097
Visit http://localhost:9097 to access the Tekton Dashboard.
Clone the project
git clone https://github.com/felipecruz91/tekton-example-2
Go to the project directory
cd tekton-example-2
To run this project in a corporate environment, you will need to configure the proxy settings in two places:
- name: httpsProxy
value: "<YOUR_CORPORATE_PROXY>"
- name: https_proxy
value: "<YOUR_CORPORATE_PROXY>"
You must create a secret to push your image to your desired image registry:
kubectl create secret docker-registry regcred \
--docker-server=<your-registry-server> \
--docker-username=<your-name> \
--docker-password=<your-pword> \
--docker-email=<your-email>
Create the pipeline resources such as the Git repository and the image:
kubectl apply -f pipeline-resources/
Create a service account that uses the regcred
credentials to push the image to your registry:
kubectl apply -f tutorial-serviceaccount.yaml
Create a Task which defines the git input and image output introduced earlier:
kubectl apply -f build-docker-image-from-git-source.yaml
You are now ready for your first TaskRun!
A TaskRun binds the inputs and outputs to already defined PipelineResources, sets values for variable substitution parameters, and executes the Steps in the Task.
kubectl apply -f build-docker-image-from-git-source-task-run.yaml
A Pipeline defines an ordered series of Tasks that you want to execute along with the corresponding inputs and outputs for each Task.
kubectl apply -f tutorial-pipeline.yaml
Finally, run the pipeline:
kubectl apply -f tutorial-pipeline-run-1.yaml