SlideShare a Scribd company logo
1 of 40
Download to read offline
Multi-Tenancy
on
Jirayut Nimsaeng (Dear)
CEO & Founder, Opsta (Thailand) Co.,Ltd.
TechTalkThai Conference: Kubernetes Trends
September 16, 2021 https://bit.ly/opsta-ttt-k8s-tenancy
Multi-Tenancy on Kubernetes
#whoami
Jirayut Nimsaeng (Dear)
Jirayut has been involved in DevSecOps, Container, Cloud Technology
and Open Source for over 10 years. He has experienced and
succeeded in transforming several companies to deliver greater
values and be more agile.
● He is Founder and CEO of Opsta (Thailand) Co.,Ltd.
● He is Cloud/DevSecOps Transformation Consultant and
Solution Architecture
● He is the first Certified Kubernetes Security Specialist (CKS)
and Certified Kubernetes Administrator (CKA) in Thailand
Multi-Tenancy on Kubernetes
Agenda
● What is Multi-Tenancy?
● Multi-Tenancy Primitive
● Access Control
● Fair Sharing
● Isolation
● Future
Multi-Tenancy on Kubernetes
What is Multi-Tenancy?
Multi-Tenancy on Kubernetes
Single vs Multi-Tenant
https://dev.to/sciencebae/multi-tenant-architecture-and-it-s-issues-h06
Multi-Tenancy on Kubernetes
Multi-Tenancy on Kubernetes
https://cloud.google.com/kubernetes-engine/docs/concepts/multitenancy-overview
Multi-Tenancy on Kubernetes
Why Kubernetes Multi-Tenancy?
● Reduced management overhead
● Reduced resource fragmentation
● Cost efficiency
Multi-Tenancy on Kubernetes
Kubernetes Multi-Tenancy Types
Soft Multi-tenancy
● trust tenants
● may has relation between
tenants
● we believe that they are not
trying to harm other tenants
● focus on preventing accidents
Hard Multi-tenancy
● zero trust tenants
● each tenant has no relation to
each other
● we believe that they are trying
to exploit the system
● focus on securing and
isolating each tenant
Multi-Tenancy on Kubernetes
Kubernetes Multi-Tenancy Models
● Namespaces as a Service
allows sharing clusters and hence enables resource efficiencies with
cluster-wide resources limitation
● Clusters as a Service
better isolation with higher management and resource overhead.
● Control Planes as a Service
virtual cluster where each tenant gets their own dedicated Kubernetes
control plane but share worker node resources
Multi-Tenancy on Kubernetes
Kubernetes
Multi-Tenancy Primitive
Multi-Tenancy on Kubernetes
Multi-Tenancy on Kubernetes Overview
https://www.vamsitalkstech.com/architecture/a-deepdive-into-kubernetes-multitenancy-1-2/
Multi-Tenancy on Kubernetes
Kubernetes Multi-Tenancy Primitive
● Access Control
Use policies to ensure that
tenants can access only what
they should have access to
○ RBAC
● Fair Sharing
Enforce limits per tenant
○ Resource Quota
○ Pod Priority
○ Quality of Service
○ Taints & Tolerations
○ Pod Affinity / Anti-affinity
● Isolation
Ensure tenants cannot access
each others’ workloads,
secrets, etc.
○ Namespace
○ Pod Security Policy
○ Network Policy
○ Sandbox
Multi-Tenancy on Kubernetes
Access Control
Multi-Tenancy on Kubernetes
RBAC
Role-based access control (RBAC) is a method of regulating access to computer
or network resources based on the roles of individual users within your organization
https://www.cncf.io/blog/2020/08/28/kubernetes-rbac-101-authorization/
Multi-Tenancy on Kubernetes
Multi-Tenancy Roles
● [ClusterRoleBinding] Cluster Administrator
● A cluster administrator has access to all cluster resources and can configure
new tenant namespaces
● [ClusterRoleBinding] Cluster view
Read privileges for all resources in the cluster
● [RoleBinding] Tenant Administrator
● A tenant administrator manages namespaces that belong to the tenant
● [RoleBinding] Tenant User
● Read/write privileges for all resources scoped to that tenant
Multi-Tenancy on Kubernetes
Sample Role
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: tenant-a-role
namespace: tenant-a
rules:
- apiGroups: ["", "extensions", "apps"]
resources: ["*"]
verbs: ["*"]
- apiGroups: ["batch"]
resources:
- jobs
- cronjobs
verbs: ["*"]
Multi-Tenancy on Kubernetes
Fair Sharing
Multi-Tenancy on Kubernetes
Resource Quota
A resource quota, defined by a ResourceQuota
object, provides constraints that limit aggregate
resource consumption per namespace.
apiVersion: v1
kind: ResourceQuota
metadata:
name: mem-cpu-demo
spec:
hard:
requests.cpu : "1"
limits.cpu : "2"
apiVersion: "v1"
kind: "LimitRange"
metadata:
name: "resource-limits"
spec:
limits:
- type: "Container"
max:
cpu: "2"
memory: "1Gi"
min:
cpu: "100m"
memory: "4Mi"
default:
cpu: "300m"
memory: "200Mi"
defaultRequest:
cpu: "200m"
memory: "100Mi"
maxLimitRequestRatio:
cpu: "10"
Multi-Tenancy on Kubernetes
Pod Priority
Priority indicates the importance of a Pod relative to other Pods. If a Pod cannot be
scheduled, the scheduler tries to preempt (evict) lower priority Pods to make scheduling of the
pending Pod possible. An administrator can use ResourceQuota to prevent users from creating
pods at high priorities.
Priority Class Purpose Value/Priority
Cluster Core Essential services to operate the cluster itself, such as Dex for
authentication
100000
Tenant Critical Services which are business-critical to your tenant, and cannot
easily move to a new machine, such as database back-ends
70000
Administrative Services Dashboards that are important for managing the cluster, but could
tolerate a short outage while moving to a new machine
50000
Best Effort (default) No priority assigned; allows termination in favor of higher priority
workloads
100
Multi-Tenancy on Kubernetes
Sample Pod Priority
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: tenant-critical
value: 70000
globalDefault: false
description: "This priority class should be used for s ervices
which are business-critical to your tenant, and cannot easily
move to a new machine, such as database back-ends "
Multi-Tenancy on Kubernetes
Quality of Service for Pods
Quality of Service (QoS) class is a Kubernetes concept that the scheduler uses
for deciding the scheduling and eviction priority of the pods.
https://medium.com/blutv/qos-classes-of-k8s-pods-722238a61c93
Multi-Tenancy on Kubernetes
Taints & Tolerations
● Taints are applied to node, to repel a set of pods.
● Tolerations are applied to pods, and allow (but do not require) the pods to
schedule onto nodes with matching taints.
● Use cases: Dedicated Nodes and Nodes with Special Hardware
Multi-Tenancy on Kubernetes
Pod Disruption Budgets
A PDB limits the number of Pods of a replicated application that are down
simultaneously from voluntary disruptions
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: zk-pdb
spec:
maxUnavailable : 1
selector:
matchLabels :
app: zookeeper
Multi-Tenancy on Kubernetes
Pod Affinity / Anti-affinity
You can use Pod anti-affinity to prevent Pods
from different tenants from being scheduled on the
same node. Anti-affinity constraints are based on
Pod labels. For example high workload shouldn’t
stay on the same node.
apiVersion: v1
kind: Pod
metadata:
name: bar
labels:
team: "billing"
spec:
affinity:
podAntiAffinity :
requiredDuringSchedulingIgnoredD
uringExecution :
- topologyKey :
"kubernetes.io/hostname"
labelSelector :
matchExpressions :
- key : "team"
operator : NotIn
values : ["billing"]
Multi-Tenancy on Kubernetes
Isolation
Multi-Tenancy on Kubernetes
Namespace
● System namespaces
Exclusively for system pods. Usually kube-system namespace and manage by
cluster administrator
● Service namespaces
These namespaces should run services or applications that need to be accessed
by services in other namespaces. Usually manage by cluster administrator
● Tenant Namespaces
Tenant namespaces should be spun up to run applications that do not need to
be accessed from other namespaces in the cluster. Usually manage by tenant
administrator
Multi-Tenancy on Kubernetes
Pod Security Policy
A PodSecurityPolicy is an admission controller resource you create that validates requests to
create and update Pods on your cluster. The PodSecurityPolicy defines a set of conditions that Pods
must meet to be accepted by the cluster. when a request to create or update a Pod does not meet the
conditions in the PodSecurityPolicy, that request is rejected and an error is returned.
https://rancher.com/blog/2020/pod-security-policies-part-2
Multi-Tenancy on Kubernetes
Sample PSP
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: restricted
spec:
privileged: false
# Required to prevent escalations to root.
allowPrivilegeEscalation
: false
# The following is redundant with non-root + disallow
privilege
# escalation, but we can provide it for defense in depth.
requiredDropCapabilities
:
- ALL
# Allow core volume types.
volumes:
- 'configMap'
- 'emptyDir'
- 'projected'
- 'secret'
- 'downwardAPI'
# Assume that persistentVolumes set up by the cluster
admin
# are safe to use.
- 'persistentVolumeClaim'
hostNetwork: false
hostIPC: false
hostPID: false
runAsUser:
# Require the container to run without
root privileges.
rule: 'MustRunAsNonRoot'
seLinux:
# Assumes the nodes are using AppArmor
rather than SELinux.
rule: 'RunAsAny'
supplementalGroups
:
rule: 'MustRunAs'
ranges:
# Forbid adding the root group.
- min: 1
max: 65535
fsGroup:
rule: 'MustRunAs'
ranges:
# Forbid adding the root group.
- min: 1
max: 65535
Multi-Tenancy on Kubernetes
PodSecurityPolicy Deprecation
Kubernetes 1.21 starts the deprecation process for PodSecurityPolicy.
The current plan is to remove PSP from Kubernetes in the 1.25 release.
Kubernetes v1.22 as an Alpha feature, Kubernetes offers a built-in Pod
Security admission controller, the successor to PodSecurityPolicies.
● https://github.com/kubernetes/enhancements/issues/2579
● https://kubernetes.io/docs/concepts/security/pod-security-admission/
Multi-Tenancy on Kubernetes
Open Policy Agent (OPA)
package kubernetes. admission
deny[msg] {
input.request.kind.kind == "Pod"
some i
image := input.request.object.spec.containers[i].image
not startswith (image, "hooli.com/")
msg := sprintf("image '%v' comes from untrusted registry" ,
[image])
}
Multi-Tenancy on Kubernetes
Network Policy
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all
namespace: tenant-a
spec:
podSelector:
matchLabels :
ingress:
- from:
- podSelector : {}
you should block traffic between
namespaces that host different
tenants' applications
Multi-Tenancy on Kubernetes
Sandbox
VM Container gVisor
Multi-Tenancy on Kubernetes
Future
Multi-Tenancy on Kubernetes
k8s-sig-multi-tenancy
https://github.com/kubernetes-sigs/multi-tenancy
Multi-Tenancy on Kubernetes
Benchmarks
https://github.com/kubernetes-sigs/multi-tenancy/blob/master/benchmarks/kubectl-mtb/README.md
Multi-Tenancy on Kubernetes
The Hierarchical Namespace Controller
$ kubectl hns create my-service -n my-team
$ kubectl hns tree my-team
my-team
└── my-service
https://github.com/kubernetes-sigs/hierarchical-namespaces
Multi-Tenancy on Kubernetes
VirtualCluster
https://www.cncf.io/blog/2019/06/20/virtual-cluster-extending-namespace-based-multi-tenancy-with-a-cluster-view/
Multi-Tenancy on Kubernetes
Wrap-up
Multi-Tenancy on Kubernetes
Key Take-aways
● Use multi-tenancy for improved resource efficiency,
cost, and operations
● Multi-tenancy is unavoidable in the future
● Choose your multi-tenancy type and model
● To do multi-tenancy, you need to config kubernetes
access control, fair sharing, and isolation
Multi-Tenancy on Kubernetes
More questions?
jirayut@opsta.co.th
Jirayut Nimsaeng
CEO & Founder
Opsta (Thailand)
086-069-4042
Facebook

