This topic describes how to upgrade the 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 Additional information: Backup and rollback.

Important An upgrade is complete within a few seconds. During an upgrade, the Logtail container is restarted, which may cause a small amount of data to be collected again or lost during collection.

Automatic upgrade

Important If you use the automatic upgrade method, your modifications to the parameters in the logtail-ds DaemonSet and alibaba-log-controller Deployment are not retained.

Alibaba Cloud ACK clusters

  1. Log on to the ACK console.
  2. In the left-side navigation pane, click Clusters.
  3. On the Clusters page, find and click the cluster in which you want to install Logtail components.
  4. In the left-side navigation pane of the page that appears, choose Operations > Add-ons.
  5. On the Logs and Monitoring tab, find logtail-ds and click Upgrade.
  6. In the Update dialog box, click OK.
    Important If the component cannot be upgraded to the latest 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

Important If you use the manual upgrade method, your existing configurations are not updated, and some features may not be supported.

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 latest version of Logtail. If you want to obtain the custom resource definition (CRD)-based collection capabilities provided in the latest version of Logtail, you also need to upgrade alibaba-log-controller. The following procedure shows how to upgrade logtail-ds.

  1. Log on to the ACK console.
  2. In the left-side navigation pane, click Clusters.
  3. On the Clusters page, find and click the cluster in which you want to install Logtail components.
  4. In the left-side navigation pane, choose Workloads > DaemonSets.
    Note If you want to upgrade alibaba-log-controller, choose Workloads > Deployments. Then, set Namespace to kube-system and find alibaba-log-controller.
  5. Set Namespace to kube-system. Then, find logtail-ds and click Edit in the Actions column.
  6. Check whether the required environment variables exist.
    If the ALIYUN_LOGTAIL_CONFIG, ALIYUN_LOGTAIL_USER_ID, or ALIYUN_LOGTAIL_USER_DEFINED_ID environment variables does not exist, your Logtail version is outdated. You can submit a ticket to obtain the upgrade method.
  7. Click Select Image Version to the right of Image Version.
  8. In the Image Version dialog box, click the latest version and click OK.
  9. In the right-side pane of the page, 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

  1. Log on to your Kubernetes cluster.
  2. Upgrade logtail-ds.
    1. Run the following command to enter the configuration mode:
      kubectl edit ds -n kube-system logtail-ds
    2. Modify the image field.
      You can obtain the latest image version on the logtail page.
    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.
  3. Upgrade alibaba-log-controller.
    1. Run the following command to enter the configuration mode:
      kubectl edit deployment -n kube-system alibaba-log-controller
    2. Modify the image field.
      You can obtain the latest image version on the alibabacloud-log-controller page.
    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.

Additional information: 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

The following procedure shows how to roll back to a version.
Note The YAML files that are backed up before an upgrade contains redundant information. You must manually delete the redundant information before you can restore the configurations of Logtail. You can use the kubectl-neat tool to delete the redundant information. You must delete the following fields: metadata.creationTimestamp, metadata.generation, metadata.resourceVersion, metadata.uid, and status.
  1. 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
  2. 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