- On-demand Self-Service
- No human intervention needed to get resources.
- Broad Network Access
- Access from anywhere.
- Resource Pooling
- Provider share resources to customers.
- Rapid Elasticity
- Get more resources quickly as needed.
- Measured Service
- Pay only for what you consume.
- Design for Failure
- Fail over gracefully.
- Avoid single points of failure.
- Implement Elasticity
- Automate deployment process.
- Scale cloud resources up, down, out, and in.
- Scheduled-based proactive scaling vs. event-based proactive scaling.
- Loose Coupling
- Minimize dependencies between components.
- Keep Things Secure
- Secure application and data.
- Manage user access control (UAC).
- Container Runtime Interface (CRI)
- Open Container Initiative (OCI)
- cgroups
- namespaces
- Container Orchestration
- Overlay Networking
- Service Discovery & Load Balancing
- Storage Orchestration
- Automated Rollouts & Rollbacks
- Automatic Bin Packing
- Autoscaling & Self-Healing
- Config & Secret Management
- Control Plane Components
- kube-apiserver
- etcd
- kube-scheduler
- kube-controller-manager
- cloud-controller-manager
- Node Components
- kubelet
- kube-proxy
- container-runtime
- Addons
- DNS
- Web UI
- Workloads
- Pod
- Deployment
- StatefulSet
- Like a Deployment, a StatefulSet manages Pods that are based on an identical container spec.
- Unlike a Deployment, a StatefulSet maintains a sticky identity for each of their Pods.
- The pods are created from the same spec, but are not interchangeable.
- Each pod has a persistent identifier that it maintains across any rescheduling.
- DaemonSet
- Job
- CronJob
- Networking
- Storage
- Configuration
- Labels do not provide uniqueness.
- Labels are key-value pairs attached to objects.
- Labels specify identifying attributes of objects.
- They are meaningful and relevant to users, but do not directly imply semantics to the core system.
- Labels are used to identify, organize, and select subsets of objects.
- Labels enable users to map their organizational structures onto objects without requiring clients to store these mappings.
- Valid label keys have two segments: an optional prefix and a required name, separated by a slash
/.- If the prefix is omitted, the label Key is presumed to be private to the user.
- Automated system components which add labels to end-user objects must specify a prefix (
kubernetes.io/,k8s.io/).
- Label Selectors
- Equality-based requirement
- Set-based requirement (
in,notin, exist, and not exist!)
- Annotations attach arbitrary non-identifying metadata to objects.
- Annotations can be small or large, structured or unstructured, and can include characters not permitted by labels.
- Note: The keys and the values in the map must be strings.
- Valid annotation keys have two segments: an optional prefix and a required name, separated by a slash
/.- The prefix is optional. If specified, the prefix must be a DNS subdomain.
- NodeSelector
- NodeSelector is the simplest recommended form of node selection constraint.
- It constrain which nodes your pod is eligible to be scheduled on based on labels on the node.
- Affinity & Anti-Affinity
- Node affinity is conceptually similar to nodeSelector, but the language is more expressive.
- Two types:
requiredDuringSchedulingIgnoredDuringExecutionpreferredDuringSchedulingIgnoredDuringExecution
- Inter-Pod Affinity & Anti-Affinity
- Constrain which nodes your pod is eligible to be scheduled based on labels on pods already running on the node.
- Rule --> This pod should (or should not) run in an X if X is already running one or more pods that meet rule Y.
- X is a topology domain like node, availability zone, region, etc. You express it using a
topologyKey. - Y is expressed as a LabelSelector with an optional associated list of namespaces (labels on pods are implicitly namespaced).
- X is a topology domain like node, availability zone, region, etc. You express it using a
- Two types:
requiredDuringSchedulingIgnoredDuringExecutionpreferredDuringSchedulingIgnoredDuringExecution
- Node affinity is a property of Pods that attracts them to a set of nodes (hard or soft).
- Taints are the opposite! They allow a node to repel a set of pods.
- Tolerations are applied to pods, and allow the pods to schedule onto nodes with matching taints.
- They allow scheduling but don't guarantee scheduling!
- Taints and tolerations work together to ensure that pods are not scheduled onto inappropriate nodes.
- Authentication
- All Kubernetes clusters have two categories of users: service accounts (managed by Kubernetes), and normal users.
- Authorization Modes
- Role-Based Access Control (RBAC)
- Role
- A Role always sets permissions within a particular namespace.
- A RoleBinding grants the permissions defined in a role to a user or set of users within a specific namespace.
- A RoleBinding may reference any Role in the same namespace.
- A RoleBinding can reference a ClusterRole and bind that ClusterRole to the namespace of the RoleBinding.
- ClusterRole
- A ClusterRole is a non-namespaced resource.
- A ClusterRoleBinding bind a ClusterRole to all the namespaces in your cluster.
- Role
- Attribute-Based Access Control (ABAC)
- ABAC defines an access control paradigm whereby access rights are granted to users through the use of policies which combine attributes together.
- Node
- Webhook
- Role-Based Access Control (RBAC)
- config
kubectl config viewkubectl config get-contextskubectl config current-contextkubectl config use-context <name>
- misc
kubectl apply -f <file>kubectl edit <object> <name>kubectl create <object> <name>kubectl delete <object> <name>
- pod
kubectl get podskubectl get pods --all-namespaceskubectl get pods --namespace=<name>kubectl logs <pod>kubectl logs <pod> --container=<name>kubectl exec --stdin --tty <pod> -- /bin/shkubectl exec --stdin --tty <pod> --container=<name> -- /bin/shkubectl port-forward <pod> <local_port>:<pod_port>kubectl port-forward deploy/<name> <local_port>:<pod_port>kubectl port-forward service/<name> <local_port>:<pod_port>kubectl top pod <name> --containerskubectl top pod <name> --sort-by=cpu
- deployment
kubectl get deployments/deployskubectl get deployments/deploys --all-namespaceskubectl get deployments/deploys --namespace=<name>kubectl get deployment/deploy <name>kubectl get deployment/deploy --namespace=<name> <name>kubectl scale deployment/<name> --replicas=<count>kubectl scale replicaset/<name> --replicas=<count>kubectl rollout status deployment/<name>kubectl rollout history deployment/<name>kubectl rollout undo deployment/<name>kubectl rollout undo deployment/<name> --to-revision=<num>kubectl rollout restart deployment/<name>
- service
kubectl get serviceskubectl get services --all-namespaceskubectl get services --namespace=<name>kubectl get service <name>kubectl get service --namespace=<name> <name>
- ingress
kubectl get ingresseskubectl get ingresses --all-namespaceskubectl get ingresses --namespace=<name>kubectl get ingress <name>kubectl get ingress --namespace=<name> <name>
- configmap
kubectl get configmapskubectl get configmaps --all-namespaceskubectl get configmaps --namespace=<name>kubectl get configmap <name>kubectl get configmap --namespace=<name> <name>
- secret
kubectl get secretskubectl get secrets --all-namespaceskubectl get secrets --namespace=<name>kubectl get secret <name>kubectl get secret --namespace=<name> <name>
- node
kubectl get nodeskubectl drain <node>kubectl cordon <node>kubectl uncordon <node>kubectl top node <node>
- auth
kubectl auth can-i <verb> <resource>kubectl auth can-i <verb> <resource> --namespace=<name>
- IaaS
- Compute engine
- Hybrid
- Kubernetes Engine
- PaaS
- App Engine
- Serverless
- Cloud Functions
- SaaS
- Managed services
- Zone
- A zone is a deployment area for Google Cloud Resources.
- A zone does not always correspond to a single physical building.
- Zones are grouped into regions.
- Think of a zone as a single failure domain within a region.
- For building a fault tolerant application, you can spread your resources across multiple zones in a region.
- Region
- Regions are independent geographic areas.
- All the zones within a region have fast network connectivity among them.
- You can run resources in different regions too:
- To bring their applications closer to users around the world.
- To protect against the loss of an entire region.
- A few Google Cloud Platform Services support placing resources in a Multi-Region.
Who can do what on which resource:
- Who
- Google Account
- Google Group
- Service Account
- User-created (custom)
- Built-in
- Default Compute Engine service account
- Google APIs service account
- Can do what
- On which resource
Roles: a group of permissions
- Primitive roles apply to a project (and all resources in the project)
- Owner
- Editor
- Viewer
- Billing Admin
- Predefined roles apply to a particular service in a project
- Custom roles can be used for practicing the principle of least privilege
- Compute
- Compute Engine
- Kubernetes Engine (GKE)
- Operation:
- Standard
- Autopilot
- Version:
- Static Channel
- Release Channels
- Rapid
- Regular
- Stable
- Availability:
- Zonal clusters
- Single-zone clusters
- Multi-zonal clusters
- Regional clusters
- Zonal clusters
- Networking:
- VPC-native
- Routes-based
- Isolation:
- Public
- Private
- Operation:
- App Engine
- Cloud Functions
- Storage
- Bigtable
- Cloud Storage
- Cloud SQL
- Cloud Spanner
- Cloud Datastore
- Big Data
- Pub/Sub
- Big Query
- Data Flow
- Data Proc
- Data Lab
- Machine Learning
- Machine Learning
- Translate API
- Vision API
- Speech API
- Natural Language API
- Internal
- Regional
- Internal TCP/UDP Load Balancer (Premium network, Pass-through)
- Internal HTTP(S) Load Balancer (Premium network, Proxy)
- Regional
- External
- Regional
- External TCP/UDP Network Load Balancer (Premium or Standard network, Pass-through)
- Regional External HTTP(S) Load Balancer (Standard network, Proxy)
- Global
- TCP Proxy Load Balancer (Premium or Standard network, Proxy)
- SSL Proxy Load balancer (Premium or Standard network, Proxy)
- Global External HTTP(S) Load Balancer (Premium or Standard network, Proxy)
- Regional