Install PorterLB on K3s

This document describes how to use kubectl and Helm to install and delete PorterLB in a K3s Kubernetes cluster.

NOTE

  • In a Kubernetes cluster, you only need to install PorterLB once. After the installation is complete, a porter-manager Deployment that contains a porter-manager Pod is installed in the cluster. The porter-manager Pod implements the functionality of PorterLB for the entire Kubernetes cluster.
  • After the installation is complete, you can scale the porter-manager Deployment and assign multiple PorterLB replicas (porter-manager Pods) to multiple cluster nodes to ensure high availability. For details, see Configure Multiple PorterLB Replicas.

Prerequisites

  • You need to prepare a K3s Kubernetes cluster, and ensure that the Kubernetes version is 1.15 or later. PorterLB requires CustomResourceDefinition (CRD) v1, which is only supported by Kubernetes 1.15 or later. PorterLB is designed to be used in bare-metal Kubernetes environments. However, you can also use a cloud-based K3s Kubernetes cluster for learning and testing.

  • If you use Helm to install porter, ensure that the Helm version is Helm 3.

Install PorterLB Using kubectl

  1. Log in to the master node of the K3s Kubernetes cluster over SSH and run the following command:

    1. kubectl apply -f https://raw.githubusercontent.com/kubesphere/porter/master/deploy/porter.yaml
  2. Run the following command to edit the porter-manager Deployment:

    1. kubectl edit deployment porter-manager -n porter-system
  3. Change port 443 to a different value (for example, 30443) to avoid a port conflict with K3s:

    1. spec:
    2. template:
    3. spec:
    4. containers:
    5. - args:
    6. - --webhook-port=443 # Change the port number.
    7. ports:
    8. - containerPort: 443 # Change the port number.
    9. hostPort: 443 # Change the port number.

    NOTE

    By default, both PorterLB and K3s use port 443. Therefore, you need to change port 443 of PorterLB to avoid the port conflict. For details, see the official K3s document.

  4. Run the following command to check whether the status of porter-manager is READY: 1/1 and STATUS: Running. If yes, PorterLB has been installed successfully.

    1. kubectl get po -n porter-system

    verify-porter-kubectl

Delete PorterLB Using kubectl

  1. To delete PorterLB, log in to the master node of the K3s Kubernetes cluster and run the following command:

    1. kubectl delete -f https://raw.githubusercontent.com/kubesphere/porter/master/deploy/porter.yaml

    NOTE

    Before deleting PorterLB, you must first delete all Services that use PorterLB.

  2. Run the following command to check the result. If the porter-system namespace does not exist, PorterLB has been deleted successfully.

    1. kubectl get ns

    verify-porter-deletion-kubectl

Install PorterLB Using Helm

  1. Log in to the master node of the K3s Kubernetes cluster over SSH and run the following command to configure the environment variable:

    1. export KUBECONFIG=/etc/rancher/k3s/k3s.yaml

    NOTE

    You need to configure this environment variable so that Helm can reach the K3s Kubernetes cluster. For details, see the official K3s document.

  2. Run the following commands to install PorterLB:

    1. helm repo add test https://charts.kubesphere.io/test
    2. helm repo update
    3. helm install porter test/porter
  3. Run the following command to edit the porter-manager Deployment:

    1. kubectl edit deployment porter-manager
  4. Change port 443 to a different value (for example, 30443) to avoid a port conflict with K3s:

    1. spec:
    2. template:
    3. spec:
    4. containers:
    5. - args:
    6. - --webhook-port=443 # Change the port number.
    7. ports:
    8. - containerPort: 443 # Change the port number.
    9. hostPort: 443 # Change the port number.

    NOTE

    By default, both PorterLB and K3s use port 443. Therefore, you need to change port 443 of PorterLB to avoid the port conflict. For details, see the official K3s document.

  5. Run the following command to check whether the status of porter-manager is READY: 1/1 and STATUS: Running. If yes, PorterLB has been installed successfully.

    1. kubectl get po -A

    verify-porter-helm

Delete PorterLB Using Helm

  1. To delete PorterLB, run the following command:

    1. helm delete porter

    NOTE

    Before deleting PorterLB, you must first delete all Services that use PorterLB.

  2. Run the following command to check the result. If the PorterLB application does not exist, PorterLB has been deleted successfully.

    1. helm ls

    verify-porter-deletion-helm

Last modified March 31, 2021: Relocated files to adapt to localization and changed links. (6b5fcb1)