How to Use Vultr’s K3s Marketplace Application

Updated on January 17, 2025
How to Use Vultr’s K3s Marketplace Application header image

Introduction

K3s marketplace application offers a lightweight Kubernetes distribution optimized for fast and efficient deployments. Designed for resource-constrained environments like edge computing, it simplifies the management of modern applications without the complexity of traditional Kubernetes setups.

Vultr's K3s marketplace application simplifies Kubernetes deployments and includes essential tools like kubectl and helm to manage and orchestrate your deployments with ease. It also includes pre-installed containers and services preinstalled to run applications on your server.

Follow this guide to use Vultr's K3s Vultr marketplace application to access a K3s cluster, enable remote access and deploy applications.

Deploy the K3s Marketplace Application on Vultr

Follow the steps below to deploy the K3s marketplace application using the Vultr Customer Portal.

  1. Open the Vultr Customer Portal Customer Portal, navigate to Products -> Compute and click Deploy Server.

  2. Select your desired instance type such as Optimized Cloud Compute or Cloud Compute.

  3. Choose your preferred Vultr location.

  4. Select an instance plan based on your project needs.

  5. Click the Marketplace Apps tab, enter and select K3s.

  6. Optional: Enter the K3s server URL and Token of an existing K3s cluster to add additional nodes.

  7. Optional: Select an SSH key to enable on the instance.

  8. Enter your desired hostname and instance label.

  9. Select any Additional Features to enable on the instance.

  10. Click Deploy to start the instance deployment process.

  11. When the deployment process is complete, click the instance to open its management page.

    Go to compute section

Access the K3s Cluster

Follow the steps below to access the K3s cluster and view all active nodes.

  1. Find and copy the instance's SSH credentials including the public IP address, and root user password in the Overview tab.

    Get the K3s instance connection details

  2. Use SSH to access the K3s instance. Replace 192.0.2.100 with the actual instance's IP address.

    console
    $ ssh root@192.0.2.100
    

    Accept the SSH fingerprint key and enter the root user password when prompted.

  3. View the active K3s version.

    console
    # k3s --version
    

    Output:

    k3s version v1.31.3+k3s1 (6e6af988)
    go version go1.22.8
  4. View all active nodes in the K3s cluster.

    console
    $ kubectl get nodes
    

    Output:

    NAME          STATUS   ROLES                  AGE     VERSION
    k3s-cluster   Ready    control-plane,master   4m11s   v1.31.3+k3s1

Enable Remote Access

The K3s instance includes a k3s-public.yaml configuration file that contains all credentials to access the K3s cluster using tools like Kubectl and Helm from other hosts. Follow the steps below to verify the default configuration path, configure the firewall, and enable remote access to the K3s cluster.

  1. View the UFW status and verify the active firewall rules.

    console
    # ufw status
    

    Output:

    Status: active
    
    To                         Action      From
    --                         ------      ----
    22/tcp                     ALLOW       Anywhere                  
    6443/tcp                   ALLOW       Anywhere                  
    30000:32767/tcp            ALLOW       Anywhere                  
    30000:32767/udp            ALLOW       Anywhere                  
    22/tcp (v6)                ALLOW       Anywhere (v6)             
    6443/tcp (v6)              ALLOW       Anywhere (v6)             
    30000:32767/tcp (v6)       ALLOW       Anywhere (v6)             
    30000:32767/udp (v6)       ALLOW       Anywhere (v6)  

    The K3s marketplace application is configured with all necessary firewall rules by default based on the above output. The following network ports are allowed through the firewall based on the above output.

    • 22: The SSH port for secure remote access to the server.
    • 6443: The Kubernetes API port that allows remote access to the K3s cluster's control plane.
    • 30000:32767/tcp: The Kubernetes NodePort services range used to expose cluster applications to external networks.

    Run the following command to allow connections to the default Kubernetes API server port 6443 if the rule does not already exist.

    console
    $ ufw allow 6443/tcp
    
  2. View the k3s-public.yaml file contents in the /root directory to use when connecting to the K3s cluster from a remote workstation.

    console
    # cat /root/k3s-public.yaml
    

    Your output should be similar to the one below.

    apiVersion: v1
    clusters:
    - cluster:
        certificate-authority-data: LS0tLS1CRU...................................
        server: https://192.0.2.100:6443
      name: default
    contexts:
    - context:
        cluster: default
        user: default
      name: default
    current-context: default
    kind: Config
    preferences: {}
    users:
    - name: default
      user:

    Use the above /root/k3s-public.yaml configuration to replace the .kube/config file on your workstation to connect to the K3s cluster.

  3. List all active nodes in the K3s cluster when connected.

    console
    $ kubectl get nodes
    

    Output:

    NAME          STATUS   ROLES                  AGE     VERSION
    k3s-cluster   Ready    control-plane,master   4m11s   v1.31.3+k3s1

