-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrated tasks to v1,added release.sh and docs.
- Loading branch information
1 parent
6500222
commit b32445a
Showing
8 changed files
with
190 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# task-openshift | ||
|
||
This repository provides various task related to OpenShift and OpenShift Pipelines. | ||
- [openshift-client](docs/task-openshift-client.md) | ||
- [tkn](docs/task-tkn.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
`OpenShift-Cient` Tekton Task | ||
----------------------- | ||
|
||
# Abstract | ||
|
||
The `openshift-client` Task is the binary for OpenShift CLI that complements kubectl for simplifying deployment and configuration applications on OpenShift. | ||
|
||
# Usage | ||
|
||
Please, consider the usage example below: | ||
|
||
```yaml | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: PipelineRun | ||
metadata: {} | ||
spec: | ||
pipelineRef: | ||
name: task-openshift-client | ||
params: | ||
- name: SCRIPT | ||
value: openShift-CLI-arguments | ||
- name: VERSION | ||
value: oc-version | ||
|
||
``` | ||
You'll need to replace `openShift-CLI-arguments` with OpenShift CLI arguments that you want to run and replace `oc-version` with the version of OpenShift you want to use. | ||
In case the Container Registry requires authentication, please consider the [Tekton Pipelines documentation][tektonPipelineAuth]. In a nutshell, you need to create a Kubernetes Secret describing the following attributes: | ||
|
||
```bash | ||
kubectl create secret docker-registry imagestreams \ | ||
--docker-server="image-registry.openshift-image-registry.svc:5000" \ | ||
--docker-username="${REGISTRY_USERNAME}" \ | ||
--docker-password="${REGISTRY_TOKEN}" | ||
``` | ||
|
||
Then make sure the Secret is linked with the Service-Account running the `TaskRun`/`PipelineRun`. | ||
|
||
## Workspace | ||
|
||
| Name | Optional | Description | | ||
| :------------ | :------------------------: | :--------------------------- | | ||
| `manifest_dir` | `true` | The workspace which contains kubernetes manifests which we want to apply on the cluster. | | ||
| `kubeconfig_dir` | `true` | The workspace which contains the the kubeconfig file if in case we want to run the oc command on another cluster. | | ||
|
||
|
||
## Params | ||
|
||
| Param | Type | Default | Description | | ||
| :------------ | :------------------------: | :--------------------------- | :------------------------- | | ||
| `SCRIPT` | `string` | (required) | The OpenShift CLI arguments to run | | ||
| `VERSION` | `string` | (required) | The OpenShift version to use | | ||
|
||
|
||
|
||
[tektonPipelineAuth]: https://tekton.dev/docs/pipelines/auth/#configuring-docker-authentication-for-docker | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
`Tkn` Tekton Task | ||
----------------------- | ||
|
||
# Abstract | ||
|
||
The `tkn` Task is a binary to perform operations on Tekton resources using tkn. | ||
|
||
# Usage | ||
|
||
Please, consider the usage example below: | ||
|
||
```yaml | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: PipelineRun | ||
metadata: {} | ||
spec: | ||
pipelineRef: | ||
name: task-tkn | ||
params: | ||
- name: SCRIPT | ||
value: "tkn $@" | ||
- name: ARGS | ||
value: tkn-command-you-want-to-execute | ||
|
||
``` | ||
You'll need to replace `tkn-command-you-want-to-execute` with tkn CLI arguments based on what operation you want to perform on the Tekton resources. | ||
In case the Container Registry requires authentication, please consider the [Tekton Pipelines documentation][tektonPipelineAuth]. In a nutshell, you need to create a Kubernetes Secret describing the following attributes: | ||
|
||
```bash | ||
kubectl create secret docker-registry imagestreams \ | ||
--docker-server="image-registry.openshift-image-registry.svc:5000" \ | ||
--docker-username="${REGISTRY_USERNAME}" \ | ||
--docker-password="${REGISTRY_TOKEN}" | ||
``` | ||
|
||
Then make sure the Secret is linked with the Service-Account running the `TaskRun`/`PipelineRun`. | ||
|
||
## Workspace | ||
|
||
| Name | Optional | Description | | ||
| :------------ | :------------------------: | :--------------------------- | | ||
| `kubeconfig_dir` | `true` | An optional workspace that allows you to provide a .kube/config file for tkn to access the cluster. | | ||
|
||
|
||
## Params | ||
|
||
| Param | Type | Default | Description | | ||
| :------------ | :------------------------: | :--------------------------- | :------------------------- | | ||
| `SCRIPT` | `string` | (required) | tkn CLI script to execute | | ||
| `ARGS` | `array` | (required) | tkn CLI arguments to run | | ||
|
||
|
||
|
||
[tektonPipelineAuth]: https://tekton.dev/docs/pipelines/auth/#configuring-docker-authentication-for-docker | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Renders and copies documentation files into the informed RELEASE_DIR, the script search for | ||
# task templates on a specific glob expression. The templates are rendered using the actual | ||
# task name and documentation is searched for and copied over to the task release directory. | ||
# | ||
|
||
shopt -s inherit_errexit | ||
set -eu -o pipefail | ||
|
||
readonly RELEASE_DIR="${1:-}" | ||
|
||
# Print error message and exit non-successfully. | ||
panic() { | ||
echo "# ERROR: ${*}" | ||
exit 1 | ||
} | ||
|
||
# Extracts the filename only, without path or extension. | ||
extract_name() { | ||
declare filename=$(basename -- "${1}") | ||
declare extension="${filename##*.}" | ||
echo "${filename%.*}" | ||
} | ||
|
||
# Finds the respective documentation for the task name | ||
find_doc() { | ||
declare task_name="${1}" | ||
find docs/ -name "${task_name}*.md" | ||
} | ||
|
||
# | ||
# Main | ||
# | ||
|
||
release() { | ||
# making sure the release directory exists, this script should only create releative | ||
# directories using it as root | ||
[[ ! -d "${RELEASE_DIR}" ]] && | ||
panic "Release dir is not found '${RELEASE_DIR}'!" | ||
|
||
# releasing all task templates using the following glob expression | ||
for t in $(ls -1 templates/task-*.yaml); do | ||
declare task_name=$(extract_name ${t}) | ||
[[ -z "${task_name}" ]] && | ||
panic "Unable to extract Task name from '${t}'!" | ||
|
||
declare task_doc="$(find_doc ${task_name})" | ||
[[ -z "${task_doc}" ]] && | ||
panic "Unable to find documentation file for '${task_name}'!" | ||
|
||
declare task_dir="${RELEASE_DIR}/tasks/${task_name}" | ||
[[ ! -d "${task_dir}" ]] && | ||
mkdir -p "${task_dir}" | ||
|
||
# rendering the helm template for the specific file, using the resource name for the | ||
# filename respectively | ||
echo "# Rendering '${task_name}' at '${task_dir}'..." | ||
helm template --show-only=${t} . >${task_dir}/${task_name}.yaml || | ||
panic "Unable to render '${t}'!" | ||
|
||
# finds the respective documentation file copying as "README.md", on the same | ||
# directory where the respective task is located | ||
echo "# Copying '${task_name}' documentation file '${task_doc}'..." | ||
cp -v -f ${task_doc} "${task_dir}/README.md" || | ||
panic "Unable to copy '${task_doc}' into '${task_dir}'" | ||
done | ||
} | ||
|
||
release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
apiVersion: tekton.dev/v1 | ||
kind: Pipeline | ||
metadata: | ||
labels: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
apiVersion: tekton.dev/v1 | ||
kind: Pipeline | ||
metadata: | ||
labels: | ||
|