Workflow-relevant resources in workflow clusters are periodically deleted. To analyze and trace the history of workflows, you can configure a persistence policy to persist workloads to a database. This way, you can view workflow logs even after the workflows or the pods of the workflows are deleted. This topic uses ApsaraDB RDS for MySQL as an example to describe how to configure a persitence policy to persistent workflows to a database.
Configure and use ApsaraDB RDS for MySQL
Create an ApsaraDB RDS for MySQL instance. For more information, see Create an ApsaraDB RDS for MySQL instance.
ImportantMake sure that the virtual private cloud (VPC) of the ApsaraDB RDS for MySQL instance is the same as that of your workflow cluster. Add the VPC CIDR block to the whitelist of the ApsaraDB RDS for MySQL instance.
Create a database and an account for the ApsaraDB RDS for MySQL instance. For more information, see Create accounts and databases.
Run the following command to create a Secret named
argo-mysql-config
in the workflow cluster to store the username and password of the database.kubectl create secret generic
Content of the Secret:
NoteSpecify the username and password of the database that you created in the previous step.
apiVersion: v1 stringData: username: database-username password: database-password kind: Secret metadata: name: argo-mysql-config namespace: default type: Opaque
Add persistence settings to the
workflow-controller-configmap
ConfigMap.NoteThe
workflow-controller-configmap
ConfigMap is stored in the namespace that uses the cluster ID as its name.host
indicates the address of the ApsaraDB RDS for MySQL instance.database
indicates the name of the database.Set
archive
totrue
.archiveTTL
indicates the retention period of the workflows. In this example, the parameter is set to 30d, which means that workflows are persisted for 30 days in the database. The valid values of the parameter are not limited.
persistence: | connectionPool: maxIdleConns: 100 maxOpenConns: 0 connMaxLifetime: 0s # 0 means connections don't have a max lifetime archiveTTL: 30d archive: true mysql: host: rm-xxx.mysql.cn-beijing.rds.aliyuncs.com port: 3306 database: argo-workflow tableName: argo_workflows userNameSecret: name: argo-mysql-config key: username passwordSecret: name: argo-mysql-config key: password
References
After workflows are persisted to the database, you can use the Argo CLI to view workflow logs even after the workflows are deleted. For more information, see Configure Log Service.