Deploy Applications on the K3s Cluster

Follow the steps below to deploy a sample application to the K3s cluster.

  1. Create a new sampleapp.yaml file.

    console
    # nano sampleapp.yaml
    
  2. Add the following configurations to the sampleapp.yaml file to create a new deployment, service and configmap.

    yaml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: greetings-app
      labels:
        app: greetings-app
    spec:
      replicas: 3
      selector:
        matchLabels:
          app: greetings-app
      template:
        metadata:
          labels:
            app: greetings-app
        spec:
          containers:
          - name: nginx
            image: nginx:latest
            ports:
            - containerPort: 80
            volumeMounts:
            - name: greetings-app-volume
              mountPath: /usr/share/nginx/html
          volumes:
          - name: greetings-app-volume
            configMap:
              name: greetings-app-config
    ---
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: greetings-app-config
    data:
      index.html: |
        <!DOCTYPE html>
        <html>
        <head>
          <title>Hello World! Greetings from Vultr</title>
        </head>
        <body>
          <h1>Greetings from Vultr!</h1>
        </body>
        </html>
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: greetings-service
    spec:
      selector:
        app: greetings-app
      ports:
      - protocol: TCP
        port: 80
        targetPort: 80
      type: NodePort
    

    Save and close the file.

  3. Apply the configuration to the K3s cluster.

    console
    # kubectl apply -f sampleapp.yaml
    

    Output:

    deployment.apps/greetings-app created
    configmap/greetings-app-config created
    service/greetings-service created
  4. View all deployments and verify that the new deployment is ready.

    console
    # kubectl get deployments
    

    Output:

    NAME            READY   UP-TO-DATE   AVAILABLE   AGE
    greetings-app   3/3     3            3           9s
  5. View all services, verify that the greetings service is available and note the external port mapping.

    console
    # kubectl get services
    

    Output:

    NAME                TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
    greetings-service   NodePort    10.43.248.243   <none>        80:32115/TCP   16s
    kubernetes          ClusterIP   10.43.0.1       <none>        443/TCP        9m59s

    The greetings-service is accessible with the NodePort 32115 based on the above 80:32115/TCP port information output.

  6. View all pods in the cluster.

    console
    # kubectl get pods
    

    Output:

    NAME                             READY   STATUS    RESTARTS   AGE
    greetings-app-74c846f898-fq68x   1/1     Running   0          119s
    greetings-app-74c846f898-jwmdd   1/1     Running   0          119s
    greetings-app-74c846f898-pb5df   1/1     Running   0          119s
  7. Access the greetings-service NodePort service port 32115 using your K3s server's IP address in a web browser such as Chrome. Replace 192.0.2.100 with your actual server's IP address.

    http://192.0.2.100:32115

    Verify that the application page displays a Greetings from Vultr message.

    A sample application running on a K3s cluster

Conclusion

You have deployed the Vultr's K3s marketplace application, enabled remote access and deployed applications on the K3s cluster. K3s eliminates the complexities of setting up Kubernetes which enables developers to focus on managing applications and scaling deployments effectively.