diff --git a/openshift-cli/Dockerfile b/openshift-cli/Dockerfile new file mode 100644 index 00000000..a5568caf --- /dev/null +++ b/openshift-cli/Dockerfile @@ -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"] diff --git a/openshift-cli/taskUsingClusterResource/octaskresource.yaml b/openshift-cli/taskUsingClusterResource/octaskresource.yaml new file mode 100644 index 00000000..25f7855e --- /dev/null +++ b/openshift-cli/taskUsingClusterResource/octaskresource.yaml @@ -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"] diff --git a/openshift-cli/taskUsingClusterResource/octaskrunresource.yaml b/openshift-cli/taskUsingClusterResource/octaskrunresource.yaml new file mode 100644 index 00000000..ca2712e7 --- /dev/null +++ b/openshift-cli/taskUsingClusterResource/octaskrunresource.yaml @@ -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 diff --git a/openshift-cli/taskUsingClusterResource/resource.yaml b/openshift-cli/taskUsingClusterResource/resource.yaml new file mode 100644 index 00000000..bf4467d9 --- /dev/null +++ b/openshift-cli/taskUsingClusterResource/resource.yaml @@ -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 \ No newline at end of file diff --git a/openshift-cli/taskUsingServiceaccount/octask.yaml b/openshift-cli/taskUsingServiceaccount/octask.yaml new file mode 100644 index 00000000..edc69c64 --- /dev/null +++ b/openshift-cli/taskUsingServiceaccount/octask.yaml @@ -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"] \ No newline at end of file diff --git a/openshift-cli/taskUsingServiceaccount/octaskrun.yaml b/openshift-cli/taskUsingServiceaccount/octaskrun.yaml new file mode 100644 index 00000000..2a134679 --- /dev/null +++ b/openshift-cli/taskUsingServiceaccount/octaskrun.yaml @@ -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 diff --git a/openshift-cli/taskUsingServiceaccount/role.yaml b/openshift-cli/taskUsingServiceaccount/role.yaml new file mode 100644 index 00000000..6dee1e11 --- /dev/null +++ b/openshift-cli/taskUsingServiceaccount/role.yaml @@ -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"] \ No newline at end of file diff --git a/openshift-cli/taskUsingServiceaccount/rolebinding.yaml b/openshift-cli/taskUsingServiceaccount/rolebinding.yaml new file mode 100644 index 00000000..87be4332 --- /dev/null +++ b/openshift-cli/taskUsingServiceaccount/rolebinding.yaml @@ -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 \ No newline at end of file diff --git a/openshift-cli/taskUsingServiceaccount/serviceaccount.yaml b/openshift-cli/taskUsingServiceaccount/serviceaccount.yaml new file mode 100644 index 00000000..6830d588 --- /dev/null +++ b/openshift-cli/taskUsingServiceaccount/serviceaccount.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: user + namespace: default \ No newline at end of file