Megan O’Keefe and Shabir Abdul Samadh
Google Cloud
YAML Your Cloud!
Managing Cloud-Hosted Resources from Kubernetes
Hello!
On Deck
What is the
Kubernetes Resource Model (KRM)?
The Kubernetes API Server
API Server
etcd
cloud-
controller-
manager
kube-
scheduler
kube-
controller-
manager
cloud provider
Control Plane Node
kubelet
kube
proxy
container
runtime
Node
kubelet
kube
proxy
container
runtime
Node
kubelet
kube
proxy
container
runtime
Node
The Declarative Model
Declarative = API objects express intent
Controllers = loop to make your desired state match the actual running state
observe
diff
act
The Kubernetes Resource Model
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: my-app
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
args: [“-port=8080”]
ports:
containerPort: 8080
……
status:
……
Metadata
Desired state
Observed state �(added/updated by the K8s system)
The Kubernetes Resource Model
The Kubernetes API can also be extended using Custom Resource Definitions (CRDs) with custom controllers.
Controllers that install + upgrade applications inside K8s
are called operators.
Why manage hosted resources with KRM?
Ways to interact with a cloud provider
Cloud Console
1st party command line
Client Libraries
3rd-party tools
eg. Terraform
kubectl
K8s client libraries
Cloud
APIs
Kubernetes API
K8s + hosted resources is hard.
Different APIs, different resource models + formats
Different paradigms (imperative vs. declarative, client-side vs. server side)
Different authentication (IAM / RBAC) systems
Add multiple cloud providers, and the complexity multiplies.
IAM: Identity and Access Management
RBAC: Role Based Access Control
What if...
Cloud
Console
1st party command line
Client
Libraries
3rd-party tools
eg. Terraform
kubectl
K8s client libraries
Kubernetes
API
Cloud
APIs
The Kubernetes Resource Model
Tightly coupled tool ecosystems
KRM ecosystem
Decoupled data model
Unifying resources with the K8s API
Git Repo
Cloud
Resources
API Server
In-Cluster Controllers
In-Cluster Resources
Cloud
Controllers
How to manage hosted resources with KRM?
YAML your cloud, in 4 steps!
First-party cloud controllers
AWS Controllers for Kubernetes (ACK)
A set of open-source Kubernetes controllers to manage hosted AWS resources
Separate controllers per resource type (EC2, S3, etc.)
Can run inside AWS Elastic Kubernetes Service (EKS)
How ACK works (S3)
EKS
Cymbal
Ads
S3
Bucket
ACK
Demo:
Managing AWS-hosted resources with AWS Controllers for Kubernetes
Google Cloud Config Connector
Like ACK, Config Connector is an in-cluster controller to manage cloud resources (this time, for Google Cloud).
Unlike ACK, Config Connector is a first-party product.
Unlike ACK, Config Connector operates as a single controller for many GCP resources.
How Config Connector Works
How Config Connector Works
GKE
Config
Connector
How Config Connector Works
apiVersion: redis.cnrm.cloud.google.com/v1beta1
kind: RedisInstance
metadata:
name: redis-cart
namespace: config-connector-resources
spec:
displayName: "Cymbal Shops Redis Cart"
region: us-central1
redisVersion: "REDIS_5_0"
tier: BASIC
memorySizeGb: 1
How Config Connector Works
GKE
Config
Connector
Memorystore
Demo:
Managing Google-Cloud Hosted Resources with Config Connector
Setting guardrails for cloud KRM
“Only cluster admins can create Memorystore instances.”
➡️ Kubernetes RBAC
“Memorystore instances must use Redis v5.”
➡️ ??
OpenPolicyAgent Gatekeeper
A policy “gate” for a Kubernetes cluster.
Runs as an admission controller (before resources can get to the API server)
Can be configured with custom policies on specific resource types, both Kubernetes and custom (Cloud)
Benefits of OPA Gatekeeper
Automate policy enforcement for Cloud resources before the resources get created
Stay in compliance with industry- or geo-specific regulations
Policies defined as K8s CRDs, can be stored in Git + approved, audited
Accelerate developer velocity + feedback loop (can check policies during CI/CD, too!)
How to use Gatekeeper
How to use Gatekeeper
GKE
Config
Connector
Memorystore
IAM
Gatekeeper
Demo:
Setting cloud guardrails with
OpenPolicyAgent
K8s workloads + Cloud workloads
GKE
Config
Connector
Memorystore
IAM
Cymbal
Shops
Gatekeeper
... Across multiple clouds...
GKE
Config
Connector
Memorystore
IAM
Cymbal
Shops
Gatekeeper
EKS
Cymbal
Ads
S3
Bucket
ACK
Are Config Connector and ACK enough?
Config Connector allows managing Google Cloud resources and ACK, enables same for Amazon Web Services resources
Still two very different tools to incorporate into the pipeline
Can we consolidate all this into one tool?
One ring popsicle to rule them all…
Crossplane
Open Source Kubernetes add-on; everything defined as KRM
Support for resource management on multiple platforms (GCP, AWS, Azure, Alibaba)
Assemble multiple resources into a composite unit and expose them as single resource definition
Set up policies and guardrails for cloud resources
How Crossplane Works
Extends the K8s API by introducing more CRDs with their own controller
A CRD per cloud provider to maintain access configuration
Enables compositions of cloud resources into higher level abstractions
Demo:
Unifying multicloud resource management with Crossplane
Demo!
Memorystore
IAM
GKE
Cymbal
Shops
EKS
Cymbal
Ads
S3
Bucket
Crossplane
Wrap-up!
There is are lots of ways to manage cloud infrastructure.
Kubernetes Resource Model (KRM) can act as the common data model to define all infrastructure in a declarative way
Different cloud providers have their own solutions to manage resources as a KRM entity
Efforts such as Crossplane enables a KRM based model with potential to abstract the underlying provider
Things we didn’t cover!
How does your KRM get from Git to your cluster(s)?
Transforming cloud KRM with kustomize / kpt.
RBAC and access control for cloud KRM.
Rego, the OPA Policy language
Other first-party tools, eg. Azure Service Operator
Resources
Try it out!
Thank You!