More Related Content

What's hot

Introduction to Kubernetes with demo
Introduction to Kubernetes with demoIntroduction to Kubernetes with demo
Introduction to Kubernetes with demoOpsta
 
Introduction to Helm
Introduction to HelmIntroduction to Helm
Introduction to HelmHarshal Shah
 
GitOps 101 Presentation.pdf
GitOps 101 Presentation.pdfGitOps 101 Presentation.pdf
GitOps 101 Presentation.pdfssuser31375f
 
Getting Started with Kubernetes
Getting Started with Kubernetes Getting Started with Kubernetes
Getting Started with Kubernetes VMware Tanzu
 
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Edureka!
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes IntroductionPeng Xiao
 
Introduction to Kubernetes and Google Container Engine (GKE)
Introduction to Kubernetes and Google Container Engine (GKE)Introduction to Kubernetes and Google Container Engine (GKE)
Introduction to Kubernetes and Google Container Engine (GKE)Opsta
 
Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!Krishna-Kumar
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopBob Killen
 
Deploying your first application with Kubernetes
Deploying your first application with KubernetesDeploying your first application with Kubernetes
Deploying your first application with KubernetesOVHcloud
 
Aks pimarox from zero to hero
Aks pimarox from zero to heroAks pimarox from zero to hero
Aks pimarox from zero to heroJohan Biere
 
