Deploy the MediaWiki charm for the first time¶
The mediawiki-k8s charm can be used to deploy a horizontally-scalable MediaWiki application. This
tutorial will walk you through each step of deploying MediaWiki using the charm.
What you’ll do¶
Deploy the MediaWiki K8s charm
Deploy and integrate a database
Configure the URL origin
Get admin credentials
Access the MediaWiki instance
Clean up the environment
What you’ll need¶
You will need a workstation, for example, a laptop, with AMD64 architecture. Your workstation should have at least 4 CPU cores, 8 GB of RAM, and 50 GB of disk space.
Tip
Using a Multipass VM (optional)
You can use Multipass to create an isolated virtual machine (VM) by running:
multipass launch 26.04 --name mediawiki-tutorial-vm --cpus 4 --memory 8G --disk 50G
To be able to work inside the Multipass VM, open a shell with the following command:
multipass shell mediawiki-tutorial-vm
This tutorial requires the following software to be installed on your workstation (either locally or in the Multipass VM):
Juju 3.6
MicroK8s 1.35
Use Concierge to set up Juju and MicroK8s:
sudo snap install --classic concierge
sudo concierge prepare -p microk8s
This first command installs Concierge, and the second command uses Concierge to install and configure Juju and MicroK8s.
For this tutorial, Juju must be bootstrapped to a MicroK8s controller. Concierge should
complete this step for you, and you can verify by checking for
msg="Bootstrapped Juju" provider=microk8s
in the terminal output and by running juju controllers.
If Concierge did not perform the bootstrap, run:
juju bootstrap microk8s tutorial-controller
Set up the environment¶
To manage resources effectively and to separate this tutorial’s workload from your usual work, create a new model in the MicroK8s controller using the following command:
juju add-model mediawiki-tutorial
Deploy the charm¶
Start by deploying the MediaWiki charm.
juju deploy mediawiki-k8s --channel 1.46/edge
Deploy and integrate database¶
MediaWiki requires a relational database. As the mysql_client interface is required by the mediawiki-k8s charm, we will use the MySQL K8s charm for this tutorial.
Deploy the mysql-k8s charm and integrate it with mediawiki-k8s with the following:
juju deploy mysql-k8s --trust --config profile=testing
juju relate mediawiki-k8s mysql-k8s
Run juju status to check the current status of the deployment.
The output should be similar to the following:
ubuntu@mediawiki-tutorial-vm:~$ juju statusModel Controller Cloud/Region Version SLA Timestamp
mediawiki-tutorial concierge-microk8s microk8s/localhost 3.6.21 unsupported 18:43:02-04:00
App Version Status Scale Charm Channel Rev Address Exposed Message
mediawiki-k8s mediawiki-1.46.0 active 1 mediawiki-k8s 1.46/edge 17 10.152.183.157 no
mysql-k8s 8.0.44 active 1 mysql-k8s 8.0/stable 400 10.152.183.82 no
Unit Workload Agent Address Ports Message
mediawiki-k8s/0* active idle 10.1.153.77
mysql-k8s/0* active idle 10.1.153.82 Primary
When the status shows “Active” for both the MediaWiki and MySQL charms, the deployment is considered finished.
Configure URL origin¶
For MediaWiki to work properly, it needs to know how users will access it. We can do this by configuring the URL origin. To keep things simple, we will use the IP of our sole mediawiki-k8s unit.
First, save the IP address of the MediaWiki charm unit in an environment variable:
UNIT_IP=$(juju status --format json | jq -r '.applications."mediawiki-k8s".units."mediawiki-k8s/0".address')
Then set the URL origin configuration to the unit’s IP:
juju config mediawiki-k8s url-origin="http://${UNIT_IP}"
Access the MediaWiki application¶
Now that we have an active deployment, let’s access the MediaWiki application by accessing the IP of a mediawiki-k8s unit. To start managing MediaWiki as an administrator, you need to create an administrator account.
By running the create-and-promote action on a mediawiki-k8s unit, Juju will create the user, promote it to the requested groups, and return a generated password for you:
juju run mediawiki-k8s/0 create-and-promote username=admin bureaucrat=true sysop=true generate-password=true
The result should be similar to the following, with the password value filled in:
ubuntu@mediawiki-tutorial-vm:~$ juju run mediawiki-k8s/0 create-and-promote username=admin bureaucrat=true sysop=true generate-password=trueRunning operation 1 with 1 task
- task 2 on unit-mediawiki-k8s-0
Waiting for task 2...
18:48:57 User 'admin' created and promoted successfully
password: <password>
username: admin
Now we can access MediaWiki in a browser at http://<UNIT_IP>. Log in with the credentials retrieved from the action above.
Note
If you are using a Multipass VM for this tutorial, you will need to route the IP from Multipass. To do this, first get the IP of the Multipass VM. Outside the Multipass VM run:
multipass info mediawiki-tutorial-vm
The first IP from this command’s output is the <VM_IP>.
Then route:
sudo ip route add <UNIT_IP> via <VM_IP>
Clean up the environment¶
Congratulations! You successfully deployed the MediaWiki charm, added a database, customized it, and accessed the application.
You can clean up your environment by following this guide: Tear down your test environment
Next steps¶
You achieved a basic deployment of the MediaWiki charm. If you want to go further in your deployment or learn more about the charm, check out these pages:
Perform basic operations with your deployment like installing extensions and skins.
Set up monitoring for your deployment by integrating with the Canonical Observability Stack (COS).
Make your deployment more secure by learning more about the charm’s security in the security overview page.
Learn more about the available relation endpoints for the MediaWiki charm.