Kubernetes snippets

Create SSL certificate on K8s

kubectl create secret tls ssl_certificate_name --key private_key_path --cert certificate_path --namespace=namespace_name 

Create Docker Registry

kubectl create secret docker-registry docker_registry_name --docker-server=https://index.docker.io/v1/ --docker-username=your_username --docker-password=your_password --docker-email=your_email -n namespace_name

Restore PostgreSQL database on Kubernetes

cat database_file.sql | kubectl -n namespace_name exec -i pod_name -- psql -U postgres_username -d database_name

Dump database

kubectl -n namespace_name exec pod_name -- bash -c "pg_dump -U postgres_username database_name" > database_file.sql