This topic describes how to upgrade Logtail components.
Upgrade description
We recommend that you use the automatic upgrade method in common scenarios. If you have modified parameters such as environment variables in the logtail-ds DaemonSet or the alibaba-log-controller Deployment, we recommend that you use the manual upgrade method to retain your modifications.
Before you upgrade the Logtail components, we recommend that you back up the description files related to the Logtail components. For more information, see Appendix 1: Backup and rollback.
Automatic upgrade
Alibaba Cloud ACK clusters
- Log on to the ACK console.
- In the left-side navigation pane, click Clusters.
- On the Clusters page, find and click the cluster in which you want to install Logtail components.
- In the left-side navigation pane of the page that appears, choose .
- On the Logs and Monitoring tab, find logtail-ds and click Upgrade.
- In the Update dialog box, click OK. Important If the component cannot be upgraded to the most recent Logtail version, the Kubernetes version of your cluster is outdated. In this case, you must upgrade the Kubernetes version of your cluster first or use the manual upgrade method.After the upgrade is performed, you can view the status of each logtail-ds pod in the Alibaba Cloud Container Service for Kubernetes (ACK) console. If each logtail-ds pod is in the running state, the upgrade is successful.
Self-managed Kubernetes clusters
You can reinstall the Logtail components to complete the automatic upgrade. For more information, see Self-managed Kubernetes clusters.
Manual upgrade
Alibaba Cloud ACK clusters
A manual upgrade covers both logtail-ds and alibaba-log-controller. In most cases, you need to only upgrade logtail-ds to obtain the collection capabilities provided in the most recent version of Logtail. If you want to obtain the custom resource definition (CRD)-based collection capabilities provided in the most recent version of Logtail, you also need to upgrade alibaba-log-controller. The following procedure shows how to upgrade logtail-ds.
- Log on to the ACK console.
- In the left-side navigation pane, click Clusters.
- On the Clusters page, find and click the cluster in which you want to install Logtail components.
- In the left-side navigation pane, choose . Note If you want to upgrade alibaba-log-controller, choose kube-system and find alibaba-log-controller.. Then, set Namespace to
- Set Namespace to kube-system. Then, find logtail-ds and click Edit in the Actions column.
- Check whether the required environment variables exist. If the ALIYUN_LOGTAIL_CONFIG, ALIYUN_LOGTAIL_USER_ID, or ALIYUN_LOGTAIL_USER_DEFINED_ID environment variable does not exist, your Logtail version is outdated. You can submit a ticket for technical support.
- Click Select Image Version to the right of Image Version.
- In the Image Version dialog box, click the most recent version and click OK.
- In the right-side pane of the page that appears, click Update. After the upgrade is performed, you can view the status of each logtail-ds pod in the ACK console. If each logtail-ds pod is in the running state, the upgrade is successful.
Self-managed Kubernetes clusters
- Log on to your Kubernetes cluster.
- Upgrade logtail-ds. After the upgrade is performed, you can run the
kubectl describe -n kube-system ds logtail-ds | grep Status:
command to view the status of each logtail-ds pod. If each logtail-ds pod is in the running state, the upgrade is successful. - Upgrade alibaba-log-controller. After the upgrade is performed, you can run the
kubectl describe -n kube-system deployment alibaba-log-controller | grep Replicas:
command to view the status of each alibaba-log-controller pod. If each alibaba-log-controller pod is in the updated state, the upgrade is successful.
Appendix 1: Backup and rollback
Backup
Before you upgrade the Logtail components, we recommend that you back up the description files related to the Logtail components. Example:
kubectl get ds -n kube-system logtail-ds -o yaml > logtail-ds.yaml
kubectl get deployment -n kube-system alibaba-log-controller -o yaml > alibaba-log-controller.yaml
kubectl get crd aliyunlogconfigs.log.alibabacloud.com -o yaml > aliyunlogconfigs-crd.yaml
kubectl get cm -n kube-system alibaba-log-configuration -o yaml > alibaba-log-configuration.yaml
Rollback
- Delete redundant information from the backup files.
cat logtail-ds.yaml | kubectl-neat > neat-logtail-ds.yaml cat alibaba-log-controller.yaml | kubectl-neat > neat-alibaba-log-controller.yaml cat aliyunlogconfigs-crd.yaml | kubectl-neat > neat-aliyunlogconfigs-crd.yaml cat alibaba-log-configuration.yaml | kubectl-neat > neat-alibaba-log-configuration.yaml
- Use the backup files after the deletion to restore the configurations of Logtail.
kubectl apply -f neat-logtail-ds.yaml kubectl apply -f neat-alibaba-log-controller.yaml kubectl apply -f neat-aliyunlogconfigs-crd.yaml kubectl apply -f neat-alibaba-log-configuration.yaml
Appendix 2: Upgrade the latest version of Logtail
The YAML file used in the Logtail version named latest is outdated. If you use this version, issues may occur during an upgrade or when new features are used. We recommend that you upgrade the latest version to the most recent version. Perform the following steps:
- Store the existing AliyunLogConfig CRD. Replace log-crds.yaml based on your business requirements.
kubectl get AliyunLogConfig -A -o yaml > log-crds.yaml
- Uninstall logtail-ds. On the Logs and Monitoring tab of the ACK console, find logtail-ds and click Uninstall. For more information about the entry point, see Automatic upgrade.
- Install logtail-ds. On the Logs and Monitoring tab of the ACK console, find logtail-ds and click Install. For more information about the entry point, see Automatic upgrade.
- Deploy the AliyunLogConfig CRD that you store. Replace log-crds.yaml based on your business requirements.
kubectl apply -f log-crds.yaml