Kamis, 15 Agustus 2024

Access postgresql on host from your container

Make sure that you can access your postgresql using: 
psql -U postgres -h localhost -W 

Docker
Install Docker (skip if you have installed docker before)
- sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" (I'm using arm processor)
- sudo apt update
- sudo apt install docker-ce
- sudo systemctl status docker (make sure status is active)
- sudo usermod -aG docker ${USER}
- su - ${USER}
- id -nG

o ifconfig docker0 check your host ip on docker
example:
ifconfig docker0 docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255 ether 02:42:54:c5:b2:d1 txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
o Running PostgreSQL in Docker
docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres


o on your container do some migration (if you are using laravel)
docker exec -it <your-laravel-container> bash
php artisan migrate

Create swap partition

lsblk to check your hdd

sudo fdisk /dev/sdX

Replace /dev/sdX with the correct device name. Inside the fdisk utility:

  • Press n to create a new partition.
  • Choose the partition number, default is usually fine.
  • Press Enter to accept the default starting and ending sectors.
  • Press t to change the partition type.
  • Enter 82 to set the partition type to "Linux swap".
  • Press w to write the changes to the disk.
sudo mkswap /dev/sdX1
sudo vim /etc/fstab
add /dev/sdX1 none swap sw 0 0
verify swap sudo swapon --show

Selasa, 13 Agustus 2024

Create secret for SSL Certificate on Ingress

 kubectl create secret  tls wildcard-secret \

--cert=wildcard.crt \

--key=wildcard.key \

-n your-app-namespace --output yaml > tls.yml


apply the configuration file
kubectl apply -f tls.yml

Install NGINX Ingress Controller

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx

helm repo update

helm install nginx-ingress ingress-nginx/ingress-nginx \

--namespace ingress-nginx \

--create-namespace

verify your installation

kubectl get pods -n ingress-nginx

kubectl get svc -n ingress-nginx


If you want to put static IP on your ingress controller

helm install nginx-ingress ingress-nginx/ingress-nginx \

--namespace ingress-nginx \

--set controller.service.loadBalancerIP=your-ip-public \

--create-namespace