Last active
March 2, 2023 09:13
-
-
Save vfarcic/182473cd7a640520a236d2f0fe51b587 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://gist.github.com/182473cd7a640520a236d2f0fe51b587 | |
################################################ | |
# Multi-Tenant Kubernetes Cluster With Capsule # | |
# https://youtu.be/H8bzEJN7fj8 # | |
################################################ | |
# Referenced videos: | |
# - K3d - How to run Kubernetes cluster locally using Rancher k3s: https://youtu.be/mCesuGk-Fks | |
######### | |
# Setup # | |
######### | |
git clone https://github.com/vfarcic/capsule-demo | |
cd capsule-demo | |
# Please watch https://youtu.be/mCesuGk-Fks if you are not familiar with k3d | |
# Feel free to use any other Kubernetes platform | |
k3d cluster create --config k3d.yaml | |
# If not using k3d, install Ingress in whichever way that works for your Kubernetes distribution | |
helm repo add clastix https://clastix.github.io/charts | |
helm upgrade --install \ | |
capsule clastix/capsule \ | |
--namespace capsule-system \ | |
--create-namespace \ | |
--wait | |
kubectl create namespace not-for-joe | |
#################### | |
# Creating tenants # | |
#################### | |
cat tenant.yaml | |
kubectl apply --filename tenant.yaml | |
kubectl get tenants | |
cat create-user.sh | |
./create-user.sh jdoe team-joe | |
################################### | |
# Creating Namespaces as a tenant # | |
################################### | |
export KUBECONFIG=jdoe-team-joe.kubeconfig | |
kubectl create namespace joe | |
kubectl create namespace team-joe-dev | |
kubectl create namespace team-joe-prod | |
kubectl create namespace team-joe-staging | |
cat tenant.yaml | |
###################################### | |
# Deploying applications as a tenant # | |
###################################### | |
cat app.yaml | |
kubectl --namespace not-for-joe \ | |
apply --filename app.yaml | |
kubectl --namespace not-for-joe get pods | |
kubectl delete namespace not-for-joe | |
kubectl --namespace joe \ | |
apply --filename app.yaml | |
kubectl --namespace joe get all | |
kubectl --namespace joe get rolebindings | |
kubectl get namespaces | |
########### | |
# Destroy # | |
########### | |
k3d cluster delete devops-toolkit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment