Score:0

How to access k3s cluster created in an azure vm with public and private ip?

ck flag

I tried below steps to setup k3s cluster.

Here are the steps to create a K3s cluster on an Azure VM with both private and public IP addresses, and access it from your laptop using kubectl:

Create an Azure VM with Ubuntu 20.04 LTS as the operating system. You can use the Azure portal or the Azure CLI to do this. Make sure you enable SSH access and assign both a private and a public IP address to the VM. Note down the public IP address of the VM, which we will use later. For more details, please see this article.

SSH into the VM using its public IP address and your SSH key or password. You can use any SSH client such as PuTTY or OpenSSH to do this. For example, if your public IP is 52.183.103.99 and your username is azureuser, you can run this command on your laptop:

ssh [email protected]

Install K3s on the VM using the official installation script. You can use curl or wget to download and run the script. For example, you can run this command on the VM:

curl -sfL https://get.k3s.io | sh -

This will install K3s as a systemd service and start it automatically. You can check the status of the service by running:

sudo systemctl status k3s

Copy the /etc/rancher/k3s/k3s.yaml file from the VM to your laptop as ~/.kube/config. This file contains the configuration for kubectl to connect to your K3s cluster. You can use scp or rsync to copy the file. For example, you can run this command on your laptop:

scp [email protected]:/etc/rancher/k3s/k3s.yaml ~/.kube/config

Edit the ~/.kube/config file on your laptop and replace the value of the server field with the public IP address of your Azure VM. For example, if your public IP is 20.59.22.167, then the server field should look like this:

server: https://20.59.22.167:6443

Install kubectl on your laptop if you don’t have it already. You can follow this guide to install kubectl on different operating systems.

Test your connection to your K3s cluster by running some kubectl commands on your laptop. For example, you can run this command to get the nodes in your cluster:

kubectl get nodes

You should see something like this:

NAME STATUS ROLES AGE VERSION k3s-vm Ready control-plane,master 10m v1.22.4+k3s1

I get below error.

E0823 18:45:36.742249 20384 memcache.go:265] couldn't get current server API group list: Get "https://20.59.22.167:6443/api?timeout=32s": tls: failed to verify certificate: x509: certificate is valid for 10.43.0.1, 127.0.0.1, 172.17.0.4, ::1, not 20.59.22.167 Unable to connect to the server: tls: failed to verify certificate: x509: certificate is valid for 10.43.0.1, 127.0.0.1, 172.17.0.4, ::1, not 20.59.22.167

20.59.22.167 is my public ip of the vm.

The steps I followed by following this link.

Can anyone give me step by step process on creating a k3s cluster on azure vm which has private ip and public ip both. So once I copy the k3s.yaml file to my laptop and set the public ip in it, it should work without any problem

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.