From f7be0d4872c75990637d98b38092a6a670974286 Mon Sep 17 00:00:00 2001 From: pratap0007 Date: Fri, 3 Jul 2020 18:31:24 +0530 Subject: [PATCH] This patch splits openshift-client task from the openshift-client directory Changes include: - moves the openshift-client task to the task directory - copies and modifies readme file for openshift-client task from openshift-client directory - copies OWNERS file from openshift-client directory - changes the yaml filename to match the resource name Issue: #386 Signed-off-by: Shiv Verma --- task/openshift-client/0.1/OWNERS | 7 +++ task/openshift-client/0.1/README.md | 53 +++++++++++++++++++ .../0.1/openshift-client.yaml | 0 3 files changed, 60 insertions(+) create mode 100644 task/openshift-client/0.1/OWNERS create mode 100644 task/openshift-client/0.1/README.md rename openshift-client/openshift-client-task.yaml => task/openshift-client/0.1/openshift-client.yaml (100%) diff --git a/task/openshift-client/0.1/OWNERS b/task/openshift-client/0.1/OWNERS new file mode 100644 index 00000000..6dc2cbf5 --- /dev/null +++ b/task/openshift-client/0.1/OWNERS @@ -0,0 +1,7 @@ +approvers: +- vdemeester +- piyush-garg +reviewers: +- vdemeester +- piyush-garg +- chmouel diff --git a/task/openshift-client/0.1/README.md b/task/openshift-client/0.1/README.md new file mode 100644 index 00000000..54d80b86 --- /dev/null +++ b/task/openshift-client/0.1/README.md @@ -0,0 +1,53 @@ +## OpenShift Client Task + +[OpenShift](http://www.openshift.com) is a Kubernetes distribution from Red Hat which provides `oc`, the [OpenShift CLI](https://docs.openshift.com/container-platform/4.1/cli_reference/getting-started-cli.html) that complements `kubectl` for simplifying deployment and configuration applications on OpenShift. + +Openshift-client runs commands against the cluster where the task run is being executed + + +## Install the Task +``` +kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/task/openshift-client/0.1/openshift-client.yaml +``` + +## Parameters + +* **ARGS:** args to execute which are appended to `oc` e.g. `start-build myapp` (_default_: `help`) + +* **SCRIPT:** script of oc commands to execute e.g. `oc get pod $1 -0 yaml` This will take the first value of ARGS as pod name (_default_: `oc $@`) + + +## Resources + +### Inputs + +* **cluster**: a `cluster`-type `PipelineResource` specifying the target OpenShift cluster to execute the commands against it + +## ServiceAccount + +If you don't specify a service account to be used for running the `TaskRun` or `PipelineRun`, the `default` [service account](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#use-the-default-service-account-to-access-the-api-server). OpenShift by default does not allow the default service account to modify objects in the namespace. Therefore you should either explicitly grant permission to the default service account (by creating rolebindings) or [create a new service account with sufficient privileges](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#service-account-permissions) and specify it on the [`TaskRun`](https://github.com/tektoncd/pipeline/blob/master/docs/taskruns.md#service-account) or [`PipelineRun`](https://github.com/tektoncd/pipeline/blob/master/docs/pipelineruns.md#service-account). + +You can do the former via `oc` and running the following command, replacing `` with your target namespace: +``` +oc policy add-role-to-user edit -z default -n +``` + +## Usage + +This `TaskRun` runs an `oc rollout` command to deploy the latest image version for `myapp` on OpenShift. + +``` +apiVersion: tekton.dev/v1beta1 +kind: TaskRun +metadata: + name: deploy-myapp +spec: + taskRef: + name: openshift-client + params: + - name: ARGS + value: + - "rollout" + - "latest" + - "myapp" +``` diff --git a/openshift-client/openshift-client-task.yaml b/task/openshift-client/0.1/openshift-client.yaml similarity index 100% rename from openshift-client/openshift-client-task.yaml rename to task/openshift-client/0.1/openshift-client.yaml