Local Multi-Domain Kubernetes for Development with Kind + Ubuntu + WSL2 + Docker Desktop

Hits: 557

Installation

WSL2 installation on Windows

Install Ubuntu on WSL2 on Windows

Docker Desktop Download

Configuration

After the Docker Desktop installation we need to enable the following WSL integrations at Docker Desktop:

  • Settings > General > check Use the WSL 2 based engine
  • Settings > Resources > check Enable integration with my default WSL distro
Continue reading “Local Multi-Domain Kubernetes for Development with Kind + Ubuntu + WSL2 + Docker Desktop”

PHP Profiler SPX – A Another Simple Profiling Tool

Hits: 604

SPX is a PHP Extension for Profiling, also open source, very simple, multimetric capable and with out-of-box web UI for listing, sorting and report details.

For installation, we need to build our extension. We can of course put the building phases directly into our Dockerfile, but I want to know, what things (extension file, webUI Files and configuration changes) need to come through the extension. For this reason, I make a seperate build process in my Dockerfile and copy everything this extension needs.

I follow the steps from official documentation (Timestamp: 20.05.2022), please check, if new or old steps were published, after this blog article)

Continue reading “PHP Profiler SPX – A Another Simple Profiling Tool”

Pod Volume via hostPath via Minikube-Docker on Apple M1

Hits: 155

Actually Docker Desktop App as default sharing Users, private etc. folder with Docker Images.

Github Repo for Example Project: https://github.com/kzorluoglu/localphp8nginxwithhelm

But Minikube need minikube mount bidirectional folder sync. From this reason i will say, use your own simple folder structure for Minikube hostPath Solution. For example:

Macbook Folder: $home/minikubeprojects
Minikube Cluster: mnt1/minikubeprojects

For mounting, you need after minikube start only this

 korayzorluoglu@MBP-von-Koray ~ % minikube mount $HOME/minikubeprojects:/mnt1/minikubeprojects

Example Configuration

Project / chart / values.yaml

mountPath: /var/www/html
nginx:
  image: nginx:1.14.2

php:
  image: php:8.1-rc-fpm-alpine

Project / chart / templates / deployments.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: php8-project-deployment
  labels:
    app: php8-project-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: php8-project-deployment
  template:
    metadata:
      labels:
        app: php8-project-deployment
    spec:
      volumes:
        # Create the shared files volume to be used in both pods
        - name: php8-project-pv-storage
          persistentVolumeClaim:
            claimName: php8-project-pv-claim
        # Add the ConfigMap we declared above as a volume for the pod
        - name: nginx-config-volume
          configMap:
            name: php8-project-nginx-config
      containers:
        - name: php8-project-nginx
          image: {{ .Values.nginx.image }}
          ports:
            - containerPort: 80
          volumeMounts:
            - name: php8-project-pv-storage
              mountPath: {{ .Values.mountPath }}
            - name: nginx-config-volume
              mountPath: /etc/nginx/nginx.conf
              subPath: nginx.conf
          # Just spin & wait forever
          command: [ "/bin/bash", "-c", "--" ]
          args: [ "while true; do sleep 30; done;" ]
        - name: php
          image: {{ .Values.php.image }}
          volumeMounts:
            - name: php8-project-pv-storage
              mountPath: {{ .Values.mountPath }}

Project / chart / templates / volume.yaml

kind: PersistentVolume
apiVersion: v1
metadata:
  name: php8-project-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/mnt1/minikubeprojects/php8/app"

---

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: php8-project-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 3Gi

Project / chart / templates / configmap.yaml

kind: ConfigMap
apiVersion: v1
metadata:
  name: php8-project-nginx-config
data:
  nginx.conf: |
    events {
    }
    http {
      server {
        listen 80 default_server;
        listen [::]:80 default_server;

        # Set nginx to serve files from the shared volume!
        root {{ .Values.mountPath }};
        server_name _;
        location / {
          try_files $uri $uri/ =404;
        }
        location ~ \.php$ {
          include fastcgi_params;
          fastcgi_param REQUEST_METHOD $request_method;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_pass 127.0.0.1:9000;
        }
      }
    }

do you need mount directoy check? for that, check the minikube directory and pod directory, or the pod details via kubectl pod describe your-chart-name

korayzorluoglu@MBP-von-Koray chart % minikube ssh && cd /mnt1/minikubeprojects && tree

Enjoy!