Thanks to visit codestin.com
Credit goes to github.com

Skip to content

jzetterman/minikube-start

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Set up a Minikube development environment

Install VMware Workstation Pro (optional)

This option is supposedly the most compatible with container deployment to vSphere. The Workstation Pro client can be downloaded for free. You will need a Broadcom support portal account, but you can create one for free.

Windows:

Download

The Linux client can also be installed

Once installed, ensure that vmrun is available from the command line by verifying that C:\Program Files (x86)\VMware\VMware Workstation exists in system PATH.

NOTE: I had C:\Program Files (x86)\VMware\VMware Workstation\bin, but not C:\Program Files (x86)\VMware\VMware Workstation and had to add it manually.

Ubuntu (and variants):

Download

Install prerequisites first by running:

sudo apt update
sudo apt install -y build-essential -y

To install VMware Workstation Pro, first navigate to the folder it was downloaded to. Then run this command, substituting the name of your specific file, which will be different as newer versions are released.

sudo bash VMware-Workstation-Full-17.6.4-24832109.x86_64.bundle

Install additional required Kernel modules by running:

sudo vmware-modconfig --console --install-all

Install Docker (optional)

You must install either VMware Workstation Pro or Docker. You can install both if desired.

Windows 11:

winget install Docker.DockerCLI

Ubuntu (and variants):

Install Docker's apt repository:

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Arch Linux (and variants):

sudo pacman -Syu
sudo pacman -S docker

NOTE: By default, Docker runs as a system service. As a best practice, Docker can be run rootless. This requires additional set up.

Install the docker-rootless package from the Arch User Repository:

sudo paru -S docker-rootless

OR

sudo yay -S docker-rootless

You will need an AUR helper to install all components. Two common helpers are Yay and Paru. Paru is my preference. It can be installed by following the installation instructions on it's Github.

Install Kubectl

kubectl is a command-line tool used to interact with Kubernetes clusters. It acts as a bridge between users and the Kubernetes control plane, allowing users to manage and operate Kubernetes resources such as pods, services, deployments, and more.

Windows 11:

winget install Kubernetes.kubectl

Verify kubectl is installed by running this command.

kubectl version --client

Linux:

Ubuntu (and variants):

NOTE: The classic tag here is extremely important. This ensures that kubectl is installed outside of a sandbox.

sudo snap install kubectl --classic

Arch Linux (and variants):

sudo pacman -Syu
sudo pacman -S kubectl

Install Minikube

Minikube is a lightweight Kubernetes implementation that creates a single-node Kubernetes cluster on your local machine. It is designed to simplify local Kubernetes development, making it accessible for developers to learn and test Kubernetes-based applications without needing a full multi-node cluster or cloud resources. Minikube is available for various operating systems, including Linux, macOS, and Windows.

Windows 11:

winget install Kubernetes.minikube

Verify that minikube was install successfully by running:

minikube version

Linux:

Ubuntu (and variants):

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
chmod +x minikube-linux-amd64
sudo mv minikube-linux-amd64 /usr/local/bin/minikube

Verify that minikube was install successfully by running:

minikube version

Arch Linux (and variants):

sudo pacman -Syu
sudo pacman -S minikube

Verify that minikube was install successfully by running:

minikube version

Start Minikube

If you installed VMware Workstation Pro, you can start minikube by running:

minikube start --driver=vmware

If you installed Docker, you can run:

minikube start --driver=docker

You should now successfully have a minikube development environment up and running.

Usage Examples

Drupal

Install Helm:

Helm is the best way to find, share, and use software built for Kubernetes. Helm helps you manage Kubernetes applications — Helm Charts help you define, install, and upgrade even the most complex Kubernetes application.

Learn more here: https://www.freecodecamp.org/news/what-is-a-helm-chart-tutorial-for-kubernetes-beginners/

Windows:

winget install Helm.Helm

Ubuntu (and variants):

NOTE: The classic tag here is extremely important. This ensures that helm is installed outside of a sandbox.

sudo snap install helm --classic

Arch Linux (and variants):

sudo pacman -S helm

Install Drupal using Helm

First add the Bitnami repository to Helm:

helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update

Next install the Drupal Helm chart. Replace my-drupal with your preferred release name. Set secure passwords for Drupal admin and the database root (avoid defaults in production-like setups).

helm install my-drupal oci://registry-1.docker.io/bitnamicharts/drupal --set drupalUsername=admin --set drupalPassword=your-secure-password --set mariadb.auth.rootPassword=your-db-root-password --set mariadb.auth.password=your-db-password

It will take several minutes to deploy. You can monitor the status of the deployment by running the following command. Substitute the name you used for your drupal instance.

kubectl get svc --namespace default -w my-drupal

as well as

kubectl get pods

Once you see a Ready status of 1/1 for both the drupal app container and the mariadb container it is ready.

Once installed you can get the service IP address by running the following command. Substitute my-drupal with the name you used for your drupal instance.

minikube service my-drupal --url

NOTE: This command will not exit. It needs to be running for the URLs to be accessible. The first URL is the HTTP URL for the Drupal instance. The second URL is the HTTPS URL for the Drupal instance. Copy the first URL and paste it into your browser, you should be presented with the Drupal welcome page. The next section describes how to configure minikube in a way that allows you to access the Drupal instance from outside the cluster, which is useful for testing and development purposes without keeping your terminal open.

Configure Ingress

We will leverage Minikube's built-in Ingress addon, which deploys an NGINX Ingress controller. Once set up, you can access Drupal directly at your Minikube cluster's IP address (e.g., http://192.168.49.2), and this remains available as long as the cluster is running.

Enable the ingress addon

minikube addons enable ingress

Verify that the ingress addon is enabled

minikube addons list | grep ingress

Create an ingress resource

Create a new file called drupal-ingress.yaml with the following content:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: drupal-ingress
spec:
  rules:
  - host: drupal.local  # Optional
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-drupal
            port:
              number: 80

Apply the ingress resource

kubectl apply -f drupal-ingress.yaml

Verify that the ingress resource is created

kubectl get ingress drupal-ingress

Optionally, update your hosts file to include the following line. Use the actual IP of your Minikube cluster. You can get it by running minikube ip:

192.168.49.2 drupal.local

NOTE: On Windows your hosts file is located at C:\Windows\System32\drivers\etc\hosts. On Linux and macOS, it is located at /etc/hosts.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published