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:
parent
a46dff4fbf
commit
e5acd27642
13
openshift-cli/Dockerfile
Normal file
13
openshift-cli/Dockerfile
Normal 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"]
|
30
openshift-cli/taskUsingClusterResource/octaskresource.yaml
Normal file
30
openshift-cli/taskUsingClusterResource/octaskresource.yaml
Normal 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"]
|
@ -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
|
17
openshift-cli/taskUsingClusterResource/resource.yaml
Normal file
17
openshift-cli/taskUsingClusterResource/resource.yaml
Normal 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
|
22
openshift-cli/taskUsingServiceaccount/octask.yaml
Normal file
22
openshift-cli/taskUsingServiceaccount/octask.yaml
Normal 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"]
|
9
openshift-cli/taskUsingServiceaccount/octaskrun.yaml
Normal file
9
openshift-cli/taskUsingServiceaccount/octaskrun.yaml
Normal 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
|
9
openshift-cli/taskUsingServiceaccount/role.yaml
Normal file
9
openshift-cli/taskUsingServiceaccount/role.yaml
Normal 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"]
|
13
openshift-cli/taskUsingServiceaccount/rolebinding.yaml
Normal file
13
openshift-cli/taskUsingServiceaccount/rolebinding.yaml
Normal 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
|
@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: user
|
||||
namespace: default
|
Loading…
Reference in New Issue
Block a user