This repository contains charms that deploy the dashboard for Juju and JAAS into Machine and Kubernetes environments.
Building the machine charm is fairly straightforward. You need a machine with Juju 3.0+ installed. The rest of the steps, in brief, are:
# From the root directory of this repo
# Build the charm
cd ./machine-charm
charmcraft pack
# Bootstrap a test controller. Make a make a model, and deploy an application, so that the dashboard has things to show.
juju bootstrap localhost localhost-test
juju add-model test
juju switch test
juju deploy ubuntu
# Switch to the controller model and setup the dashboard
juju switch controller
# If apt fails to install packages when deploying the dashboard you may need to run the following:
# sudo iptables -P FORWARD ACCEPT
juju deploy ./juju-dashboard*.charm dashboard
juju relate controller dashboard
juju dashboard
Once you login following the instructions in the output of juju dashboard
you should be able to see the controller model, as well as the test model and test application that you deployed.
This script pulls that latest Github release of the dashboard and extracts it to the appropriate folder in machine-charm
:
./scripts/update-machine-charm-dashboard.sh
This guide covers every step necessary to build and test a k8s charm, from updating the facades in js-libjuju, to rebuilding the dashboard source, to building the charm. You can skip some steps if you don't need to update every part of the toolchain.
Bulid from source, or snap install --channel=3.0/beta juju
Follow the guide on the docker website to install the latest version of the Docker engine.
In brief:
snap install microk8s --classic
sudo usermod -a -G microk8s $USER
sudo chown -f -R $USER ~/.kube
su - $USER
microk8s status --wait-ready
microk8s.enable hostpath-storage dns
microk8s config | juju add-k8s --client micro
juju bootstrap micro
There is no need to git clone
the repository, in the section "Building the Kubernetes Charm" we will set the <image-id>
to canonicalwebteam/juju-dashboard:latest
- Checkout
git@github.com:canonical/juju-dashboard.git
- Build the container with
DOCKER_BUILDKIT=1 docker build -t juju-dashboard .
- Take note of the image id. You can get it with
docker image inspect juju-dashboard | grep "Id"
- Add the docker image that you just build to microk8s' build in docker repo, as it cannot talk to the docker registry on the host machine:
docker image save juju-dashboard | microk8s ctr image import -
You're finally ready to build the charm! Change to the root directory of this repo, and run:
# Build the charm
cd ./k8s-charm
charmcraft pack
# Switch to the controller model and deploy the dashboard
juju switch controller
# image id must include: "sha256:..."
# using latest OCI release
juju deploy --resource dashboard-image=canonicalwebteam/juju-dashboard:latest ./juju-dashboard*.charm dashboard
# alternatively, using a custom OCI image
# juju deploy --resource dashboard-image=<image id> ./juju-dashboard*.charm dashboard
juju relate controller dashboard
juju dashboard
Login to the dashboard, per the instructions from the juju dashboard
command.
Sometimes, it may be useful to access the dashboard directly, rather than through the ssh tunnel. (E.g., you are trying to determine which part of the pipeline has broken, or access a test server remotely.)
This is made difficult in development environments, where the controller will typically be using self signed certs. Modern browsers will simply refuse to connect to the controller API. Here's a workaround:
You must tell your browser to trust the controller's cert in order to get a working dashboard. This requires Firefox, or another browser that allows you to override the security warning. Here's how to do so:
- From the CLI, execute
juju switch controller && juju status
- Note the ip address for the controller, and for the dashboard.
- Open Firefox, and visit https://:17070
- Click to the advanced part of the security prompt, and accept the risk.
- Firefox will display a "bad request" page. This is okay. You have successfully accepted the ssl cert!
- From the CLI, execute
juju dashboard
, and make note of the username and password. You don't need to leave the command running, as you are accessing the dashboard directly, rather than using the proxy server. - In Firefox, visit https://.
- Login with username and password you obtained in step 1.
charmcraft login
cd ./machine-charm
charmcraft pack
charmcraft upload juju-dashboard*.charm
charmcraft release juju-dashboard --channel=... --revision=...
git clone git@github.com:canonical/juju-dashboard.git
cd juju-dashboard
DOCKER_BUILDKIT=1 docker build -t juju-dashboard .
Get the the docker image ID with docker image inspect juju-dashboard | grep "Id"
charmcraft login
charmcraft upload-resource juju-dashboard-k8s dashboard-image --image=[image-id]
charmcraft login
cd ./k8s-charm
charmcraft pack
charmcraft upload juju-dashboard-k8s*.charm
charmcraft release juju-dashboard-k8s --channel=... --revision=[output-from-upload] --resource=dashboard-image:[resource-revision-number]