Rancher 2.0 Technical Deep Dive
Rancher 2.0 Technical Deep DiveRancher 2.0 Technical Deep Dive
Rancher 2.0 Technical Deep DiveLINE Corporation
 
ArgoCD Meetup PPT final.pdf
ArgoCD Meetup PPT final.pdfArgoCD Meetup PPT final.pdf
ArgoCD Meetup PPT final.pdfamanmakwana3
 
OpenShift 4, the smarter Kubernetes platform
OpenShift 4, the smarter Kubernetes platformOpenShift 4, the smarter Kubernetes platform
OpenShift 4, the smarter Kubernetes platformKangaroot
 
Kubernates vs Openshift: What is the difference and comparison between Opensh...
Kubernates vs Openshift: What is the difference and comparison between Opensh...Kubernates vs Openshift: What is the difference and comparison between Opensh...
Kubernates vs Openshift: What is the difference and comparison between Opensh...jeetendra mandal
 

What's hot (20)

Introduction to Kubernetes with demo
Introduction to Kubernetes with demoIntroduction to Kubernetes with demo
Introduction to Kubernetes with demo
 
Introduction to Helm
Introduction to HelmIntroduction to Helm
Introduction to Helm
 
GitOps 101 Presentation.pdf
GitOps 101 Presentation.pdfGitOps 101 Presentation.pdf
GitOps 101 Presentation.pdf
 
Getting Started with Kubernetes
Getting Started with Kubernetes Getting Started with Kubernetes
Getting Started with Kubernetes
 
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
Docker & kubernetes
Docker & kubernetesDocker & kubernetes
Docker & kubernetes
 
Introduction to Kubernetes and Google Container Engine (GKE)
Introduction to Kubernetes and Google Container Engine (GKE)Introduction to Kubernetes and Google Container Engine (GKE)
Introduction to Kubernetes and Google Container Engine (GKE)
 
Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes Workshop
 
Deploying your first application with Kubernetes
Deploying your first application with KubernetesDeploying your first application with Kubernetes
Deploying your first application with Kubernetes
 
Gitlab, GitOps & ArgoCD
Gitlab, GitOps & ArgoCDGitlab, GitOps & ArgoCD
Gitlab, GitOps & ArgoCD
 
