- Create a VM for rancher server:
multipass launch --name rancher-server --cpus 4 --mem 4g --disk 20g
multipass exec rancher-server -- bash -c "curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" sh -"
multipass exec rancher-server sudo cat /etc/rancher/k3s/k3s.yaml > ~/.kube/rancher-server.yaml
RANCHER_SERVER_IP=$(multipass info k3s | grep IPv4 | awk '{print $2}')
sed -i '' "s/127.0.0.1/${RANCHER_SERVER_IP}/" ~/.kube/rancher-server.yaml
kubie ctx default
brew install helm@3
- Install cert manager, make sure to get the latest https://cert-manager.io/docs/installation/helm/
cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.5.3 \
--set installCRDs=true
kubectl create namespace cattle-system
- Install rancher
helm install rancher rancher-latest/rancher \
--namespace cattle-system \
--set hostname=rancher.localdev
- Wait until the pods under
cattle-system
namespace are running and finished loading the server. This might take few minutes - Create a VM for k3s client:
multipass launch --name k3s-client --cpus 4 --mem 4g --disk 20g
multipass exec k3s-client -- bash -c "curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" sh -"
- Install Rancher's generated YAMLs on the client:
# We are using the Host header as it's not possible to edit /etc/hosts on multipass (and maybe not needed)
curl --insecure -H "Host: rancher.localdev" -sfL https://$RANCHER_SERVER_IP/v3/import/...-m-j7wlcfmc.yaml | kubectl apply -f -
- Run
multipass exec k3s-client -- bash -c "kubectl get cm coredns -n kube-system -o yaml"
and look forhosts /etc/coredns/NodeHosts {
- Add a new row directly after with the IP and the host, with
192.168.64.4 rancher.localdev
it should look like:
Corefile: |
.:53 {
......
hosts /etc/coredns/NodeHosts {
192.168.64.4 rancher.localdev
ttl 60
reload 15s
fallthrough
}
....
}
- Restart rancher agent:
multipass exec k3s-client -- bash -c "kubectl -n cattle-system rollout restart deployment cattle-cluster-agent"
- Wait until it's up. It should work now.
This has been tested with:
Rancher 2.6.0
$ k3s -v
k3s version v1.21.4+k3s1 (3e250fdb)
go version go1.16.6
$ multipass version [Wed Sep 1 01:56:05 2021] 2 ↵
multipass 1.7.0+mac
multipassd 1.7.0+mac