Skip to content

Instantly share code, notes, and snippets.

View k4kratik's full-sized avatar
🐳

Kratik Jain k4kratik

🐳
View GitHub Profile
@k4kratik
k4kratik / kratik-zoho-login.md
Last active October 12, 2020 03:59
Instructions on How to use k4kratik/zoho Docker Image to Automate your login on Zoho People.

To make this work as expected, provide these three Environments correctly and then you are good to go!

  1. ENV1 - your email - Plain text
  2. ENV2 - your password - Base64 encoded
  3. ZOHO_NOTIFY_WEBHOOK - Webhook, where you want to send notifications - Plain Text

I have tried with Webhook URL of one of my room on Google Chat.

So for setting up you env, do this -

@k4kratik
k4kratik / docker-image-check.sh
Last active May 22, 2021 09:27
Script to find if your Docker image with the specific tag exists or not. Check the blog at https://blog.virtualk.xyz/check-docker-image.
function DockerImageCheckFunction() {
# you can comment all the DEBUG echo statements, there are here just for info.
DHUB_TOKEN=$(curl -sSLd "username=${DOCKER_HUB_USERNAME}&password=${DOCKER_HUB_PASSWORD}" https://hub.docker.com/v2/users/login | jq -r ".token")
echo "[DEBUG] [$(date)] Token is: $DHUB_TOKEN"
echo
echo "[DEBUG] [$(date)] Hitting the endpoint: https://hub.docker.com/v2/repositories/${DOCKER_REPO}/tags/${DOCKER_TAG}/"
REPO_RESPONSE=$(curl -sH "Authorization: JWT $DHUB_TOKEN" "https://hub.docker.com/v2/repositories/${DOCKER_REPO}/tags/${DOCKER_TAG}/")
echo
from datetime import datetime, timedelta
def deletion_time(ttl):
print("[DEBUG] The Current Time is: ",datetime.now())
delete_at_time = datetime.now() + timedelta(minutes=int(ttl))
print("[DEBUG] This Will be deleted at: ",delete_at_time)
hh = delete_at_time.hour
mm = delete_at_time.minute
yyyy = delete_at_time.year
month = delete_at_time.month
AWSTemplateFormatVersion: "2010-09-09"
Description: Schedule automatic deletion of CloudFormation stacks
# Advance way to customize our Parameters inputs, looks very good to the users :)
Metadata:
License: Apache-2.0
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
@k4kratik
k4kratik / create-users-in-k8s.md
Last active April 19, 2022 05:04
create users for k8s cluster as per the requirements and assign them the minimum permissions required to function properly

How to set up users in Kubernetes?

When we set up Kubernetes the default config file (aka kubeconfig file) has admin privileges. This is fine when you are the only one who is going to access the cluster*(still not a good practice tho!)* but what if there are multiple teams/devs involved and they also need to access the cluster for some use case, obviously, they don't need the full access, So now what? Will you give them your kubeconfig file(or the access) which has full permissions? Absolutely not!

Have you heard about the Principle of least privilege? It dictates - A subject should be given only those privileges needed for it to complete its task. If a subject does not need an access right, the subject should not have that right.

So we should create users as per the requirements and assign them the minimum permissions to function properly, right? but how do we do it?

Just to be clear, Kubernetes does not have the support for users natively. And from the [documentation](https://kubernetes.

@k4kratik
k4kratik / vault-deploy.yml
Last active October 19, 2023 10:08
Vault Deployment for Vault Operator with External Secrets for Kubernetes
apiVersion: "vault.banzaicloud.com/v1alpha1"
kind: "Vault"
metadata:
name: "vault"
labels:
app.kubernetes.io/name: vault
namespace: vault-operator
spec:
size: 3
image: vault:1.13.3
@k4kratik
k4kratik / rbac.yaml
Created October 2, 2023 12:47
required RBAC permissions for vault to be deployed in K8s
kind: ServiceAccount
apiVersion: v1
metadata:
name: vault
namespace: vault-operator
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
@k4kratik
k4kratik / secret-store.yaml
Last active October 19, 2023 10:10
secret-store.yaml
apiVersion: external-secrets.io/v1beta1
kind: ClusterSecretStore
metadata:
name: vault-secret-store
spec:
provider:
vault:
server: "https://vault.vault-operator:8200"
# adding this to verify CA, as we are using self-signed certificates.
@k4kratik
k4kratik / sample-external-secret.yaml
Last active October 19, 2023 11:14
ExternalSecret maniefest
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: sample-external-secrets
namespace: vault-operator
spec:
refreshInterval: 15s
secretStoreRef:
name: vault-secret-store # name of the secret store
kind: ClusterSecretStore