Deployment Overview of MicroK8s on Server¶
Prerequisites and Basic Requirements¶
To ensure a successful deployment, the following requirements must be met:
-
Operating System: Ubuntu
-
Privileges: Root or sudo access is required for all installation steps.
-
Package Manager:
aptandsnapdmust be available. -
Network Access: The server requires outbound internet access to download packages via
aptandsnap.
Application Installation Process¶
The application is installed using a combination of system package management and the Snap package manager. The installation process follows these steps:
-
Docker Engine Installation: Docker is installed on the host system to support containerized workloads.
-
Package Index Update: The
aptpackage index is updated to ensure all dependencies are current. -
Snapd Installation: The
snapdservice is installed viaapt. -
MicroK8s Installation: MicroK8s (version
1.31/stable) is installed using the Snap package manager with the--classicconfinement flag. -
User Configuration: The
rootuser is added to themicrok8sgroup to allow necessary permissions for cluster management. -
Addon Activation: The following MicroK8s addons are enabled:
-
dns: Provides internal DNS services within the cluster. -
hostpath-storage: Provides local storage capabilities using host paths. -
dashboard: Deploys the Kubernetes web-based user interface. -
CLI Configuration: A command alias is created so that
kubectlcan be used directly viamicrok8s kubectl.
Docker Containers and Their Deployment¶
The deployment includes a specialized Nginx container managed via Docker Compose to handle SSL certificate management.
| Service | Image | Ports | Volumes | Environment Variables | Restart Policy |
|---|---|---|---|---|---|
nginx | jonasal/nginx-certbot:latest | Host Network Mode | - nginx_secrets:/etc/letsencrypt- /data/nginx/user_conf.d:/etc/nginx/user_conf.d | [email protected] | unless-stopped |
Custom Scripts and Additional Setup¶
The following actions are performed during the initial setup to ensure service availability:
-
Dashboard Access Token Generation: An access token is generated for the Kubernetes Dashboard using the command
microk8s kubectl create token default. -
Port Forwarding: A background process is initiated to forward the Kubernetes Dashboard port from the cluster to the host at
10443:443to allow external management access.
Location of Configuration Files and Data¶
The following paths are used for configuration and persistent data:
-
Nginx/Certbot Secrets: Managed via an external Docker volume named
nginx_secrets. -
Nginx User Configurations:
/data/nginx/user_conf.d -
Nginx Environment Variables:
/data/nginx/nginx-certbot.env
Available Ports for Connection¶
The following ports are utilized by the application:
-
10443: Kubernetes Dashboard (via port forwarding). -
80/443: Managed via Nginx in host network mode for SSL termination.
Starting and Stopping the Application¶
Management of the MicroK8s service is performed using the following commands:
-
Check Status:
microk8s status -
Enable Addons:
microk8s enable <addon_name> -
Kubectl Command Usage: Use
kubectl(via the created alias) for all cluster management tasks.