1
0
mirror of https://github.com/tektoncd/catalog.git synced 2024-11-21 05:55:35 +00:00

Add examples for using oc

This will add examples of using oc binary in task
It will add a dockerfile of oc binary and two
examples

1. Using oc on same cluster using serviceAccount
2. Using oc on different cluster using clusterResource

Thanks
This commit is contained in:
Piyush Garg 2019-04-26 16:39:34 +05:30 committed by tekton-robot
parent a46dff4fbf
commit e5acd27642
9 changed files with 130 additions and 0 deletions

13
openshift-cli/Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM docker.io/centos:7
RUN cd /tmp \
&& yum -y update \
&& yum install -y wget \
&& wget https://mirror.openshift.com/pub/openshift-v3/clients/4.0.22/linux/oc.tar.gz \
&& tar -xvzf oc.tar.gz \
&& mv oc /usr/local/bin/ \
&& rm -rf oc.tar.gz
ENTRYPOINT ["oc"]
CMD ["help"]

View File

@ -0,0 +1,30 @@
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: task-openshift-command-clusterresource
spec:
inputs:
resources:
- name: clusterdetails
type: cluster
steps:
- name: version
image: quay.io/openshift-pipeline/openshift-cli
command:
- /usr/local/bin/oc
args: ["--kubeconfig", "/workspace/${inputs.resources.clusterdetails.name}/kubeconfig", "--context", "${inputs.resources.clusterdetails.name}", "version"]
- name: pods
image: quay.io/openshift-pipeline/openshift-cli
command:
- /usr/local/bin/oc
args: ["--kubeconfig", "/workspace/${inputs.resources.clusterdetails.name}/kubeconfig", "--context", "${inputs.resources.clusterdetails.name}", "get", "pods"]
- name: user
image: quay.io/openshift-pipeline/openshift-cli
command:
- /usr/local/bin/oc
args: ["--kubeconfig", "/workspace/${inputs.resources.clusterdetails.name}/kubeconfig", "--context", "${inputs.resources.clusterdetails.name}", "whoami"]
- name: status
image: quay.io/openshift-pipeline/openshift-cli
command:
- /usr/local/bin/oc
args: ["--kubeconfig", "/workspace/${inputs.resources.clusterdetails.name}/kubeconfig", "--context", "${inputs.resources.clusterdetails.name}", "status"]

View File

@ -0,0 +1,12 @@
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: task-run-openshift-command-clusterresource
spec:
taskRef:
name: task-openshift-command-clusterresource
inputs:
resources:
- name: clusterdetails
resourceRef:
name: cluster-details

View File

@ -0,0 +1,17 @@
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: cluster-details
spec:
type: cluster
params:
- name: url
value: https://api.com
- name: name
value: oc-test
- name: username
value: test
- name: token
value: akakkakaaa
- name: cadata
value: data

View File

@ -0,0 +1,22 @@
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: task-openshift-command
namespace: default
spec:
steps:
- name: version
image: quay.io/openshift-pipeline/openshift-cli
command:
- /usr/local/bin/oc
args: ["version"]
- name: user
image: quay.io/openshift-pipeline/openshift-cli
command:
- /usr/local/bin/oc
args: ["whoami"]
- name: pods
image: quay.io/openshift-pipeline/openshift-cli
command:
- /usr/local/bin/oc
args: ["get", "pods"]

View File

@ -0,0 +1,9 @@
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: task-run-openshift-command
namespace: default
spec:
serviceAccount: user
taskRef:
name: task-openshift-command

View File

@ -0,0 +1,9 @@
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: default
name: get-pod-role
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get"]

View File

@ -0,0 +1,13 @@
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: get-pod-role-binding
namespace: default
subjects:
- kind: ServiceAccount
name: user
namespace: default
roleRef:
kind: Role
name: get-pod-role
apiGroup: rbac.authorization.k8s.io

View File

@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: user
namespace: default