mirror of
https://github.com/tektoncd/catalog.git
synced 2024-11-22 06:02:51 +00:00
457f4ef2a2
The task `kubectl-actions` is a generic task which can be used to perform k8s-actions. We take the whole script as a `params` whereas the existing task `kubectl-deploy` only works for deploying the pod and fulfills the specific criteria. Signed-off-by: vinamra28 <vinjain@redhat.com> |
||
---|---|---|
.. | ||
samples | ||
kubernetes-actions.yaml | ||
README.md |
kubernetes actions
This is a generic task used to perform kubernetes actions such as kubectl get deployment
or kubectl create -f filename.yaml
. For more commands see.
Install the task
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/task/kubernetes-actions/0.1/kubernetes-actions.yaml
Inputs
Parameters
- script: script of
kubectl
commands to execute e.g.kubectl get pod $1 -0 yaml
. This will take the first value of ARGS as pod name (default:kubectl $@
) - args: args to execute which are appended to
kubectl
e.g.start-build myapp
(default:help
) - image: Default image being
gcr.io/cloud-builders/kubectl
. If somebody wants to use their own image then they can provide it as a part of params. For example an image avilable islachlanevenson/k8s-kubectl
Workspaces
- kubeconfig-dir: If you want to deploy you application to another cluster then you can mount your
kubeconfig
file via thisworkspace
. (Default: emptyDir:{} in casekubeconfig
is not mounted) - manifest-dir: Manifest files can be provided via the workspaces.(Default: emptyDir:{} in case no manifest is provided)
Usage
In case no manifests are mounted
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: kubectl-run
spec:
taskRef:
name: kubectl-actions
params:
- name: SCRIPT
value: |
kubectl get pods
echo "-----------"
kubectl get deploy
workspaces:
- name: kubeconfig-dir
emptyDir: {}
- name: manifest-dir
emptyDir: {}
In case manifest is present on GitHub
:
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: kubectl-run
spec:
taskRef:
name: kubectl-actions
params:
- name: script
value: |
kubectl apply -f https://raw.githubusercontent.com/vinamra28/social-client/master/k8s/deployment.yaml
----------
kubectl get deployment
workspaces:
- name: kubeconfig-dir
emptyDir: {}
- name: manifest-dir
emptyDir: {}
Kubectl Patch Deployment Image Example
If you have existing deployment and after period of time image of the application is being updated. So to update the container image in the deployment, this task can be used as this task will patch the image with the new image in the existing deployment. The TaskRun for this scenario can be found here