In a previous article, I shared with you the steps I took, to get k3s installed (with the Kubernetes Dashboard) on top of an Ubuntu guest Operating System within an Oracle VirtualBox appliance, with the help of Vagrant.
[ https://technology.amis.nl/2020/01/15/rapidly-spinning-up-a-vm-with-ubuntu-and-k3s-with-the-kubernetes-dashboard-on-my-windows-laptop-using-vagrant-and-oracle-virtualbox/]
For training and demo purposes, I wanted to add mysql to my k3s demo environment and in order to test the environment, I also wanted to include the book service (RESTful Web Service Spring Boot application) that I created earlier and ran in Minikube.
[https://technology.amis.nl/2019/03/05/using-a-restful-web-service-spring-boot-application-in-minikube-together-with-an-external-dockerized-mysql-database/]
I also wanted to create my own prepackaged Vagrant Box from an existing virtual machine (a re-usable box).
[https://www.vagrantup.com/docs/boxes/base.html]
[https://scotch.io/tutorials/how-to-create-a-vagrant-base-box-from-an-existing-one]
In this article I will share with you the steps I took to get it all working. For example, I had to get my Docker built images working with the containerd container runtime in k3s.
In my existing demo environment, created when I wrote a previous article , I changed the content of the Vagrantfile to:
[https://technology.amis.nl/2020/01/15/rapidly-spinning-up-a-vm-with-ubuntu-and-k3s-with-the-kubernetes-dashboard-on-my-windows-laptop-using-vagrant-and-oracle-virtualbox/]
Vagrant.configure("2") do |config| config.vm.box = "ubuntu/bionic64" config.vm.define "ubuntu_k3s" do |ubuntu_k3s| config.vm.network "forwarded_port", guest: 8001, host: 8001, auto_correct: true config.vm.network "forwarded_port", guest: 9010, host: 9010, auto_correct: true config.vm.network "forwarded_port", guest: 9020, host: 9020, auto_correct: true config.vm.network "forwarded_port", guest: 9110, host: 9110, auto_correct: true config.vm.provider "virtualbox" do |vb| vb.name = "Ubuntu k3s" vb.memory = "8192" vb.cpus = "1" args = [] config.vm.provision "k3s shell script", type: "shell", path: "scripts/k3s.sh", args: args args = [] config.vm.provision "helm shell script", type: "shell", path: "scripts/helm.sh", args: args args = [] config.vm.provision "dashboard shell script", type: "shell", path: "scripts/dashboard.sh", args: args end end end Here, you can see I added the extra ports needed for the book service (RESTful Web Service Spring Boot application).
From the subdirectory named env on my Windows laptop, I opened a Windows Command Prompt (cmd) and typed: vagrant box update
This command updates the box for the current Vagrant environment if there are updates available. The command can also update a specific box (outside of an active Vagrant environment), by specifying the –box flag.
[https://www.vagrantup.com/docs/cli/box.html#box-update]
With the following output:
From the subdirectory named env on my Windows laptop, I opened a Windows Command Prompt (cmd) and typed: vagrant up
This command creates and configures guest machines according to your Vagrantfile.
[https://www.vagrantup.com/docs/cli/up.html]
With the following output (only showing the part about dashboard):
ubuntu_k3s: **** Begin preparing dashboard
ubuntu_k3s: **** Install Kubernetes Dashboard
ubuntu_k3s: namespace/kubernetes-dashboard created
ubuntu_k3s: serviceaccount/kubernetes-dashboard created
ubuntu_k3s: service/kubernetes-dashboard created
ubuntu_k3s: secret/kubernetes-dashboard-certs created
ubuntu_k3s: secret/kubernetes-dashboard-csrf created
ubuntu_k3s: secret/kubernetes-dashboard-key-holder created
ubuntu_k3s: configmap/kubernetes-dashboard-settings created
ubuntu_k3s: role.rbac.authorization.k8s.io/kubernetes-dashboard created
ubuntu_k3s: clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
ubuntu_k3s: rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
ubuntu_k3s: clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
ubuntu_k3s: deployment.apps/kubernetes-dashboard created
ubuntu_k3s: service/dashboard-metrics-scraper created
ubuntu_k3s: deployment.apps/dashboard-metrics-scraper created
ubuntu_k3s: **** Create Helm chart
ubuntu_k3s: Creating k3s-chart
ubuntu_k3s: **** Install Helm chart k3s-chart
ubuntu_k3s: NAME: k3s-release
ubuntu_k3s: LAST DEPLOYED: Sun Apr 26 13:30:16 2020
ubuntu_k3s: NAMESPACE: default
ubuntu_k3s: STATUS: deployed
ubuntu_k3s: REVISION: 1
ubuntu_k3s: TEST SUITE: None
ubuntu_k3s: **** Waiting 30 seconds …
ubuntu_k3s: **** List helm releases
ubuntu_k3s: NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
ubuntu_k3s: k3s-release default 1 2020-04-26 13:30:16.309325567 +0000 UTC deployed k3s-chart-0.1.0 1.16.0
ubuntu_k3s: **** List secrets with namespace kubernetes-dashboard
ubuntu_k3s: NAME
ubuntu_k3s:
ubuntu_k3s:
ubuntu_k3s:
ubuntu_k3s:
ubuntu_k3s: TYPE
ubuntu_k3s:
ubuntu_k3s:
ubuntu_k3s:
ubuntu_k3s:
ubuntu_k3s: DATA AGE
ubuntu_k3s: kubernetes-dashboard-token-kdq6q kubernetes.io/service-account-token 3 35s
ubuntu_k3s: default-token-mdb9j kubernetes.io/service-account-token 3 35s
ubuntu_k3s: kubernetes-dashboard-certs Opaque 0 35s
ubuntu_k3s: admin-user-token-xl9zz kubernetes.io/service-account-token 3 32s
ubuntu_k3s: kubernetes-dashboard-csrf Opaque 1 35s
ubuntu_k3s: kubernetes-dashboard-key-holder Opaque 2 35s
ubuntu_k3s: **** Describe secret with namespace kubernetes-dashboard
ubuntu_k3s: Name: admin-user-token-xl9zz
ubuntu_k3s: Namespace: kubernetes-dashboard
ubuntu_k3s: Labels: <none>
ubuntu_k3s: Annotations: kubernetes.io/service-account.name: admin-user
ubuntu_k3s: kubernetes.io/service-account.uid: d053ea00-f5c6-4091-9383-19a83dcfc48d
ubuntu_k3s:
ubuntu_k3s: Type: kubernetes.io/service-account-token
ubuntu_k3s:
ubuntu_k3s: Data
ubuntu_k3s: ====
ubuntu_k3s: ca.crt: 526 bytes
ubuntu_k3s: namespace: 20 bytes
ubuntu_k3s: token: eyJhbGciOiJSUzI1NiIsImtpZCI6IkVyWGhzYmU5N2NNblVkUG5aMnZBNTlKYWtyaFZ6OHVCaG51ckZoNGhqMG8ifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXhsOXp6Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJkMDUzZWEwMC1mNWM2LTQwOTEtOTM4My0xOWE4M2RjZmM0OGQiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6YWRtaW4tdXNlciJ9.a2npBwkMqXBNFkB_Fdq0NM4EH3e1KFuilp9x7CYf30TwG8Ne5b-0mwMOp5jC-JtR5Q_RSu9bO_2OxrafE-QQ6IEPAck0veOKoj8-tXN97VnSTn-zUriXpHcyHyOjDhS7ac7Qcrtp9Qgk_bdQUFzV79_BGvPFAcIAOMvbaRZE0KFaTYbhNN6zOwJymZS7MTOncp57aLvAdLvEqTX258RtYgHjT-ro0ajf8o8sTdeeAhuMAIhRCJHmLYzXx_cXCke_nJx0eEYmmqajIviUR77Lcr0psfaksm45WjAK_Mt1Y-tkzEIA407O6uk_hf_W-fxqhB-w5kypEVUOeON_V9b_iQ
ubuntu_k3s: **** End preparing dashboard
In the Web Browser on my Windows laptop, I started the Kubernetes Dashboard (http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy) and I entered the value for the token (as can be seen above) and clicked on button “Sign in”.
