Kubernetes Service Account and RBAC Tutorial

In this tutorial, we created a Service Account with a Role and RoleBinding for read-only access to Pods. You can find the source code in the GitHub repository. What is a Service Account in Kubernetes? A Service Account in Kubernetes is a special type of account that is used by processes or applications running inside Pods to authenticate and interact with the Kubernetes API. Unlike User Accounts, which are typically associated with human users, Service Accounts are designed for non-human access. They are used to grant specific permissions to applications, allowing them to interact with the Kubernetes cluster in a controlled and secure way. ...

January 16, 2025 · 5 min · Hamid

Hashicorp Vault Agent Tutorial: Generating .env from Vault Secrets

In this tutorial, we will set up Vault Agent to generate a .env file with secrets from HashiCorp Vault. We’ll use the AppRole authentication method to securely authenticate and retrieve secrets, then write them to an environment file for use in your application. You can find the complete configuration files and setup used in this tutorial in the GitHub repository. ⚠️ Important Note: This tutorial uses Vault in development mode (-dev) for simplicity. Development mode is not secure and should only be used for testing and learning purposes. In a production environment: ...

January 2, 2025 · 4 min · Hamid

Run GitLab CI Jobs on a Specific Runner

I have two runners in my project. One is on Microsoft Azure for Azure deployments, and the other is on DigitalOcean for its deployments. Today, I realized that all of my jobs are being handled by the Azure runner, causing our tests to take too much time due to significant network delay when connecting to the database across data centers. Therefore, I needed to configure specific jobs to run on designated runners. Here, I’ll explain how to do that. ...

October 31, 2024 · 2 min · Hamid

Install Docker and Docker Compose by single command and use it without sudo :)

I know it looks crazy, but to be honest, I am frustrated with searching “install docker ubuntu” and copying and pasting lots of commands every time. If this happens to you a lot, you can bookmark this gist and just copy and paste it to install Docker, Compose, and post-installation commands. for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done && sudo apt-get update && sudo apt-get install ca-certificates curl gnupg && sudo install -m 0755 -d /etc/apt/keyrings && curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg && sudo chmod a+r /etc/apt/keyrings/docker.gpg && echo \ "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \ "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update && sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin && sudo groupadd docker && sudo usermod -aG docker $USER && newgrp docker && sudo docker run hello-world A shorter way If you don’t want to copy such a long command, you can easily run this one: ...

September 8, 2023 · 2 min · Hamid

Hello world Kubernetes with Nginx on Minikube

Kubernetes gives you the ability to deploy your app in a highly available way, and it has provisioning features that you can use to avoid manual tasks. There are tons of tutorials about Kubernetes out there, but in this simple post, I just want to give you the simplest deployment ever in Kubernetes. You will see how to deploy nginx with Kubernetes and access it easily. Before deployment, make sure you have properly installed kubectl and minikube, and remove any old stuff from minikube using the delete and start commands. ...

August 18, 2023 · 3 min · Hamid