Kubernetes security
Kubernetes securityKubernetes security
Kubernetes security
 
Introduction to helm
Introduction to helmIntroduction to helm
Introduction to helm
 
Aks pimarox from zero to hero
Aks pimarox from zero to heroAks pimarox from zero to hero
Aks pimarox from zero to hero
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
Rancher 2.0 Technical Deep Dive
Rancher 2.0 Technical Deep DiveRancher 2.0 Technical Deep Dive
Rancher 2.0 Technical Deep Dive
 
ArgoCD Meetup PPT final.pdf
ArgoCD Meetup PPT final.pdfArgoCD Meetup PPT final.pdf
ArgoCD Meetup PPT final.pdf
 
OpenShift 4, the smarter Kubernetes platform
OpenShift 4, the smarter Kubernetes platformOpenShift 4, the smarter Kubernetes platform
OpenShift 4, the smarter Kubernetes platform
 
Kubernates vs Openshift: What is the difference and comparison between Opensh...
Kubernates vs Openshift: What is the difference and comparison between Opensh...Kubernates vs Openshift: What is the difference and comparison between Opensh...
Kubernates vs Openshift: What is the difference and comparison between Opensh...
 

Similar to How we can do Multi-Tenancy on Kubernetes

MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...
MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...
MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...Jitendra Bafna
 
12 Ways Not to get 'Hacked' your Kubernetes Cluster
12 Ways Not to get 'Hacked' your Kubernetes Cluster12 Ways Not to get 'Hacked' your Kubernetes Cluster
12 Ways Not to get 'Hacked' your Kubernetes ClusterSuman Chakraborty
 
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)QAware GmbH
 
Federated Kubernetes: As a Platform for Distributed Scientific Computing
Federated Kubernetes: As a Platform for Distributed Scientific ComputingFederated Kubernetes: As a Platform for Distributed Scientific Computing
Federated Kubernetes: As a Platform for Distributed Scientific ComputingBob Killen
 
Introduction to containers, k8s, Microservices & Cloud Native
Introduction to containers, k8s, Microservices & Cloud NativeIntroduction to containers, k8s, Microservices & Cloud Native
Introduction to containers, k8s, Microservices & Cloud NativeTerry Wang
 
Evolution of security strategies in K8s environments- All day devops
Evolution of security strategies in K8s environments- All day devops Evolution of security strategies in K8s environments- All day devops
Evolution of security strategies in K8s environments- All day devops Jose Manuel Ortega Candel
 
Kubernetes: https://youtu.be/KnjnQj-FvfQ
Kubernetes: https://youtu.be/KnjnQj-FvfQKubernetes: https://youtu.be/KnjnQj-FvfQ
Kubernetes: https://youtu.be/KnjnQj-FvfQRahul Malhotra
 
OSDC 2017: Automating Kubernetes Cluster Operations with Operators by Timo De...
OSDC 2017: Automating Kubernetes Cluster Operations with Operators by Timo De...OSDC 2017: Automating Kubernetes Cluster Operations with Operators by Timo De...
OSDC 2017: Automating Kubernetes Cluster Operations with Operators by Timo De...NETWAYS
 
OSDC 2017 - Timo Derstappen - Automating kubernetes cluster operations with o...
OSDC 2017 - Timo Derstappen - Automating kubernetes cluster operations with o...OSDC 2017 - Timo Derstappen - Automating kubernetes cluster operations with o...
OSDC 2017 - Timo Derstappen - Automating kubernetes cluster operations with o...NETWAYS
 
Running Kubernetes in Kubernetes
Running Kubernetes in KubernetesRunning Kubernetes in Kubernetes
Running Kubernetes in KubernetesQAware GmbH
 
