forked from openshift-pipelines/task-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
task-oc.yaml
88 lines (80 loc) · 4.66 KB
/
task-oc.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
# Source: task-oc/templates/task-openshift-client.yaml
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: openshift-client
labels:
app.kubernetes.io/version: 0.0.1
annotations:
tekton.dev/displayName: openshift client
tekton.dev/pipelines.minVersion: 0.17.0
tekton.dev/tags: cli
spec:
description: >-
This task runs commands against the cluster provided by user
and if not provided then where the Task is being executed.
OpenShift is a Kubernetes distribution from Red Hat which provides oc,
the OpenShift CLI that complements kubectl for simplifying deployment
and configuration applications on OpenShift.
workspaces:
- name: manifest_dir
optional: true
description: >-
The workspace which contains kubernetes manifests which we want to apply on the cluster.
- name: kubeconfig_dir
optional: true
description: >-
The workspace which contains the the kubeconfig file if in case we want to run the oc command on another cluster.
params:
- name: SCRIPT
description: The OpenShift CLI arguments to run
type: string
default: "oc help"
- name: VERSION
description: The OpenShift Version to use
type: string
default: "latest"
stepTemplate:
env:
- name: PARAMS_SCRIPT
value: "$(params.SCRIPT)"
- name: PARAMS_VERSION
value: "$(params.VERSION)"
- name: WORKSPACES_MANIFEST_DIR_BOUND
value: "$(workspaces.manifest_dir.bound)"
- name: WORKSPACES_MANIFEST_DIR_PATH
value: "$(workspaces.manifest_dir.path)"
- name: WORKSPACES_KUBECONFIG_DIR_BOUND
value: "$(workspaces.kubeconfig_dir.bound)"
- name: WORKSPACES_KUBECONFIG_DIR_PATH
value: "$(workspaces.kubeconfig_dir.path)"
steps:
- name: load-scripts
image: registry.access.redhat.com/ubi8-minimal:latest
workingDir: /scripts
script: |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TSU9OCg==" |base64 -d >oc-common.sh
chmod +x oc-*.sh
volumeMounts:
- name: scripts-dir
mountPath: /scripts
- name: oc
image: registry.redhat.io/openshift4/ose-cli@sha256:3d5b31cc3fbf878015e5c3ed1d48379d74b15b77a1a823024a7a2b7cd5e2e86d
env:
- name: HOME
value: /tekton/home
command:
- /scripts/oc-client.sh
securityContext:
runAsNonRoot: true
runAsUser: 65532
volumeMounts:
- name: scripts-dir
mountPath: /scripts
volumes:
- name: scripts-dir
emptyDir: {}