Mojo - first run

Ubuntu install

curl -ssL https://magic.modular.com/43a01b4c-d8e4-4b1d-a514-efa04460bf5c | bash

Initialize Project

magic init hello-world --format mojoproject

Go into new project and start mojo shell

cd hello-world && magic shell

Create your hello.mojo file

fn main():
    print("Hello, world!")

Run the mojo file

mojo hello.mojo

Build an executable binary

mojo build hello.mojo

If getting the error: "mojo: error: unable to find suitable c++ compiler for linking"

add compilers to Ubuntu: sudo apt-get install build-essential

If getting error:

/usr/bin/ld: cannot find -lz: No such file or directory
/usr/bin/ld: cannot find -ltinfo: No such file or directory
collect2: error: ld returned 1 exit status
mojo: error: failed to link executable

sudo apt-get install zlib1g-dev libtinfo-dev

Run the binary

./hello

Run a different mojo app, like something you got from github...

magic run mojo hello_interop.mojo

Linux CLI cheatsheet

Shorten the shown directory path default in terminal

bob@bob-ubuntu:~/Really/Long/Path/Here/$ to bob@bob-ubuntu:~/Here/$

PROMPT_DIRTRIM=1

Checkout Remote Github Branch

git fetch
git branch --track <name-of-branch> <name-of-remote:eg. origin>/<name-of-branch>
git switch <name-of-branch>

Caching Github credentials

Install prerequisites

Github CLI RHEL installation example

sudo dnf install 'dnf-command(config-manager)'
sudo dnf config-manager --addrepo https://cli.github/packages/rpm/gh-cli.repo
sudo dnf install gh --repo gh-cli

Provide your login details

First create a PAT token in GH UI then:

gh auth login
  1. github.com
  2. https
  3. autheticate github cli: yes
  4. paste auth token
  5. Paste the PAT token you created here
  6. Live a calm and productive life

Installing AKS Helm Charts

Add a helm repo eg. azure marketplace

helm repo add azure-marketplace https://marketplace.azurecr.io/helm/v1/repo

Search for a helm file in the added local repos

helm search repo {filter keyword:optional}

Test a helm char (simulated)

helm install --debug --dry-run my-release ./chart-name

Install helm chart

helm install {values .yaml file to use:optional} my-release ./char-name

You can use a .tgz or repository-name/chart-name instead of ./char-name

Example output:

NAME: aks-store-demo
LAST DEPLOYED: Thu Jul 11 19:38:35 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None

Query installed releases on cluster

helm list

To upgrade an existing release

helm upgrade my-app ./app-chart

This will only update the delta

Get manifest information for a release

helm get manifest aks-store-demo

Validate pod is deployed

kubectl get pods -o wide -w

Delete a helm release

helm delete aks-store-demo

Install helm chart with set values from cli

helm install --set replicaCount=5 aks-store-demo ./aks-store-demo

If a helm chart has "dependencies:" install them with

helm dependency build ./app-chart

Update dependency

helm dependency update ./app-chart

View helm deployment/upgrade history

helm history my-app

Roll back helm release

helm rollback my-app 2

Note: the "2" is referring to the revision output from "helm history ..."

Examples of using function, like if statements, in helm charts

1 2 Next Last