Pod Volume via hostPath via Minikube-Docker on Apple M1

Hits: 81

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!

Minikube on an Apple M1

Hits: 1613

Minikube? is local Kubernetes.

Kubernetes? is open source portable and flexible platform for managing containerized services, we have also declarative configuration and automation for services.

Docker Desktop on Apple M1

First thing, what we needed, it’s a Docker Desktop App for Apple Silicon.

Please check the Official Installation Guide, if installation steps changes has or new steps added..)

Docker Installation on Apple M1:

  • Download Docker Setup
  • Install Rosetta 2 Binaries
    • To install manually from the command line, run the following command
softwareupdate --install-rosetta

Important We Starting the Docker Desktop app after installation! (because i don’t did that!!!)

ok, so now docker desktop up and running…

Minikube

Minikube also has Official Installation Guide, please check the Official documentation, if the steps has changes or new steps added.

Why? because Docker and Minikube working ever day for integration for Apple Silicon, that means for us, the Installation Requirements or steps can be changes in the future.

Today’s minikube installation Steps, run following command in command line.

  • Download Minikube release
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64
  • Install Minikube
sudo install minikube-darwin-amd64 /usr/local/bin/minikube

After Minikube Installation, we should be able to start minikube. Actually one drive supported. Its’a docker, that means, we must be the driver as argument for minikube start given.

minikube start --driver=docker

with this command, minikube will download kubernetes required docker images, this can take a little longer.

everything looks good and minikube working very well. Let’s starting we the dashboard.. for that run followed single command in command line.

minikube dashboard

and here is..

Gitlab Installation WSL2 + Docker + Kubernetes + Helm 3

Hits: 526

helm create gitlab gitlab/gitlab
kubectl create namespace gitlab

gitlab/values.yaml

## GitLab Edition
### ref: https://about.gitlab.com/products/
### - CE - Community Edition
### - EE - Enterprise Edition - (requires license issued by GitLab Inc)
###
edition: CE
#
### GitLab CE image
### ref: https://hub.docker.com/r/gitlab/gitlab-ce/tags/
###
ceImage: gitlab/gitlab-ce:9.1.2-ce.0

certmanager-issuer:
  email: me@myserver.com

## Enable persistence using Persistent Volume Claims
## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
## ref: https://docs.gitlab.com/ce/install/requirements.html#storage
##
persistence:
  ## This volume persists generated configuration files, keys, and certs.
  ##
  gitlabEtc:
    enabled: true
    size: 1Gi
    ## If defined, volume.beta.kubernetes.io/storage-class: <storageClass>
    ## Default: volume.alpha.kubernetes.io/storage-class: default
    ##
    # storageClass:
    accessMode: ReadWriteOnce
  ## This volume is used to store git data and other project files.
  ## ref: https://docs.gitlab.com/omnibus/settings/configuration.html#storing-git-data-in-an-alternative-directory
  ##
  gitlabData:
    enabled: true
    size: 10Gi
    ## If defined, volume.beta.kubernetes.io/storage-class: <storageClass>
    ## Default: volume.alpha.kubernetes.io/storage-class: default
    ##
    # storageClass:
    accessMode: ReadWriteOnce
  gitlabRegistry:
    enabled: true
    size: 10Gi
    ## If defined, volume.beta.kubernetes.io/storage-class: <storageClass>
    ## Default: volume.alpha.kubernetes.io/storage-class: default
    ##
    # storageClass:

  postgresql:
    persistence:
      # storageClass:
      size: 10Gi
  ## Configuration values for the Redis dependency.
  ## ref: https://github.com/kubernetes/charts/blob/master/stable/redis/README.md
  ##
  redis:
    persistence:
      # storageClass:
      size: 10Gi


externalUrl: 'https://gitlab.local'

omnibusConfigRuby: |
  # This is example config of what you may already have in your omnibusConfigRuby object
  unicorn['worker_processes'] = 2;
  gitlab_rails['trusted_proxies'] = ["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16"];

  registry_external_url 'https://containerregistry.local';

  # These are the settings needed to support proxied SSL
  nginx['listen_port'] = 80
  nginx['listen_https'] = false
  nginx['proxy_set_headers'] = {
    "X-Forwarded-Proto" => "https",
    "X-Forwarded-Ssl" => "on"
  }
  registry_nginx['listen_port'] = 80
  registry_nginx['listen_https'] = false
  registry_nginx['proxy_set_headers'] = {
    "X-Forwarded-Proto" => "https",
    "X-Forwarded-Ssl" => "on"
  }

ingress:
  enabled: true
  annotations:
   kubernetes.io/ingress.class: nginx
   # kubernetes.io/tls-acme: 'true' Annotation used for letsencrypt support

  hosts:
    - gitlab.local
    - containerregistry.local

    ## gitlab Ingress TLS configuration
    ## Secrets must be created in the namespace, and is not done for you in this chart

#    tls:
#      - secretName: gitlab-tls
#        hosts:
#          - gitlab.local
#          - containerregistry.local
helm install --namespace=gitlab gitlab -f values.yaml gitlab/gitlab

Create Docker Image with Tag from .tar file and push in Private Docker Registery

Hits: 533

Create Docker Image from .tar file

$ docker load --input my-dockerized-app-0.0.1.tar

Create a tag.

Before tag creating, i will learn my source image/newly created docker image ID for the tag creating command..

 $ docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

we can find that via “docker image ls”, but put the grep command, because i want only the same name having images seen, what I as grep argument given.

$ docker image ls | grep my-docker
my-dockerized-app                        0.0.1       c0f32faf4320   1 minute ago      

And now i can create a new tag for local or for private docker registry

Option 1. Tag for Only Local Using

$ docker tag c0f32faf4320 my-dockerized-app:0.0.1

Option 2. Tag for Local and over Local/Open Registry

$ docker tag c0f32faf4320 docker.d8devs.com/apps/my-dockerized-app:0.0.1
$ docker push docker.d8devs.com/apps/my-dockerized-app:0.0.1

Example Usage:

in docker-compose.yml

version: '3'
services:
    frontend:
        image: my-dockerized-app:0.0.1
......
.....
....

for Kubernetes deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-deployment
  labels:
    app: app-test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app-test
  template:
    metadata:
      labels:
        app: app-test
    spec:
      containers:
      - name: frontend
        image: my-dockerized-app:0.0.1 // or docker.d8devs.com/apps/my-dockerized-app:0.0.1 (dont forget use the imagePullSecrets for privat Registry)

Docker (Ubuntu, Linux) – #ERROR: Couldn’t connect to Docker daemon at http+docker://localhost – is it running?

Hits: 523

it’s means in many times(%95), your user not under docker group placed, or your post-install (docker group, user actions etc. steps) not completely done yet. For temporary fix, you can your docker/docker-compose command with sudo run.

kzorloglu@kzorloglu:~/projects/chameleon$ composer up
#ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

to

kzorloglu@kzorloglu:~/projects/chameleon$ sudo composer up