Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Tentang Tasks
Berbeda dengan Aplikasi (proses yang berjalan lama), Tugas berjalan selama jangka waktu tertentu, lalu berhenti. Tugas berjalan di penampungnya sendiri berdasarkan konfigurasi di Aplikasi induk, dan dapat dikonfigurasi untuk menggunakan resource terbatas (misalnya, penyimpanan disk CPU/memori/ephemeral).
Kasus Penggunaan untuk Tugas
Memigrasikan database
Menjalankan tugas batch (terjadwal/tidak terjadwal)
Mengirim email
Mentransformasi data (ETL)
Memproses data (upload/pencadangan/download)
Cara kerja Tasks
Tugas dieksekusi secara asinkron dan berjalan secara independen dari Aplikasi induk atau Tugas lain yang berjalan di Aplikasi yang sama. Aplikasi yang dibuat untuk menjalankan Tugas tidak memiliki rute yang dibuat atau ditetapkan, dan siklus proses Run dilewati. Siklus proses Upload kode sumber dan Build masih berlanjut dan menghasilkan image container yang digunakan untuk menjalankan Tugas setelah mendorong Aplikasi (lihat Siklus proses aplikasi di Men-deploy Aplikasi).
Siklus proses Tugas adalah sebagai berikut:
Anda mendorong Aplikasi untuk menjalankan tugas dengan perintah kf push APP_NAME --task.
Anda menjalankan Tugas di Aplikasi dengan perintah kf run-task APP_NAME. Tugas mewarisi variabel lingkungan, binding layanan, alokasi resource, perintah pengaktifan, dan grup keamanan yang terikat ke Aplikasi.
Kf membuat PipelineRun Tekton dengan nilai dari Aplikasi dan parameter dari perintah run-task.
Tekton PipelineRun membuat Pod Kubernetes yang meluncurkan penampung berdasarkan konfigurasi di Aplikasi dan Tugas.
Eksekusi tugas berhenti (Tugas keluar atau dihentikan secara manual), Pod yang mendasarinya dihentikan atau dihentikan. Pod Tugas yang dihentikan akan dipertahankan sehingga log Tugas dapat diakses melalui perintah kf logs APP_NAME --task.
Jika Anda menghentikan Tugas sebelum berhenti, Tekton PipelineRun akan dibatalkan (lihat Membatalkan PipelineRun), Pod yang mendasarinya beserta log akan dihapus. Log Tugas yang dihentikan dikirim ke aliran logging level cluster jika dikonfigurasi (misalnya, Stackdriver, Fluentd).
Jika jumlah Tugas yang berjalan di Aplikasi lebih dari 500, Tugas terlama akan otomatis dihapus.
Kebijakan Retensi Tugas
Tugas dibuat sebagai resource kustom di cluster Kubernetes. Oleh karena itu, penting untuk tidak menghabiskan ruang database etcd yang mendasarinya. Secara default, Kf hanya menyimpan 500 Tugas terbaru per Aplikasi. Setelah jumlah Tugas mencapai 500, Tugas terlama (beserta Pod dan log yang mendasarinya) akan otomatis dihapus.
Logging Tugas dan Histori Eksekusi
Semua data atau pesan yang dihasilkan Tugas ke STDOUT atau STDERR tersedia dengan menggunakan perintah kf logs APP_NAME --task. Mekanisme logging level cluster (seperti Stackdriver, Fluentd) akan mengirimkan log Tugas ke tujuan logging yang dikonfigurasi.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-04 UTC."],[],[],null,["# Tasks\n\nAbout Tasks\n-----------\n\nIn contrast to Apps (long-running processes), Tasks run for a finite amount of time and then stops. Tasks run in their own containers based on configuration on the parent App, and it could be configured to use limited resources (e.g. CPU/memory/ephermeral disk storage).\n\nUse Cases for Tasks\n-------------------\n\n- Migrating a database\n- Running a batch job (scheduled/unscheduled)\n- Sending an email\n- Transforming data (ETL)\n- Processing data (upload/backup/download)\n\nHow Tasks work\n--------------\n\nTasks are executed asynchronously and run independently from the parent App or other Tasks running on the same App. An App created for running Tasks does not have routes created or assigned, and the **Run** lifecycle is skipped. The **Source code upload** and **Build** lifecycles still proceed and result in a container image used for running Tasks after pushing the App (see App lifecycles at [Deploying an Application](../how-to/deploying-an-app)).\n\nThe lifecycle of a Task is as follows:\n\n1. You push an App for running tasks with the `kf push APP_NAME --task` command.\n2. You run a Task on the App with the `kf run-task APP_NAME` command. Task inherits the environment variables, service bindings, resource allocation, start-up command, and security groups bound to the App.\n3. Kf creates a Tekton [PipelineRun](https://github.com/tektoncd/pipeline/blob/master/docs/pipelineruns.md) with values from the App and parameters from the `run-task` command.\n4. The Tekton PipelineRun creates a Kubernetes Pod which launches a container based on the configurations on the App and Task.\n5. Task execution stops (Task exits or is terminated manually), the underlying Pod is either stopped or terminated. Pods of stopped Tasks are preserved and thus Task logs are accessible via the `kf logs APP_NAME --task` command.\n6. If you terminate a Task before it stops, the Tekton PipelineRun is cancelled (see [Cancelling a PipelineRun](https://github.com/tektoncd/pipeline/blob/master/docs/pipelineruns.md#cancelling-a-pipelinerun)), the underlying Pod together with the logs are deleted. The logs of termianted Tasks are delivered to the cluster level logging streams if configured (e.g. Stackdriver, Fluentd).\n7. If the number of Tasks run on an App is greater than 500, the oldest Tasks are automatically deleted.\n\nTasks Retention Policy\n----------------------\n\nTasks are created as custom resources in the Kubernetes cluster, therefore, it is important not to exhaust the space of the underlying `etcd` database. By default, Kf only keeps the latest 500 Tasks per each App. Once the number of Tasks reach 500, the oldest Tasks (together with the underlying Pods and logs) will be automatically deleted.\n\nTask Logging and Execution History\n----------------------------------\n\nAny data or messages the Task outputs to STDOUT or STDERR is available by using the `kf logs APP_NAME --task` command. Cluster level logging mechanism (such as Stackdriver, Fluentd) will deliver the Task logs to the configured logging destination."]]