-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a image with `kubectl` installed, we can setup `step` of `task` in tekton to create arbitrary rsource of kubernates.
- Loading branch information
1 parent
058bab1
commit d0db9ea
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Kubectl | ||
|
||
This Task deploys (or delete) a Kubernates resource (pod). It uses | ||
[`kubectl`](https://kubernetes.io/zh/docs/reference/kubectl/kubectl/) for that. | ||
|
||
## Install the Task | ||
|
||
``` | ||
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/kubectl/kubectl-deploy.yaml | ||
``` | ||
|
||
## Install ClusterRolebinding | ||
|
||
``` | ||
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/kubectl/clusterrolebinding.yaml | ||
``` | ||
|
||
## Inputs | ||
|
||
### Parameters | ||
|
||
* **manifest:**: The content of the resource to deploy | ||
|
||
## Usage | ||
|
||
This TaskRun runs the Task to deploy the given Kubernetes resource. | ||
|
||
``` | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: TaskRun | ||
metadata: | ||
name: kubectl-deploy-pod | ||
spec: | ||
taskRef: | ||
name: kubectl-deploy-pod | ||
inputs: | ||
params: | ||
- name: manifest | ||
value: | | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: myapp-pod | ||
labels: | ||
app: myapp | ||
spec: | ||
containers: | ||
- name: myapp-container | ||
image: docker | ||
command: ['sh', '-c', 'echo Hello Kubernetes! && sleep 3600'] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: default-admin | ||
subjects: | ||
- kind: ServiceAccount | ||
name: default | ||
namespace: default | ||
roleRef: | ||
kind: ClusterRole | ||
name: cluster-admin | ||
apiGroup: rbac.authorization.k8s.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: kubectl-deploy-pod | ||
namespace: default | ||
spec: | ||
params: | ||
- name: manifest | ||
description: Content of the resource to deploy | ||
- name: image | ||
default: gcr.io/cloud-builders/kubectl # it is huge | ||
description: Kubectl wrapper image | ||
steps: | ||
- name: kubeconfig | ||
image: $(inputs.params.image) | ||
script: | | ||
echo "$(inputs.params.manifest)" > /tmp/resource.yaml | ||
kubectl create -f /tmp/resource.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: TaskRun | ||
metadata: | ||
name: kubectl-deploy-pod | ||
spec: | ||
taskRef: | ||
name: kubectl-deploy-pod | ||
params: | ||
- name: manifest | ||
value: | | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: myapp-pod | ||
labels: | ||
app: myapp | ||
spec: | ||
containers: | ||
- name: myapp-container | ||
image: docker | ||
command: ['sh', '-c', 'echo Hello Kubernetes! && sleep 3600'] |