Initial Juju tutorial on Apple Silicon w Multipass

Hi all,

I’m just doing starting using juju, currently with multipass ubuntu 22.04 + microk8s on a macbook pro m3 (aarch64) host. When deploying the postgresql-k8s charm to my microk8s cluster via juju, I encounter an issue with pod’s node selector. The issue appears to be that the juju charm is setup for amd64 arch and my vm is running aarch64 via host-passthrough or something

From juju status, I see the following

Unit              Workload  Agent       Address  Ports  Message
postgresql-k8s/0  waiting   allocating                  installing agent

Here is the bit I think is the issue and the error message event from microk8s kubectl describe pod postgresql-k8s-0 -n welcome-k8s

...
Node-Selectors:              kubernetes.io/arch=amd64
...
Events:
  Type     Reason            Age                  From               Message
  ----     ------            ----                 ----               -------
Warning  FailedScheduling  45s (x2 over 5m45s)  default-scheduler  0/1 nodes are available: 1 node(s) didn't match Pod's node affinity/selector. preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling..

Here is the output of uname -m on the vm

aarch64

And the command to run the vm in general, which is from the tutorial

multipass launch --cpus 4 --memory 8G --disk 30G --name test-juju-vm charm-dev

Is there a configured postgresql-k8s charm that uses aarch64, should I reconfigure my vm to use amd64, or should I custom configure the charm to use aarch64?

EDIT: The juju deploy command

juju deploy postgresql-k8s --channel 14/stable --trust

2 Likes

Hi @errcsool I had the same trouble with a different charm on multipass on M2. That being said, I’m not sure how “architecture” plays a role in k8s charms (do we need to upload a separate arm image?)

With machine charms it’s slightly more straightforward (example).

Another option to try is a workloadless k8s charm.

1 Like

Hi @errcsool

First of all, yes you are correct, the reason is mismatching architecture. Your hardware and the VM are arm64 but the Postgres k8s charm is only built and released for amd64.

This can be verified in two ways:

  1. If you go to the charmhub here and click the version dropdown in the upper-left corner, you can see it only has amd64 versions.
  2. Or, the kubectl describe pod output you pasted also suggested the same.

Secondly, the solution you mentioned (change multipass vm to amd64) won’t work, because I do not think you can’t launch an amd64 VM on arm64 hardware with multipass. This feature will not come any time soon according to this discussion here: Announcing the first Release Candidate for Apple M1 support - #12 by saviq - Multipass - Ubuntu Community Hub.

As far as I know, the only tool that can launch cross-architecture VMs on arm64 is lima. See the official doc here. I think this might be the easy solution to finish the tutorial on arm64 machines, but I haven’t tried it yet, feel free to give it a go, I will also test this solution later.

If, for some reason, you have to stick with multipass, there is also a hard way:

  1. Clone the Postgres k8s charm repo, change the bases part to something like:
type: charm

bases:
  - build-on:
    - name: ubuntu
      channel: "22.04"
      architectures: [arm64]
    run-on:
    - name: ubuntu
      channel: "22.04"
      architectures: [arm64]
  1. Build arm64 version of the Postgres image. The repo for the image is here. This is needed because this image isn’t built for arm64. I have done this step already and published my image, so you can save yourself the trouble of doing it again by simply reusing my image. Tag: ironcore864/charmed-postgresql:14.10.

  2. Change the upstream-source in the metadata.yaml to use the aforementioned arm64 image.

  3. Pack and deploy the charm from local. When deploying, do not forget to set the arch constraint, you can either set it on the model or on the app level. Learn more about constraint here.

Although this is the hard way to go, it’s guaranteed to work, and you can learn more about juju/charms and even some other tools like rockcraft during ths journey.

I hope this helps.

As you go further with this tutorial, I think you will surely meet more issues related to arm64. Feel free to reach out again later :slight_smile: I will do a comprehensive tutorial for arm64/mac users later.

5 Likes

@sed-i @ironcore864 Thank you! Yes, basically I was going to do the hard way you mentioned

The UTM tool also runs x64 vm images on Mac w/ Apple Silicon probably with the Hypervisor framework or Rosetta or something. Using another VM tool requires some extra configuration of the juju environment, including setup of microk8s from the appropriate snap and setting up the corresponding juju controllers and credentials that are pre-packaged in the multipass/charm-dev vm. Nothing crazy, though. I’m sure the comprehensive arm64/mac tutorial would be appreciated by some folks looking to get setup from a Mac :slight_smile:

1 Like