Securing Access to Cloud Resources from K8S
Identities
Types of Identities that can be used for applications
Methods
The ways to secure a services: good, bad, the ugly.
Extra
Cross Cloud Access through OpenID Connect
# Agenda
# CHAPTER 1
Also called principals and how to authorize access.
Subjects (Identities) |
---|
Service Account |
Users |
Groups |
A subject or Kubernetes identity is granted permissions through a Role and a RoleBinding or ClusterRoleBinding.
Security Principals (Identities) |
---|
Service Principal |
Users |
Groups |
Azure added managed identities, which is a service principal whose life cycle is managed by Azure. There are two sub-types: user-assigned and system-assigned.
Security Principal | who |
Role Definition | what you can do |
Scope | where you can do it |
In Azure RBAC, you combine the above elements into a Role Assignment that has Actions and NotActions permissions.
Principals (Identities) |
---|
Service Account |
Google Account (user) |
Google Group |
Principals are defined referenced using UPN (User Principal Name) [RFC 822] or <name>@<tree-name>. A Google Group is a collection of Google Accounts, often used as a distribution list within Gmail.
Identity | who |
Role | what access |
which resources |
In Google Cloud IAM, each Project will have a list of bindings that include a role and members (list of identities)
Identities |
---|
IAM role |
IAM user |
IAM user group |
Principals are defined referenced using UPN (User Principal Name) [RFC 822] or <name>@<tree-name>. A Google Group is a collection of Google Accounts, often used as a distribution list within Gmail.
IAM identities are referenced using an ARN. Permissions are defined in a policy that is attached to an identity. EC2 instances can be associated to a role through an Instance Profile.
Identity | who |
Policy | what access |
Policy | which resources |
# CHAPTER 2
The methods available for Kubernetes deployed applications across the cloud providers
Where to secure the service?
1. Node level using cloud identity
2. Service level using credentials
3. Pod level service account
Why this are bad?
Why is this bad?
Violates PoLP (Principal of Least Privilege).
All containers now have access to the cloud resource. Only use this method if read-only access, such as ECR/GCR/ACR container registries.
This preferred method.
Authentication will happen through an external provider such as an OIDC (OpenID Connect) provider to grant access and allow the Pod through the service account impersonate the cloud identity and access the resource.
# IMPLEMENTATIONS
# IMPLEMENTATIONS
IAM Role for Service Account
# IMPLEMENTATIONS
AAD Pod Identity enables K8S applications to use Azure AD to allow access to the cloud resource.
# IMPLEMENTATIONS
Azure is adding support for Workload Identity for AKS.
# Chapter 3
Cross Cloud Access and other topics.
Access AWS or Azure resource from GKE.
Access Google or Azure cloud resource from EKS.
Role trust to federated service that an alternative OpenID provider
# Chapter 3
Snippets
az identity create --resource-group "${IDENTITY_RESOURCE_GROUP}" --name "${IDENTITY_NAME}"
# fetch identity client id from managed identity created earlier
IDENTITY_CLIENT_ID=$(az identity show --resource-group "${IDENTITY_RESOURCE_GROUP}" \
--name "${IDENTITY_NAME}" --query "clientId" --output tsv)
# fetch DNS id used to grant access to the managed identity
DNS_ID=$(az network dns zone show --name "${AZURE_DNS_ZONE}" \
--resource-group "${AZURE_DNS_ZONE_RESOURCE_GROUP}" --query "id" --output tsv)
az role assignment create --role "DNS Zone Contributor" \
--assignee "${IDENTITY_CLIENT_ID}" --scope "${DNS_ID}"