Przeglądaj źródła

Merge pull request #231 from ChristianLempa:kestra_boilerplates_init

Kestra_boilerplates_init
Christian Lempa 1 rok temu
rodzic
commit
4bf1d0e7fd

+ 38 - 0
kestra/docker/file-build.yaml

@@ -0,0 +1,38 @@
+# Kestra Docker File Build Template
+# ---
+# 
+# Build a Docker image from a File.
+#
+
+id: docker-file-build
+namespace: # your-namespace
+
+tasks:
+
+  - id: file
+    type: io.kestra.core.tasks.flows.WorkingDirectory
+    tasks:
+      - id: createFiles
+        type: io.kestra.core.tasks.storages.LocalFiles
+        inputs:
+          Dockerfile: |
+            FROM alpine:latest
+            WORKDIR /app
+            COPY . /app
+            RUN apk add --update python3
+            CMD [ "python", "main.py"]
+          main.py: |
+            if __name__ == "__main__":
+              print("Hello from Docker!")
+              exit(0)
+
+      - id: build
+        type: io.kestra.plugin.docker.Build
+        dockerfile: "src/Dockerfile"
+        tags: 
+          - your-username/your-repository:your-tag
+        push: true
+        credentials:
+          registry: https://index.docker.io/v1/
+          username: "{{ secret('YOUR_USERNAME') }}"
+          password: "{{ secret('YOUR_PASSWORD') }}"

+ 29 - 0
kestra/docker/git-build.yaml

@@ -0,0 +1,29 @@
+# Kestra Docker Git Build Template
+# ---
+# 
+# Build a Docker image from a Git repository.
+#
+
+id: docker-git-build
+namespace: # your-namespace
+
+tasks:
+
+  - id: git
+    type: io.kestra.core.tasks.flows.WorkingDirectory
+    tasks:
+      - id: clone
+        type: io.kestra.plugin.git.Clone
+        url: https://your-git-repo-url
+        branch: your-branch
+
+      - id: build
+        type: io.kestra.plugin.docker.Build
+        dockerfile: "src/Dockerfile"
+        tags: 
+          - your-username/your-repository:your-tag
+        push: true
+        credentials:
+          registry: https://index.docker.io/v1/
+          username: "{{ secret('YOUR_USERNAME') }}"
+          password: "{{ secret('YOUR_PASSWORD') }}"

+ 64 - 0
kestra/inputs.yaml

@@ -0,0 +1,64 @@
+# Kestra Inputs Template
+# ---
+# 
+# Inputs is a list of dynamic values passed to the flow at runtime. 
+# 
+
+id: inputs
+namespace: # your-namespace
+
+inputs:
+  - id: string
+    type: STRING
+
+  - id: optional
+    type: STRING
+    required: false
+
+  - id: int
+    type: INT
+
+  - id: bool
+    type: BOOLEAN
+
+  - id: float
+    type: FLOAT
+
+  - id: instant
+    type: DATETIME
+
+  - id: date
+    type: DATE
+
+  - id: time
+    type: TIME
+
+  - id: duration
+    type: DURATION
+
+  - id: file
+    type: FILE
+
+  - id: optionalFile
+    type: FILE
+
+  - id: instantDefaults
+    type: DATETIME
+    defaults: "2013-08-09T14:19:00Z"
+
+  - id: json
+    type: JSON
+
+  - id: uri
+    type: URI
+
+  - id: secret
+    type: SECRET
+
+  - id: nested.string
+    type: STRING
+
+tasks:
+  - id: using_inputs
+    type: io.kestra.core.tasks.log.Log
+    message: "{{ inputs.string }}"

+ 19 - 0
kestra/python/command.yaml

@@ -0,0 +1,19 @@
+# Kestra Python Command Template
+# ---
+# 
+# This template is a simple Python script.
+# 
+# usage:
+#   make sure the Kestra instance can access the /app/scripts/your-python-script.py file
+#   if you're running Kestra in Docker, use a volume to mount the file/directory.
+
+id: python-command
+namespace: # your-namespace
+
+tasks:
+
+  - id: python_command
+    type: io.kestra.plugin.scripts.python.Commands
+    commands:
+      - python /app/scripts/your-python-script.py
+    runner: PROCESS  # or DOCKER (might be deprecated in the future) use TaskRunner instead

+ 28 - 0
kestra/python/script.yaml

@@ -0,0 +1,28 @@
+# Kestra Python Command Template
+# ---
+# 
+# This template is a simple Python script that can be used to make a request to a website and log the status code.
+# 
+
+id: python-script
+namespace: # your-namespace
+
+tasks:
+
+  - id: python_script
+    type: io.kestra.plugin.scripts.python.Script
+    runner: DOCKER  # (might be deprecated in the future) use TaskRunner instead
+    script: |
+        from kestra import Kestra
+        import requests
+        
+        response = requests.get('{{inputs.website}}')
+        print(response.status_code)
+        
+        Kestra.outputs({'status': response.status_code, 'text': response.text})
+    beforeCommands:
+      - pip install requests kestra
+
+  - id: log
+    type: io.kestra.core.tasks.log.Log
+    message: "StatusCode: {{outputs.pythonscript.vars.status}}"

+ 16 - 0
kestra/variables.yaml

@@ -0,0 +1,16 @@
+# Kestra Variable Template
+# ---
+# 
+# 
+#
+
+id: variables
+namespace: # your-namespace
+
+variables:
+  variable-name: "variable-value"
+
+tasks:
+  - id: using_variables
+    type: io.kestra.core.tasks.log.Log
+    message: "{{ vars.variable-name }}"

+ 18 - 0
kestra/webhook.yaml

@@ -0,0 +1,18 @@
+# Kestra Webhook Template
+# ---
+# 
+# This template is a simple webhook trigger that can be used to trigger a task execution.
+# 
+# usage:
+#   curl http://your-kestra-instance/api/v1/executions/webhook/your-namespace/your-task-id/your-secret-key
+
+id: webhook
+namespace: # your-namespace
+
+tasks:
+  # your-tasks
+
+triggers:
+  - id: webhook
+    type: io.kestra.core.models.triggers.types.Webhook
+    key: # your-secret-key, keep this secret!