(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive OverviewBob Killen
 
Getting started with google kubernetes engine
Getting started with google kubernetes engineGetting started with google kubernetes engine
Getting started with google kubernetes engineShreya Pohekar
 
DevOpsDaysRiga 2018: Andrew Martin - Continuous Kubernetes Security
DevOpsDaysRiga 2018: Andrew Martin - Continuous Kubernetes Security DevOpsDaysRiga 2018: Andrew Martin - Continuous Kubernetes Security
DevOpsDaysRiga 2018: Andrew Martin - Continuous Kubernetes Security DevOpsDays Riga
 
Containers kuberenetes
Containers kuberenetesContainers kuberenetes
Containers kuberenetescsegayan
 

Similar to How we can do Multi-Tenancy on Kubernetes (20)

MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...
MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...
MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...
 
12 Ways Not to get 'Hacked' your Kubernetes Cluster
12 Ways Not to get 'Hacked' your Kubernetes Cluster12 Ways Not to get 'Hacked' your Kubernetes Cluster
12 Ways Not to get 'Hacked' your Kubernetes Cluster
 
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
 
Federated Kubernetes: As a Platform for Distributed Scientific Computing
Federated Kubernetes: As a Platform for Distributed Scientific ComputingFederated Kubernetes: As a Platform for Distributed Scientific Computing
Federated Kubernetes: As a Platform for Distributed Scientific Computing
 
Introduction to containers, k8s, Microservices & Cloud Native
Introduction to containers, k8s, Microservices & Cloud NativeIntroduction to containers, k8s, Microservices & Cloud Native
Introduction to containers, k8s, Microservices & Cloud Native
 
Kubernetes basics and hands on exercise
Kubernetes basics and hands on exerciseKubernetes basics and hands on exercise
Kubernetes basics and hands on exercise
 
Evolution of security strategies in K8s environments- All day devops
Evolution of security strategies in K8s environments- All day devops Evolution of security strategies in K8s environments- All day devops
Evolution of security strategies in K8s environments- All day devops
 
Containers kuberenetes
Containers kuberenetesContainers kuberenetes
Containers kuberenetes
 
Containers kuberenetes
Containers kuberenetesContainers kuberenetes
Containers kuberenetes
 
Kubernetes: https://youtu.be/KnjnQj-FvfQ
Kubernetes: https://youtu.be/KnjnQj-FvfQKubernetes: https://youtu.be/KnjnQj-FvfQ
Kubernetes: https://youtu.be/KnjnQj-FvfQ
 
Kubernetes security with AWS
Kubernetes security with AWSKubernetes security with AWS
Kubernetes security with AWS
 
OSDC 2017: Automating Kubernetes Cluster Operations with Operators by Timo De...
OSDC 2017: Automating Kubernetes Cluster Operations with Operators by Timo De...OSDC 2017: Automating Kubernetes Cluster Operations with Operators by Timo De...
OSDC 2017: Automating Kubernetes Cluster Operations with Operators by Timo De...
 
OSDC 2017 - Timo Derstappen - Automating kubernetes cluster operations with o...
OSDC 2017 - Timo Derstappen - Automating kubernetes cluster operations with o...OSDC 2017 - Timo Derstappen - Automating kubernetes cluster operations with o...
OSDC 2017 - Timo Derstappen - Automating kubernetes cluster operations with o...
 
Kubernetes 101 for_penetration_testers_-_null_mumbai
Kubernetes 101 for_penetration_testers_-_null_mumbaiKubernetes 101 for_penetration_testers_-_null_mumbai
Kubernetes 101 for_penetration_testers_-_null_mumbai
 
Container Orchestration using kubernetes
Container Orchestration using kubernetesContainer Orchestration using kubernetes
Container Orchestration using kubernetes
 
Running Kubernetes in Kubernetes
Running Kubernetes in KubernetesRunning Kubernetes in Kubernetes
Running Kubernetes in Kubernetes
 
(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview(Draft) Kubernetes - A Comprehensive Overview
(Draft) Kubernetes - A Comprehensive Overview
 
Getting started with google kubernetes engine
Getting started with google kubernetes engineGetting started with google kubernetes engine
Getting started with google kubernetes engine
 
DevOpsDaysRiga 2018: Andrew Martin - Continuous Kubernetes Security
DevOpsDaysRiga 2018: Andrew Martin - Continuous Kubernetes Security DevOpsDaysRiga 2018: Andrew Martin - Continuous Kubernetes Security
DevOpsDaysRiga 2018: Andrew Martin - Continuous Kubernetes Security
 
Containers kuberenetes
Containers kuberenetesContainers kuberenetes
Containers kuberenetes
 

More from Opsta

Deploy 22 microservices from scratch in 30 mins with GitOps
Deploy 22 microservices from scratch in 30 mins with GitOpsDeploy 22 microservices from scratch in 30 mins with GitOps
Deploy 22 microservices from scratch in 30 mins with GitOpsOpsta
 
Let's build Developer Portal with Backstage
Let's build Developer Portal with BackstageLet's build Developer Portal with Backstage
Let's build Developer Portal with BackstageOpsta
 
Kubernetes Secrets Management on Production with Demo
Kubernetes Secrets Management on Production with DemoKubernetes Secrets Management on Production with Demo
Kubernetes Secrets Management on Production with DemoOpsta
 
Introduction of CCE and DevCloud
Introduction of CCE and DevCloudIntroduction of CCE and DevCloud
Introduction of CCE and DevCloudOpsta
 
How to build DevSecOps Platform on Huawei Cloud
How to build DevSecOps Platform on Huawei CloudHow to build DevSecOps Platform on Huawei Cloud
How to build DevSecOps Platform on Huawei CloudOpsta
 
Make a better DevOps with GitOps
Make a better DevOps with GitOpsMake a better DevOps with GitOps
Make a better DevOps with GitOpsOpsta
 
Deploy Application on Kubernetes
Deploy Application on KubernetesDeploy Application on Kubernetes
Deploy Application on KubernetesOpsta
 
Platform Engineering
Platform EngineeringPlatform Engineering
Platform EngineeringOpsta
 
Manage Kubernetes Clusters with Cluster API and ArgoCD
Manage Kubernetes Clusters with Cluster API and ArgoCDManage Kubernetes Clusters with Cluster API and ArgoCD
Manage Kubernetes Clusters with Cluster API and ArgoCDOpsta
 
Security Process in DevSecOps
Security Process in DevSecOpsSecurity Process in DevSecOps
Security Process in DevSecOpsOpsta
 
Scaling DevSecOps Culture for Enterprise
Scaling DevSecOps Culture for EnterpriseScaling DevSecOps Culture for Enterprise
Scaling DevSecOps Culture for EnterpriseOpsta
 
Introduction to Kubernetes and GKE
Introduction to Kubernetes and GKEIntroduction to Kubernetes and GKE
Introduction to Kubernetes and GKEOpsta
 
Introduction to Google Cloud Platform
Introduction to Google Cloud PlatformIntroduction to Google Cloud Platform
Introduction to Google Cloud PlatformOpsta
 
Managing traffic routing with istio and envoy workshop
Managing traffic routing with istio and envoy workshopManaging traffic routing with istio and envoy workshop
Managing traffic routing with istio and envoy workshopOpsta
 
How to pass the Google Certification Exams
How to pass the Google Certification ExamsHow to pass the Google Certification Exams
How to pass the Google Certification ExamsOpsta
 
How to Become DevOps
How to Become DevOpsHow to Become DevOps
How to Become DevOpsOpsta
 
DevOps: The Future of Software Development
DevOps: The Future of Software DevelopmentDevOps: The Future of Software Development
DevOps: The Future of Software DevelopmentOpsta
 
Real World CI/CD with Kubernetes
Real World CI/CD with KubernetesReal World CI/CD with Kubernetes
Real World CI/CD with KubernetesOpsta
 
Journey of Kubernetes Scaling
Journey of Kubernetes ScalingJourney of Kubernetes Scaling
Journey of Kubernetes ScalingOpsta
 
DevOps Transformation in Technical
DevOps Transformation in TechnicalDevOps Transformation in Technical
DevOps Transformation in TechnicalOpsta
 

More from Opsta (20)

Deploy 22 microservices from scratch in 30 mins with GitOps
Deploy 22 microservices from scratch in 30 mins with GitOpsDeploy 22 microservices from scratch in 30 mins with GitOps
Deploy 22 microservices from scratch in 30 mins with GitOps
 
Let's build Developer Portal with Backstage
Let's build Developer Portal with BackstageLet's build Developer Portal with Backstage
Let's build Developer Portal with Backstage
 
Kubernetes Secrets Management on Production with Demo
Kubernetes Secrets Management on Production with DemoKubernetes Secrets Management on Production with Demo
Kubernetes Secrets Management on Production with Demo
 
Introduction of CCE and DevCloud
Introduction of CCE and DevCloudIntroduction of CCE and DevCloud
Introduction of CCE and DevCloud
 
How to build DevSecOps Platform on Huawei Cloud
How to build DevSecOps Platform on Huawei CloudHow to build DevSecOps Platform on Huawei Cloud
How to build DevSecOps Platform on Huawei Cloud
 
Make a better DevOps with GitOps
Make a better DevOps with GitOpsMake a better DevOps with GitOps
Make a better DevOps with GitOps
 
Deploy Application on Kubernetes
Deploy Application on KubernetesDeploy Application on Kubernetes
Deploy Application on Kubernetes
 
Platform Engineering
Platform EngineeringPlatform Engineering
Platform Engineering
 
Manage Kubernetes Clusters with Cluster API and ArgoCD
Manage Kubernetes Clusters with Cluster API and ArgoCDManage Kubernetes Clusters with Cluster API and ArgoCD
Manage Kubernetes Clusters with Cluster API and ArgoCD
 
Security Process in DevSecOps
Security Process in DevSecOpsSecurity Process in DevSecOps
Security Process in DevSecOps
 
Scaling DevSecOps Culture for Enterprise
Scaling DevSecOps Culture for EnterpriseScaling DevSecOps Culture for Enterprise
Scaling DevSecOps Culture for Enterprise
 
Introduction to Kubernetes and GKE
Introduction to Kubernetes and GKEIntroduction to Kubernetes and GKE
Introduction to Kubernetes and GKE
 
Introduction to Google Cloud Platform
Introduction to Google Cloud PlatformIntroduction to Google Cloud Platform
Introduction to Google Cloud Platform
 
Managing traffic routing with istio and envoy workshop
Managing traffic routing with istio and envoy workshopManaging traffic routing with istio and envoy workshop
Managing traffic routing with istio and envoy workshop
 
How to pass the Google Certification Exams
How to pass the Google Certification ExamsHow to pass the Google Certification Exams
How to pass the Google Certification Exams
 
How to Become DevOps
How to Become DevOpsHow to Become DevOps
How to Become DevOps
 
DevOps: The Future of Software Development
DevOps: The Future of Software DevelopmentDevOps: The Future of Software Development
DevOps: The Future of Software Development
 
Real World CI/CD with Kubernetes
Real World CI/CD with KubernetesReal World CI/CD with Kubernetes
Real World CI/CD with Kubernetes
 
Journey of Kubernetes Scaling
Journey of Kubernetes ScalingJourney of Kubernetes Scaling
Journey of Kubernetes Scaling
 
DevOps Transformation in Technical
DevOps Transformation in TechnicalDevOps Transformation in Technical
DevOps Transformation in Technical
 

Recently uploaded

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Recently uploaded (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

How we can do Multi-Tenancy on Kubernetes

  • 1. Multi-Tenancy on Jirayut Nimsaeng (Dear) CEO & Founder, Opsta (Thailand) Co.,Ltd. TechTalkThai Conference: Kubernetes Trends September 16, 2021 https://bit.ly/opsta-ttt-k8s-tenancy
  • 2. Multi-Tenancy on Kubernetes #whoami Jirayut Nimsaeng (Dear) Jirayut has been involved in DevSecOps, Container, Cloud Technology and Open Source for over 10 years. He has experienced and succeeded in transforming several companies to deliver greater values and be more agile. ● He is Founder and CEO of Opsta (Thailand) Co.,Ltd. ● He is Cloud/DevSecOps Transformation Consultant and Solution Architecture ● He is the first Certified Kubernetes Security Specialist (CKS) and Certified Kubernetes Administrator (CKA) in Thailand
  • 3. Multi-Tenancy on Kubernetes Agenda ● What is Multi-Tenancy? ● Multi-Tenancy Primitive ● Access Control ● Fair Sharing ● Isolation ● Future
  • 5. Multi-Tenancy on Kubernetes Single vs Multi-Tenant https://dev.to/sciencebae/multi-tenant-architecture-and-it-s-issues-h06
  • 6. Multi-Tenancy on Kubernetes Multi-Tenancy on Kubernetes https://cloud.google.com/kubernetes-engine/docs/concepts/multitenancy-overview
  • 7. Multi-Tenancy on Kubernetes Why Kubernetes Multi-Tenancy? ● Reduced management overhead ● Reduced resource fragmentation ● Cost efficiency
  • 8. Multi-Tenancy on Kubernetes Kubernetes Multi-Tenancy Types Soft Multi-tenancy ● trust tenants ● may has relation between tenants ● we believe that they are not trying to harm other tenants ● focus on preventing accidents Hard Multi-tenancy ● zero trust tenants ● each tenant has no relation to each other ● we believe that they are trying to exploit the system ● focus on securing and isolating each tenant
  • 9. Multi-Tenancy on Kubernetes Kubernetes Multi-Tenancy Models ● Namespaces as a Service allows sharing clusters and hence enables resource efficiencies with cluster-wide resources limitation ● Clusters as a Service better isolation with higher management and resource overhead. ● Control Planes as a Service virtual cluster where each tenant gets their own dedicated Kubernetes control plane but share worker node resources
  • 11. Multi-Tenancy on Kubernetes Multi-Tenancy on Kubernetes Overview https://www.vamsitalkstech.com/architecture/a-deepdive-into-kubernetes-multitenancy-1-2/
  • 12. Multi-Tenancy on Kubernetes Kubernetes Multi-Tenancy Primitive ● Access Control Use policies to ensure that tenants can access only what they should have access to ○ RBAC ● Fair Sharing Enforce limits per tenant ○ Resource Quota ○ Pod Priority ○ Quality of Service ○ Taints & Tolerations ○ Pod Affinity / Anti-affinity ● Isolation Ensure tenants cannot access each others’ workloads, secrets, etc. ○ Namespace ○ Pod Security Policy ○ Network Policy ○ Sandbox
  • 14. Multi-Tenancy on Kubernetes RBAC Role-based access control (RBAC) is a method of regulating access to computer or network resources based on the roles of individual users within your organization https://www.cncf.io/blog/2020/08/28/kubernetes-rbac-101-authorization/
  • 15. Multi-Tenancy on Kubernetes Multi-Tenancy Roles ● [ClusterRoleBinding] Cluster Administrator ● A cluster administrator has access to all cluster resources and can configure new tenant namespaces ● [ClusterRoleBinding] Cluster view Read privileges for all resources in the cluster ● [RoleBinding] Tenant Administrator ● A tenant administrator manages namespaces that belong to the tenant ● [RoleBinding] Tenant User ● Read/write privileges for all resources scoped to that tenant
  • 16. Multi-Tenancy on Kubernetes Sample Role kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: name: tenant-a-role namespace: tenant-a rules: - apiGroups: ["", "extensions", "apps"] resources: ["*"] verbs: ["*"] - apiGroups: ["batch"] resources: - jobs - cronjobs verbs: ["*"]
  • 18. Multi-Tenancy on Kubernetes Resource Quota A resource quota, defined by a ResourceQuota object, provides constraints that limit aggregate resource consumption per namespace. apiVersion: v1 kind: ResourceQuota metadata: name: mem-cpu-demo spec: hard: requests.cpu : "1" limits.cpu : "2" apiVersion: "v1" kind: "LimitRange" metadata: name: "resource-limits" spec: limits: - type: "Container" max: cpu: "2" memory: "1Gi" min: cpu: "100m" memory: "4Mi" default: cpu: "300m" memory: "200Mi" defaultRequest: cpu: "200m" memory: "100Mi" maxLimitRequestRatio: cpu: "10"
  • 19. Multi-Tenancy on Kubernetes Pod Priority Priority indicates the importance of a Pod relative to other Pods. If a Pod cannot be scheduled, the scheduler tries to preempt (evict) lower priority Pods to make scheduling of the pending Pod possible. An administrator can use ResourceQuota to prevent users from creating pods at high priorities. Priority Class Purpose Value/Priority Cluster Core Essential services to operate the cluster itself, such as Dex for authentication 100000 Tenant Critical Services which are business-critical to your tenant, and cannot easily move to a new machine, such as database back-ends 70000 Administrative Services Dashboards that are important for managing the cluster, but could tolerate a short outage while moving to a new machine 50000 Best Effort (default) No priority assigned; allows termination in favor of higher priority workloads 100
  • 20. Multi-Tenancy on Kubernetes Sample Pod Priority apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: tenant-critical value: 70000 globalDefault: false description: "This priority class should be used for s ervices which are business-critical to your tenant, and cannot easily move to a new machine, such as database back-ends "
  • 21. Multi-Tenancy on Kubernetes Quality of Service for Pods Quality of Service (QoS) class is a Kubernetes concept that the scheduler uses for deciding the scheduling and eviction priority of the pods. https://medium.com/blutv/qos-classes-of-k8s-pods-722238a61c93
  • 22. Multi-Tenancy on Kubernetes Taints & Tolerations ● Taints are applied to node, to repel a set of pods. ● Tolerations are applied to pods, and allow (but do not require) the pods to schedule onto nodes with matching taints. ● Use cases: Dedicated Nodes and Nodes with Special Hardware
  • 23. Multi-Tenancy on Kubernetes Pod Disruption Budgets A PDB limits the number of Pods of a replicated application that are down simultaneously from voluntary disruptions apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: zk-pdb spec: maxUnavailable : 1 selector: matchLabels : app: zookeeper
  • 24. Multi-Tenancy on Kubernetes Pod Affinity / Anti-affinity You can use Pod anti-affinity to prevent Pods from different tenants from being scheduled on the same node. Anti-affinity constraints are based on Pod labels. For example high workload shouldn’t stay on the same node. apiVersion: v1 kind: Pod metadata: name: bar labels: team: "billing" spec: affinity: podAntiAffinity : requiredDuringSchedulingIgnoredD uringExecution : - topologyKey : "kubernetes.io/hostname" labelSelector : matchExpressions : - key : "team" operator : NotIn values : ["billing"]
  • 26. Multi-Tenancy on Kubernetes Namespace ● System namespaces Exclusively for system pods. Usually kube-system namespace and manage by cluster administrator ● Service namespaces These namespaces should run services or applications that need to be accessed by services in other namespaces. Usually manage by cluster administrator ● Tenant Namespaces Tenant namespaces should be spun up to run applications that do not need to be accessed from other namespaces in the cluster. Usually manage by tenant administrator
  • 27. Multi-Tenancy on Kubernetes Pod Security Policy A PodSecurityPolicy is an admission controller resource you create that validates requests to create and update Pods on your cluster. The PodSecurityPolicy defines a set of conditions that Pods must meet to be accepted by the cluster. when a request to create or update a Pod does not meet the conditions in the PodSecurityPolicy, that request is rejected and an error is returned. https://rancher.com/blog/2020/pod-security-policies-part-2
  • 28. Multi-Tenancy on Kubernetes Sample PSP apiVersion: policy/v1beta1 kind: PodSecurityPolicy metadata: name: restricted spec: privileged: false # Required to prevent escalations to root. allowPrivilegeEscalation : false # The following is redundant with non-root + disallow privilege # escalation, but we can provide it for defense in depth. requiredDropCapabilities : - ALL # Allow core volume types. volumes: - 'configMap' - 'emptyDir' - 'projected' - 'secret' - 'downwardAPI' # Assume that persistentVolumes set up by the cluster admin # are safe to use. - 'persistentVolumeClaim' hostNetwork: false hostIPC: false hostPID: false runAsUser: # Require the container to run without root privileges. rule: 'MustRunAsNonRoot' seLinux: # Assumes the nodes are using AppArmor rather than SELinux. rule: 'RunAsAny' supplementalGroups : rule: 'MustRunAs' ranges: # Forbid adding the root group. - min: 1 max: 65535 fsGroup: rule: 'MustRunAs' ranges: # Forbid adding the root group. - min: 1 max: 65535
  • 29. Multi-Tenancy on Kubernetes PodSecurityPolicy Deprecation Kubernetes 1.21 starts the deprecation process for PodSecurityPolicy. The current plan is to remove PSP from Kubernetes in the 1.25 release. Kubernetes v1.22 as an Alpha feature, Kubernetes offers a built-in Pod Security admission controller, the successor to PodSecurityPolicies. ● https://github.com/kubernetes/enhancements/issues/2579 ● https://kubernetes.io/docs/concepts/security/pod-security-admission/
  • 30. Multi-Tenancy on Kubernetes Open Policy Agent (OPA) package kubernetes. admission deny[msg] { input.request.kind.kind == "Pod" some i image := input.request.object.spec.containers[i].image not startswith (image, "hooli.com/") msg := sprintf("image '%v' comes from untrusted registry" , [image]) }
  • 31. Multi-Tenancy on Kubernetes Network Policy apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: deny-all namespace: tenant-a spec: podSelector: matchLabels : ingress: - from: - podSelector : {} you should block traffic between namespaces that host different tenants' applications
  • 36. Multi-Tenancy on Kubernetes The Hierarchical Namespace Controller $ kubectl hns create my-service -n my-team $ kubectl hns tree my-team my-team └── my-service https://github.com/kubernetes-sigs/hierarchical-namespaces
  • 39. Multi-Tenancy on Kubernetes Key Take-aways ● Use multi-tenancy for improved resource efficiency, cost, and operations ● Multi-tenancy is unavoidable in the future ● Choose your multi-tenancy type and model ● To do multi-tenancy, you need to config kubernetes access control, fair sharing, and isolation
  • 40. Multi-Tenancy on Kubernetes More questions? jirayut@opsta.co.th Jirayut Nimsaeng CEO & Founder Opsta (Thailand) 086-069-4042 Facebook