Gitlab Installation WSL2 + Docker + Kubernetes + Helm 3

Hits: 760

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: 1175

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)

Magic Mirror – PIR Sensor – Update #3

Hits: 232

The idea of installing the motion detector is that it either turns the HDMI signal on or off. IF the motion detector does not detect any movement for 9 seconds (value that can be changed as required), it switches of the HDMI Signal. As soon as movement is registered again, it switches the signal on again. If movement is also registered during 60 seconds, the timer is reset to zero..

The pir sensor connected to raspberry pi with female-female jumper cable.

  • VCC to Pin 2
  • GND to Pin 6
  • OUT to Pin 12

And now the motion detector should switch the HDMI signal on or off. Two shell scripts are created for this. The first is created with command:

sudo nano /home/pi/magicmirror/monitor_on.sh

with following content:

vcgencmd display_power 1 > /dev/null

the second script with the command:

sudo nano /home/pi/magicmirror/monitor_on.sh

with following content:

vcgencmd display_power 0 > /dev/null

Now a python script.. Create this script with the command:

sudo nano /home/pi/magicmirror/pir_monitor_controller.py

with following content:

#!/usr/bin/env python

import sys
import time
import RPi.GPIO as io 
import subprocess

io.setmode(io.BOARD)
SHUTOFF_DELAY = 9
PIR_PIN=12

def main():
    io.setup(PIR_PIN, io.IN)
    turned_off = False
    last_motion_time = time.time()
    while True:
        if io.input(PIR_PIN):
            last_motion_time = time.time()
            sys.stdout.flush()
            if turned_off:
                turned_off = False
                turn_on()
        else:
            if not turned_off and time.time() > (last_motion_time + SHUTOFF_DELAY):
                turned_off = True
                turn_off()
            if not turned_off and time.time() > (last_motion_time + 1):
                time.sleep(.1)
def turn_on():
    subprocess.call("sh /home/pi/magicmirror/monitor_on.sh", shell=True)

def turn_off():
    subprocess.call("sh /home/pi/magicmirror/monitor_off.sh", shell=True)

if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        io.cleanup() 

Now service file… a service file has to be added so that this script is always executed when it is started. The command:

cd /lib/systemd/system/
sudo nano pir_monitor_controller.service

with the following content:

[Unit]      
Description=MagicMirror PIR Service       
After=multi-user.target       
                
[Service]       
Type=idle       
ExecStart=/usr/bin/python /home/pi/magicmirror/pir_monitor_controller.py > /home/pi/magicmirror/pir_monitor_controller.log 2>&1       
                
[Install]       
WantedBy=multi-user.target
sudo systemctl daemon-reload 
sudo systemctl enable pir_monitor_controller.service 
sudo systemctl start pir_monitor_controller.service

and Testing..